From f27f3ea5055888f7f1c797d0fd7fb26a2013c89c Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期二, 24 十月 2023 19:40:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/verb/analysis/AnalysisGas.java |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/verb/analysis/AnalysisGas.java b/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/verb/analysis/AnalysisGas.java
index 170c5a0..d787fa3 100644
--- a/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/verb/analysis/AnalysisGas.java
+++ b/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/verb/analysis/AnalysisGas.java
@@ -18,10 +18,13 @@
 import com.ld.igds.temp.dto.TempParam;
 import com.ld.igds.util.BytesUtil;
 import com.ld.igds.util.ContextUtil;
+import com.ld.igds.util.NumberUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -55,7 +58,12 @@
 
         log.info("姘斾綋妫�娴嬪紑濮嬭В鏋�");
         Res209 res209 = JSONObject.parseObject(reMessage.getContentStr(),Res209.class);
+        if(2==res209.getState()){
 
+        }else{
+            log.info("姘斾綋娌℃湁閲囬泦瀹屾垚锛屽彇娑堣В鏋愶紒");
+            return;
+        }
         DepotConf depotConf = commonService.getCacheDepotConfBySerId(ser.getCompanyId(),ser.getId() );
         //涓讳綋淇℃伅
         Gas gas = new Gas();
@@ -72,12 +80,14 @@
         Integer[] n2ValArray = res209.getN2ValArray();
         Integer[] pH3ValArray = res209.getPH3ValArray();
         Integer[] cO2ValArray = res209.getCO2ValArray();
+        double sumO2 = 0.0, sumCo2 = 0.0, sumPh3 = 0.0, sumN2 = 0.0;
         for (int i=0;i<res209.getCO2ValArray().length;i++){
             info = new GasInfo();
             info.setId(ContextUtil.buildInfoId(gas.getCompanyId(), gas.getDepotId(), gas.getBatchId()));
             info.setPassCode(i+1);
             info.setPerCo2(cO2ValArray[i].doubleValue());
-            info.setPerO2(99 - (n2ValArray[i].doubleValue() /10 ));
+            NumberFormat numberFormat = new DecimalFormat("0.00");
+            info.setPerO2(Double.parseDouble(numberFormat.format(99 - (n2ValArray[i].doubleValue() /10 ))));
             info.setPerPh3(pH3ValArray[i].doubleValue());
             info.setPerN2(n2ValArray[i].doubleValue() / 10);
             items.add(info);
@@ -122,7 +132,10 @@
             if (info.getPerN2() < gas.getPerN2Min()) {
                 gas.setPerN2Min(info.getPerN2());
             }
-
+            sumO2 += info.getPerO2();
+            sumCo2 += info.getPerCo2();
+            sumPh3 += info.getPerPh3();
+            sumN2 += info.getPerN2();
             //鍥哄畾涓猴細passCode,co2,o2,ph3,n2;passCode,co2,o2,ph3,n2;"
             sb.append(info.getPassCode());
             sb.append(",");
@@ -135,6 +148,13 @@
             sb.append(info.getPerN2());
             sb.append(";");
         }
+
+        if(res209.getCO2ValArray().length>1){
+            gas.setPerCo2(NumberUtil.keepPrecision(sumCo2/res209.getCO2ValArray().length, 2));
+            gas.setPerO2(NumberUtil.keepPrecision(sumO2/res209.getCO2ValArray().length, 2));
+            gas.setPerN2(NumberUtil.keepPrecision(sumN2/res209.getCO2ValArray().length, 2));
+            gas.setPerPh3(NumberUtil.keepPrecision(sumPh3/res209.getCO2ValArray().length, 2));
+        }
         gas.setPoints(sb.toString());
         gasService.saveInfoGas(items);
 

--
Gitblit v1.9.3