package com.fzzy.protocol;
|
|
|
import com.alibaba.fastjson.JSON;
|
import com.fzzy.gateway.data.BaseReqData;
|
import com.fzzy.protocol.data.THDto;
|
import io.netty.channel.Channel;
|
import lombok.extern.slf4j.Slf4j;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* 协议解析全局常量
|
*/
|
@Slf4j
|
public class ProtocolUtils {
|
|
|
|
|
|
/**
|
* 请求缓存 key = deviceId,value = requData
|
*/
|
private static Map<String, BaseReqData> contextSyncReqMap = new HashMap<>();
|
|
/**
|
* 请求缓存 key = deviceId,value = thDto
|
*/
|
private static Map<String, THDto> contextThMap = new HashMap<>();
|
|
|
//-粮温备用点
|
public static final double ERROR_TEMP = -100;
|
//-粮温故障点
|
public static final double FAULT_TEMP = -101;
|
//-粮温补偿点-针对锥形仓补点使用
|
public static final double ADD_TEMP = -102;
|
|
|
/**
|
* 将执行命令信息存放在缓存
|
*
|
* @param depotId 仓库编码
|
* @param reqData 请求参数信息
|
*/
|
public static void addSyncReq2Map(String depotId, BaseReqData reqData) {
|
contextSyncReqMap.put(depotId, reqData);
|
}
|
|
public static synchronized BaseReqData getSyncReq(String depotId) {
|
log.info(JSON.toJSONString(contextSyncReqMap));
|
//contextSyncReqMap.get(depotId);
|
return contextSyncReqMap.get(depotId);
|
}
|
public static synchronized BaseReqData delSyncReq(String depotId) {
|
log.info(JSON.toJSONString(contextSyncReqMap));
|
//contextSyncReqMap.get(depotId);
|
return contextSyncReqMap.remove(depotId);
|
}
|
|
public static void addTh2Map(String deviceId, THDto thDto) {
|
contextThMap.put(deviceId, thDto);
|
}
|
|
public static THDto getCacheTh(String deviceId) {
|
return contextThMap.get(deviceId);
|
}
|
|
}
|