Преглед изворни кода

在不修改前端的情况下 所有的类型均在新增的时候加一,返回的时候-1,且定时任务和获取实时结果也减1计算 适应组态不能为0的情况

王苗苗 пре 6 месеци
родитељ
комит
8a32ef2e87

+ 60 - 0
src/main/java/com/xlht/xlhtproject/controller/ScheduledTasks.java

@@ -57,6 +57,8 @@ public class ScheduledTasks {
             return;
         }
         //投药(写入数据库)
+        //2024年09月29日16:10:17 因为鲍工那里组态不支持0,前端不做处理的情况下,新增的时候++,返回的时候--,其他就不用处理了
+        this.parseData(latestRecord);
         //计算实时的碳源投加量 (2个池子需要分开存)
         BigDecimal val1 = this.calculateUtils.calculateMedicineByLastRecord(latestRecord, 1);
         if(!Objects.isNull(val1) && val1.compareTo(BigDecimal.ZERO) < 0){
@@ -82,6 +84,64 @@ public class ScheduledTasks {
         log.info("进入了定时投药的逻辑处理--结束");
     }
 
+    private void parseData(TXlhtMedicineParam latestRecord) {
+        Integer typeOne = latestRecord.getTypeOne();
+        if(!Objects.isNull(typeOne)){
+            latestRecord.setTypeOne(typeOne - 1);
+        }
+        Integer typeTwo = latestRecord.getTypeTwo();
+        if(!Objects.isNull(typeTwo)){
+            latestRecord.setTypeTwo(typeTwo - 1);
+        }
+        Integer jsLlTypeOne = latestRecord.getJsLlTypeOne();
+        if(!Objects.isNull(jsLlTypeOne)){
+            latestRecord.setJsLlTypeOne(jsLlTypeOne - 1);
+        }
+        Integer jsLlTypeTwo = latestRecord.getJsLlTypeTwo();
+        if(!Objects.isNull(jsLlTypeTwo)){
+            latestRecord.setJsLlTypeTwo(jsLlTypeTwo - 1);
+        }
+        Integer jsCodTypeOne = latestRecord.getJsCodTypeOne();
+        if(!Objects.isNull(jsCodTypeOne)){
+            latestRecord.setJsCodTypeOne(jsCodTypeOne - 1);
+        }
+        Integer jsCodTypeTwo = latestRecord.getJsCodTypeTwo();
+        if(!Objects.isNull(jsCodTypeTwo)){
+            latestRecord.setJsCodTypeTwo(jsCodTypeTwo - 1);
+        }
+        Integer hycXsyTypeOne = latestRecord.getHycXsyTypeOne();
+        if(!Objects.isNull(hycXsyTypeOne)){
+            latestRecord.setHycXsyTypeOne(hycXsyTypeOne - 1);
+        }
+        Integer hycXsyTypeTwo = latestRecord.getHycXsyTypeTwo();
+        if(!Objects.isNull(hycXsyTypeTwo)){
+            latestRecord.setHycXsyTypeTwo(hycXsyTypeTwo - 1);
+        }
+        Integer qycYxyTypeOne = latestRecord.getQycYxyTypeOne();
+        if(!Objects.isNull(qycYxyTypeOne)){
+            latestRecord.setQycYxyTypeOne(qycYxyTypeOne - 1);
+        }
+        Integer qycYxyTypeTwo = latestRecord.getQycYxyTypeTwo();
+        if(!Objects.isNull(qycYxyTypeTwo)){
+            latestRecord.setQycYxyTypeTwo(qycYxyTypeTwo - 1);
+        }
+        Integer qycAdTypeOne = latestRecord.getQycAdTypeOne();
+        if(!Objects.isNull(qycAdTypeOne)){
+            latestRecord.setQycAdTypeOne(qycAdTypeOne - 1);
+        }
+        Integer qycAdTypeTwo = latestRecord.getQycAdTypeTwo();
+        if(!Objects.isNull(qycAdTypeTwo)){
+            latestRecord.setQycAdTypeTwo(qycAdTypeTwo - 1);
+        }
+        Integer jsTnTypeOne = latestRecord.getJsTnTypeOne();
+        if(!Objects.isNull(jsTnTypeOne)){
+            latestRecord.setJsTnTypeOne(jsTnTypeOne - 1);
+        }
+        Integer jsTnTypeTwo = latestRecord.getJsTnTypeTwo();
+        if(!Objects.isNull(jsTnTypeTwo)){
+            latestRecord.setJsTnTypeTwo(jsTnTypeTwo - 1);
+        }
+    }
 
 
 }

