瀏覽代碼

计算碳源投加调整

王苗苗 6 月之前
父節點
當前提交
14a14a38be
共有 1 個文件被更改,包括 11 次插入4 次删除
  1. 11 4
      slibra-quartz/src/main/java/com/slibra/quartz/task/RyTask.java

+ 11 - 4
slibra-quartz/src/main/java/com/slibra/quartz/task/RyTask.java

@@ -914,15 +914,17 @@ public class RyTask
 
         Integer type = param.getType();//0自动 1一号池 2二号池 3人工投放
 
+        BigDecimal yymd = param.getYymd();
+
         //计算
         if(!Objects.isNull(type)) {
             if(3 == type){
                 return medicineAmount;
             }
             //计算1号池的值
-            BigDecimal oneResult = this.getResultByDiff(hycXsyType, hycXsyOne, htfksd, qycAdType, qycAdOne, qycYxyType, qycYxyOne, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs, jsCodType, jsCodOne, zhxs, tydl, "one");
+            BigDecimal oneResult = this.getResultByDiff(hycXsyType, hycXsyOne, htfksd, qycAdType, qycAdOne, qycYxyType, qycYxyOne, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs, jsCodType, jsCodOne, zhxs, tydl, "one", yymd);
             //计算二号池的值
-            BigDecimal twoResult = this.getResultByDiff(hycXsyType, hycXsyTwo, htfksd, qycAdType, qycAdTwo, qycYxyType, qycYxyTwo, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs, jsCodType, jsCodTwo, zhxs, tydl, "two");
+            BigDecimal twoResult = this.getResultByDiff(hycXsyType, hycXsyTwo, htfksd, qycAdType, qycAdTwo, qycYxyType, qycYxyTwo, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs, jsCodType, jsCodTwo, zhxs, tydl, "two", yymd);
             //判断,返回值
             if(0 == type)
                 return oneResult.compareTo(twoResult) > 0 ? oneResult : twoResult;
@@ -939,7 +941,7 @@ public class RyTask
 
     private BigDecimal getResultByDiff(Integer hycXsyType, BigDecimal hycXsyVal, BigDecimal htfksd, Integer qycAdType, BigDecimal qycAdVal, Integer qycYxyType,
                                        BigDecimal qycYxyVal, BigDecimal xzxs, BigDecimal jzxs, Integer jsLlType, BigDecimal jsLlVal, BigDecimal slfpxs, BigDecimal kzxs, Integer jsCodType,
-                                       BigDecimal jsCodVal, BigDecimal zhxs, BigDecimal tydl, String whichCZ) {
+                                       BigDecimal jsCodVal, BigDecimal zhxs, BigDecimal tydl, String whichCZ, BigDecimal yymd) {
         //2024年09月14日10:26:11  不同池子,根据不同类型,获取最新的数据,计算碳源投加量
         //获取最新的实时数据
         SmartAdd smartAdd = this.frontService.smartAddDataInfo();
@@ -1021,10 +1023,15 @@ public class RyTask
             zhxs = BigDecimal.ZERO;
         if(Objects.isNull(tydl))
             tydl = BigDecimal.ZERO;
+        if(Objects.isNull(yymd) || yymd.compareTo(BigDecimal.ZERO) <= 0)
+            return null;//除数不能为0
         //1)计算挟走量
         BigDecimal xzl = (((BigDecimal_2.multiply(hycXsyVal).subtract(htfksd)).add(((qycAdVal.add(qycYxyVal)).multiply(xzxs).subtract(htfksd)))).multiply((jzxs.subtract(BigDecimal_1)))).multiply((jsLlVal.multiply(slfpxs))).divide(BigDecimal_1000, NUMBER_SCALE_4, RoundingMode.HALF_UP);
         //2)计算碳源投加总量
-        return (xzl.multiply(kzxs).subtract((jsLlVal.multiply(slfpxs).multiply(jsCodVal).multiply(zhxs).divide(BigDecimal_1000, NUMBER_SCALE_4, RoundingMode.HALF_UP)))).divide(tydl, NUMBER_SCALE_4, RoundingMode.HALF_UP);
+        BigDecimal total = (xzl.multiply(kzxs).subtract((jsLlVal.multiply(slfpxs).multiply(jsCodVal).multiply(zhxs).divide(BigDecimal_1000, NUMBER_SCALE_4, RoundingMode.HALF_UP)))).divide(tydl, NUMBER_SCALE_4, RoundingMode.HALF_UP);
+        //2024年09月14日15:33:37 计算出来的结果太大,是几千,把第三步公式也加上
+        //计算加药流量
+        return DecimalUtils.getNLengthHalfUp(total.divide(yymd, NUMBER_SCALE_10, RoundingMode.HALF_UP).divide(BigDecimal_1000, NUMBER_SCALE_10, RoundingMode.HALF_UP), INT_3);
     }