// 待认证
QueryFilter queryFilter0 = new QueryFilter();
queryFilter0.addCommand(new Command("busStatus", Op.EQ, "0"));
int taxStatus0 = taxInfoDao.getCount(queryFilter0);
int businessStatus0 = businessInfoDao.getCount(queryFilter0);
int socialSecurityStatus0 = socialSecurityDao.getCount(queryFilter0);
int status0 = taxStatus0 + businessStatus0 + socialSecurityStatus0;
// 待审核
QueryFilter queryFilter1 = new QueryFilter();
queryFilter1.addCommand(new Command("busStatus", Op.EQ, "1"));
int taxStatus1 = taxInfoDao.getCount(queryFilter1);
int businessStatus1 = businessInfoDao.getCount(queryFilter1);
int socialSecurityStatus1 = socialSecurityDao.getCount(queryFilter1);
int status1 = taxStatus1 + businessStatus1 + socialSecurityStatus1;
// 已通过
QueryFilter queryFilter2 = new QueryFilter();
queryFilter2.addCommand(new Command("busStatus", Op.EQ, "2"));
int taxStatus2 = taxInfoDao.getCount(queryFilter2);
int businessStatus2 = businessInfoDao.getCount(queryFilter2);
int socialSecurityStatus2 = socialSecurityDao.getCount(queryFilter2);
int status2 = taxStatus2 + businessStatus2 + socialSecurityStatus2;
// 未通过
QueryFilter queryFilter3 = new QueryFilter();
queryFilter3.addCommand(new Command("busStatus", Op.EQ, "3"));
int taxStatus3 = taxInfoDao.getCount(queryFilter3);
int businessStatus3 = businessInfoDao.getCount(queryFilter3);
int socialSecurityStatus3 = socialSecurityDao.getCount(queryFilter3);
int status3 = taxStatus3 + businessStatus3 + socialSecurityStatus3;
这样的代码从status0到status3有4组
java有没有这种功能,写一个函数,里面用for循环
JSONObject result = new JSONObject();
for(int i = 0; i < 4 ;i++){
QueryFilter queryFilteri = new QueryFilter();
queryFilteri.addCommand(new Command("busStatus", Op.EQ, "i"));
int taxStatusi = taxInfoDao.getCount(queryFilteri);
int businessStatusi = businessInfoDao.getCount(queryFilteri);
int socialSecurityStatusi = socialSecurityDao.getCount(queryFilteri);
int result = taxStatusi + businessStatusi + socialSecurityStatusi;
result.put("statusi", statusi);
}
当然我这样写是错的,但是有没有什么功能能实现这个函数?
这难道不应该用数组去实现吗?恭喜你,看到一坨屎一样的代码想要把它优化是成长为一名高级工程师的必经之路,你看那些大师们身上都是屎迹斑斑。