ソースを参照

碳源投加获取最新数据调整

王苗苗 6 ヶ月 前
コミット
a67c1b7c2a

+ 1 - 1
src/main/java/com/xlht/xlhtproject/domain/TXinyiMedicineParam.java

@@ -79,7 +79,7 @@ public class TXinyiMedicineParam
     private BigDecimal qycAdTwo;
 
     /** 进水总氮类型(0手动 1仪表) */
-    private Long jsTnType;
+    private Integer jsTnType;
 
     /** 进水总氮1号池 */
     private BigDecimal jsTnOne;

+ 69 - 3
src/main/java/com/xlht/xlhtproject/service/impl/TXinyiMedicineParamServiceImpl.java

@@ -1,14 +1,19 @@
 package com.xlht.xlhtproject.service.impl;
 
 
+import com.xlht.xlhtproject.domain.SmartAdd;
 import com.xlht.xlhtproject.domain.TXinyiMedicineParam;
+import com.xlht.xlhtproject.mapper.TShuju1Mapper;
 import com.xlht.xlhtproject.mapper.TXinyiMedicineParamMapper;
 import com.xlht.xlhtproject.service.ITXinyiMedicineParamService;
+import com.xlht.xlhtproject.utils.CalculateUtils;
 import com.xlht.xlhtproject.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Objects;
 
@@ -19,14 +24,19 @@ import java.util.Objects;
  * @author slibra
  * @date 2024-09-09
  */
+@Slf4j
 @Service
 public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamService
 {
     @Autowired
     private TXinyiMedicineParamMapper tXinyiMedicineParamMapper;
 
-    /*@Autowired
-    private TXinyiIndustryMapper xinyiIndustryMapper;*/
+    @Autowired
+    private TShuju1Mapper shuju1Mapper;
+
+    @Autowired
+    private CalculateUtils calculateUtils;
+
 
     /**
      * 查询智能投药参数设置
@@ -107,8 +117,64 @@ public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamServi
         TXinyiMedicineParam latestRecord = this.tXinyiMedicineParamMapper.getLatestRecord();
         //todo 额外查询 碳源投加瞬时流量
         if(!Objects.isNull(latestRecord)){
-
+            this.addExtra(latestRecord);
         }
         return latestRecord;
     }
+
+    private void addExtra(TXinyiMedicineParam latestRecord) {
+        //2024年09月20日13:42:18  有可能用户选择的是仪表或者化验,需要获取实时数据
+        //获取最新的实时数据
+        SmartAdd smartAdd = this.shuju1Mapper.getNewestData();
+        if(!Objects.isNull(smartAdd)){
+            //获取对应的类型
+            Integer hycXsyType = latestRecord.getHycXsyType();
+            Integer qycAdType = latestRecord.getQycAdType();
+            Integer qycYxyType = latestRecord.getQycYxyType();
+            Integer jsCodType = latestRecord.getJsCodType();
+            Integer jsLlType = latestRecord.getJsLlType();
+            Integer jsTnType = latestRecord.getJsTnType();
+            if(!Objects.isNull(hycXsyType)){
+                if(1 == hycXsyType){//化验
+                    latestRecord.setHycXsyOne(smartAdd.getHyXsyHYOne());
+                    latestRecord.setHycXsyTwo(smartAdd.getHyXsyHYTwo());
+                }else if(2 == hycXsyType){//预测
+                    latestRecord.setHycXsyOne(smartAdd.getHyXsyYCOne());
+                    latestRecord.setHycXsyTwo(smartAdd.getHyXsyYCTwo());
+                }
+            }
+            if(!Objects.isNull(qycAdType) && 1 == qycAdType){//化验
+                latestRecord.setQycAdOne(smartAdd.getQyAdHYOne());
+                latestRecord.setQycAdTwo(smartAdd.getQyAdHYTwo());
+            }
+            if(!Objects.isNull(qycYxyType) && 1 == qycYxyType){//化验
+                latestRecord.setQycYxyOne(smartAdd.getQyXsyHYOne());
+                latestRecord.setQycYxyTwo(smartAdd.getQyXsyHYTwo());
+            }
+            if(!Objects.isNull(jsCodType)){
+                if(1 == jsCodType){//仪表
+                    latestRecord.setJsCodOne(smartAdd.getJsCodYB());
+                    latestRecord.setJsCodTwo(smartAdd.getJsCodYB());
+                }else if(2 == jsCodType){//化验
+                    latestRecord.setJsCodOne(smartAdd.getJsCodHY());
+                    latestRecord.setJsCodTwo(smartAdd.getJsCodHY());
+                }
+            }
+            if(!Objects.isNull(jsLlType) && 1 == jsLlType){//仪表
+                latestRecord.setJsLlOne(smartAdd.getJslYB());
+                latestRecord.setJsLlTwo(smartAdd.getJslYB());
+            }
+            if(!Objects.isNull(jsTnType) && 1 == jsTnType){//仪表
+                latestRecord.setJsTnOne(smartAdd.getJsTnYB());
+                latestRecord.setJsTnTwo(smartAdd.getJsTnYB());
+            }
+            //计算实时的碳源投加量 (2个池子需要分开存 ToDo)
+            BigDecimal val = this.calculateUtils.calculateMedicineByLastRecord(latestRecord, 1);
+            if(!Objects.isNull(val) && val.compareTo(BigDecimal.ZERO) < 0){
+                log.info("计算得到的碳源投加量是负数,按0处理");
+                val = BigDecimal.ZERO;
+            }
+            latestRecord.setMedicineAmount(val);
+        }
+    }
 }