fix(device): 修复设备注册和容量记录功能

- 修复ledger树排序字段设置,使用正确的设备ID而非固定值0
- 添加设备注册查询逻辑,支持通过NDID和CLDID获取注册信息
- 实现线路ID动态获取机制,避免硬编码导致的数据错误
- 添加空值检查和异常处理,提升系统稳定性
- 优化MQTT消息处理中的设备容量记录流程
This commit is contained in:
xy
2026-06-24 20:34:52 +08:00
parent 723fe45286
commit cf6e07eec1
2 changed files with 18 additions and 3 deletions

View File

@@ -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<CsLinePO> 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);

View File

@@ -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)) {