| | |
| | | BigDecimal factoryNum = new BigDecimal(0); |
| | | BigDecimal processNum = new BigDecimal(0); |
| | | // 循环4次,分别统计近4个月的数据(当前月、前1个月、前2个月、前3个月) |
| | | for (int i = 0; i < 4; i++) { |
| | | for (int i = 3; i >= 0; i--) { |
| | | // 计算当前循环对应的月份(i=0:当前月,i=1:前1个月,以此类推) |
| | | LocalDate currentMonth = today.minusMonths(i); |
| | | // 当月的开始日期(每月1号) |
| | |
| | | .filter(inspect -> inspect.getInspectType().equals(1)) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | factoryNum= factoryNum.add(reduce1); |
| | | processNum= processNum.add(reduce1); |
| | | BigDecimal reduce2 = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(2)) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | processNum = processNum.add(reduce2); |
| | | factoryNum = factoryNum.add(reduce2); |
| | | |
| | | // 构建当月统计项 |
| | | QualityStatisticsItem item = new QualityStatisticsItem(); |