0x04心跳回复问题修复

This commit is contained in:
ZZ 2021-08-03 17:46:25 +08:00
parent 0b3e5733e7
commit 8dc79f02f4

View File

@ -27,15 +27,11 @@ public class HBLogic implements ServiceLogic {
String pileNo = (String) req.get("pileNo"); String pileNo = (String) req.get("pileNo");
String gunId = (String) req.get("gunId"); String gunId = (String) req.get("gunId");
String gunStatus = (String) req.get("gunStatus"); String gunStatus = (String) req.get("gunStatus");
int gunStatusInt = 0; int gunStatusInt = Integer.parseInt(gunStatus);
if (ServiceResult.HEX_FAIL.equals(gunStatus)) String gunKey = "gun:".concat(pileNo).concat(gunId);
gunStatusInt = 1;
String gunKey = pileNo.concat(gunId);
Map<String, Integer> cacheGun = REDIS.getCacheMap(gunKey); Map<String, Integer> cacheGun = REDIS.getCacheMap(gunKey);
int cacheGunStatus = cacheGun.get(gunKey); cacheGun.put("status", gunStatusInt);
if ((1 == cacheGunStatus && 0 == gunStatusInt) || (0 == cacheGunStatus && 1 == gunStatusInt)) { REDIS.setCacheMap(gunKey, cacheGun);
cacheGun.put(gunKey, gunStatusInt);
}
String resultStr = "680D00000004".concat(pileNo).concat(gunId).concat(ServiceResult.HEX_OK); String resultStr = "680D00000004".concat(pileNo).concat(gunId).concat(ServiceResult.HEX_OK);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK); return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);