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 22be0b41..f0b78e33 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 @@ -8,11 +8,13 @@ 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; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.MessageFormat; +@Slf4j @Service(value = NodeConstant.HEARTBEAT) public class HeartbeatCommand implements BaseCommand{ @@ -49,20 +51,22 @@ 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; } //判断是不是风机 + String keyPLCDeviceStatus = String.format("RT:%d:iturbineoperationmode", deviceId); String keyCommFaultState = String.format("RT:%d:commfaultstate",deviceId); Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus); + log.debug("设备ID:{},在线状态:{},通讯状态: {}", deviceId, online, plcDeviceStatus); 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); } } } diff --git a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java index 1c458a88..35b49241 100644 --- a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java +++ b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java @@ -161,7 +161,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node List tabMappingVoList = sysImptabmappingMapper.getMappingInfoListByLinkIdAndDeviceId(sysCommunicationLinkVo.getId(), dev.getId()); - if (sysCommunicationLinkVo.getProtocol() == 17 || sysCommunicationLinkVo.getProtocol() == 9){ + if (sysCommunicationLinkVo.getProtocol() == 17 || sysCommunicationLinkVo.getProtocol() == 9) { List orderMappingVoList = tabMappingVoList.stream().filter(item -> ObjectUtil.isNotEmpty(JSONObject.parseObject(item.getParams()).get("order"))).collect(Collectors.toList()); tabMappingVoList.clear(); tabMappingVoList.addAll(orderMappingVoList); @@ -238,8 +238,10 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node @Override public void handleData(TerminalMessage data) { JsonNode jsonNode = data.getData(); + log.info("收到消息:{}",data.getData()); String deviceId = jsonNode.get("deviceId").asText(); JsonNode values = jsonNode.get("values"); + JsonNode archiveValues = jsonNode.get("archiveValues"); Long dataTime = jsonNode.get("dataTime").asLong(); Map keyValueMap = new HashMap<>(); String modelCode = dataService.deviceModelMap.get(deviceId); @@ -254,30 +256,36 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node String fieldName = keysHigh.next(); String key = String.format("RT:%s:%s", deviceId, fieldName.toLowerCase()); keyValueMap.put(key, values.get(fieldName)); - if (highKey.contains(fieldName)){ - highSpeedValueMap.put(fieldName,values.get(fieldName)); + } + log.info("values解析成功"); + Iterator archiveKeys = archiveValues.fieldNames(); + while (archiveKeys.hasNext()) { + String fieldName = archiveKeys.next(); + String key = String.format("RT:%s:%s", deviceId, fieldName.toLowerCase()); + keyValueMap.put(key, values.get(fieldName)); + if (highKey.contains(fieldName)) { + highSpeedValueMap.put(fieldName, values.get(fieldName)); } - if (lowKey.contains(fieldName)){ - lowSpeedValueMap.put(fieldName,values.get(fieldName)); + if (lowKey.contains(fieldName)) { + lowSpeedValueMap.put(fieldName, values.get(fieldName)); } } + log.info("archive解析成功"); + //更新td + if (!highSpeedValueMap.isEmpty()) { + List highSpeedData = new ArrayList<>(); + RTData rtHighData = RTData.builder().dataTime(dataTime).deviceId(Long.valueOf(deviceId)).values(highSpeedValueMap).build(); + highSpeedData.add(rtHighData); + tdEngineService.updateYCHighValues(highSpeedData, modelCode); + } + + if (!lowSpeedValueMap.isEmpty()) { + List lowSpeedData = new ArrayList<>(); + RTData rtLowData = RTData.builder().dataTime(dataTime).deviceId(Long.valueOf(deviceId)).values(lowSpeedValueMap).build(); + lowSpeedData.add(rtLowData); + tdEngineService.updateYCLowValues(lowSpeedData, modelCode); + } adminRedisTemplate.mSet(keyValueMap); - if (jsonNode.get("isStore") != null && jsonNode.get("isStore").asBoolean()) { - //更新td - if (!highSpeedValueMap.isEmpty()){ - List highSpeedData = new ArrayList<>(); - RTData rtHighData = RTData.builder().dataTime(dataTime).deviceId(Long.valueOf(deviceId)).values(highSpeedValueMap).build(); - highSpeedData.add(rtHighData); - tdEngineService.updateYCHighValues(highSpeedData,modelCode); - } - - if (!lowSpeedValueMap.isEmpty()){ - List lowSpeedData = new ArrayList<>(); - RTData rtLowData = RTData.builder().dataTime(dataTime).deviceId(Long.valueOf(deviceId)).values(lowSpeedValueMap).build(); - lowSpeedData.add(rtLowData); - tdEngineService.updateYCLowValues(lowSpeedData,modelCode); - } - } } @Override @@ -368,25 +376,25 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")) { String stateDesc = dataService.stateDescMap.get(model).get(item.getAttrCode()); if (item.getAttrValue().equals(0)) { - deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 复归"); - if (StringUtils.isNotEmpty(stateDesc)){ + deviceEventInfo.setEventText(item.getAttrCode() + fieldName + " 复归"); + if (StringUtils.isNotEmpty(stateDesc)) { List descList = Arrays.stream(stateDesc.split("\\|")).toList(); - deviceEventInfo.setEventText(item.getAttrCode()+fieldName + descList.get(0)); + deviceEventInfo.setEventText(item.getAttrCode() + fieldName + descList.get(0)); } deviceEventInfo.setEventLevel(0); } else { - deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 动作"); - if (StringUtils.isNotEmpty(stateDesc)){ + deviceEventInfo.setEventText(item.getAttrCode() + fieldName + " 动作"); + if (StringUtils.isNotEmpty(stateDesc)) { List descList = Arrays.stream(stateDesc.split("\\|")).toList(); - deviceEventInfo.setEventText(item.getAttrCode()+fieldName + descList.get(1)); + deviceEventInfo.setEventText(item.getAttrCode() + fieldName + descList.get(1)); } Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode()); - log.info("level:{}",level); - log.info("fieldname{}",fieldName); - deviceEventInfo.setEventLevel( level == null ? 0 : level); + log.info("level:{}", level); + log.info("fieldname{}", fieldName); + deviceEventInfo.setEventLevel(level == null ? 0 : level); } } else { - deviceEventInfo.setEventText(item.getAttrCode()+fieldName + eventType + ",属性值为:" + item.getAttrValue() + ",越限值为:" + item.getLimitValue()); + deviceEventInfo.setEventText(item.getAttrCode() + fieldName + eventType + ",属性值为:" + item.getAttrValue() + ",越限值为:" + item.getLimitValue()); deviceEventInfo.setEventLevel(1); } valueList.add(deviceEventInfo); diff --git a/docs/deploy/asserts/image-redis03.png b/docs/deploy/asserts/image-redis03.png deleted file mode 100644 index b9fa038a..00000000 Binary files a/docs/deploy/asserts/image-redis03.png and /dev/null differ diff --git a/ui/dasadmin/src/views/backend/WindBlower/index.vue b/ui/dasadmin/src/views/backend/WindBlower/index.vue index d270d7b1..8f9708a1 100644 --- a/ui/dasadmin/src/views/backend/WindBlower/index.vue +++ b/ui/dasadmin/src/views/backend/WindBlower/index.vue @@ -118,7 +118,7 @@
启动() const overviewData = reactive({ - // iturbineoperationmode: '-', + // processedoperationmode: '-', iwindspeed: '-', iwinddirection: '-', igenspeed: '-', @@ -963,12 +963,12 @@ const createScroll = () => { } const realTimeData = ref({ - iturbineoperationmode: 1111, + processedoperationmode: 1111, locked: 0, }) const realTimeDataState = computed(() => { - switch (realTimeData.value.iturbineoperationmode) { + switch (realTimeData.value.processedoperationmode) { case 20: return '并网' case 10: @@ -1015,7 +1015,7 @@ const createRealTimeData = async () => { try { const modelList: any = await getModelList() const realData: any = await getRealTimeData() - realTimeData.value.iturbineoperationmode = getRealTimeState(realData) + realTimeData.value.processedoperationmode = getRealTimeState(realData) realTimeData.value.locked = realData.locked temperatureChartsData[0].value = getCutDecimalsValue(realData.itempoutdoor_1sec) diff --git a/ui/dasadmin/src/views/backend/energyManage/index.vue b/ui/dasadmin/src/views/backend/energyManage/index.vue index 8bd860b1..730cfd88 100644 --- a/ui/dasadmin/src/views/backend/energyManage/index.vue +++ b/ui/dasadmin/src/views/backend/energyManage/index.vue @@ -6,7 +6,14 @@
风机列表
- +