jiazx0107@163.com
2023-11-06 69cd9f59a0fabf12f8c9147fcba7f69817a870b3
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);