jiazx0107@163.com
2023-12-02 5bb3ad3944ff229baff1d8bb92caf55d816ee68b
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
package com.fzzy.protocol.fzzy.analysis;
 
import com.fzzy.api.Constant;
import com.fzzy.api.data.ApiCommonDevice;
import com.fzzy.gateway.GatewayUtils;
import com.fzzy.gateway.entity.GatewayDevice;
import com.fzzy.protocol.fzzy.builder.ObjectCommandBuilder;
import com.fzzy.protocol.fzzy.builder.SimpleCommandBuilder;
import com.fzzy.protocol.fzzy.cmd.BaseRemoteImpl;
import com.fzzy.protocol.fzzy.data.ReMessage;
import com.fzzy.protocol.fzzy.data.SendMessage;
import com.fzzy.protocol.fzzy.resp.Response1001;
import com.fzzy.protocol.fzzy.server.ServerUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * 系统类协议解析
 */
@Slf4j
@Component(AnalysisSystem.BEAN_ID)
public class AnalysisSystem extends BaseRemoteImpl {
 
    public static final String BEAN_ID = "fzzy.analysisSystem";
 
 
    public void analysis1001(ReMessage reMessage) {
 
        //获取到登陆信息,执行设备信息整理
        ApiCommonDevice device = Constant.getCommonDeviceCache(reMessage.getSn());
        if (null == device) {
            device = new ApiCommonDevice();
        }
        device.setIp(reMessage.getIp());
        device.setPort(reMessage.getPort());
        device.setSn(reMessage.getSn());
        device.setId(reMessage.getIedId());
        Constant.updateCache(device);
 
 
        //返回当前系统时间
        Response1001 response = new Response1001();
        response.setTime(DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"));
 
        ObjectCommandBuilder commandBuilder = ObjectCommandBuilder.getInstance();
        SendMessage message = commandBuilder.buildMessage(reMessage, ServerUtils.FUNCTION_1001, response);
        send(message);
 
        log.info("控制柜----->>>平台:控制柜上线登陆成功-IP={},PORT={}", reMessage.getIp(), reMessage.getPort());
    }
 
    public void analysis1003(ReMessage reMessage, ApiCommonDevice ser) {
    }
 
    public void analysis1004(ReMessage reMessage, ApiCommonDevice ser) {
    }
 
    public void analysis1005(ReMessage reMessage, ApiCommonDevice ser) {
        //直接返回
        SimpleCommandBuilder commandBuilder = SimpleCommandBuilder.getInstance();
        SendMessage message = commandBuilder.buildMessage(ser, ServerUtils.FUNCTION_1005);
        send(message);
    }
 
    public void analysis1006(ReMessage reMessage, ApiCommonDevice ser) {
 
        //TODO
    }
 
    public void analysis1007(ReMessage reMessage, ApiCommonDevice ser) {
 
        log.info("控制柜----->>>平台:控制柜仓库状态信息同步完成-控制柜={}", ser.getIp());
    }
 
    public void analysis1008(ReMessage message, ApiCommonDevice ser) {
 
    }
 
    public void analysis1009(ReMessage message, ApiCommonDevice ser) {
 
    }
 
    public void analysis1010(ReMessage reMessage, ApiCommonDevice ser) {
        log.info("控制柜----->>>平台:控制柜仓库配置信息同步完成-控制柜={}", ser.getIp());
    }
}