Ver código fonte

pms 瑞都设备利用率 看板与 汇总页面保持一致。

zhangcl 1 mês atrás
pai
commit
69de8c5b3f

+ 9 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -1656,7 +1656,7 @@ public class IotStaticController {
         }
 
         // key日期2026-06-08   value日期对应的日报数量
-        Map<String, Set<Long>> dateReportDeviceIdPair = new HashMap<>();
+        Map<String, List<Long>> dateReportDeviceIdPair = new HashMap<>();
         reports.forEach(report -> {
             // 按照日期维度统计各 工作量数据 累计用电量 累计油耗 累计注气量 累计注水量
             LocalDateTime reportLocalDate = report.getCreateTime();
@@ -1666,11 +1666,13 @@ public class IotStaticController {
             Set<Long> reportDeviceIds = report.getDeviceIds();
             if (CollUtil.isNotEmpty(reportDeviceIds)) {
                 if (dateReportDeviceIdPair.containsKey(reportDateStr)) {
-                    Set<Long> tempDeviceIds = dateReportDeviceIdPair.get(reportDateStr);
+                    List<Long> tempDeviceIds = dateReportDeviceIdPair.get(reportDateStr);
                     tempDeviceIds.addAll(reportDeviceIds);
                     dateReportDeviceIdPair.put(reportDateStr, tempDeviceIds);
                 } else {
-                    dateReportDeviceIdPair.put(reportDateStr, reportDeviceIds);
+                    List<Long> tempDeviceIds = new ArrayList<>();
+                    tempDeviceIds.addAll(reportDeviceIds);
+                    dateReportDeviceIdPair.put(reportDateStr, tempDeviceIds);
                 }
             }
         });
@@ -1680,14 +1682,16 @@ public class IotStaticController {
             dateReportDeviceIdPair.forEach((reportDateStr, deviceIds) -> {
                 // 计算每天的所有日报涉及到的压裂连油主设备
                 // 1. 求交集:实际使用的A B类设备
-                Set<Long> utilizedDeviceIds = deviceIds.stream()
+                List<Long> utilizedDeviceIds = deviceIds.stream()
                         .filter(abDeviceIds::contains)
-                        .collect(Collectors.toSet());
+                        .collect(Collectors.toList());
                 if (CollUtil.isNotEmpty(abDeviceIds)) {
                     BigDecimal deviceUtilization = new BigDecimal((double) utilizedDeviceIds.size() / abDeviceIds.size())
                             .setScale(4, RoundingMode.HALF_UP);
                     dateReportUtilizationPair.put(reportDateStr, deviceUtilization);
                 }
+                System.out.println(reportDateStr + "瑞都设备利用率-分子:" + utilizedDeviceIds.size());
+                System.out.println(reportDateStr + "瑞都设备利用率-分母:" + abDeviceIds.size());
             });
         }
         // 5. 按日期升序补全最近7天,缺失填0

+ 4 - 16
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrddailyreport/IotRdDailyReportServiceImpl.java

@@ -1277,7 +1277,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         // 20260604 修改设备利用率统计逻辑 统计 压裂 连油 主设备 rq_iot_device_associate
         // 队伍日报中关联的主设备数量 /(队伍下所有主设备数量-封存设备数量)
         Set<Long> mainDeviceIds = new HashSet<>();
-        Set<Long> fcMainDeviceIds = new HashSet<>();
+        Set<Long> usedMainDeviceIds = new HashSet<>();
         // key设备id   value设备所属部门id
         Map<Long, Long> mainDeviceIdPair = new HashMap<>();
         IotDeviceAssociatePageReqVO deviceAssocReqVO = new IotDeviceAssociatePageReqVO();
@@ -1300,11 +1300,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         // 过滤掉 封存 的 压裂 连油 主设备
         if (CollUtil.isNotEmpty(mainDevices)) {
             mainDevices.forEach(device -> {
-                /* if ("fc".equals(device.getDeviceStatus())) {
-                    fcMainDeviceIds.add(device.getId());
-                } else { */
-                    abDeviceIds.add(device.getId());
-                // }
+                abDeviceIds.add(device.getId());
             });
         }
 
@@ -1458,16 +1454,6 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                                 cumulativeWaterVolumePair.put("cumulativeWaterVolume", tempTotalWaterVolume);
                             }
                         }
-                        // 井数 日报关联任务 完工 井数 +1
-                        /* if ("井数".equals(unit)) {
-                            tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
-                            if (cumulativeWorkingWellPair.containsKey("cumulativeWorkingWell")) {
-                                BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get("cumulativeWorkingWell");
-                                cumulativeWorkingWellPair.put("cumulativeWorkingWell", tempTotalCumulativeWorkingWell.add(tempWorkingWell));
-                            } else {
-                                cumulativeWorkingWellPair.put("cumulativeWorkingWell", tempTotalCumulativeWorkingWell);
-                            }
-                        } */
                         if ("段数".equals(unit)) {
                             // 累计施工层
                             tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
@@ -2048,6 +2034,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         rate = 0;
                     }
                     utilizationRatePair.put(projectDeptId, BigDecimal.valueOf(rate));
+                    System.out.println(projectDeptId + "瑞都设备利用率-分子:" + reportDeviceCount);
+                    System.out.println(projectDeptId + "瑞都设备利用率-分母:" + projectDeviceCount);
                 });
             }
         }