Browse Source

计算投药 不再仅仅返回结果 把用户选择,和真实使用,以及创哥那里使用的哪些值都保存下来

王苗苗 1 month ago
parent
commit
310ce7b042

+ 60 - 12
slibra-system/src/main/java/com/slibra/business/service/impl/TXinyiMedicineParamServiceImpl.java

@@ -3,6 +3,7 @@ package com.slibra.business.service.impl;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Objects;
 
@@ -209,9 +210,22 @@ public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamServi
     }
 
 
-    public BigDecimal calculateMedicineByLastRecord(TXinyiMedicineParam param) {
+    /**
+     * 2025年04月27日10:26:29  逻辑调整:以前此方法只返回计算的碳源投加的结果,现在改成:
+     * 返回map:存放:
+     * 1.计算结果  CALCULATE_VAL
+     * 2.用户选择的采用的哪个池子投药  CHOOSE_POOL:0一池 1二池 2自动 3手动
+     * 3.真实的投药池子(自动的话,2选1)ADD_POOL:0一池 1二池
+     * 4.投加时间 这里不用,由定时任务处理。
+     * 5.创哥返回的控制系数 KZXS 自动就取最大值,非自动选哪个池子就返回哪个的
+     * 6.创哥返回的后反馈设定 HTFKSD 自动就取最大值,非自动选哪个池子就返回哪个的
+     * @param param
+     * @return
+     */
+    public HashMap<Object, Object> calculateMedicineByLastRecord(TXinyiMedicineParam param) {
+        HashMap<Object, Object> map = new HashMap<>();
         if (Objects.isNull(param)) {
-            return null;
+            return map;
         }
 
         //2025年04月24日17:21:58 控制系数获取创哥预测的值,不再由用户主动输入
@@ -219,8 +233,12 @@ public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamServi
         AutoFeedback autoFeedback2 = autoFeedbackMapper.selectAutoFeedbackLatestByPool(2);
         if(Objects.isNull(autoFeedback1) || Objects.isNull(autoFeedback2)){
             log.error("获取创哥推荐的系数失败,无法计算");
-            return null;
+            return map;
         }
+        BigDecimal htfksd1 = autoFeedback1.getBasePara();
+        BigDecimal htfksd2 = autoFeedback2.getBasePara();
+        BigDecimal kzxs1 = autoFeedback1.getCoef();
+        BigDecimal kzxs2 = autoFeedback2.getCoef();
 
         //计算用到的值
         Integer hycXsyType = param.getHycXsyType();
@@ -271,27 +289,57 @@ public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamServi
         //计算
         if(!Objects.isNull(type)) {
             if(3 == type){
-                return medicineAmount;
+//                return medicineAmount;
+                map.put("CHOOSE_POOL", 3);
+                map.put("ADD_POOL", null);
+                map.put("CALCULATE_VAL", medicineAmount);
+                map.put("HTFKSD", null);
+                map.put("KZXS", null);
+                return map;
             }
             //计算1号池的值
-            BigDecimal oneResult = this.getResultByDiff(hycXsyType, hycXsyOne, autoFeedback1.getBasePara(), qycAdType, qycAdOne, qycYxyType, qycYxyOne, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, autoFeedback1.getCoef(), jsCodType, jsCodOne, zhxs, tydl, "one", yymd, sxps);
+            BigDecimal oneResult = this.getResultByDiff(hycXsyType, hycXsyOne, htfksd1, qycAdType, qycAdOne, qycYxyType, qycYxyOne, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs1, jsCodType, jsCodOne, zhxs, tydl, "one", yymd, sxps);
             //计算二号池的值
-            BigDecimal twoResult = this.getResultByDiff(hycXsyType, hycXsyTwo, autoFeedback2.getBasePara(), qycAdType, qycAdTwo, qycYxyType, qycYxyTwo, xzxs, jzxs, jsLlType, jsLlTwo, slfpxs, autoFeedback2.getCoef(), jsCodType, jsCodTwo, zhxs, tydl, "two", yymd, sxps);
+            BigDecimal twoResult = this.getResultByDiff(hycXsyType, hycXsyTwo, htfksd2, qycAdType, qycAdTwo, qycYxyType, qycYxyTwo, xzxs, jzxs, jsLlType, jsLlTwo, slfpxs, kzxs2, jsCodType, jsCodTwo, zhxs, tydl, "two", yymd, sxps);
             //判断,返回值
             if(0 == type){
+                map.put("CHOOSE_POOL", 2);
                 if(!Objects.isNull(oneResult) && !Objects.isNull(twoResult)){
-                    return oneResult.compareTo(twoResult) > 0 ? oneResult : twoResult;
+                    if(oneResult.compareTo(twoResult) > 0){
+                        map.put("ADD_POOL", 0);
+                        map.put("CALCULATE_VAL", oneResult);
+                        map.put("HTFKSD", htfksd1);
+                        map.put("KZXS", kzxs1);
+                        return map;
+                    }else{
+                        map.put("ADD_POOL", 1);
+                        map.put("CALCULATE_VAL", twoResult);
+                        map.put("HTFKSD", htfksd2);
+                        map.put("KZXS", kzxs2);
+                        return map;
+                    }
                 }
             }
             else if(1 == type) {
-                return oneResult;
-            }else if(2 == type)
-                return twoResult;
+                map.put("CHOOSE_POOL", 0);
+                map.put("ADD_POOL", 0);
+                map.put("CALCULATE_VAL", oneResult);
+                map.put("HTFKSD", htfksd1);
+                map.put("KZXS", kzxs1);
+                return map;
+            }else if(2 == type){
+                map.put("CHOOSE_POOL", 1);
+                map.put("ADD_POOL", 1);
+                map.put("CALCULATE_VAL", twoResult);
+                map.put("HTFKSD", htfksd2);
+                map.put("KZXS", kzxs2);
+                return map;
+            }
             else {
-                return null;//错误的配置
+                return map;//错误的配置
             }
         }
-        return null;
+        return map;
     }
 
     private BigDecimal getResultByDiff(Integer hycXsyType, BigDecimal hycXsyVal, BigDecimal htfksd, Integer qycAdType, BigDecimal qycAdVal, Integer qycYxyType,