From 46abf68b045098c70380ef9c7083514e56a96362 Mon Sep 17 00:00:00 2001 From: HuangHuiKang Date: Fri, 27 Feb 2026 18:17:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A4=A7=E5=B1=8F=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95GC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/service/device/DeviceServiceImpl.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java index 1ce799cbc..98b11669c 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java @@ -1192,15 +1192,20 @@ public class DeviceServiceImpl implements DeviceService { try { String deviceIdsJson = deviceMapper.selectDeviceIdsByGoviewId(goviewId); + log.info("deviceIdsJson: {}", deviceIdsJson); if (StringUtils.isBlank(deviceIdsJson)) { + log.info("deviceIdsJson is blank, returning empty result"); return result; } // 1. 解析(允许重复 device) List>> deviceAttributeList = parseDeviceIdsJson(deviceIdsJson); + log.info("Parsed deviceAttributeList size: {}", deviceAttributeList.size()); + if (CollectionUtils.isEmpty(deviceAttributeList)) { + log.info("deviceAttributeList is empty, returning empty result"); return result; } @@ -1212,12 +1217,15 @@ public class DeviceServiceImpl implements DeviceService { Set allAttributeIds = deviceAttributeList.stream() .flatMap(e -> e.getValue().stream()) .collect(Collectors.toSet()); + log.info("allDeviceIds: {}", allDeviceIds); + log.info("allAttributeIds: {}", allAttributeIds); // 3. 批量查设备 Map deviceMap = deviceMapper .selectBatchIds(allDeviceIds) .stream() .collect(Collectors.toMap(DeviceDO::getId, Function.identity())); + log.info("deviceMap size: {}", deviceMap.size()); // 4. 批量查属性 Map attributeMap = @@ -1228,23 +1236,32 @@ public class DeviceServiceImpl implements DeviceService { DeviceContactModelDO::getId, Function.identity() )); + log.info("attributeMap size: {}", attributeMap.size()); + // 5. 批量查运行状态 Map latestRecordMap = getLatestDeviceOperationRecords(allDeviceIds); + log.info("latestRecordMap size: {}", latestRecordMap.size()); + // 6. 批量查最新采集数据(需为批量方法) Map>> deviceDataMap = createDeviceDataMapBatch(allDeviceIds, attributeMap); + log.info("deviceDataMap size: {}", deviceDataMap.size()); + // 7. 按原始结构组装(不合并重复设备) for (Map.Entry> entry : deviceAttributeList) { Long deviceId = entry.getKey(); Set attributeIds = entry.getValue(); + log.info("Processing deviceId: {}, attributeIds: {}", deviceId, attributeIds); DeviceDO device = deviceMap.get(deviceId); if (device == null) { + log.info("Device not found for deviceId: {}", deviceId); + continue; } @@ -1266,6 +1283,7 @@ public class DeviceServiceImpl implements DeviceService { DeviceContactModelDO attribute = attributeMap.get(attributeId); if (attribute == null) { + log.info("Attribute not found for attributeId: {}", attributeId); continue; } @@ -1289,7 +1307,7 @@ public class DeviceServiceImpl implements DeviceService { deviceResult.put("attributes", attributeList); result.add(deviceResult); } - + log.info("Final result size: {}", result.size()); } catch (Exception e) { log.error("Failed to get multi-device attributes by goviewId: {}", goviewId, e); }