czt
2025-06-10 694f541f9f4bc51818395be84e5ddf322c8048d8
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.ld.igds.common.CoreCommonService;
import com.ld.igds.common.CoreSerService;
import com.ld.igds.common.dto.THDto;
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.grain.GrainUtil;
import com.ld.igds.grain.dto.GrainItemInfo;
import com.ld.igds.io.notify.NotifyGrainInvoker;
import com.ld.igds.models.DepotConf;
import com.ld.igds.models.DeviceSer;
import com.ld.igds.models.DicSysConf;
import com.ld.igds.models.Grain;
import com.ld.igds.order.ExeOrderService;
import com.ld.igds.protocol.bhzn.verb.dto.IoMessage;
import com.ld.igds.warn.WarnUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.*;
 
/**
 * 协议解析
 *
 * @author vince
 */
@Slf4j
@Component(AnalysisService.BEAN_ID)
public class AnalysisService {
 
 
    public static final String BEAN_ID = "bhznVerb.analysisService";
 
    @Autowired
    private CoreSerService coreSerService;
    @Autowired
    private CoreCommonService commonService;
    @Autowired
    private NotifyGrainInvoker notifyGrainInvoker;
    @Autowired
    private GrainUtil grainUtil;
    @Autowired
    private WarnUtils warnUtils;
    @Autowired
    private ExeOrderService exeOrderService;
    @Autowired
    private AnalysisDevice analysisDevice;
    @Autowired
    private AnalysisGas analysisGas;
    @Autowired
    private AnalysisES analysisEs;
    @Autowired
    private AnalysisWeather analysisWeather;
    /**
     * @param message
     */
    public void analysis(IoMessage message)  {
        try{
            DeviceSer ser = coreSerService.getCacheSerBySn(message.getCompanyId(), message.getSn());
            if (null == ser) {
                log.warn("控制柜------>>>平台:当前组织编码={},分机ID={},系统没有获取到分机信息,报文无法进行解析", message.getCompanyId(), message.getSn());
 
                return;
            }else{
                    ser.setIp(message.getIp());
                    ser.setPort(message.getPort());
                    ser.setStatus(Constant.YN_Y);
                    coreSerService.updateByData(ser);
            }
            //根据接口编号进行解析路由
            switch (message.getCmd()) {
                case 247:
                    analysisDevice.analysis(message, ser);
                    break;
                case 209:
                    analysisGas.analysis(message, ser);
                    break;
                case 240:
                    analysisEs.analysis(message, ser);
                    break;
                case 160:
                    analysisWeather.analysis(message, ser);
                    break;
                default:
                    log.error("控制柜命令码解析失败!");
                    break;
            }
        }catch (Exception e){
            log.error("控制柜解析失败出错:" + e.getMessage(),e);
        }
    }
 
}