for(int i= 0;i<date.size()-1;i++) { for (int j = 0; j < ruleGroupList.size(); j++) { RuleThroughputRate throughputRate = new RuleThroughputRate(); throughputRate.setProductId(criteria.getProductId()); //时间条件插入 throughputRate.setStartDate(date.get(i)); throughputRate.setEndDate(date.get(i + 1)); //折线图Y轴 List <String> rateList = new ArrayList(); //规则名条件插入 String ruleName = ruleGroupList.get(j); throughputRate.setRuleName(ruleName); //根据规则集名称计算通过率并插入 if(ValidatorUtils.isEmpty(ruleName)){ continue; } List<String> list = riskRuleLogService.findIdRuleGroupByStatus(throughputRate); int throughput =list.size(); int sum = riskRuleLogService.findIdRuleByGroup(throughputRate).size(); int rate = 0; if (sum != 0) { rate = throughput * 100 / sum; rateList.add(String.valueOf(rate)); } else { //通过X轴取通过率,如果为空填NULL rateList.add("null"); } throughputRate.setThroughRateList(rateList); throughputRateList.add(throughputRate); } }
多重循环时add操作在最后一重进行否则会发生覆盖