jiazx0107@163.com
2023-11-06 69cd9f59a0fabf12f8c9147fcba7f69817a870b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.ld.igds.protocol.bhzn.verb.analysis;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.common.CoreCommonService;
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.models.DepotConf;
import com.ld.igds.models.DeviceSer;
import com.ld.igds.models.Gas;
import com.ld.igds.models.GasInfo;
import com.ld.igds.protocol.bhzn.verb.command.BaseRemoteImpl;
import com.ld.igds.protocol.bhzn.verb.dto.IoMessage;
import com.ld.igds.protocol.bhzn.verb.dto.Res208;
import com.ld.igds.protocol.bhzn.verb.dto.Res209;
import com.ld.igds.util.ContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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;
 
/**
 * 能耗解析
 */
@Slf4j
@Component(AnalysisES.BEAN_ID)
public class AnalysisES extends BaseRemoteImpl {
 
    public static final String BEAN_ID = "bhzn.analysisEs";
 
    @Autowired
    private CoreDeviceService deviceService;
    @Autowired
    private NotifyWebInvoker notifyInvoker;
    @Autowired
    private CoreCommonService commonService;
    @Autowired
    private CoreEsService esService;
 
    /**
     * 设备状态
     *
     * @param reMessage
     * @param ser
     */
    public void analysis(IoMessage reMessage, DeviceSer ser) {
 
        log.info("能耗开始解析");
        Res208 res208 = JSONObject.parseObject(reMessage.getContentStr(), Res208.class);
        if(2==res208.getState()){
 
        }else{
            log.info("气体没有采集完成,取消解析!");
            return;
        }
        DepotConf depotConf = commonService.getCacheDepotConfBySerId(ser.getCompanyId(),ser.getId() );
 
        EsData esData = new EsData();
        esData.setCompanyId(ser.getCompanyId());
        esData.setDepotId(depotConf.getDepotId());
        esData.setDeviceId("0");
        esData.setDeviceName("");
        esData.setUpdateTime(new Date());
        esData.setUa(Double.valueOf(res208.getVA()));
        esData.setUb(Double.valueOf(res208.getVB()));
        esData.setUc(Double.valueOf(res208.getVC()));
 
        esData.setIa(Double.valueOf(res208.getIA()));
        esData.setIb(Double.valueOf(res208.getIB()));
        esData.setIc(Double.valueOf(res208.getIC()));
        esData.setF(Double.valueOf(res208.getZPL()));
 
        esData.setEp(0.0);
        esData.setEq(0.0);
        esData.setEs(0.0);
        esData.setEsFan(0.0);
        esData.setEsAir(0.0);
        esData.setEsLamp(0.0);
        esData.setEs(res208.getZNH());
        log.info("控制柜----->>>平台:能耗数据解析完成-仓库={}", esData.getDepotId());
 
        esService.saveAndUpdateInc(esData);
    }
 
}