Bläddra i källkod

pms 瑞恒日报 平台井部分施工完成的任务处理

zhangcl 5 dagar sedan
förälder
incheckning
6e8a96db56

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/vo/IotRdDailyReportPageReqVO.java

@@ -29,6 +29,9 @@ public class IotRdDailyReportPageReqVO extends PageParam {
     @Schema(description = "项目id", example = "32587")
     private Long projectId;
 
+    @Schema(description = "平台井标识 2非平台井 1平台井 0默认值", example = "2")
+    private Integer platformWell;
+
     @Schema(description = "平台井组", example = "463e3996-be48-4758-8229-c1351cbf3e37")
     private String platformGroup;
 

+ 5 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/vo/IotRdDailyReportStatisticsRespVO.java

@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.time.LocalDateTime;
 import java.util.List;
 
 @Schema(description = "管理后台 - 瑞都日报 统计 Response VO")
@@ -61,6 +62,10 @@ public class IotRdDailyReportStatisticsRespVO {
     @ExcelProperty("已完成工作量")
     private BigDecimal finishedWorkload;
 
+    @Schema(description = "任务创建时间")
+    @ExcelProperty("任务创建时间")
+    private LocalDateTime createTime;
+
     @Schema(description = "工作量明细")
     @ExcelProperty("工作量明细")
     private List<IotRdDailyReportStatisticsItemVO> items;

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrddailyreport/IotRdDailyReportMapper.java

@@ -78,6 +78,7 @@ public interface IotRdDailyReportMapper extends BaseMapperX<IotRdDailyReportDO>
                 .inIfPresent(IotRdDailyReportDO::getDeptId, reqVO.getDeptIds())
                 .eqIfPresent(IotRdDailyReportDO::getProjectId, reqVO.getProjectId())
                 .inIfPresent(IotRdDailyReportDO::getProjectId, reqVO.getProjectIds())
+                .eqIfPresent(IotRdDailyReportDO::getPlatformWell, reqVO.getPlatformWell())
                 .eqIfPresent(IotRdDailyReportDO::getPlatformGroup, reqVO.getPlatformGroup())
                 .eqIfPresent(IotRdDailyReportDO::getTaskId, reqVO.getTaskId())
                 .inIfPresent(IotRdDailyReportDO::getTaskId, reqVO.getTaskIds())

+ 6 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/dailyreport/CreateRdDailyReportOrderJob.java

@@ -124,9 +124,13 @@ public class CreateRdDailyReportOrderJob implements JobHandler {
                     // 已经施工完成的关联井不再生成日报
                     // 未施工完成的关联井需要和相关主井一起生成日报
                     platformTasks.forEach(task -> {
-                        if (2 == task.getPlatformWell() && !"wg".equals(task.getStatus())
+                        /* if (2 == task.getPlatformWell() && !"wg".equals(task.getStatus())
                                 && mainWellTaskPair.containsKey(task.getPlatformGroup()) && !unfinishedTaskIds.contains(task.getId())) {
                             qualifiedTasks.add(mainWellTaskPair.get(task.getPlatformGroup()));
+                        } */
+                        if (1 == task.getPlatformWell() && "wg".equals(task.getStatus())
+                                && !mainWellTaskPair.containsKey(task.getPlatformGroup()) && !unfinishedTaskIds.contains(task.getId())) {
+                            qualifiedTasks.add(task);
                         }
                     });
                 }
@@ -157,6 +161,7 @@ public class CreateRdDailyReportOrderJob implements JobHandler {
             }
             Map<Long, DeptDO> deptPair = deptService.getDeptMap(deptIds);
             // 以任务为维度 生成瑞都日报 部门为任务配置的工单填报人对应的部门
+            // todo 任务填报人列表中 如果有人属于队伍上 则 设置日报deptId=队伍id 这样项目部填报人也能看到日报
             qualifiedTasks.forEach(task -> {
                 if (!taskIds.contains(task.getId()) && CollUtil.isNotEmpty(task.getSubmitter())) {
                     // 生成当天的日报

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

@@ -154,6 +154,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         }
         updateObj.setReportName(dailyReport.getReportName());
         updateObj.setPlatformWell(dailyReport.getPlatformWell());
+        updateObj.setPlatformGroup(dailyReport.getPlatformGroup());
         return updateObj;
     }
 
@@ -178,9 +179,13 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
             if (ObjUtil.isNotEmpty(taskId)) {
                 // 查找关联的任务 更新任务的 施工状态
                 IotProjectTaskDO task = iotProjectTaskMapper.selectById(taskId);
-                task.setStatus(updateReqVO.getRdStatus());
-                task.setRdStatus(updateReqVO.getRdStatus());
-                iotProjectTaskMapper.updateById(task);
+                if (!"wg".equals(task.getStatus()) && StrUtil.isNotBlank(task.getRdStatus())) {
+                    // 兼容平台井关联的任务已经完工,没有填报数据,但是关联井没有完工的情况
+                    // 此时没有填写日报数据主井任务不必更新状态
+                    task.setStatus(updateReqVO.getRdStatus());
+                    task.setRdStatus(updateReqVO.getRdStatus());
+                    iotProjectTaskMapper.updateById(task);
+                }
                 // 如果是平台井 且 关联井也设置了 施工状态 也要同步更新关联井任务的施工状态
                 if (1 == platformWell) {
                     // key平台井关联井的任务taskId   value平台井关联井的任务施工状态数据字典value
@@ -351,6 +356,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
             // 查询所有任务关联的队伍信息 如果任务选择了多个队伍 队伍名称逗号分隔
             // key任务id      value任务选择的施工队伍名称集合
             Map<Long, String> taskDeptNamePair = new HashMap<>();
+            // key任务id      value任务创建时间集合
+            Map<Long, LocalDateTime> taskCreateTimePair = new HashMap<>();
             // key任务id      value任务选择的施工队伍对应的项目部名称集合
             Map<Long, String> taskProjectDeptPair = new HashMap<>();
             IotProjectTaskPageReqVO relatedTaskReqVO = new IotProjectTaskPageReqVO();
@@ -406,6 +413,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                 tasks.forEach(task -> {
                     taskPair.put(task.getId(), task.getWellName());
                     taskStatusPair.put(task.getId(), task.getStatus());
+                    taskCreateTimePair.put(task.getId(), task.getCreateTime());
                     // 获取所有任务的工作量数据
                     taskWorkloadPair.put(task.getId(), new BigDecimal(task.getWorkloadDesign()));
                     if (techniqueDictPair.containsKey(task.getTechnique())) {
@@ -468,6 +476,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
             dailyReports.forEach(report -> {
                 // 设置每个任务的工作量数据  单位相同的工作量值作合并处理
                 List<IotTaskAttrModelProperty> taskAttrs = report.getExtProperty();
+                Long taskId = report.getTaskId();
                 // 暂存不同单位的工作量属性值
                 BigDecimal tempTotalBridgePlug = BigDecimal.ZERO;               // 桥塞(个数)
                 BigDecimal tempTotalRunCount = BigDecimal.ZERO;                 // 趟数
@@ -494,8 +503,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         if ("个数".equals(unit)) {
                             // 钻可溶桥塞  钻复合桥塞
                             tempTotalBridgePlug = tempTotalBridgePlug.add(actualValue);
-                            if (bridgePlugPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempBridgePlug = bridgePlugPair.get(report.getDeptId());
+                            if (bridgePlugPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempBridgePlug = bridgePlugPair.get(report.getTaskId());
                                 bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug.add(tempBridgePlug));
                             } else {
                                 bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug);
@@ -503,8 +512,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         }
                         if ("趟数".equals(unit)) {
                             tempTotalRunCount = tempTotalRunCount.add(actualValue);
-                            if (runCountPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempRunCount = runCountPair.get(report.getDeptId());
+                            if (runCountPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempRunCount = runCountPair.get(report.getTaskId());
                                 runCountPair.put(report.getTaskId(), tempTotalRunCount.add(tempRunCount));
                             } else {
                                 runCountPair.put(report.getTaskId(), tempTotalRunCount);
@@ -512,8 +521,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         }
                         if ("小时".equals(unit)) {
                             tempTotalHourCount = tempTotalHourCount.add(actualValue);
-                            if (hourCountPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempHourCount = hourCountPair.get(report.getDeptId());
+                            if (hourCountPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempHourCount = hourCountPair.get(report.getTaskId());
                                 hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
                             } else {
                                 hourCountPair.put(report.getTaskId(), tempTotalHourCount);
@@ -523,8 +532,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                             // 将 actualValue 换算成 H
                             BigDecimal hours = actualValue.multiply(new BigDecimal("24"));
                             tempTotalHourCount = tempTotalHourCount.add(hours);
-                            if (hourCountPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempHourCount = hourCountPair.get(report.getDeptId());
+                            if (hourCountPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempHourCount = hourCountPair.get(report.getTaskId());
                                 hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
                             } else {
                                 hourCountPair.put(report.getTaskId(), tempTotalHourCount);
@@ -532,8 +541,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         }
                         if ("方".equals(unit)) {
                             tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
-                            if (waterVolumePair.containsKey(report.getDeptId())) {
-                                BigDecimal tempWaterVolume = waterVolumePair.get(report.getDeptId());
+                            if (waterVolumePair.containsKey(report.getTaskId())) {
+                                BigDecimal tempWaterVolume = waterVolumePair.get(report.getTaskId());
                                 waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume.add(tempWaterVolume));
                             } else {
                                 waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume);
@@ -541,8 +550,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         }
                         if ("井数".equals(unit)) {
                             tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
-                            if (cumulativeWorkingWellPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get(report.getDeptId());
+                            if (cumulativeWorkingWellPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get(report.getTaskId());
                                 cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell.add(tempWorkingWell));
                             } else {
                                 cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell);
@@ -551,8 +560,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         if ("段数".equals(unit)) {
                             // 累计施工层
                             tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
-                            if (cumulativeWorkingLayersPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempWorkingLayer = cumulativeWorkingLayersPair.get(report.getDeptId());
+                            if (cumulativeWorkingLayersPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempWorkingLayer = cumulativeWorkingLayersPair.get(report.getTaskId());
                                 cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers.add(tempWorkingLayer));
                             } else {
                                 cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers);
@@ -560,8 +569,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         }
                         if ("台次".equals(unit) && "当日泵车台次".equals(attr.getName())) {
                             tempTotalPumpTrips = tempTotalPumpTrips.add(actualValue);
-                            if (pumpTripsPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempPumpTrips = pumpTripsPair.get(report.getDeptId());
+                            if (pumpTripsPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempPumpTrips = pumpTripsPair.get(report.getTaskId());
                                 pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips.add(tempPumpTrips));
                             } else {
                                 pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips);
@@ -570,8 +579,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         if ("台次".equals(unit) && ("当日仪表/混砂".equals(attr.getName())
                                 || "当日混砂".equals(attr.getName()) || "当日仪表".equals(attr.getName()))) {
                             tempTotalMixSand = tempTotalMixSand.add(actualValue);
-                            if (mixSandPair.containsKey(report.getDeptId())) {
-                                BigDecimal tempMixSand = mixSandPair.get(report.getDeptId());
+                            if (mixSandPair.containsKey(report.getTaskId())) {
+                                BigDecimal tempMixSand = mixSandPair.get(report.getTaskId());
                                 mixSandPair.put(report.getTaskId(), tempTotalMixSand.add(tempMixSand));
                             } else {
                                 mixSandPair.put(report.getTaskId(), tempTotalMixSand);
@@ -605,6 +614,9 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                     if (taskDeptNamePair.containsKey(taskId)) {
                         uniqueReport.setDeptName(taskDeptNamePair.get(taskId));
                     }
+                    if (taskCreateTimePair.containsKey(taskId)) {
+                        uniqueReport.setCreateTime(taskCreateTimePair.get(taskId));
+                    }
                     /* if (teamProjectPair.containsKey(deptId)) {
                         Long parentId = teamProjectPair.get(deptId);
                         if (projectDeptPair.containsKey(parentId)) {
@@ -695,6 +707,13 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                 });
             }
         }
+        // 将 result 集合按照 集合中元素的 属性 创建时间 倒序排列
+        if (CollUtil.isNotEmpty(result)) {
+            result.sort(Comparator.comparing(
+                    IotRdDailyReportStatisticsRespVO::getCreateTime,
+                    Comparator.nullsLast(Comparator.reverseOrder())
+            ));
+        }
         return result;
     }
 
@@ -705,13 +724,47 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         }
         // 需要发送提醒消息的日报对象
         List<IotRdDailyReportDO> tobeSendMsgReports = new ArrayList<>();
+        // 主井日报
+        List<IotRdDailyReportDO> mainPlatformReports = new ArrayList<>();
+        // 关联井日报
+        List<IotRdDailyReportDO> relatePlatformReports = new ArrayList<>();
         reports.forEach(report -> {
             IotRdDailyReportDO updatedReport = updateIotRdDailyReport(report);
             // 标识当前任务井是 普通井 或 平台井主井 关联的任务审批人发送提醒消息
             if (1 == updatedReport.getPlatformWell() || 0 == updatedReport.getPlatformWell()) {
                 tobeSendMsgReports.add(updatedReport);
             }
+            // 记录关联井集合
+            if (2 == updatedReport.getPlatformWell()) {
+                relatePlatformReports.add(updatedReport);
+            }
+            // 记录平台井主井集合
+            if (1 == updatedReport.getPlatformWell()) {
+                mainPlatformReports.add(updatedReport);
+            }
         });
+
+        // 兼容平台井任务 主井任务已经施工完成 但是关联井仍在施工的情况 此时 平台井 下拉列表中 选择不到主井
+        // 此时应该同步修改主井任务的 填写状态 审批状态
+        if (CollUtil.isNotEmpty(relatePlatformReports) && CollUtil.isEmpty(mainPlatformReports)) {
+            // 找到关联井对应的主井 并把 主井 添加到 准备发送消息提醒的集合 tobeSendMsgReports
+            IotRdDailyReportDO randomRelatedReport = relatePlatformReports.get(0);
+            String platformGroup = randomRelatedReport.getPlatformGroup();
+            // 根据 platformGroup 找到主井日报
+            IotRdDailyReportPageReqVO reqVO = new IotRdDailyReportPageReqVO();
+            reqVO.setPlatformGroup(platformGroup);
+            reqVO.setPlatformWell(1);
+            List<IotRdDailyReportDO> mainWellReports = iotRdDailyReportMapper.dailyReports(reqVO);
+            if (CollUtil.isNotEmpty(mainWellReports)) {
+                IotRdDailyReportDO mainWellReport = mainWellReports.get(0);
+                // 设置 日报审批状态为 审批中 auditStatus = 10
+                mainWellReport.setAuditStatus(10);
+                // 设置 日报填写状态 保存 已完成
+                mainWellReport.setStatus(1);
+                iotRdDailyReportMapper.updateById(mainWellReport);
+            }
+        }
+
         // 考虑到平台井的情况 只向有审批权限的人发送一次 钉钉提醒及站内信
         // 任务为平台井时 只向主井的任务的 填报人所属部门或上级项目部下 有审批权限的人 发送消息提醒
         if (CollUtil.isNotEmpty(tobeSendMsgReports)) {