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..8dc312f0 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); @@ -240,6 +240,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node JsonNode jsonNode = 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 +255,34 @@ 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)); + } + 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)); } } + //更新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 +373,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);