Browse Source

pms 保养工单列表 性能优化

zhangcl 16 giờ trước cách đây
mục cha
commit
3a5a0a78aa

+ 7 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotmainworkorder/IotMainWorkOrderServiceImpl.java

@@ -276,8 +276,11 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
             });
         }
         // 查询 运行记录模板中 正常的累计时长 公里数集合
-        Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
-                new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
+        Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = new HashMap<>();
+        if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(deviceCategoryIds)) {
+            deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
+                    new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
+        }
         // 以保养工单为维度 统计每个工单相关的保养项的最近保养距离 key保养工单id    value保养工单下每个保养项的的最小保养距离集合
         Map<Long, List<Map<String, Object>>> orderDistancePair = new HashMap<>();
         // key保养工单id  value设备保养工单明细下所有保养规则数据最小值
@@ -285,7 +288,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
 
         // 计算出每个保养工单明细的不同保养规则的保养距离最小值
         if (CollUtil.isNotEmpty(workOrderBomS)) {
-            workOrderBomS.forEach(bom -> {
+            for (IotMainWorkOrderBomDO bom : workOrderBomS) {
                 BigDecimal runningTimeDistance = null;
                 BigDecimal runningKiloDistance = null;
                 BigDecimal naturalDateDistance = null;
@@ -358,7 +361,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
                     tempDistances.add(tempDistance);
                     orderDistancePair.put(bom.getWorkOrderId(), tempDistances);
                 }
-            });
+            }
         }
         try {
             // 以 保养工单id 为维度 统计每个保养工单明细中 距离最近的保养数据