+ 124 - 0
src/main/java/com/xlht/xlhtproject/service/impl/TXlhtMedicineParamServiceImpl.java

@@ -78,9 +78,71 @@ public class TXlhtMedicineParamServiceImpl implements ITXlhtMedicineParamService
     public int insertTXlhtMedicineParam(TXlhtMedicineParam tXlhtMedicineParam)
     {
         tXlhtMedicineParam.setCreateTime(DateUtils.getNowDate());
+        //2024年09月29日15:39:42 因为组态如果传0可能会有问题,所有的数值+1,这样前端就不用做任何调整了
+        this.addOneForZTAndFront(tXlhtMedicineParam);
         return tXlhtMedicineParamMapper.insertTXlhtMedicineParam(tXlhtMedicineParam);
     }
 
+    private void addOneForZTAndFront(TXlhtMedicineParam tXlhtMedicineParam) {
+        Integer typeOne = tXlhtMedicineParam.getTypeOne();
+        if(!Objects.isNull(typeOne)){
+            tXlhtMedicineParam.setTypeOne(typeOne + 1);
+        }
+        Integer typeTwo = tXlhtMedicineParam.getTypeTwo();
+        if(!Objects.isNull(typeTwo)){
+            tXlhtMedicineParam.setTypeTwo(typeTwo + 1);
+        }
+        Integer jsLlTypeOne = tXlhtMedicineParam.getJsLlTypeOne();
+        if(!Objects.isNull(jsLlTypeOne)){
+            tXlhtMedicineParam.setJsLlTypeOne(jsLlTypeOne + 1);
+        }
+        Integer jsLlTypeTwo = tXlhtMedicineParam.getJsLlTypeTwo();
+        if(!Objects.isNull(jsLlTypeTwo)){
+            tXlhtMedicineParam.setJsLlTypeTwo(jsLlTypeTwo + 1);
+        }
+        Integer jsCodTypeOne = tXlhtMedicineParam.getJsCodTypeOne();
+        if(!Objects.isNull(jsCodTypeOne)){
+            tXlhtMedicineParam.setJsCodTypeOne(jsCodTypeOne + 1);
+        }
+        Integer jsCodTypeTwo = tXlhtMedicineParam.getJsCodTypeTwo();
+        if(!Objects.isNull(jsCodTypeTwo)){
+            tXlhtMedicineParam.setJsCodTypeTwo(jsCodTypeTwo + 1);
+        }
+        Integer hycXsyTypeOne = tXlhtMedicineParam.getHycXsyTypeOne();
+        if(!Objects.isNull(hycXsyTypeOne)){
+            tXlhtMedicineParam.setHycXsyTypeOne(hycXsyTypeOne + 1);
+        }
+        Integer hycXsyTypeTwo = tXlhtMedicineParam.getHycXsyTypeTwo();
+        if(!Objects.isNull(hycXsyTypeTwo)){
+            tXlhtMedicineParam.setHycXsyTypeTwo(hycXsyTypeTwo + 1);
+        }
+        Integer qycYxyTypeOne = tXlhtMedicineParam.getQycYxyTypeOne();
+        if(!Objects.isNull(qycYxyTypeOne)){
+            tXlhtMedicineParam.setQycYxyTypeOne(qycYxyTypeOne + 1);
+        }
+        Integer qycYxyTypeTwo = tXlhtMedicineParam.getQycYxyTypeTwo();
+        if(!Objects.isNull(qycYxyTypeTwo)){
+            tXlhtMedicineParam.setQycYxyTypeTwo(qycYxyTypeTwo + 1);
+        }
+        Integer qycAdTypeOne = tXlhtMedicineParam.getQycAdTypeOne();
+        if(!Objects.isNull(qycAdTypeOne)){
+            tXlhtMedicineParam.setQycAdTypeOne(qycAdTypeOne + 1);
+        }
+        Integer qycAdTypeTwo = tXlhtMedicineParam.getQycAdTypeTwo();
+        if(!Objects.isNull(qycAdTypeTwo)){
+            tXlhtMedicineParam.setQycAdTypeTwo(qycAdTypeTwo + 1);
+        }
+        Integer jsTnTypeOne = tXlhtMedicineParam.getJsTnTypeOne();
+        if(!Objects.isNull(jsTnTypeOne)){
+            tXlhtMedicineParam.setJsTnTypeOne(jsTnTypeOne + 1);
+        }
+        Integer jsTnTypeTwo = tXlhtMedicineParam.getJsTnTypeTwo();
+        if(!Objects.isNull(jsTnTypeTwo)){
+            tXlhtMedicineParam.setJsTnTypeTwo(jsTnTypeTwo + 1);
+        }
+
+    }
+
     /**
      * 修改智能投药参数设置
      * 
@@ -131,6 +193,8 @@ public class TXlhtMedicineParamServiceImpl implements ITXlhtMedicineParamService
         //2024年09月20日13:42:18  有可能用户选择的是仪表或者化验,需要获取实时数据
         //获取最新的实时数据
         SmartAdd smartAdd = this.shuju1Mapper.getNewestData();
+        //2024年09月29日16:10:17 因为鲍工那里组态不支持0,前端不做处理的情况下,新增的时候++,返回的时候--,其他就不用处理了
+        this.parseData(latestRecord);
         if(!Objects.isNull(smartAdd)){
             //获取对应的类型
             //一池的实时数据处理
@@ -226,6 +290,66 @@ public class TXlhtMedicineParamServiceImpl implements ITXlhtMedicineParamService
                 latestRecord.setTytjTransientLLOne(tTbDu.getC1TjLl());
                 latestRecord.setTytjTransientLLTwo(tTbDu.getC2TjLl());
             }
+
+        }
+    }
+
+    private void parseData(TXlhtMedicineParam latestRecord) {
+        Integer typeOne = latestRecord.getTypeOne();
+        if(!Objects.isNull(typeOne)){
+            latestRecord.setTypeOne(typeOne - 1);
+        }
+        Integer typeTwo = latestRecord.getTypeTwo();
+        if(!Objects.isNull(typeTwo)){
+            latestRecord.setTypeTwo(typeTwo - 1);
+        }
+        Integer jsLlTypeOne = latestRecord.getJsLlTypeOne();
+        if(!Objects.isNull(jsLlTypeOne)){
+            latestRecord.setJsLlTypeOne(jsLlTypeOne - 1);
+        }
+        Integer jsLlTypeTwo = latestRecord.getJsLlTypeTwo();
+        if(!Objects.isNull(jsLlTypeTwo)){
+            latestRecord.setJsLlTypeTwo(jsLlTypeTwo - 1);
+        }
+        Integer jsCodTypeOne = latestRecord.getJsCodTypeOne();
+        if(!Objects.isNull(jsCodTypeOne)){
+            latestRecord.setJsCodTypeOne(jsCodTypeOne - 1);
+        }
+        Integer jsCodTypeTwo = latestRecord.getJsCodTypeTwo();
+        if(!Objects.isNull(jsCodTypeTwo)){
+            latestRecord.setJsCodTypeTwo(jsCodTypeTwo - 1);
+        }
+        Integer hycXsyTypeOne = latestRecord.getHycXsyTypeOne();
+        if(!Objects.isNull(hycXsyTypeOne)){
+            latestRecord.setHycXsyTypeOne(hycXsyTypeOne - 1);
+        }
+        Integer hycXsyTypeTwo = latestRecord.getHycXsyTypeTwo();
+        if(!Objects.isNull(hycXsyTypeTwo)){
+            latestRecord.setHycXsyTypeTwo(hycXsyTypeTwo - 1);
+        }
+        Integer qycYxyTypeOne = latestRecord.getQycYxyTypeOne();
+        if(!Objects.isNull(qycYxyTypeOne)){
+            latestRecord.setQycYxyTypeOne(qycYxyTypeOne - 1);
+        }
+        Integer qycYxyTypeTwo = latestRecord.getQycYxyTypeTwo();
+        if(!Objects.isNull(qycYxyTypeTwo)){
+            latestRecord.setQycYxyTypeTwo(qycYxyTypeTwo - 1);
+        }
+        Integer qycAdTypeOne = latestRecord.getQycAdTypeOne();
+        if(!Objects.isNull(qycAdTypeOne)){
+            latestRecord.setQycAdTypeOne(qycAdTypeOne - 1);
+        }
+        Integer qycAdTypeTwo = latestRecord.getQycAdTypeTwo();
+        if(!Objects.isNull(qycAdTypeTwo)){
+            latestRecord.setQycAdTypeTwo(qycAdTypeTwo - 1);
+        }
+        Integer jsTnTypeOne = latestRecord.getJsTnTypeOne();
+        if(!Objects.isNull(jsTnTypeOne)){
+            latestRecord.setJsTnTypeOne(jsTnTypeOne - 1);
+        }
+        Integer jsTnTypeTwo = latestRecord.getJsTnTypeTwo();
+        if(!Objects.isNull(jsTnTypeTwo)){
+            latestRecord.setJsTnTypeTwo(jsTnTypeTwo - 1);
         }
     }
 }