更新心跳逻辑

This commit is contained in:
谷成伟 2024-12-11 09:50:01 +08:00
parent 6d1dd1ae26
commit 70b723a15d

View File

@ -49,7 +49,7 @@ public class HeartbeatCommand implements BaseCommand{
if (devices != null && devices.isArray()) {
for (JsonNode device : devices) {
Long deviceId = device.get("deviceId").asLong();
Boolean online = device.get("online").asBoolean();
int online = device.get("online").asInt();
DeviceInfoCache deviceInfoCacheById = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId);
if (deviceInfoCacheById == null || !deviceInfoCacheById.getObjectType().equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG)) {
continue;
@ -59,10 +59,10 @@ public class HeartbeatCommand implements BaseCommand{
String keyCommFaultState = String.format("RT:%d:commfaultstate",deviceId);
Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus);
if (plcDeviceStatus == null){
adminRedisTemplate.set(keyCommFaultState, online ? 0 : 1);
adminRedisTemplate.set(keyCommFaultState, (online == 1) ? 0 : 1);
}
else{
adminRedisTemplate.set(keyCommFaultState, online && (plcDeviceStatus != 0) ? 0 : 1);
adminRedisTemplate.set(keyCommFaultState, (online == 1) && (plcDeviceStatus != 0) ? 0 : 1);
}
}
}