Răsfoiți Sursa

pms 瑞都 单井单队伍统计 施工井统计逻辑优化

zhangcl 15 ore în urmă
părinte
comite
36836d26eb

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

@@ -1234,6 +1234,22 @@ public class IotRdDailyReportController {
         Map<Long, BigDecimal> groupIdCumulativeWorkingLayersPair = new HashMap<>();
         // key小组最后1条记录id      value台次 当日仪表/混砂
         Map<Long, BigDecimal> groupIdMixSandPair = new HashMap<>();
+        // 已经完工的任务id集合
+        Set<Long> finishedTaskIds = new HashSet<>();
+
+        DataPermissionUtils.executeIgnore(() -> {
+            IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
+            taskReqVO.setTaskIds(convertList(reports, IotRdDailyReportDO::getTaskId));
+            List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(taskReqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    // 筛选出 完工 的任务集合 任务完工 施工井数 +1
+                    if ("wg".equals(task.getRdStatus())) {
+                        finishedTaskIds.add(task.getId());
+                    }
+                });
+            }
+        });
 
         // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
         IotRdDailyReportPageReqVO currentTaskReqVO = new IotRdDailyReportPageReqVO();
@@ -1341,7 +1357,7 @@ public class IotRdDailyReportController {
                                 groupWaterVolumePair.put(uniqueKey, tempTotalWaterVolume);
                             }
                         }
-                        if ("井数".equals(unit)) {
+                        /* if ("井数".equals(unit)) {
                             tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
                             if (groupCumulativeWorkingWellPair.containsKey(uniqueKey)) {
                                 BigDecimal tempWorkingWell = groupCumulativeWorkingWellPair.get(uniqueKey);
@@ -1349,6 +1365,12 @@ public class IotRdDailyReportController {
                             } else {
                                 groupCumulativeWorkingWellPair.put(uniqueKey, tempTotalCumulativeWorkingWell);
                             }
+                        } */
+                        // 施工完成的井累计计数 1
+                        if (finishedTaskIds.contains(report.getTaskId())) {
+                            groupCumulativeWorkingWellPair.put(uniqueKey, new BigDecimal("1"));
+                        } else {
+                            groupCumulativeWorkingWellPair.put(uniqueKey, BigDecimal.ZERO);
                         }
                         if ("段数".equals(unit)) {
                             // 累计施工层
@@ -1652,8 +1674,12 @@ public class IotRdDailyReportController {
                         if ("方".equals(unit)) {
                             tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
                         }
-                        if ("井数".equals(unit)) {
+                        /* if ("井数".equals(unit)) {
                             tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
+                        } */
+                        if (finishedTaskIds.contains(report.getTaskId()) && "wg".equals(report.getRdStatus())) {
+                            // 只有任务完工且日报施工状态为 完工 才统计 井数为 1
+                            tempTotalCumulativeWorkingWell = new BigDecimal("1");
                         }
                         if ("段数".equals(unit)) {
                             tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
@@ -1797,6 +1823,22 @@ public class IotRdDailyReportController {
         Map<Long, BigDecimal> groupIdCumulativeWorkingLayersPair = new HashMap<>();
         // key小组最后1条记录id      value台次 当日仪表/混砂
         Map<Long, BigDecimal> groupIdMixSandPair = new HashMap<>();
+        // 已经完工的任务id集合
+        Set<Long> finishedTaskIds = new HashSet<>();
+
+        DataPermissionUtils.executeIgnore(() -> {
+            IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
+            taskReqVO.setTaskIds(convertList(reports, IotRdDailyReportDO::getTaskId));
+            List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(taskReqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    // 筛选出 完工 的任务集合 任务完工 施工井数 +1
+                    if ("wg".equals(task.getRdStatus())) {
+                        finishedTaskIds.add(task.getId());
+                    }
+                });
+            }
+        });
 
         // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
         IotRdDailyReportPageReqVO currentTaskReqVO = new IotRdDailyReportPageReqVO();
@@ -1904,7 +1946,7 @@ public class IotRdDailyReportController {
                                 groupWaterVolumePair.put(uniqueKey, tempTotalWaterVolume);
                             }
                         }
-                        if ("井数".equals(unit)) {
+                        /* if ("井数".equals(unit)) {
                             tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
                             if (groupCumulativeWorkingWellPair.containsKey(uniqueKey)) {
                                 BigDecimal tempWorkingWell = groupCumulativeWorkingWellPair.get(uniqueKey);
@@ -1912,6 +1954,12 @@ public class IotRdDailyReportController {
                             } else {
                                 groupCumulativeWorkingWellPair.put(uniqueKey, tempTotalCumulativeWorkingWell);
                             }
+                        } */
+                        // 施工完成的井累计计数 1
+                        if (finishedTaskIds.contains(report.getTaskId())) {
+                            groupCumulativeWorkingWellPair.put(uniqueKey, new BigDecimal("1"));
+                        } else {
+                            groupCumulativeWorkingWellPair.put(uniqueKey, BigDecimal.ZERO);
                         }
                         if ("段数".equals(unit)) {
                             // 累计施工层
@@ -2215,8 +2263,12 @@ public class IotRdDailyReportController {
                         if ("方".equals(unit)) {
                             tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
                         }
-                        if ("井数".equals(unit)) {
+                        /* if ("井数".equals(unit)) {
                             tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
+                        } */
+                        if (finishedTaskIds.contains(report.getTaskId()) && "wg".equals(report.getRdStatus())) {
+                            // 只有任务完工且日报施工状态为 完工 才统计 井数为 1
+                            tempTotalCumulativeWorkingWell = new BigDecimal("1");
                         }
                         if ("段数".equals(unit)) {
                             tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);