jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
package com.ld.igds.protocol.fzzy.analysis;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.common.CoreDeviceService;
import com.ld.igds.io.notify.NotifyWebInvoker;
import com.ld.igds.io.constant.OrderRespEnum;
import com.ld.igds.models.DeviceSer;
import com.ld.igds.protocol.fzzy.ServerUtils;
import com.ld.igds.protocol.fzzy.command.BaseRemoteImpl;
import com.ld.igds.protocol.fzzy.dto.ReMessage;
import com.ld.igds.protocol.fzzy.resp.Response3102;
 
import lombok.extern.slf4j.Slf4j;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 设备操作类
 */
@Slf4j
@Component(AnalysisDevice.BEAN_ID)
public class AnalysisDevice extends BaseRemoteImpl {
 
    public static final String BEAN_ID = "fzzy.analysisDevice";
 
    @Autowired
    private CoreDeviceService deviceService;
    @Autowired
    private NotifyWebInvoker notifyInvoker;
 
 
    public void analysis3101(ReMessage reMessage, DeviceSer ser) {
        log.debug("-DO NOTHING-");
        //DO NOTHING
    }
 
    /**
     * 设备状态
     *
     * @param reMessage
     * @param ser
     */
    public void analysis3102(ReMessage reMessage, DeviceSer ser) {
 
        List<Response3102> responseList = JSONObject.parseArray(reMessage.getContent(), Response3102.class);
        
        
        if(null == responseList || responseList.isEmpty()){
             log.error("控制柜----->>>>平台:解析返回出现问题,没有返回设备列表");
            return;
        }
 
        String status;
        for (Response3102 resp : responseList) {
            status = ServerUtils.analysisDeviceStatus(resp.getDeviceId(), resp.getStatus());
            log.info("解析控制柜返回设备状态-解析后---{}--{}---{}--{}", ser.getCompanyId(), ser.getId(), resp.getDeviceId(), status);
            ServerUtils.add2StatusMap(ser.getCompanyId(), ser.getId(), resp.getDeviceId(), status);
        }
        deviceService.updateStatus(ser.getCompanyId(), ser.getId(), ServerUtils.getStatusMap());
 
        notifyInvoker.notifyAnalysisStatusSuccess(ser.getCompanyId(), ser.getId(), OrderRespEnum.MSG_SUCCESS, "设备状态查询成功并完成解析!");
    }
 
    public void analysis3103(ReMessage message, DeviceSer ser) {
        //DO NOTHING
    }
 
    public void analysis3201(ReMessage message, DeviceSer ser) {
        //DO NOTHING
    }
 
 
}