lipenghui пре 1 недеља
родитељ
комит
64b4557a90

+ 11 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -703,9 +703,13 @@ public class IotDeviceServiceImpl implements IotDeviceService {
                 pageReqVO.getPageSize()), pageReqVO.getDeviceIds(), pageReqVO.getBomFlag());
         // 查询所有 设备boms节点的所有上级节点名称 拼接出 全路径 的bom节点
         List<Long> bomNodeIds = new ArrayList<>();
+        Set<Long> deptIds = new HashSet<>();
+        Set<Long> deviceIds = new HashSet<>();
         if (CollUtil.isNotEmpty(page.getRecords())) {
             page.getRecords().forEach(device -> {
                 bomNodeIds.add(Long.valueOf(device.getBomNodeId()));
+                deptIds.add(device.getDeptId());
+                deviceIds.add(device.getId());
             });
             // 查询 bomNodeIds 集合中每个bom节点的所有上级节点
             Map<Long, String> bomFullPaths = iotDeviceBomService.buildBomFullPaths(bomNodeIds);
@@ -717,6 +721,13 @@ public class IotDeviceServiceImpl implements IotDeviceService {
                 }
             });
         }
+        Map<String, List<IotDeviceMaterialRespVO>> bomMaterialsPair = iotDeviceMaterialService.bomMaterials(deptIds, deviceIds, new HashSet<>(bomNodeIds));
+        page.getRecords().forEach(device -> {
+            String uniqueKey = StrUtil.join("-", device.getId(), device.getBomNodeId());
+            if (bomMaterialsPair.containsKey(uniqueKey)) {
+                device.setDeviceBomMaterials(bomMaterialsPair.get(uniqueKey));
+            }
+        });
         return new PageResult<>(page.getRecords(), page.getTotal());
     }