diff --git a/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java b/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java index cbafa444..5c13d899 100644 --- a/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java +++ b/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java @@ -1,7 +1,10 @@ package com.das.modules.node.command; +import com.das.common.constant.EquipmentTypeIds; import com.das.common.utils.AdminRedisTemplate; import com.das.common.utils.StringUtils; +import com.das.modules.cache.domain.DeviceInfoCache; +import com.das.modules.cache.service.CacheService; import com.das.modules.node.constant.NodeConstant; import com.das.modules.node.domain.bo.TerminalMessage; import com.fasterxml.jackson.databind.JsonNode; @@ -17,6 +20,9 @@ public class HeartbeatCommand implements BaseCommand{ @Autowired AdminRedisTemplate adminRedisTemplate; + + @Autowired + CacheService cacheService; @Override public void doCommand(TerminalMessage data) { JsonNode dataInfo = data.getData(); @@ -39,6 +45,27 @@ public class HeartbeatCommand implements BaseCommand{ adminRedisTemplate.expire(key, 300L); } } + JsonNode devices = data.getData().get("devices"); + if (devices != null && devices.isArray()) { + for (JsonNode device : devices) { + Long deviceId = device.get("deviceId").asLong(); + Boolean online = device.get("online").asBoolean(); + DeviceInfoCache deviceInfoCacheById = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId); + if (deviceInfoCacheById == null || !deviceInfoCacheById.getObjectType().equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG)) { + continue; + } + //判断是不是风机 + String keyPLCDeviceStatus = String.format("RT:%d:iturbineoperationmode", deviceId); + String keyDeviceStatus = String.format("RT:%d:commfaultstate"); + Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus); + if (plcDeviceStatus == null){ + adminRedisTemplate.set(keyDeviceStatus, online ? 1 : 0); + } + else{ + adminRedisTemplate.set(keyDeviceStatus, online && plcDeviceStatus == 1 ? 1 : 0); + } + } + } } } }