From cf6e07eec1155dcd1eff7b935f191bbfa1f09d43 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Wed, 24 Jun 2026 20:34:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(device):=20=E4=BF=AE=E5=A4=8D=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=E5=86=8C=E5=92=8C=E5=AE=B9=E9=87=8F=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复ledger树排序字段设置,使用正确的设备ID而非固定值0 - 添加设备注册查询逻辑,支持通过NDID和CLDID获取注册信息 - 实现线路ID动态获取机制,避免硬编码导致的数据错误 - 添加空值检查和异常处理,提升系统稳定性 - 优化MQTT消息处理中的设备容量记录流程 --- .../njcn/access/handler/MqttMessageHandler.java | 17 ++++++++++++++++- .../service/impl/CsDeviceServiceImpl.java | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java b/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java index aaec036..a96770d 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java @@ -395,8 +395,23 @@ public class MqttMessageHandler { updateLineInfo(nDid,item); } //2.录入各个模块设备容量 + CsDeviceRegistry csDeviceRegistry = csDeviceRegistryFeignClient.queryByCurrentNdidAndClDid(nDid, 0).getData(); + String lineId; + if (Objects.isNull(csDeviceRegistry)) { + List lines = csLineFeignClient.findByNdid(nDid).getData(); + if (CollectionUtil.isEmpty(lines)) { + throw new BusinessException("通过装置NDID获取监测点信息失败"); + } + CsLinePO line = lines.stream().filter(item2->Objects.equals(item2.getClDid(),0)).findFirst().orElse(null); + if (Objects.isNull(line)) { + throw new BusinessException("通过逻辑子设备ID获取监测点信息失败"); + } + lineId = line.getLineId(); + } else { + lineId = csDeviceRegistry.getId(); + } CsDevCapacityPO csDevCapacity = new CsDevCapacityPO(); - csDevCapacity.setLineId(nDid.concat("0")); + csDevCapacity.setLineId(lineId); csDevCapacity.setCldid(item.getClDid()); csDevCapacity.setCapacity(Objects.isNull(item.getCapacityA())?0.0:item.getCapacityA()); list3.add(csDevCapacity); diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java index 9648b2d..8659435 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java @@ -310,7 +310,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { param.setPid(vo.getId()); param.setName(item.getName()); param.setLevel(3); - param.setSort(0); + param.setSort(po.getClDid()); csLedgerService.addLedgerTree(param); appLineTopologyDiagramPo.setId(devAccessParam.getTopologyDiagram()); appLineTopologyDiagramPo.setLat(item.getLat()); @@ -535,7 +535,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { param.setPid(vo.getId()); param.setName(item.getClDev().toString() + "#监测点"); param.setLevel(3); - param.setSort(0); + param.setSort(item.getClDev()); csLedgerService.addLedgerTree(param); //4.存储设备注册表数据,用来后续保留监测点id if (CollUtil.isEmpty(data)) {