From 68c15b469ab210165457804af80581b83308be23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=88=90=E4=BC=9F?= Date: Thu, 5 Dec 2024 14:01:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=BF=83=E8=B7=B3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=A3=8E=E6=9C=BA=E9=80=9A=E8=AE=AF=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/command/HeartbeatCommand.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) 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); + } + } + } } } }