소스 검색

质量月报 - S0501、S2007、S3004、S4012、S4013、S5001后台计算方法优化

wangggziwen 1 년 전
부모
커밋
ee545edf49

+ 132 - 89
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS0501Controller.java

@@ -72,23 +72,6 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
             }
         }
 
-//        do {
-//            TMonthlyQualityReportS0501 reportS0501 = new TMonthlyQualityReportS0501();
-//            reportS0501.setMonth(startMonth);
-//            reportS0501.setYear(startYear);
-//            TMonthlyQualityReportS0501 reportS05011 = tMonthlyQualityReportS0501Service.selectTMonthlyQualityReportS0501ListMonth(reportS0501);
-//            if (reportS05011 != null) {
-//                dataMap.put(startYear + "-" + startMonth, reportS05011);
-//            }
-//            if (startMonth == 12) {
-//                startMonth = 1;
-//                startYear++;
-//            } else {
-//                startMonth++;
-//            }
-//        } while (startYear != endYear || startMonth != endMonth + 1);
-
-
         if (dataMap.size() == 0) {
             return AjaxResult.success();
         }
@@ -97,17 +80,17 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
         String firstKey = keys.get(0);
         TMonthlyQualityReportS0501 firstValue = dataMap.get(firstKey);
         // 最大值
-        BigDecimal pMax = new BigDecimal(firstValue.getP());
-        BigDecimal iMax = new BigDecimal(firstValue.getI());
-        BigDecimal oMax = new BigDecimal(firstValue.getO());
-        BigDecimal nMax = new BigDecimal(firstValue.getN());
-        BigDecimal fiftyMax = new BigDecimal(firstValue.getFifty());
+        BigDecimal pMax = new BigDecimal(firstValue.getP() == null ? "0" : firstValue.getP());
+        BigDecimal iMax = new BigDecimal(firstValue.getI() == null ? "0" : firstValue.getI());
+        BigDecimal oMax = new BigDecimal(firstValue.getO() == null ? "0" : firstValue.getO());
+        BigDecimal nMax = new BigDecimal(firstValue.getN() == null ? "0" : firstValue.getN());
+        BigDecimal fiftyMax = new BigDecimal(firstValue.getFifty() == null ? "0" : firstValue.getFifty());
         // 最小值
-        BigDecimal pMin = new BigDecimal(firstValue.getP());
-        BigDecimal iMin = new BigDecimal(firstValue.getI());
-        BigDecimal oMin = new BigDecimal(firstValue.getO());
-        BigDecimal nMin = new BigDecimal(firstValue.getN());
-        BigDecimal fiftyMin = new BigDecimal(firstValue.getFifty());
+        BigDecimal pMin = new BigDecimal(firstValue.getP() == null ? "0" : firstValue.getP());
+        BigDecimal iMin = new BigDecimal(firstValue.getI() == null ? "0" : firstValue.getI());
+        BigDecimal oMin = new BigDecimal(firstValue.getO() == null ? "0" : firstValue.getO());
+        BigDecimal nMin = new BigDecimal(firstValue.getN() == null ? "0" : firstValue.getN());
+        BigDecimal fiftyMin = new BigDecimal(firstValue.getFifty() == null ? "0" : firstValue.getFifty());
         // 平均值
         BigDecimal pAvg = new BigDecimal(BigInteger.ZERO);
         BigDecimal iAvg = new BigDecimal(BigInteger.ZERO);
@@ -120,35 +103,65 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
         BigDecimal oSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal nSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal fiftySum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int pCount = 0;
