ソースを参照

质量月报 - S5003、S6101、S6301后台计算方法优化

wangggziwen 1 年間 前
コミット
7e1839615f

+ 5 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS0501Controller.java

@@ -234,6 +234,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
                 if (p.compareTo(pMax) > 0) { pMax = p; }
                 if (p.compareTo(pMin) < 0) { pMin = p; }
                 pSum = pSum.add(p);
+                pCount++;
             }
             String i1 = monthlyQualityReportS0501.getI();
             if (i1 != null) {
@@ -241,6 +242,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
                 if (i.compareTo(iMax) > 0) { iMax = i; }
                 if (i.compareTo(iMin) < 0) { iMin = i; }
                 iSum = iSum.add(i);
+                iCount++;
             }
             String o1 = monthlyQualityReportS0501.getO();
             if (o1 != null) {
@@ -248,6 +250,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
                 if (o.compareTo(oMax) > 0) { oMax = o; }
                 if (o.compareTo(oMin) < 0) { oMin = o; }
                 oSum = oSum.add(o);
+                oCount++;
             }
             String n1 = monthlyQualityReportS0501.getN();
             if (n1 != null) {
@@ -255,6 +258,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
                 if (n.compareTo(nMax) > 0) { nMax = n; }
                 if (n.compareTo(nMin) < 0) { nMin = n; }
                 nSum = nSum.add(n);
+                nCount++;
             }
             String fifty1 = monthlyQualityReportS0501.getFifty();
             if (fifty1 != null) {
@@ -262,6 +266,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
                 if (fifty.compareTo(fiftyMax) > 0) { fiftyMax = fifty; }
                 if (fifty.compareTo(fiftyMin) < 0) { fiftyMin = fifty; }
                 fiftySum = fiftySum.add(fifty);
+                fiftyCount++;
             }
         }
         if (pCount != 0) {

+ 4 - 1
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS2007Controller.java

@@ -81,7 +81,6 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
         int endPointCount = 0;
         int pressureDifferenceCount = 0;
         int productionCount = 0;
-        int Count = 0;
         for (TMonthlyQualityReportS2007 monthlyQualityReportS2007 : tMonthlyQualityReportS2007s) {
             String viscosity1 = monthlyQualityReportS2007.getViscosity();
             if (viscosity1 != null) {
@@ -89,6 +88,7 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
                 if (viscosity.compareTo(viscosityMax) > 0) { viscosityMax = viscosity; }
                 if (viscosity.compareTo(viscosityMin) < 0) { viscosityMin = viscosity; }
                 viscositySum = viscositySum.add(viscosity);
+                viscosityCount++;
             }
             String endPoint1 = monthlyQualityReportS2007.getEndPoint();
             if (endPoint1 != null) {
@@ -96,6 +96,7 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
                 if (endPoint.compareTo(endPointMax) > 0) { endPointMax = endPoint; }
                 if (endPoint.compareTo(endPointMin) < 0) { endPointMin = endPoint; }
                 endPointSum = endPointSum.add(endPoint);
+                endPointCount++;
             }
             String pressureDifference1 = monthlyQualityReportS2007.getPressureDifference();
             if (pressureDifference1 != null) {
@@ -103,6 +104,7 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
                 if (pressureDifference.compareTo(pressureDifferenceMax) > 0) { pressureDifferenceMax = pressureDifference; }
                 if (pressureDifference.compareTo(pressureDifferenceMin) < 0) { pressureDifferenceMin = pressureDifference; }
                 pressureDifferenceSum = pressureDifferenceSum.add(pressureDifference);
+                pressureDifferenceCount++;
             }
             String productionString = monthlyQualityReportS2007.getProduction();
             if (productionString != null) {
@@ -113,6 +115,7 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
                 if (production.compareTo(productionMax) > 0) { productionMax = production; }
                 if (production.compareTo(productionMin) < 0) { productionMin = production; }
                 productionSum = productionSum.add(production);
+                productionCount++;
             }
         }
         if (viscosityCount != 0) {

+ 1 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS3004Controller.java

@@ -67,6 +67,7 @@ public class TMonthlyQualityReportS3004Controller extends BaseController
                 if (naOh.compareTo(naOhMax) > 0) { naOhMax = naOh; }
                 if (naOh.compareTo(naOhMin) < 0) { naOhMin = naOh; }
                 naOhSum = naOhSum.add(naOh);
+                naOhCount++;
             }
         }
         if (naOhCount != 0) {

+ 2 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS4012Controller.java

@@ -74,6 +74,7 @@ public class TMonthlyQualityReportS4012Controller extends BaseController
                 if (ethylene.compareTo(ethyleneMax) > 0) { ethyleneMax = ethylene; }
                 if (ethylene.compareTo(ethyleneMin) < 0) { ethyleneMin = ethylene; }
                 ethyleneSum = ethyleneSum.add(ethylene);
+                ethyleneCount++;
             }
             String propylene1 = monthlyQualityReportS4012.getPropylene();
             if (propylene1 != null) {
@@ -85,6 +86,7 @@ public class TMonthlyQualityReportS4012Controller extends BaseController
                     propyleneMin = propylene;
                 }
                 propyleneSum = propyleneSum.add(propylene);
