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);
|
}
|
}
|