From dd4f9c9e39e075043c9bdd86afdd0cb195d08ab8 Mon Sep 17 00:00:00 2001
From: ws <ws@123.com>
Date: 星期二, 10 十月 2023 09:34:32 +0800
Subject: [PATCH] 优化熏蒸备案

---
 igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/AnalysisService.java |   83 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/AnalysisService.java b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/AnalysisService.java
index 0cff6e1..37b58e2 100644
--- a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/AnalysisService.java
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/AnalysisService.java
@@ -2,9 +2,12 @@
 
 import com.ld.igds.common.CoreDeviceService;
 import com.ld.igds.constant.BizType;
+import com.ld.igds.es.dto.EsData;
+import com.ld.igds.es.service.CoreEsService;
 import com.ld.igds.gas.CoreGasService;
 import com.ld.igds.io.constant.OrderRespEnum;
 import com.ld.igds.io.notify.NotifyWebInvoker;
+import com.ld.igds.io.request.BaseRequest;
 import com.ld.igds.io.request.CheckGasRequest;
 import com.ld.igds.io.request.DeviceControlRequest;
 import com.ld.igds.models.Gas;
@@ -18,6 +21,7 @@
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.text.DecimalFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -34,6 +38,8 @@
     private NotifyWebInvoker notifyInvoker;
     @Autowired
     private CoreGasService gasService;
+    @Autowired
+    private CoreEsService esService;
 
 
     /**
@@ -80,17 +86,26 @@
 
         int sumNum = results.size();
         double co2, o2, ph3, n2;
+        DecimalFormat df = new DecimalFormat("#0.00");
         double sumO2 = 0.0, sumCo2 = 0.0, sumPh3 = 0.0, sumN2 = 0.0;
+        int num = 1;
         StringBuffer sb = new StringBuffer();
         for (ModbusGasResult gasResult : results) {
+            //浜屾哀鍖栫⒊锛屽崟浣嶏細PPM锛岀洿鎺ヤ娇鐢�
             co2 = gasResult.getCo2().doubleValue();
-            o2 = gasResult.getO2().doubleValue();
+            //姘ф皵锛岄櫎浠�10锛屽崟浣嶏細鐧惧垎姣�
+            o2 = Double.valueOf(df.format(gasResult.getO2().doubleValue()*0.1));
+            //纾峰寲姘紝鍗曚綅锛歅PM锛岀洿鎺ヤ娇鐢�
             ph3 = gasResult.getPh3().doubleValue();
-            n2 = -100;
+            n2 = Double.valueOf(df.format(99.9 - o2));;
 
-            //TODO >>>>> 鏍规嵁杩斿洖鍊艰繘琛屽垽鏂拰杞崲
-
-
+            if(num == 1){
+                gas.setPerCo2Min(co2);
+                gas.setPerO2Min(o2);
+                gas.setPerPh3Min(ph3);
+                gas.setPerN2Min(n2);
+            }
+            num ++;
             if (gas.getPerCo2Max() < co2) {
                 gas.setPerCo2Max(co2);
             }
@@ -146,4 +161,62 @@
         notifyInvoker.notifyWeb(gas.getCompanyId(), OrderRespEnum.MSG_SUCCESS, BizType.GAS, request.getDepotId() + " 姘斾綋妫�娴嬶細缁撴灉杩斿洖鎴愬姛.");
         log.info("鎺у埗鏌�----->>>骞冲彴锛氭皵浣撹В鏋愬畬鎴�-浠撳簱={}", request.getDepotId());
     }
+
+    /**
+     * 瑙f瀽鑳借�楁暟鎹�
+     *
+     * @param request
+     * @param result
+     */
+    public void analysisEs(BaseRequest request, Number result) {
+
+        log.debug("----------寮�濮嬫墽琛岃兘鑰楃粨鏋滆В鏋�----{}", request.getDepotId());
+
+
+        //鏈夊姛鐢佃兘鍒ゆ柇鏄惁杩斿洖鏈夋晥鏁版嵁
+        if (null == result) {
+            log.error("---鑳借�楁暟鎹繑鍥炴暟鎹笉瀹屾暣锛屽仠姝㈣В鏋�----{}", result.toString());
+            return;
+        }
+
+        EsData esData = new EsData();
+        esData.setCompanyId(request.getCompanyId());
+        esData.setDepotId(request.getDepotId());
+        esData.setUpdateTime(new Date());
+
+        esData.setEp(result.doubleValue());
+        esData.setEs(result.doubleValue());
+
+        log.info("Modbus鐢佃〃----->>>骞冲彴锛氳兘鑰楁暟鎹В鏋愬畬鎴�-浠撳簱={}", esData.getDepotId());
+        esService.saveAndUpdateInc(esData);
+    }
+
+    /**
+     * 瑙f瀽绌鸿皟鐘舵��
+     *
+     * @param request
+     * @param result
+     */
+    public void analysisTempStatus(BaseRequest request, Number result) {
+
+        log.debug("----------寮�濮嬫墽琛岃兘鑰楃粨鏋滆В鏋�----{}", request.getDepotId());
+
+
+        //鏈夊姛鐢佃兘鍒ゆ柇鏄惁杩斿洖鏈夋晥鏁版嵁
+        if (null == result) {
+            log.error("---鑳借�楁暟鎹繑鍥炴暟鎹笉瀹屾暣锛屽仠姝㈣В鏋�----{}", result.toString());
+            return;
+        }
+
+        EsData esData = new EsData();
+        esData.setCompanyId(request.getCompanyId());
+        esData.setDepotId(request.getDepotId());
+        esData.setUpdateTime(new Date());
+
+        esData.setEp(result.doubleValue());
+        esData.setEs(result.doubleValue());
+
+        log.info("Modbus鐢佃〃----->>>骞冲彴锛氳兘鑰楁暟鎹В鏋愬畬鎴�-浠撳簱={}", esData.getDepotId());
+        esService.saveAndUpdateInc(esData);
+    }
 }

--
Gitblit v1.9.3