终端心跳状态

This commit is contained in:
ZZ 2022-02-25 13:16:32 +08:00
parent 5e92204b66
commit bb92694576

View File

@ -20,7 +20,7 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex;
@Component("HBLogic") @Component("HBLogic")
public class HBLogic implements ServiceLogic { public class HBLogic implements ServiceLogic {
private static Logger log = LoggerFactory.getLogger(HBLogic.class); private static final Logger log = LoggerFactory.getLogger(HBLogic.class);
public static final String[] stable = {"空闲", "故障"}; public static final String[] stable = {"空闲", "故障"};
@ -30,12 +30,14 @@ public class HBLogic implements ServiceLogic {
Map<String, Object> req = sp.getParameters(); Map<String, Object> req = sp.getParameters();
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"); Integer gunStatus = (Integer) req.get("gunStatus");
Long gunStatusInt = Long.parseLong(gunStatus);
String gunkey = "gun:".concat(pileNo).concat(gunId); String gunkey = "gun:".concat(pileNo).concat(gunId);
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey); Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
cacheGun.put("statusInt", gunStatusInt);
cacheGun.put("hbtime", Calendar.getInstance().getTimeInMillis()); cacheGun.put("hbtime", Calendar.getInstance().getTimeInMillis());
String status = (String) cacheGun.get("status");
if ("离线".equals(status) || "故障".equals(status)) {
cacheGun.put("status", stable[gunStatus]);
}
REDIS.setCacheMap(gunkey, cacheGun); REDIS.setCacheMap(gunkey, cacheGun);
String skey = gunkey.concat(".seqhex"); String skey = gunkey.concat(".seqhex");
String seq = seqHex(skey); String seq = seqHex(skey);