Ver Fonte

pms 瑞都日报 汇总卡片 井数

zhangcl há 1 dia atrás
pai
commit
60411f0925

+ 57 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/IotRdDailyReportController.java

@@ -1377,6 +1377,9 @@ public class IotRdDailyReportController {
         // key 部门id-队伍id      value队伍工作量数据 台次 当日泵车台次 当日仪表/混砂
         Map<String, BigDecimal> groupMixSandPair = new HashMap<>();
 
+        // key 部门id-队伍id   value 累计完工井
+        Map<String, Set<Long>> groupFinishedWellPair = new HashMap<>();
+
         // key小组最后1条记录id   value 桥塞(个数)
         Map<Long, BigDecimal> groupIdBridgePlugPair = new HashMap<>();
         // key小组最后1条记录id      value趟数
@@ -1397,6 +1400,13 @@ public class IotRdDailyReportController {
         Map<Long, BigDecimal> groupIdMixSandPair = new HashMap<>();
         // 已经完工的任务id集合
         Set<Long> finishedTaskIds = new HashSet<>();
+
+        // key小组最后1条记录id      value累计完工井
+        Map<Long, Set<Long>> groupIdFinishedWellPair = new HashMap<>();
+
+        // keykey小组最后1条记录id   value完工井id集合
+        Map<Long, Set<Long>> cumulativeWellsPair = new HashMap<>();
+
         // key日报id   value生产动态明细
         Map<Long, List<IotRdDailyReportDetailRespVO>> reportDetailsPair = new HashMap<>();
 
@@ -1426,7 +1436,7 @@ public class IotRdDailyReportController {
         if (CollUtil.isNotEmpty(deptTaskDailyReports)) {
             deptTaskDailyReports.forEach(report -> {
                 String uniqueKey = StrUtil.join("-", report.getDeptId(), report.getTaskId());
-
+                // 油耗
                 BigDecimal dailyFuel = report.getDailyFuel();
                 dailyFuel = ObjUtil.isEmpty(dailyFuel) ? BigDecimal.ZERO : dailyFuel;
                 if (groupFuelPair.containsKey(uniqueKey)) {
@@ -1436,6 +1446,20 @@ public class IotRdDailyReportController {
                 } else {
                     groupFuelPair.put(uniqueKey, dailyFuel);
                 }
+                // 累计完工井
+                // 日报关联的任务井id
+                Long taskId = report.getTaskId();
+                if (ObjUtil.isNotEmpty(taskId) && finishedTaskIds.contains(taskId)) {
+                    if (groupFinishedWellPair.containsKey(uniqueKey)) {
+                        Set<Long> existTaskIds = groupFinishedWellPair.get(uniqueKey);
+                        existTaskIds.add(taskId);
+                        groupFinishedWellPair.put(uniqueKey, existTaskIds);
+                    } else {
+                        Set<Long> existTaskIds = new HashSet<>();
+                        existTaskIds.add(taskId);
+                        groupFinishedWellPair.put(uniqueKey, existTaskIds);
+                    }
+                }
 
                 // 设置每个任务的工作量数据  单位相同的工作量值作合并处理
                 List<IotTaskAttrModelProperty> taskAttrs = report.getExtProperty();
@@ -1590,8 +1614,11 @@ public class IotRdDailyReportController {
                     if (groupRunCountPair.containsKey(uniqueKey)) {
                         groupIdRunCountPair.put(groupId, groupRunCountPair.get(uniqueKey));
                     }
-                    if (groupCumulativeWorkingWellPair.containsKey(uniqueKey)) {
+                    /* if (groupCumulativeWorkingWellPair.containsKey(uniqueKey)) {
                         groupIdCumulativeWorkingWellPair.put(groupId, groupCumulativeWorkingWellPair.get(uniqueKey));
+                    } */
+                    if (groupFinishedWellPair.containsKey(uniqueKey)) {
+                        groupIdFinishedWellPair.put(groupId, groupFinishedWellPair.get(uniqueKey));
                     }
                     if (groupHourCountPair.containsKey(uniqueKey)) {
                         groupIdHourCountPair.put(groupId, groupHourCountPair.get(uniqueKey));
@@ -1965,7 +1992,7 @@ public class IotRdDailyReportController {
             // 趟数
             findAndThen(groupIdRunCountPair, reportVO.getId(), runCount -> reportVO.setGroupIdRunCount(runCount));
             // 井数
-            findAndThen(groupIdCumulativeWorkingWellPair, reportVO.getId(), workingWell -> reportVO.setGroupIdCumulativeWorkingWell(workingWell));
+            findAndThen(groupIdFinishedWellPair, reportVO.getId(), workingWells -> reportVO.setGroupIdCumulativeWorkingWell(new BigDecimal(workingWells.size())));
             // 小时H
             findAndThen(groupIdHourCountPair, reportVO.getId(), hourCount -> reportVO.setGroupIdHourCount(hourCount));
             // 油耗
@@ -2031,6 +2058,9 @@ public class IotRdDailyReportController {
         // key 部门id-队伍id      value队伍工作量数据 台次 当日泵车台次 当日仪表/混砂
         Map<String, BigDecimal> groupMixSandPair = new HashMap<>();
 
+        // key 部门id-队伍id   value 完工井id集合
+        Map<String, Set<Long>> groupFinishedWellPair = new HashMap<>();
+
         // key小组最后1条记录id   value 桥塞(个数)
         Map<Long, BigDecimal> groupIdBridgePlugPair = new HashMap<>();
         // key小组最后1条记录id      value趟数
@@ -2051,6 +2081,10 @@ public class IotRdDailyReportController {
         Map<Long, BigDecimal> groupIdMixSandPair = new HashMap<>();
         // 已经完工的任务id集合
         Set<Long> finishedTaskIds = new HashSet<>();
+
+        // key小组最后1条记录id      value完工井id集合
+        Map<Long, Set<Long>> groupIdFinishedWellPair = new HashMap<>();
+
         // key日报id   value生产动态明细
         Map<Long, List<IotRdDailyReportDetailRespVO>> reportDetailsPair = new HashMap<>();
 
@@ -2094,6 +2128,21 @@ public class IotRdDailyReportController {
                     groupFuelPair.put(uniqueKey, dailyFuel);
                 }
 
+                // 累计完工井
+                // 日报关联的任务井id
+                Long taskId = report.getTaskId();
+                if (ObjUtil.isNotEmpty(taskId) && finishedTaskIds.contains(taskId)) {
+                    if (groupFinishedWellPair.containsKey(uniqueKey)) {
+                        Set<Long> existTaskIds = groupFinishedWellPair.get(uniqueKey);
+                        existTaskIds.add(taskId);
+                        groupFinishedWellPair.put(uniqueKey, existTaskIds);
+                    } else {
+                        Set<Long> existTaskIds = new HashSet<>();
+                        existTaskIds.add(taskId);
+                        groupFinishedWellPair.put(uniqueKey, existTaskIds);
+                    }
+                }
+
                 // 设置每个任务的工作量数据  单位相同的工作量值作合并处理
                 List<IotTaskAttrModelProperty> taskAttrs = report.getExtProperty();
                 // 暂存不同单位的工作量属性值
@@ -2247,8 +2296,11 @@ public class IotRdDailyReportController {
                     if (groupRunCountPair.containsKey(uniqueKey)) {
                         groupIdRunCountPair.put(groupId, groupRunCountPair.get(uniqueKey));
                     }
-                    if (groupCumulativeWorkingWellPair.containsKey(uniqueKey)) {
+                    /* if (groupCumulativeWorkingWellPair.containsKey(uniqueKey)) {
                         groupIdCumulativeWorkingWellPair.put(groupId, groupCumulativeWorkingWellPair.get(uniqueKey));
+                    } */
+                    if (groupFinishedWellPair.containsKey(uniqueKey)) {
+                        groupIdFinishedWellPair.put(groupId, groupFinishedWellPair.get(uniqueKey));
                     }
                     if (groupHourCountPair.containsKey(uniqueKey)) {
                         groupIdHourCountPair.put(groupId, groupHourCountPair.get(uniqueKey));
@@ -2628,7 +2680,7 @@ public class IotRdDailyReportController {
             // 趟数
             findAndThen(groupIdRunCountPair, reportVO.getId(), runCount -> reportVO.setGroupIdRunCount(runCount));
             // 井数
-            findAndThen(groupIdCumulativeWorkingWellPair, reportVO.getId(), workingWell -> reportVO.setGroupIdCumulativeWorkingWell(workingWell));
+            findAndThen(groupIdFinishedWellPair, reportVO.getId(), workingWells -> reportVO.setGroupIdCumulativeWorkingWell(new BigDecimal(workingWells.size())));
             // 小时H
             findAndThen(groupIdHourCountPair, reportVO.getId(), hourCount -> reportVO.setGroupIdHourCount(hourCount));
             // 油耗

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

@@ -1250,6 +1250,11 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         // key工作量标识   value累计 台次 当日泵车台次
         Map<String, BigDecimal> cumulativePumpTripsPair = new HashMap<>();
 
+        // 已经完工的任务id集合
+        Set<Long> finishedTaskIds = new HashSet<>();
+        // key井唯一标识   value累计完工井id集合
+        Map<String, Set<Long>> cumulativeWellsPair = new HashMap<>();
+
         // 查询 瑞都 施工状态 字典数据 筛选出施工设备为 LY 的记录
         Set<String> lyStatuses = new HashSet<>();
         List<DictDataDO> rdStatuses = dictDataService.getDictDataListByDictType("rdStatus");
@@ -1326,6 +1331,21 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         List<IotRdDailyReportDO> dailyReports = iotRdDailyReportMapper.dailyReports(pageReqVO);
         // 累加所有日报的 工作量 数据 油耗 桥塞 趟数 井数...
         if (CollUtil.isNotEmpty(dailyReports)) {
+            // 遍历日报 找到每个日报关联的任务的 施工队伍
+            List<Long> taskIds = convertList(dailyReports, IotRdDailyReportDO::getTaskId);
+            Set<Long> uniqueTaskIds = new HashSet<>(taskIds);
+            IotProjectTaskPageReqVO relatedTaskReqVO = new IotProjectTaskPageReqVO();
+            relatedTaskReqVO.setTaskIds(new ArrayList<>(uniqueTaskIds));
+            List<IotProjectTaskDO> relatedTasks = iotProjectTaskMapper.selectList(relatedTaskReqVO);
+            if (CollUtil.isNotEmpty(relatedTasks)) {
+                relatedTasks.forEach(task -> {
+                    // 筛选出 完工 的任务集合 任务完工 施工井数 +1
+                    if ("wg".equals(task.getRdStatus())) {
+                        finishedTaskIds.add(task.getId());
+                    }
+                });
+            }
+
             // 筛选出所有日报关联的任务集合
             dailyReports.forEach(report -> {
                 // 筛选出日报中施工的 主设备id 集合
@@ -1336,9 +1356,22 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                             .filter(abDeviceIds::contains)
                             .forEach(reportMainDeviceIds::add);
                 }
-                /* if (CollUtil.isNotEmpty(report.getDeviceIds())) {
-                    reportDeviceIds.addAll(report.getDeviceIds());
-                } */
+                // 累计完工井
+                // 日报关联的任务井id
+                Long taskId = report.getTaskId();
+                if (ObjUtil.isNotEmpty(taskId) && finishedTaskIds.contains(taskId)) {
+                    // 统计各项目部下的完工井
+                    if (cumulativeWellsPair.containsKey("cumulativeWorkingWell")) {
+                        Set<Long> existTaskIds = cumulativeWellsPair.get("cumulativeWorkingWell");
+                        existTaskIds.add(taskId);
+                        cumulativeWellsPair.put("cumulativeWorkingWell", existTaskIds);
+                    } else {
+                        Set<Long> existTaskIds = new HashSet<>();
+                        existTaskIds.add(taskId);
+                        cumulativeWellsPair.put("cumulativeWorkingWell", existTaskIds);
+                    }
+                }
+                // 油耗
                 BigDecimal dailyFuel = report.getDailyFuel();
                 dailyFuel = ObjUtil.isEmpty(dailyFuel) ? BigDecimal.ZERO : dailyFuel;
                 if (cumulativeFuelsPair.containsKey("cumulativeFuels")) {
@@ -1519,12 +1552,12 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
             waterVolumeResp.setDeptName("cumulativeWaterVolume");
             result.add(waterVolumeResp);
         }
-        if (CollUtil.isNotEmpty(cumulativeWorkingWellPair)) {
-            Collection<BigDecimal> cumulativeWorkingWells = cumulativeWorkingWellPair.values();
-            Optional<BigDecimal> workingWells = cumulativeWorkingWells.stream().findAny();
-            BigDecimal workingWell = workingWells.get();
+        if (CollUtil.isNotEmpty(cumulativeWellsPair)) {
+            Collection<Set<Long>> taskIds = cumulativeWellsPair.values();
+            Optional<Set<Long>> workingWells = taskIds.stream().findAny();
+            Set<Long> workingWell = workingWells.get();
             IotRdDailyReportStatisticsRespVO workingWellResp = new IotRdDailyReportStatisticsRespVO();
-            workingWellResp.setCumulativeWorkingWell(workingWell);
+            workingWellResp.setCumulativeWorkingWell(new BigDecimal(workingWell.size()));
             workingWellResp.setDeptName("cumulativeWorkingWell");
             result.add(workingWellResp);
         }