+                propyleneCount++;
             }
         }
         if (ethyleneCount != 0) {

+ 1 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS4013Controller.java

@@ -67,6 +67,7 @@ public class TMonthlyQualityReportS4013Controller extends BaseController
                 if (ethylene.compareTo(ethyleneMax) > 0) { ethyleneMax = ethylene; }
                 if (ethylene.compareTo(ethyleneMin) < 0) { ethyleneMin = ethylene; }
                 ethyleneSum = ethyleneSum.add(ethylene);
+                ethyleneCount++;
             }
         }
         if (ethyleneCount != 0) {

+ 3 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS5001Controller.java

@@ -87,6 +87,7 @@ public class TMonthlyQualityReportS5001Controller extends BaseController
                 if (butene.compareTo(buteneMax) > 0) { buteneMax = butene; }
                 if (butene.compareTo(buteneMin) < 0) { buteneMin = butene; }
                 buteneSum = buteneSum.add(butene);
+                buteneCount++;
             }
             String propylene1 = monthlyQualityReportS5001.getPropylene();
             if ( propylene1 != null) {
@@ -98,6 +99,7 @@ public class TMonthlyQualityReportS5001Controller extends BaseController
                     propyleneMin = propylene;
                 }
                 propyleneSum = propyleneSum.add(propylene);
+                propyleneCount++;
             }
             String mapd1 = monthlyQualityReportS5001.getMapd();
             if (mapd1 != null) {
@@ -109,6 +111,7 @@ public class TMonthlyQualityReportS5001Controller extends BaseController
                     mapdMin = mapd;
                 }
                 mapdSum = mapdSum.add(mapd);
