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 gunId = (String) req.get("gunId");
String gunStatus = (String) req.get("gunStatus");
int gunStatusInt = 0;
if (ServiceResult.HEX_FAIL.equals(gunStatus))
gunStatusInt = 1;
String gunKey = pileNo.concat(gunId);
int gunStatusInt = Integer.parseInt(gunStatus);
String gunKey = "gun:".concat(pileNo).concat(gunId);
Map<String, Integer> cacheGun = REDIS.getCacheMap(gunKey);
int cacheGunStatus = cacheGun.get(gunKey);
if ((1 == cacheGunStatus && 0 == gunStatusInt) || (0 == cacheGunStatus && 1 == gunStatusInt)) {
cacheGun.put(gunKey, gunStatusInt);
}
cacheGun.put("status", gunStatusInt);
REDIS.setCacheMap(gunKey, cacheGun);
String resultStr = "680D00000004".concat(pileNo).concat(gunId).concat(ServiceResult.HEX_OK);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);