+        int iCount = 0;
+        int oCount = 0;
+        int nCount = 0;
+        int fiftyCount = 0;
         for(Map.Entry entry : dataMap.entrySet()) {
             TMonthlyQualityReportS0501 mapValue = (TMonthlyQualityReportS0501) entry.getValue();
-            BigDecimal p = new BigDecimal(mapValue.getP());
-            BigDecimal i = new BigDecimal(mapValue.getI());
-            BigDecimal o = new BigDecimal(mapValue.getO());
-            BigDecimal n = new BigDecimal(mapValue.getN());
-            BigDecimal fifty = new BigDecimal(mapValue.getFifty());
-            if (p.compareTo(pMax) > 0) { pMax = p; }
-            if (i.compareTo(iMax) > 0) { iMax = i; }
-            if (o.compareTo(oMax) > 0) { oMax = o; }
-            if (n.compareTo(nMax) > 0) { nMax = n; }
-            if (fifty.compareTo(fiftyMax) > 0) { fiftyMax = fifty; }
-            if (p.compareTo(pMin) < 0) { pMin = p; }
-            if (i.compareTo(iMin) < 0) { iMin = i; }
-            if (o.compareTo(oMin) < 0) { oMin = o; }
-            if (n.compareTo(nMin) < 0) { nMin = n; }
-            if (fifty.compareTo(fiftyMin) < 0) { fiftyMin = fifty; }
-            pSum = pSum.add(p);
-            iSum = iSum.add(i);
-            oSum = oSum.add(o);
-            nSum = nSum.add(n);
-            fiftySum = fiftySum.add(fifty);
+            String p1 = mapValue.getP();
+            if (p1 != null) {
+                BigDecimal p = new BigDecimal(p1);
+                if (p.compareTo(pMax) > 0) { pMax = p; }
+                if (p.compareTo(pMin) < 0) { pMin = p; }
+                pSum = pSum.add(p);
+            }
+            String i1 = mapValue.getI();
+            if (i1 != null) {
+                BigDecimal i = new BigDecimal(i1);
+                if (i.compareTo(iMax) > 0) { iMax = i; }
+                if (i.compareTo(iMin) < 0) { iMin = i; }
+                iSum = iSum.add(i);
+            }
+            String o1 = mapValue.getO();
+            if (o1 != null) {
+                BigDecimal o = new BigDecimal(o1);
+                if (o.compareTo(oMax) > 0) { oMax = o; }
+                if (o.compareTo(oMin) < 0) { oMin = o; }
+                oSum = oSum.add(o);
+            }
+            String n1 = mapValue.getN();
+            if (n1 != null) {
+                BigDecimal n = new BigDecimal(n1);
+                if (n.compareTo(nMax) > 0) { nMax = n; }
+                if (n.compareTo(nMin) < 0) { nMin = n; }
+                nSum = nSum.add(n);
+            }
+            String fifty1 = mapValue.getFifty();
+            if (fifty1 != null) {
+                BigDecimal fifty = new BigDecimal(fifty1);
+                if (fifty.compareTo(fiftyMax) > 0) { fiftyMax = fifty; }
+                if (fifty.compareTo(fiftyMin) < 0) { fiftyMin = fifty; }
+                fiftySum = fiftySum.add(fifty);
+            }
+        }
+        if (pCount != 0) {
+            pAvg = pSum.divide(new BigDecimal(pCount), 2, RoundingMode.HALF_UP);
+        }
+        if (iCount != 0) {
+            iAvg = iSum.divide(new BigDecimal(iCount), 2, RoundingMode.HALF_UP);
+        }
+        if (oCount != 0) {
+            oAvg = oSum.divide(new BigDecimal(oCount), 2, RoundingMode.HALF_UP);
+        }
+        if (nCount != 0) {
+            nAvg = nSum.divide(new BigDecimal(nCount), 2, RoundingMode.HALF_UP);
+        }
+        if (fiftyCount != 0) {
+            fiftyAvg = fiftySum.divide(new BigDecimal(fiftyCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(dataMap.size());
-        pAvg = pSum.divide(count, 2, RoundingMode.HALF_UP);
-        iAvg = iSum.divide(count, 2, RoundingMode.HALF_UP);
-        oAvg = oSum.divide(count, 2, RoundingMode.HALF_UP);
-        nAvg = nSum.divide(count, 2, RoundingMode.HALF_UP);
-        fiftyAvg = fiftySum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("正构烷烃(max)="+ pMax.toString() + "\t");
         description.append("异构烷烃(max)="+ iMax.toString() + "\t");
@@ -185,17 +198,17 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS0501 firstValue = tMonthlyQualityReportS0501s.get(0);
         // 最大值
-        BigDecimal pMax = new BigDecimal(firstValue.getP());
-        BigDecimal iMax = new BigDecimal(firstValue.getI());
-        BigDecimal oMax = new BigDecimal(firstValue.getO());
-        BigDecimal nMax = new BigDecimal(firstValue.getN());
-        BigDecimal fiftyMax = new BigDecimal(firstValue.getFifty());
+        BigDecimal pMax = new BigDecimal(firstValue.getP() == null ? "0" : firstValue.getP());
+        BigDecimal iMax = new BigDecimal(firstValue.getI() == null ? "0" : firstValue.getI());
+        BigDecimal oMax = new BigDecimal(firstValue.getO() == null ? "0" : firstValue.getO());
+        BigDecimal nMax = new BigDecimal(firstValue.getN() == null ? "0" : firstValue.getN());
+        BigDecimal fiftyMax = new BigDecimal(firstValue.getFifty() == null ? "0" : firstValue.getFifty());
         // 最小值
-        BigDecimal pMin = new BigDecimal(firstValue.getP());
-        BigDecimal iMin = new BigDecimal(firstValue.getI());
-        BigDecimal oMin = new BigDecimal(firstValue.getO());
-        BigDecimal nMin = new BigDecimal(firstValue.getN());
-        BigDecimal fiftyMin = new BigDecimal(firstValue.getFifty());
+        BigDecimal pMin = new BigDecimal(firstValue.getP() == null ? "0" : firstValue.getP());
+        BigDecimal iMin = new BigDecimal(firstValue.getI() == null ? "0" : firstValue.getI());
+        BigDecimal oMin = new BigDecimal(firstValue.getO() == null ? "0" : firstValue.getO());
+        BigDecimal nMin = new BigDecimal(firstValue.getN() == null ? "0" : firstValue.getN());
+        BigDecimal fiftyMin = new BigDecimal(firstValue.getFifty() == null ? "0" : firstValue.getFifty());
         // 平均值
         BigDecimal pAvg = new BigDecimal(BigInteger.ZERO);
         BigDecimal iAvg = new BigDecimal(BigInteger.ZERO);
@@ -208,34 +221,64 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
         BigDecimal oSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal nSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal fiftySum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int pCount = 0;
+        int iCount = 0;
+        int oCount = 0;
+        int nCount = 0;
+        int fiftyCount = 0;
         for (TMonthlyQualityReportS0501 monthlyQualityReportS0501 : tMonthlyQualityReportS0501s) {
-            BigDecimal p = new BigDecimal(monthlyQualityReportS0501.getP());
-            BigDecimal i = new BigDecimal(monthlyQualityReportS0501.getI());
-            BigDecimal o = new BigDecimal(monthlyQualityReportS0501.getO());
-            BigDecimal n = new BigDecimal(monthlyQualityReportS0501.getN());
-            BigDecimal fifty = new BigDecimal(monthlyQualityReportS0501.getFifty());
-            if (p.compareTo(pMax) > 0) { pMax = p; }
-            if (i.compareTo(iMax) > 0) { iMax = i; }
-            if (o.compareTo(oMax) > 0) { oMax = o; }
-            if (n.compareTo(nMax) > 0) { nMax = n; }
-            if (fifty.compareTo(fiftyMax) > 0) { fiftyMax = fifty; }
-            if (p.compareTo(pMin) < 0) { pMin = p; }
-            if (i.compareTo(iMin) < 0) { iMin = i; }
-            if (o.compareTo(oMin) < 0) { oMin = o; }
-            if (n.compareTo(nMin) < 0) { nMin = n; }
-            if (fifty.compareTo(fiftyMin) < 0) { fiftyMin = fifty; }
-            pSum = pSum.add(p);
-            iSum = iSum.add(i);
-            oSum = oSum.add(o);
-            nSum = nSum.add(n);
-            fiftySum = fiftySum.add(fifty);
+            String p1 = monthlyQualityReportS0501.getP();
+            if (p1 != null) {
+                BigDecimal p = new BigDecimal(p1);
+                if (p.compareTo(pMax) > 0) { pMax = p; }
+                if (p.compareTo(pMin) < 0) { pMin = p; }
+                pSum = pSum.add(p);
+            }
+            String i1 = monthlyQualityReportS0501.getI();
+            if (i1 != null) {
+                BigDecimal i = new BigDecimal(i1);
+                if (i.compareTo(iMax) > 0) { iMax = i; }
+                if (i.compareTo(iMin) < 0) { iMin = i; }
+                iSum = iSum.add(i);
+            }
+            String o1 = monthlyQualityReportS0501.getO();
+            if (o1 != null) {
+                BigDecimal o = new BigDecimal(o1);
+                if (o.compareTo(oMax) > 0) { oMax = o; }
+                if (o.compareTo(oMin) < 0) { oMin = o; }
+                oSum = oSum.add(o);
+            }
+            String n1 = monthlyQualityReportS0501.getN();
+            if (n1 != null) {
+                BigDecimal n = new BigDecimal(n1);
+                if (n.compareTo(nMax) > 0) { nMax = n; }
+                if (n.compareTo(nMin) < 0) { nMin = n; }
+                nSum = nSum.add(n);
+            }
+            String fifty1 = monthlyQualityReportS0501.getFifty();
+            if (fifty1 != null) {
+                BigDecimal fifty = new BigDecimal(fifty1);
+                if (fifty.compareTo(fiftyMax) > 0) { fiftyMax = fifty; }
+                if (fifty.compareTo(fiftyMin) < 0) { fiftyMin = fifty; }
+                fiftySum = fiftySum.add(fifty);
+            }
+        }
+        if (pCount != 0) {
+            pAvg = pSum.divide(new BigDecimal(pCount), 2, RoundingMode.HALF_UP);
+        }
+        if (iCount != 0) {
+            iAvg = iSum.divide(new BigDecimal(iCount), 2, RoundingMode.HALF_UP);
+        }
+        if (oCount != 0) {
+            oAvg = oSum.divide(new BigDecimal(oCount), 2, RoundingMode.HALF_UP);
+        }
+        if (nCount != 0) {
+            nAvg = nSum.divide(new BigDecimal(nCount), 2, RoundingMode.HALF_UP);
+        }
+        if (fiftyCount != 0) {
+            fiftyAvg = fiftySum.divide(new BigDecimal(fiftyCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS0501s.size());
-        pAvg = pSum.divide(count, 2, RoundingMode.HALF_UP);
-        iAvg = iSum.divide(count, 2, RoundingMode.HALF_UP);
-        oAvg = oSum.divide(count, 2, RoundingMode.HALF_UP);
-        nAvg = nSum.divide(count, 2, RoundingMode.HALF_UP);
-        fiftyAvg = fiftySum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("正构烷烃(max)="+ pMax.toString() + "\t");
         description.append("异构烷烃(max)="+ iMax.toString() + "\t");

+ 60 - 34
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS2007Controller.java

@@ -51,19 +51,21 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS2007 firstValue = tMonthlyQualityReportS2007s.get(0);
         String firstProductionString = firstValue.getProduction();
-        if (firstProductionString.indexOf("/") != -1) {
-            firstProductionString = firstProductionString.substring(1, firstProductionString.indexOf("/"));
+        if (firstProductionString != null) {
+            if (firstProductionString.indexOf("/") != -1) {
+                firstProductionString = firstProductionString.substring(1, firstProductionString.indexOf("/"));
+            }
         }
         // 最大值
-        BigDecimal viscosityMax = new BigDecimal(firstValue.getViscosity());
-        BigDecimal endPointMax = new BigDecimal(firstValue.getEndPoint());
-        BigDecimal pressureDifferenceMax = new BigDecimal(firstValue.getPressureDifference());
-        BigDecimal productionMax = new BigDecimal(firstProductionString);
+        BigDecimal viscosityMax = new BigDecimal(firstValue.getViscosity() == null ? "0" : firstValue.getViscosity());
+        BigDecimal endPointMax = new BigDecimal(firstValue.getEndPoint() == null ? "0" : firstValue.getEndPoint());
+        BigDecimal pressureDifferenceMax = new BigDecimal(firstValue.getPressureDifference() == null ? "0" : firstValue.getPressureDifference());
+        BigDecimal productionMax = new BigDecimal(firstProductionString == null ? "0" : firstProductionString);
         // 最小值
-        BigDecimal viscosityMin = new BigDecimal(firstValue.getViscosity());
-        BigDecimal endPointMin = new BigDecimal(firstValue.getEndPoint());
-        BigDecimal pressureDifferenceMin = new BigDecimal(firstValue.getPressureDifference());
-        BigDecimal productionMin = new BigDecimal(firstProductionString);
+        BigDecimal viscosityMin = new BigDecimal(firstValue.getViscosity() == null ? "0" : firstValue.getViscosity());
+        BigDecimal endPointMin = new BigDecimal(firstValue.getEndPoint() == null ? "0" : firstValue.getEndPoint());
+        BigDecimal pressureDifferenceMin = new BigDecimal(firstValue.getPressureDifference() == null ? "0" : firstValue.getPressureDifference());
+        BigDecimal productionMin = new BigDecimal(firstProductionString == null ? "0" : firstProductionString);
         // 平均值
         BigDecimal viscosityAvg = new BigDecimal(BigInteger.ZERO);
         BigDecimal endPointAvg = new BigDecimal(BigInteger.ZERO);
@@ -74,33 +76,57 @@ public class TMonthlyQualityReportS2007Controller extends BaseController
         BigDecimal endPointSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal pressureDifferenceSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal productionSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int viscosityCount = 0;
+        int endPointCount = 0;
+        int pressureDifferenceCount = 0;
+        int productionCount = 0;
+        int Count = 0;
         for (TMonthlyQualityReportS2007 monthlyQualityReportS2007 : tMonthlyQualityReportS2007s) {
-            BigDecimal viscosity = new BigDecimal(monthlyQualityReportS2007.getViscosity());
-            BigDecimal endPoint = new BigDecimal(monthlyQualityReportS2007.getEndPoint());
-            BigDecimal pressureDifference = new BigDecimal(monthlyQualityReportS2007.getPressureDifference());
-            String productionString = firstValue.getProduction();
-            if (productionString.indexOf("/") != -1) {
-                productionString = productionString.substring(1, productionString.indexOf("/"));
+            String viscosity1 = monthlyQualityReportS2007.getViscosity();
+            if (viscosity1 != null) {
+                BigDecimal viscosity = new BigDecimal(viscosity1);
+                if (viscosity.compareTo(viscosityMax) > 0) { viscosityMax = viscosity; }
+                if (viscosity.compareTo(viscosityMin) < 0) { viscosityMin = viscosity; }
+                viscositySum = viscositySum.add(viscosity);
+            }
+            String endPoint1 = monthlyQualityReportS2007.getEndPoint();
+            if (endPoint1 != null) {
+                BigDecimal endPoint = new BigDecimal(endPoint1);
+                if (endPoint.compareTo(endPointMax) > 0) { endPointMax = endPoint; }
+                if (endPoint.compareTo(endPointMin) < 0) { endPointMin = endPoint; }
+                endPointSum = endPointSum.add(endPoint);
+            }
+            String pressureDifference1 = monthlyQualityReportS2007.getPressureDifference();
+            if (pressureDifference1 != null) {
+                BigDecimal pressureDifference = new BigDecimal(pressureDifference1);
+                if (pressureDifference.compareTo(pressureDifferenceMax) > 0) { pressureDifferenceMax = pressureDifference; }
+                if (pressureDifference.compareTo(pressureDifferenceMin) < 0) { pressureDifferenceMin = pressureDifference; }
+                pressureDifferenceSum = pressureDifferenceSum.add(pressureDifference);
+            }
+            String productionString = monthlyQualityReportS2007.getProduction();
+            if (productionString != null) {
+                if (productionString.indexOf("/") != -1) {
+                    productionString = productionString.substring(1, productionString.indexOf("/"));
+                }
+                BigDecimal production = new BigDecimal(productionString);
+                if (production.compareTo(productionMax) > 0) { productionMax = production; }
+                if (production.compareTo(productionMin) < 0) { productionMin = production; }
+                productionSum = productionSum.add(production);
             }
-            BigDecimal production = new BigDecimal(productionString);
-            if (viscosity.compareTo(viscosityMax) > 0) { viscosityMax = viscosity; }
-            if (endPoint.compareTo(endPointMax) > 0) { endPointMax = endPoint; }
-            if (pressureDifference.compareTo(pressureDifferenceMax) > 0) { pressureDifferenceMax = pressureDifference; }
-            if (production.compareTo(productionMax) > 0) { productionMax = production; }
-            if (viscosity.compareTo(viscosityMin) < 0) { viscosityMin = viscosity; }
-            if (endPoint.compareTo(endPointMin) < 0) { endPointMin = endPoint; }
-            if (pressureDifference.compareTo(pressureDifferenceMin) < 0) { pressureDifferenceMin = pressureDifference; }
-            if (production.compareTo(productionMin) < 0) { productionMin = production; }
-            viscositySum = viscositySum.add(viscosity);
-            endPointSum = endPointSum.add(endPoint);
-            pressureDifferenceSum = pressureDifferenceSum.add(pressureDifference);
-            productionSum = productionSum.add(production);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS2007s.size());
-        viscosityAvg = viscositySum.divide(count, 2, RoundingMode.HALF_UP);
-        endPointAvg = endPointSum.divide(count, 2, RoundingMode.HALF_UP);
-        pressureDifferenceAvg = pressureDifferenceSum.divide(count, 2, RoundingMode.HALF_UP);
-        productionAvg = productionSum.divide(count, 2, RoundingMode.HALF_UP);
+        if (viscosityCount != 0) {
+            viscosityAvg = viscositySum.divide(new BigDecimal(viscosityCount), 2, RoundingMode.HALF_UP);
+        }
+        if (endPointCount != 0) {
+            endPointAvg = endPointSum.divide(new BigDecimal(endPointCount), 2, RoundingMode.HALF_UP);
+        }
+        if (pressureDifferenceCount != 0) {
+            pressureDifferenceAvg = pressureDifferenceSum.divide(new BigDecimal(pressureDifferenceCount), 2, RoundingMode.HALF_UP);
+        }
+        if (productionCount != 0) {
+            productionAvg = productionSum.divide(new BigDecimal(productionCount), 2, RoundingMode.HALF_UP);
+        }
         StringBuffer description = new StringBuffer();
         description.append("QO粘度(max)="+ viscosityMax.toString() + "\t");
         description.append("汽油终馏点(max)="+ endPointMax.toString() + "\t");

+ 14 - 8
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS3004Controller.java

@@ -51,21 +51,27 @@ public class TMonthlyQualityReportS3004Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS3004 firstValue = tMonthlyQualityReportS3004s.get(0);
         // 最大值
-        BigDecimal naOhMax = new BigDecimal(firstValue.getNaOh());
+        BigDecimal naOhMax = new BigDecimal(firstValue.getNaOh() == null ? "0" : firstValue.getNaOh());
         // 最小值
-        BigDecimal naOhMin = new BigDecimal(firstValue.getNaOh());
+        BigDecimal naOhMin = new BigDecimal(firstValue.getNaOh() == null ? "0" : firstValue.getNaOh());
         // 平均值
         BigDecimal naOhAvg = new BigDecimal(BigInteger.ZERO);
         // 总和
         BigDecimal naOhSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int naOhCount = 0;
         for (TMonthlyQualityReportS3004 monthlyQualityReportS3004 : tMonthlyQualityReportS3004s) {
-            BigDecimal naOh = new BigDecimal(monthlyQualityReportS3004.getNaOh());
-            if (naOh.compareTo(naOhMax) > 0) { naOhMax = naOh; }
-            if (naOh.compareTo(naOhMin) < 0) { naOhMin = naOh; }
-            naOhSum = naOhSum.add(naOh);
+            String naOh1 = monthlyQualityReportS3004.getNaOh();
+            if (naOh1 != null) {
+                BigDecimal naOh = new BigDecimal(naOh1);
+                if (naOh.compareTo(naOhMax) > 0) { naOhMax = naOh; }
+                if (naOh.compareTo(naOhMin) < 0) { naOhMin = naOh; }
+                naOhSum = naOhSum.add(naOh);
+            }
+        }
+        if (naOhCount != 0) {
+            naOhAvg = naOhSum.divide(new BigDecimal(naOhCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS3004s.size());
-        naOhAvg = naOhSum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("naOh(max)="+ naOhMax.toString() + "\t");
         description.append("naOh(min)="+ naOhMin.toString() + "\t");

+ 31 - 15
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS4012Controller.java

@@ -53,30 +53,46 @@ public class TMonthlyQualityReportS4012Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS4012 firstValue = tMonthlyQualityReportS4012s.get(0);
         // 最大值
-        BigDecimal ethyleneMax = new BigDecimal(firstValue.getEthylene());
-        BigDecimal propyleneMax = new BigDecimal(firstValue.getPropylene());
+        BigDecimal ethyleneMax = new BigDecimal(firstValue.getEthylene() == null ? "0" : firstValue.getEthylene());
+        BigDecimal propyleneMax = new BigDecimal(firstValue.getPropylene() == null ? "0" : firstValue.getPropylene());
         // 最小值
-        BigDecimal ethyleneMin = new BigDecimal(firstValue.getEthylene());
-        BigDecimal propyleneMin = new BigDecimal(firstValue.getPropylene());
+        BigDecimal ethyleneMin = new BigDecimal(firstValue.getEthylene() == null ? "0" : firstValue.getEthylene());
+        BigDecimal propyleneMin = new BigDecimal(firstValue.getPropylene() == null ? "0" : firstValue.getPropylene());
         // 平均值
         BigDecimal ethyleneAvg = new BigDecimal(BigInteger.ZERO);
         BigDecimal propyleneAvg = new BigDecimal(BigInteger.ZERO);
         // 总和
         BigDecimal ethyleneSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal propyleneSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int ethyleneCount = 0;
+        int propyleneCount = 0;
         for (TMonthlyQualityReportS4012 monthlyQualityReportS4012 : tMonthlyQualityReportS4012s) {
-            BigDecimal ethylene = new BigDecimal(monthlyQualityReportS4012.getEthylene());
-            BigDecimal propylene = new BigDecimal(monthlyQualityReportS4012.getPropylene());
-            if (ethylene.compareTo(ethyleneMax) > 0) { ethyleneMax = ethylene; }
-            if (propylene.compareTo(propyleneMax) > 0) { propyleneMax = propylene; }
-            if (ethylene.compareTo(ethyleneMin) < 0) { ethyleneMin = ethylene; }
-            if (propylene.compareTo(propyleneMin) < 0) { propyleneMin = propylene; }
-            ethyleneSum = ethyleneSum.add(ethylene);
-            propyleneSum = propyleneSum.add(propylene);
+            String ethylene1 = monthlyQualityReportS4012.getEthylene();
+            if (ethylene1 != null) {
+                BigDecimal ethylene = new BigDecimal(ethylene1);
+                if (ethylene.compareTo(ethyleneMax) > 0) { ethyleneMax = ethylene; }
+                if (ethylene.compareTo(ethyleneMin) < 0) { ethyleneMin = ethylene; }
+                ethyleneSum = ethyleneSum.add(ethylene);
+            }
+            String propylene1 = monthlyQualityReportS4012.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);
+            }
+        }
+        if (ethyleneCount != 0) {
+            ethyleneAvg = ethyleneSum.divide(new BigDecimal(ethyleneCount), 2, RoundingMode.HALF_UP);
+        }
+        if (propyleneCount != 0) {
+            propyleneAvg = propyleneSum.divide(new BigDecimal(propyleneCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS4012s.size());
-        ethyleneAvg = ethyleneSum.divide(count, 2, RoundingMode.HALF_UP);
-        propyleneAvg = propyleneSum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("ethylene(max)="+ ethyleneMax.toString() + "\t");
         description.append("propylene(max)="+ propyleneMax.toString() + "\n");

+ 14 - 8
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS4013Controller.java

@@ -51,21 +51,27 @@ public class TMonthlyQualityReportS4013Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS4013 firstValue = tMonthlyQualityReportS4013s.get(0);
         // 最大值
-        BigDecimal ethyleneMax = new BigDecimal(firstValue.getEthylene());
+        BigDecimal ethyleneMax = new BigDecimal(firstValue.getEthylene() == null ? "0" : firstValue.getEthylene());
         // 最小值
-        BigDecimal ethyleneMin = new BigDecimal(firstValue.getEthylene());
+        BigDecimal ethyleneMin = new BigDecimal(firstValue.getEthylene() == null ? "0" : firstValue.getEthylene());
         // 平均值
         BigDecimal ethyleneAvg = new BigDecimal(BigInteger.ZERO);
         // 总和
         BigDecimal ethyleneSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int ethyleneCount = 0;
         for (TMonthlyQualityReportS4013 monthlyQualityReportS4013 : tMonthlyQualityReportS4013s) {
-            BigDecimal ethylene = new BigDecimal(monthlyQualityReportS4013.getEthylene());
-            if (ethylene.compareTo(ethyleneMax) > 0) { ethyleneMax = ethylene; }
-            if (ethylene.compareTo(ethyleneMin) < 0) { ethyleneMin = ethylene; }
-            ethyleneSum = ethyleneSum.add(ethylene);
+            String ethylene1 = monthlyQualityReportS4013.getEthylene();
+            if (ethylene1 != null) {
+                BigDecimal ethylene = new BigDecimal(ethylene1);
+                if (ethylene.compareTo(ethyleneMax) > 0) { ethyleneMax = ethylene; }
+                if (ethylene.compareTo(ethyleneMin) < 0) { ethyleneMin = ethylene; }
+                ethyleneSum = ethyleneSum.add(ethylene);
+            }
+        }
+        if (ethyleneCount != 0) {
+            ethyleneAvg = ethyleneSum.divide(new BigDecimal(ethyleneCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS4013s.size());
-        ethyleneAvg = ethyleneSum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("ethylene(max)="+ ethyleneMax.toString() + "\t");
         description.append("ethylene(min)="+ ethyleneMin.toString() + "\t");

+ 48 - 22
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS5001Controller.java

@@ -61,13 +61,13 @@ public class TMonthlyQualityReportS5001Controller extends BaseController
         // 获取list第一个元素
         TMonthlyQualityReportS5001 firstValue = tMonthlyQualityReportS5001s.get(0);
         // 最大值
-        BigDecimal buteneMax = new BigDecimal(firstValue.getButene());
-        BigDecimal propyleneMax = new BigDecimal(firstValue.getPropylene());
-        BigDecimal mapdMax = new BigDecimal(firstValue.getMapd());
+        BigDecimal buteneMax = new BigDecimal(firstValue.getButene() == null ? "0" : firstValue.getButene());
+        BigDecimal propyleneMax = new BigDecimal(firstValue.getPropylene() == null ? "0" : firstValue.getPropylene());
+        BigDecimal mapdMax = new BigDecimal(firstValue.getMapd() == null ? "0" : firstValue.getMapd());
         // 最小值
-        BigDecimal buteneMin = new BigDecimal(firstValue.getButene());
-        BigDecimal propyleneMin = new BigDecimal(firstValue.getPropylene());
-        BigDecimal mapdMin = new BigDecimal(firstValue.getMapd());
+        BigDecimal buteneMin = new BigDecimal(firstValue.getButene() == null ? "0" : firstValue.getButene());
+        BigDecimal propyleneMin = new BigDecimal(firstValue.getPropylene() == null ? "0" : firstValue.getPropylene());
+        BigDecimal mapdMin = new BigDecimal(firstValue.getMapd() == null ? "0" : firstValue.getMapd());
         // 平均值
         BigDecimal buteneAvg = new BigDecimal(BigInteger.ZERO);
         BigDecimal propyleneAvg = new BigDecimal(BigInteger.ZERO);
@@ -76,24 +76,50 @@ public class TMonthlyQualityReportS5001Controller extends BaseController
         BigDecimal buteneSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal propyleneSum = new BigDecimal(BigInteger.ZERO);
         BigDecimal mapdSum = new BigDecimal(BigInteger.ZERO);
+        // 计数
+        int buteneCount = 0;
+        int propyleneCount = 0;
+        int mapdCount = 0;
         for (TMonthlyQualityReportS5001 monthlyQualityReportS5001 : tMonthlyQualityReportS5001s) {
-            BigDecimal butene = new BigDecimal(monthlyQualityReportS5001.getButene());
-            BigDecimal propylene = new BigDecimal(monthlyQualityReportS5001.getPropylene());
-            BigDecimal mapd = new BigDecimal(monthlyQualityReportS5001.getMapd());
-            if (butene.compareTo(buteneMax) > 0) { buteneMax = butene; }
-            if (propylene.compareTo(propyleneMax) > 0) { propyleneMax = propylene; }
-            if (mapd.compareTo(mapdMax) > 0) { mapdMax = mapd; }
-            if (butene.compareTo(buteneMin) < 0) { buteneMin = butene; }
-            if (propylene.compareTo(propyleneMin) < 0) { propyleneMin = propylene; }
-            if (mapd.compareTo(mapdMin) < 0) { mapdMin = mapd; }
-            buteneSum = buteneSum.add(butene);
-            propyleneSum = propyleneSum.add(propylene);
-            mapdSum = mapdSum.add(mapd);
+            String butene1 = monthlyQualityReportS5001.getButene();
+            if (butene1 != null) {
+                BigDecimal butene = new BigDecimal(butene1);
+                if (butene.compareTo(buteneMax) > 0) { buteneMax = butene; }
+                if (butene.compareTo(buteneMin) < 0) { buteneMin = butene; }
+                buteneSum = buteneSum.add(butene);
+            }
+            String propylene1 = monthlyQualityReportS5001.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);
+            }
+            String mapd1 = monthlyQualityReportS5001.getMapd();
+            if (mapd1 != null) {
+                BigDecimal mapd = new BigDecimal(mapd1);
+                if (mapd.compareTo(mapdMax) > 0) {
+                    mapdMax = mapd;
+                }
+                if (mapd.compareTo(mapdMin) < 0) {
+                    mapdMin = mapd;
+                }
+                mapdSum = mapdSum.add(mapd);
+            }
+        }
+        if (buteneCount != 0) {
+            buteneAvg = buteneSum.divide(new BigDecimal(buteneCount), 2, RoundingMode.HALF_UP);
+        }
+        if (propyleneCount != 0) {
+            propyleneAvg = propyleneSum.divide(new BigDecimal(propyleneCount), 2, RoundingMode.HALF_UP);
+        }
+        if (mapdCount != 0) {
+            mapdAvg = mapdSum.divide(new BigDecimal(mapdCount), 2, RoundingMode.HALF_UP);
         }
-        BigDecimal count = new BigDecimal(tMonthlyQualityReportS5001s.size());
-        buteneAvg = buteneSum.divide(count, 2, RoundingMode.HALF_UP);
-        propyleneAvg = propyleneSum.divide(count, 2, RoundingMode.HALF_UP);
-        mapdAvg = mapdSum.divide(count, 2, RoundingMode.HALF_UP);
         StringBuffer description = new StringBuffer();
         description.append("butene(max)="+ buteneMax.toString() + "\t");
         description.append("propylene(max)="+ propyleneMax.toString() + "\t");