CZT
2023-10-19 ad16e7c6dac7d23b3bb903f1d3750978f1d7066d
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.ld.igds.protocol.fzzy.analysis;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.es.dto.EsData;
import com.ld.igds.es.service.CoreEsService;
import com.ld.igds.models.DeviceSer;
import com.ld.igds.protocol.fzzy.dto.ReMessage;
import com.ld.igds.protocol.fzzy.resp.Response4001;
 
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.util.Date;
import java.util.List;
 
/**
 * 解析能耗
 *
 * @author andy
 */
@Slf4j
@Component(AnalysisEs.BEAN_ID)
public class AnalysisEs {
 
    public static final String BEAN_ID = "fzzy.analysisEnergy";
 
    @Autowired
    private CoreEsService esService;
 
    /**
     * 能耗解析 2022-12-17弃用,改用新的解析方式
     * <p>
     * "ep":"4340.100","eq":"4802.100","houseId":"3P07","ia":"0.300","ib":"0.300","ic":"0.000","seqId":0,"ua":"229.4","ub":"229.2","uc":"229.0"
     *
     * @param reMessage
     * @param ser
     */
//    public void analysis4001(ReMessage reMessage, DeviceSer ser) {
//
//        Response4001 response = JSONObject.parseObject(reMessage.getContent(), Response4001.class);
//
//        //有功电能判断是否返回有效数据
//        if (null == response.getEp()) {
//            log.error("---能耗数据返回数据不完整,停止解析----{}", reMessage.toString());
//            return;
//        }
//
//        EsData esData = new EsData();
//        esData.setCompanyId(ser.getCompanyId());
//        esData.setDepotId(response.getHouseId());
//        esData.setUpdateTime(new Date());
//        esData.setUa(response.getUa());
//        esData.setUb(response.getUb());
//        esData.setUc(response.getUc());
//
//        esData.setIa(response.getIa());
//        esData.setIb(response.getIb());
//        esData.setIc(response.getIc());
//        esData.setF(response.getF() == null ? 0.0 : response.getF());
//
//        esData.setEp(response.getEp());
//        esData.setEq(response.getEq());
//        if (null != response.getEs()) {
//            esData.setEs(response.getEs());
//        } else {
//            esData.setEs(0.0);
//        }
//
//        esData.setEsFan(response.getEsFan() == null ? 0.0 : response.getEsFan());
//        esData.setEsAir(response.getEsAir() == null ? 0.0 : response.getEsAir());
//        esData.setEsLamp(response.getEsLamp() == null ? 0.0 : response.getEsLamp());
//
//        log.info("控制柜----->>>平台:能耗数据解析完成-仓库={}", esData.getDepotId());
//
//        esService.saveAndUpdateInc(esData);
//    }
 
    /**
     * 2022-12-17启用,报文内容为列表集合
     * "content": [{"houseId": "0135","deviceId": "6001","deviceName": "1号仓主控柜电表","ua": "220","ub": "220","uc": "220","ia": "0.1","ib": "0.1","ic": "0.1","pa": "50","pb": "50","pc": "50","pfa": "0.4","pfb": "0.4","pfc": "0.4","f": "50","ep": "123","eq": "123","es": "456","esFan": "0","esAir": "0", "esLamp": "0"}]
     * @param reMessage
     * @param ser
     */
    public void analysis4001(ReMessage reMessage, DeviceSer ser) {
 
        List<Response4001> result = JSON.parseArray(reMessage.getContent(), Response4001.class);
 
        //有功电能判断是否返回有效数据
        if (null == result || result.isEmpty()) {
            log.error("---能耗返回数据为空,停止解析----{}", reMessage.toString());
            return;
        }
 
        EsData esData;
        for (Response4001 response : result) {
            if (null == response.getEp()) {
                log.error("---能耗数据返回数据不完整,停止解析----{}", reMessage.toString());
                return;
            }
            esData = new EsData();
            esData.setCompanyId(ser.getCompanyId());
            esData.setDepotId(response.getHouseId());
            esData.setDeviceId(StringUtils.isEmpty(response.getDeviceId())?"0":response.getDeviceId());
            esData.setDeviceName(response.getDeviceName());
            esData.setUpdateTime(new Date());
            esData.setUa(response.getUa());
            esData.setUb(response.getUb());
            esData.setUc(response.getUc());
 
            esData.setIa(response.getIa());
            esData.setIb(response.getIb());
            esData.setIc(response.getIc());
            esData.setF(response.getF() == null ? 0.0 : response.getF());
 
            esData.setEp(response.getEp());
            esData.setEq(response.getEq());
            if (null != response.getEs()) {
                esData.setEs(response.getEs());
            } else {
                esData.setEs(0.0);
            }
 
            esData.setEsFan(response.getEsFan() == null ? 0.0 : response.getEsFan());
            esData.setEsAir(response.getEsAir() == null ? 0.0 : response.getEsAir());
            esData.setEsLamp(response.getEsLamp() == null ? 0.0 : response.getEsLamp());
 
            log.info("控制柜----->>>平台:能耗数据解析完成-仓库={}", esData.getDepotId());
 
            esService.saveAndUpdateInc(esData);
        }
    }
 
}