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
package com.fzzy.protocol.fzzy.analysis;
 
import com.alibaba.fastjson.JSONObject;
import com.fzzy.api.data.ApiCommonDevice;
import com.fzzy.gateway.data.BaseReqData;
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.Response2102;
import com.fzzy.protocol.fzzy.server.ServerUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
 
/**
 * 粮情解析
 *
 * @author Andy
 */
@Slf4j
@Component(AnalysisGrain.BEAN_ID)
public class AnalysisGrain extends BaseRemoteImpl {
 
    public static final String BEAN_ID = "fzzy.analysisGrain";
 
 
    public static int ERROR_CHECK_TAG = -1000;//粮温,气体,虫害,故障值
 
    public static int ERROR_CHECK_TAG2 = -2000;//传感器故障或者不在线
 
 
    public void analysis2101(ReMessage reMessage, ApiCommonDevice ser) {
        //DO NOTHING
    }
 
    /**
     * 粮情返回信息解析
     *
     * @param reMessage
     * @param ser
     */
    public void analysis2102(ReMessage reMessage, ApiCommonDevice ser) {
 
        try {
 
            //返回控制柜信息
            returnMsg(ser);
 
            Response2102 response = JSONObject.parseObject(reMessage.getContent(), Response2102.class);
 
            String depotId = response.getHouseId();
 
            //获取请求信息
            BaseReqData reqData = ServerUtils.getSyncReq(depotId);
 
 
            //粮情解析
            log.info("控制柜--->平台粮情信息--{}", response);
 
 
        } catch (Exception e) {
 
            log.error("控制柜--->平台粮情信息异常-{}", e);
 
        }
    }
 
    private void returnMsg(ApiCommonDevice ser) {
        //先回复控制柜
        SimpleCommandBuilder commandBuilder = SimpleCommandBuilder.getInstance();
        SendMessage message = commandBuilder.buildMessage(ser, ServerUtils.FUNCTION_2102);
        send(message);
    }
}