转义缓存枪的3个状态

This commit is contained in:
ZZ 2021-08-05 17:49:27 +08:00
parent 4602d58d0e
commit cf8b5a54c8

View File

@ -24,6 +24,8 @@ public class RealtimeDataLogic implements ServiceLogic {
private static Logger log = LoggerFactory.getLogger(RealtimeDataLogic.class);
public static final String[] stable = {"离线","故障","空闲","充电"};
public static final String[] pvgstable = {"", "", "未知"};
private static final String[] hftable = {"急停按钮动作故障","无可用整流模块","出风口温度过高","交流防雷故障","交直流模块DC20通信中断","绝缘检测模块FC08通信中断","电度表通信中断","读卡器通信中断","RC10通信中断","风扇调速板故障","直流熔断器故障","高压接触器故障","门打开"};
@Override
@ -34,28 +36,28 @@ public class RealtimeDataLogic implements ServiceLogic {
RealtimeData realtimeData = objectMapper.convertValue(req, RealtimeData.class);
String pileNo = realtimeData.getPileNo();
String gunId = realtimeData.getGunId();
String status = realtimeData.getStatus();
realtimeData.setCreateBy("SYSTEM");
realtimeData.setCreateTime(Calendar.getInstance().getTime());
String gunkey = "gun:".concat(pileNo).concat(gunId);
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
cacheGun.put("status", status);
String statusplain = stable[Integer.parseInt(realtimeData.getStatus())];
cacheGun.put("status", statusplain);
cacheGun.put("pileGunStatus", pvgstable[Integer.parseInt(realtimeData.getPileGunStatus())]);
cacheGun.put("vehicleGunStatus", pvgstable[Integer.parseInt(realtimeData.getVehicleGunStatus())]);
String hardwareFault = realtimeData.getHardwareFault();
String hfs = toBits(hardwareFault);
char[] hfcs = hfs.toCharArray();
String hfsplain = "";
for (int i = hfcs.length-1; i >=0; i--) {
if (hfcs[i] == 49) {
hfsplain = hfsplain.concat(hftable[hfcs.length-i-1]).concat("");
}
}
cacheGun.put("hf", hfsplain);
REDIS.setCacheMap(gunkey, cacheGun);
String orderNo = realtimeData.getOrderNo();
if (orderNo.equals("00000000000000000000000000000000")) {
// todo tidy logic
String hardwareFault = realtimeData.getHardwareFault();
String hfs = toBits(hardwareFault);
char[] hfcs = hfs.toCharArray();
String hfsplain = "";
for (int i = hfcs.length-1; i >=0; i--) {
if (hfcs[i] == 49) {
hfsplain = hfsplain.concat(hftable[hfcs.length-i-1]).concat("");
}
}
cacheGun.put("hf", hfsplain);
} else {
String orderkey = "order:".concat(orderNo);
String orderkey = "order:".concat(orderNo);
if (!orderNo.equals("00000000000000000000000000000000")) {
Map<String, Object> order = REDIS.getCacheMap(orderkey);
List<RealtimeData> realtimeDataList = (List<RealtimeData>) order.get("realtimeDataList");
if (realtimeDataList == null) {
@ -63,7 +65,7 @@ public class RealtimeDataLogic implements ServiceLogic {
}
realtimeDataList.add(realtimeData);
order.put("soc", realtimeData.getSoc());
order.put("status", status);
order.put("status", statusplain);
order.put("realtimeDataList", realtimeDataList);
REDIS.setCacheMap(orderkey, order);
}