diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java index 5fe70d7a..7944f9b1 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java @@ -116,53 +116,49 @@ public class CoalWashingDailyAnalysisEntity extends OrgCommonEntity { for (int i = 0; i < inputItems.size(); i++) { CoalWashingDailyAnalysisItemVo item = inputItems.get(i); - if (i == 0) { - item.setFddAvgP1(item.getFddp1()); - } else { - int nullCount = 0; - for (int j = 0; j < i; j++) { - if (item.getFddp1() == null) { - nullCount++; - } else { + item.setFddAvgP1(0.0); - item.setFddAvgP1( - ObjectUtils.defaultIfNull(item.getFddp1(), 0.0) - + inputItems.get(j).getFddAvgP1()); - } - } - if (i - nullCount > 0) { - - item.setFddAvgP1(item.getFddAvgP1() / (i - nullCount)); + int nullCount = 0; + for (int j = 0; j <= i; j++) { + if (inputItems.get(j).getFddp1() == null) { + nullCount++; } else { - item.setFddAvgP1(null); + + item.setFddAvgP1( + ObjectUtils.defaultIfNull(inputItems.get(j).getFddp1(), 0.0) + + item.getFddAvgP1()); } } + if (i - nullCount + 1 > 0) { + + item.setFddAvgP1(item.getFddAvgP1() / (double) (i - nullCount + 1)); + } else { + item.setFddAvgP1(null); + } } for (int i = 0; i < inputItems.size(); i++) { CoalWashingDailyAnalysisItemVo item = inputItems.get(i); - if (i == 0) { - item.setFddAvgP2(item.getFddp2()); - } else { - int nullCount = 0; - for (int j = 0; j < i; j++) { - if (item.getFddp2() == null) { - nullCount++; - } else { + item.setFddAvgP2(0.0); - item.setFddAvgP2( - ObjectUtils.defaultIfNull(item.getFddp2(), 0.0) - + inputItems.get(j).getFddAvgP2()); - } - } - if (i - nullCount > 0) { - - item.setFddAvgP2(item.getFddAvgP2() / (i - nullCount)); + int nullCount = 0; + for (int j = 0; j <= i; j++) { + if (inputItems.get(j).getFddp2() == null) { + nullCount++; } else { - item.setFddAvgP2(null); + + item.setFddAvgP2( + ObjectUtils.defaultIfNull(inputItems.get(j).getFddp2(), 0.0) + + item.getFddAvgP2()); } } + if (i - nullCount + 1 > 0) { + + item.setFddAvgP2(item.getFddAvgP2() / (double) (i - nullCount + 1)); + } else { + item.setFddAvgP2(null); + } } } }