+                mapdCount++;
             }
         }
         if (buteneCount != 0) {

+ 19 - 8
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS5003Controller.java

@@ -51,21 +51,32 @@ public class TMonthlyQualityReportS5003Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS5003 firstValue = tMonthlyQualityReportS5003s.get(0);
         // 最大值
-        BigDecimal propyleneMax = new BigDecimal(firstValue.getPropylene());
+        BigDecimal propyleneMax = new BigDecimal(firstValue.getPropylene() == null ? "0" : firstValue.getPropylene());
         // 最小值
-        BigDecimal propyleneMin = new BigDecimal(firstValue.getPropylene());
+        BigDecimal propyleneMin = new BigDecimal(firstValue.getPropylene() == null ? "0" : firstValue.getPropylene());
         // 平均值
         BigDecimal propyleneAvg = new BigDecimal(BigInteger.ZERO);
         // 总和
         BigDecimal propyleneSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int propyleneCount = 0;
         for (TMonthlyQualityReportS5003 monthlyQualityReportS5003 : tMonthlyQualityReportS5003s) {
-            BigDecimal propylene = new BigDecimal(monthlyQualityReportS5003.getPropylene());
-            if (propylene.compareTo(propyleneMax) > 0) { propyleneMax = propylene; }
-            if (propylene.compareTo(propyleneMin) < 0) { propyleneMin = propylene; }
-            propyleneSum = propyleneSum.add(propylene);
+            String propylene1 = monthlyQualityReportS5003.getPropylene();
+            if (propylene1 != null) {
+                BigDecimal propylene = new BigDecimal(propylene1);
+                if (propylene.compareTo(propyleneMax) > 0) {
+                    propyleneMax = propylene;
+                }
+                if (propylene.compareTo(propyleneMin) < 0) {
+                    propyleneMin = propylene;
+                }
+                propyleneSum = propyleneSum.add(propylene);
+                propyleneCount++;
+            }
+        }
+        if (propyleneCount != 0) {
+            propyleneAvg = propyleneSum.divide(new BigDecimal(propyleneCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS5003s.size());
-        propyleneAvg = propyleneSum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("propylene(max)="+ propyleneMax.toString() + "\t");
         description.append("propylene(min)="+ propyleneMin.toString() + "\t");

+ 49 - 16
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS6101Controller.java

@@ -67,24 +67,57 @@ public class TMonthlyQualityReportS6101Controller extends BaseController
         BigDecimal brNumberSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal totalSulfurSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal totalNitrogenSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int brNumberCount = 0;
+        int totalSulfurCount = 0;
+        int totalNitrogenCount = 0;
         for (TMonthlyQualityReportS6101 monthlyQualityReportS6101 : tMonthlyQualityReportS6101s) {
-            BigDecimal brNumber = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6101.getBrNumber()) ? "0" : monthlyQualityReportS6101.getBrNumber());
-            BigDecimal totalSulfur = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6101.getTotalSulfur()) ? "0" : monthlyQualityReportS6101.getTotalSulfur());
-            BigDecimal totalNitrogen = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6101.getTotalNitrogen()) ? "0" : monthlyQualityReportS6101.getTotalNitrogen());
-            if (brNumber.compareTo(brNumberMax) > 0) { brNumberMax = brNumber; }
-            if (totalSulfur.compareTo(totalSulfurMax) > 0) { totalSulfurMax = totalSulfur; }
-            if (totalNitrogen.compareTo(totalNitrogenMax) > 0) { totalNitrogenMax = totalNitrogen; }
-            if (brNumber.compareTo(brNumberMin) < 0) { brNumberMin = brNumber; }
-            if (totalSulfur.compareTo(totalSulfurMin) < 0) { totalSulfurMin = totalSulfur; }
-            if (totalNitrogen.compareTo(totalNitrogenMin) < 0) { totalNitrogenMin = totalNitrogen; }
-            brNumberSum = brNumberSum.add(brNumber);
-            totalSulfurSum = totalSulfurSum.add(totalSulfur);
-            totalNitrogenSum = totalNitrogenSum.add(totalNitrogen);
+            String brNumber1 = monthlyQualityReportS6101.getBrNumber();
+            if (brNumber1 != null) {
+                BigDecimal brNumber = new BigDecimal(brNumber1);
+                if (brNumber.compareTo(brNumberMax) > 0) {
+                    brNumberMax = brNumber;
+                }
+                if (brNumber.compareTo(brNumberMin) < 0) {
+                    brNumberMin = brNumber;
+                }
+                brNumberSum = brNumberSum.add(brNumber);
+                brNumberCount++;
+            }
+            String totalSulfur1 = monthlyQualityReportS6101.getTotalSulfur();
+            if (totalSulfur1 != null) {
+                BigDecimal totalSulfur = new BigDecimal(totalSulfur1);
+                if (totalSulfur.compareTo(totalSulfurMax) > 0) {
+                    totalSulfurMax = totalSulfur;
+                }
+                if (totalSulfur.compareTo(totalSulfurMin) < 0) {
+                    totalSulfurMin = totalSulfur;
+                }
+                totalSulfurSum = totalSulfurSum.add(totalSulfur);
+                totalSulfurCount++;
+            }
+            String totalNitrogen1 = monthlyQualityReportS6101.getTotalNitrogen();
+            if (totalNitrogen1 != null) {
+                BigDecimal totalNitrogen = new BigDecimal(totalNitrogen1);
+                if (totalNitrogen.compareTo(totalNitrogenMax) > 0) {
+                    totalNitrogenMax = totalNitrogen;
+                }
+                if (totalNitrogen.compareTo(totalNitrogenMin) < 0) {
+                    totalNitrogenMin = totalNitrogen;
+                }
+                totalNitrogenSum = totalNitrogenSum.add(totalNitrogen);
+                totalNitrogenCount++;
+            }
+        }
+        if (brNumberCount != 0) {
+            brNumberAvg = brNumberSum.divide(new BigDecimal(brNumberCount), 2, RoundingMode.HALF_UP);
+        }
+        if (totalSulfurCount != 0) {
+            totalSulfurAvg = totalSulfurSum.divide(new BigDecimal(totalSulfurCount), 2, RoundingMode.HALF_UP);
+        }
+        if (totalNitrogenCount != 0) {
+            totalNitrogenAvg = totalNitrogenSum.divide(new BigDecimal(totalNitrogenCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS6101s.size());
-        brNumberAvg = brNumberSum.divide(count, 2, RoundingMode.HALF_UP);
-        totalSulfurAvg = totalSulfurSum.divide(count, 2, RoundingMode.HALF_UP);
-        totalNitrogenAvg = totalNitrogenSum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("brNumber(max)="+ brNumberMax.toString() + "\t");
         description.append("totalSulfur(max)="+ totalSulfurMax.toString() + "\t");

+ 75 - 24
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS6301Controller.java

@@ -73,32 +73,83 @@ public class TMonthlyQualityReportS6301Controller extends BaseController
         BigDecimal C250Sum = new BigDecimal(BigInteger.ZERO);
         BigDecimal C4Sum = new BigDecimal(BigInteger.ZERO);
         BigDecimal C410Sum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int C5ConjugatedDienesDcpd30Count = 0;
+        int C5ConjugatedDienesDcpd40Count = 0;
+        int C250Count = 0;
+        int C4Count = 0;
+        int C410Count = 0;
         for (TMonthlyQualityReportS6301 monthlyQualityReportS6301 : tMonthlyQualityReportS6301s) {
-            BigDecimal C5ConjugatedDienesDcpd30 = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6301.getC5ConjugatedDienesDcpd30()) ? "0" : monthlyQualityReportS6301.getC5ConjugatedDienesDcpd30());
-            BigDecimal C5ConjugatedDienesDcpd40 = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6301.getC5ConjugatedDienesDcpd40()) ? "0" : monthlyQualityReportS6301.getC5ConjugatedDienesDcpd40());
-            BigDecimal C250 = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6301.getC250()) ? "0" : monthlyQualityReportS6301.getC250());
-            BigDecimal C4 = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6301.getC4()) ? "0" : monthlyQualityReportS6301.getC4());
-            BigDecimal C410 = new BigDecimal(StringUtils.isNull(monthlyQualityReportS6301.getC410()) ? "0" : monthlyQualityReportS6301.getC410());
-            if (C5ConjugatedDienesDcpd30.compareTo(C5ConjugatedDienesDcpd30Max) > 0) { C5ConjugatedDienesDcpd30Max = C5ConjugatedDienesDcpd30; }
-            if (C5ConjugatedDienesDcpd40.compareTo(C5ConjugatedDienesDcpd40Max) > 0) { C5ConjugatedDienesDcpd40Max = C5ConjugatedDienesDcpd40; }
-            if (C250.compareTo(C250Max) > 0) { C250Max = C250; }
-            if (C4.compareTo(C4Max) > 0) { C4Max = C4; }
-            if (C410.compareTo(C410Max) > 0) { C410Max = C410; }
-            if (C5ConjugatedDienesDcpd30.compareTo(C5ConjugatedDienesDcpd30Min) < 0) { C5ConjugatedDienesDcpd30 = C5ConjugatedDienesDcpd30; }
-            if (C5ConjugatedDienesDcpd40.compareTo(C5ConjugatedDienesDcpd40Min) < 0) { C5ConjugatedDienesDcpd40 = C5ConjugatedDienesDcpd40; }
-            if (C250.compareTo(C250Min) < 0) { C250 = C250; }
-            if (C4.compareTo(C4Min) < 0) { C4 = C4; }
-            if (C410.compareTo(C410Min) < 0) { C410 = C410; }
-            C5ConjugatedDienesDcpd30Sum = C5ConjugatedDienesDcpd30Sum.add(C5ConjugatedDienesDcpd30);
-            C5ConjugatedDienesDcpd40Sum = C5ConjugatedDienesDcpd40Sum.add(C5ConjugatedDienesDcpd40);
-            C250Sum = C250Sum.add(C250);
-            C4Sum = C4Sum.add(C4);
-            C410Sum = C410Sum.add(C410);
+            String c5ConjugatedDienesDcpd301 = monthlyQualityReportS6301.getC5ConjugatedDienesDcpd30();
+            if (c5ConjugatedDienesDcpd301 != null) {
+                BigDecimal C5ConjugatedDienesDcpd30 = new BigDecimal(c5ConjugatedDienesDcpd301);
+                if (C5ConjugatedDienesDcpd30.compareTo(C5ConjugatedDienesDcpd30Max) > 0) {
+                    C5ConjugatedDienesDcpd30Max = C5ConjugatedDienesDcpd30;
+                }
+                if (C5ConjugatedDienesDcpd30.compareTo(C5ConjugatedDienesDcpd30Min) < 0) {
+                    C5ConjugatedDienesDcpd30Min = C5ConjugatedDienesDcpd30;
+                }
+                C5ConjugatedDienesDcpd30Sum = C5ConjugatedDienesDcpd30Sum.add(C5ConjugatedDienesDcpd30);
+                C5ConjugatedDienesDcpd30Count++;
+            }
+            String c5ConjugatedDienesDcpd401 = monthlyQualityReportS6301.getC5ConjugatedDienesDcpd40();
+            if (c5ConjugatedDienesDcpd401 != null) {
+                BigDecimal C5ConjugatedDienesDcpd40 = new BigDecimal(c5ConjugatedDienesDcpd401);
+                if (C5ConjugatedDienesDcpd40.compareTo(C5ConjugatedDienesDcpd40Max) > 0) {
+                    C5ConjugatedDienesDcpd40Max = C5ConjugatedDienesDcpd40;
+                }
+                if (C5ConjugatedDienesDcpd40.compareTo(C5ConjugatedDienesDcpd40Min) < 0) {
+                    C5ConjugatedDienesDcpd40 = C5ConjugatedDienesDcpd40;
+                }
+                C5ConjugatedDienesDcpd40Sum = C5ConjugatedDienesDcpd40Sum.add(C5ConjugatedDienesDcpd40);
+                C5ConjugatedDienesDcpd40Count++;
+            }
+            String c2501 = monthlyQualityReportS6301.getC250();
+            if (c2501 != null) {
+                BigDecimal C250 = new BigDecimal(c2501);
+                if (C250.compareTo(C250Max) > 0) {
+                    C250Max = C250;
+                }
+                if (C250.compareTo(C250Min) < 0) {
+                    C250 = C250;
+                }
+                C250Sum = C250Sum.add(C250);
+                C250Count++;
+            }
+            String c41 = monthlyQualityReportS6301.getC4();
+            if (c41 != null) {
+                BigDecimal C4 = new BigDecimal(c41);
+                if (C4.compareTo(C4Max) > 0) {
+                    C4Max = C4;
+                }
+                if (C4.compareTo(C4Min) < 0) {
+                    C4 = C4;
+                }
+                C4Sum = C4Sum.add(C4);
+                C4Count++;
+            }
+            String c4101 = monthlyQualityReportS6301.getC410();
+            if (c4101 != null) {
+                BigDecimal C410 = new BigDecimal(c4101);
+                if (C410.compareTo(C410Max) > 0) {
+                    C410Max = C410;
+                }
+                if (C410.compareTo(C410Min) < 0) {
+                    C410 = C410;
+                }
+                C410Sum = C410Sum.add(C410);
+                C410Count++;
+            }
+        }
+        if ((C5ConjugatedDienesDcpd30Count+C5ConjugatedDienesDcpd40Count) != 0) {
+            C5ConjugatedDienesDcpdAvg = (C5ConjugatedDienesDcpd30Sum.add(C5ConjugatedDienesDcpd40Sum)).divide(new BigDecimal(C5ConjugatedDienesDcpd30Count+C5ConjugatedDienesDcpd40Count), 2, RoundingMode.HALF_UP);
+        }
+        if (C250Count != 0) {
+            C250Avg = C250Sum.divide(new BigDecimal(C250Count), 2, RoundingMode.HALF_UP);
+        }
+        if ((C4Count+C410Count) != 0) {
+            C4Avg = (C4Sum.add(C410Sum)).divide(new BigDecimal((C4Count+C410Count)), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS6301s.size());
-        C5ConjugatedDienesDcpdAvg = (C5ConjugatedDienesDcpd30Sum.add(C5ConjugatedDienesDcpd40Sum)).divide(count, 2, RoundingMode.HALF_UP);
-        C250Avg = C250Sum.divide(count, 2, RoundingMode.HALF_UP);
-        C4Avg = (C4Sum.add(C410Sum)).divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("C5ConjugatedDienesDcpd30(max)="+ (C5ConjugatedDienesDcpd30Max.compareTo(C5ConjugatedDienesDcpd40Max) > 0 ? C5ConjugatedDienesDcpd30Max : C5ConjugatedDienesDcpd40Max).toString().toString() + "\t");
         description.append("C250(max)="+ C250Max.toString() + "\t");