Explorar o código

pms 日报 搬迁安装天数

zhangcl hai 3 semanas
pai
achega
d91e36e8f6

+ 10 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -144,6 +144,8 @@ public class IotRhDailyReportController {
         Map<Long, String> taskPair = new HashMap<>();
         // key任务id   value设计注气量
         Map<Long, String> taskExtPropertyPair = new HashMap<>();
+        // 搬迁安装天数
+        Map<Long, BigDecimal> relocationDaysPair = new HashMap<>();
         DataPermissionUtils.executeIgnore(() -> {
             // 查询日报关联的项目信息
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
@@ -175,7 +177,13 @@ public class IotRhDailyReportController {
                 });
             }
             // 查询每个任务的搬迁安装天数
+            List<IotRhDailyReportDO> relocationDays = iotRhDailyReportService.relocationDays(null);
 
+            if (CollUtil.isNotEmpty(relocationDays)) {
+                relocationDays.forEach(day -> {
+                    relocationDaysPair.put(day.getTaskId(), day.getRelocationDays());
+                });
+            }
         });
         // 2. 拼接数据
         return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {
@@ -187,6 +195,8 @@ public class IotRhDailyReportController {
             findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
             // 2.4 设计注气量
             findAndThen(taskExtPropertyPair, reportVO.getTaskId(), designInjection -> reportVO.setDesignInjection(designInjection));
+            // 2.5 搬迁安装天数
+            findAndThen(relocationDaysPair, reportVO.getTaskId(), relocationDays -> reportVO.setRelocationDays(relocationDays));
         });
     }
 

+ 8 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrhdailyreport/IotRhDailyReportMapper.java

@@ -52,7 +52,7 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
                 .eqIfPresent(IotRhDailyReportDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                 .eqIfPresent(IotRhDailyReportDO::getAuditStatus, reqVO.getAuditStatus())
                 .betweenIfPresent(IotRhDailyReportDO::getCreateTime, reqVO.getCreateTime())
-                .orderByDesc(IotRhDailyReportDO::getId));
+                .orderByDesc(IotRhDailyReportDO::getCreateTime));
     }
 
     /* default List<IotRhDailyReportDO> selectList(IotRhDailyReportPageReqVO reqVO) {
@@ -90,6 +90,13 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
     // 修改selectList方法,使用XML实现
     List<IotRhDailyReportDO> selectListGrouped(@Param("reqVO") IotRhDailyReportPageReqVO reqVO);
 
+    /**
+     * 查询每个任务的搬迁安装天数
+     * @param reqVO
+     * @return
+     */
+    List<IotRhDailyReportDO> relocationDays(@Param("reqVO") IotRhDailyReportPageReqVO reqVO);
+
     /**
      * 根据条件查询瑞恒日报记录
      *

+ 8 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportService.java

@@ -62,6 +62,14 @@ public interface IotRhDailyReportService {
      */
     List<IotRhDailyReportDO> taskActualProgress(IotRhDailyReportPageReqVO reqVO);
 
+    /**
+     * 查询每个任务的搬迁安装天数
+     *
+     * @param reqVO taskId
+     * @return 每个任务的搬迁安装天数
+     */
+    List<IotRhDailyReportDO> relocationDays(IotRhDailyReportPageReqVO reqVO);
+
     /**
      * 查询指定队伍下包含的增压机的产能
      *

+ 24 - 16
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -194,38 +194,37 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
 
             AtomicReference<LocalDateTime> moveDate = new AtomicReference<>();
             AtomicReference<LocalDateTime> commencementDate = new AtomicReference<>();
-
+            LocalDateTime reportDate = createReqVO.getFillOrderCreateTime();
             // 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
-            // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录 不能使用 LocalDateTime.now() 来查询,应该使用 运行记录工单的日期查询
-            IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, LocalDateTime.now());
+            // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录 不能使用 LocalDateTime.now() 来查询,应该使用 运行记录工单的创建日期查询
+            IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, reportDate);
             if (ObjUtil.isEmpty(existReport)) {
                 // 设置任务时间范围 昨天下午4点到今天下午4点
-                // 设置任务时间范围 昨天下午4点到今天下午4点
-                LocalDateTime now = LocalDateTime.now();
+                // LocalDateTime now = LocalDateTime.now();
                 // 今天下午4点
-                LocalDateTime today4pm = now.withHour(16).withMinute(0).withSecond(0).withNano(0);
+                LocalDateTime today4pm = reportDate.withHour(16).withMinute(0).withSecond(0).withNano(0);
                 // 昨天下午4点
                 LocalDateTime yesterday4pm = today4pm.minusDays(1);
                 iotRhDailyReport.setConstructionStartDate(yesterday4pm);
                 iotRhDailyReport.setConstructionEndDate(today4pm);
                 // 查询当前日报状态 是否是 施工 或 搬迁
-                if (3 == iotRhDailyReport.getConstructionStatus()) {
+                /* if (3 == iotRhDailyReport.getConstructionStatus()) {
                     commencementDate.set(yesterday4pm);
                 }
                 if (1 == iotRhDailyReport.getConstructionStatus()) {
                     moveDate.set(yesterday4pm);
-                }
+                } */
                 // 历史日报数据
                 // 根据历史当前小队历史的日报 计算 搬迁安装天数 (开工日期 - 搬迁日期)
                 // 暂时无法通过列表计算搬迁安装天数(因为需要按照任务分组同时查询当前分页所有日报的 开工日期 搬迁日期)
-                IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
+                /* IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
                 reportReqVO.setTaskId(taskId);
-                List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
+                List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO); */
                 // 将当前日报也添加到 集合groupedReports中 共同筛选开工日期 搬迁日期
                 // AtomicReference<LocalDateTime> moveDate = new AtomicReference<>();
                 // AtomicReference<LocalDateTime> commencementDate = new AtomicReference<>();
                 // 先当前更新的日报的 施工状态
-                if (CollUtil.isNotEmpty(groupedReports)) {
+                /* if (CollUtil.isNotEmpty(groupedReports)) {
                     groupedReports.forEach(report -> {
                         // 施工状态 数据字典 constructionStatus 施工3  动迁1
                         if (3 == report.getConstructionStatus()) {
@@ -235,9 +234,9 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                             moveDate.set(report.getConstructionStartDate());
                         }
                     });
-                }
+                } */
                 // 开工日期 搬迁日期 都存在 才能计算 搬迁安装天数
-                if (ObjUtil.isNotEmpty(commencementDate.get()) && ObjUtil.isNotEmpty(moveDate.get())) {
+                /* if (ObjUtil.isNotEmpty(commencementDate.get()) && ObjUtil.isNotEmpty(moveDate.get())) {
                     LocalDateTime start = moveDate.get();    // 搬迁日期
                     LocalDateTime end = commencementDate.get(); // 开工日期(晚于搬迁日期)
                     // 计算时间差(Duration.between 接受 start 和 end 参数)
@@ -247,7 +246,9 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                     // 计算总天数(包括小数部分):总秒数除以一天的秒数(24 * 3600)
                     double totalDays = totalSeconds / (24.0 * 3600.0);
                     iotRhDailyReport.setRelocationDays(new BigDecimal(totalDays));
-                }
+                } */
+                iotRhDailyReport.setCreateTime(reportDate);
+                iotRhDailyReport.setUpdateTime(reportDate);
                 iotRhDailyReportMapper.insert(iotRhDailyReport);
             } else {
                 // 修改现有记录
@@ -294,7 +295,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                 } */
                 iotRhDailyReportMapper.updateById(iotRhDailyReport);
                 // 更新后再查询就是最新的值
-                IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
+                /* IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
                 reportReqVO.setTaskId(taskId);
                 List<IotRhDailyReportDO> groupedReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
                 if (CollUtil.isNotEmpty(groupedReports)) {
@@ -320,7 +321,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                     double totalDays = totalSeconds / (24.0 * 3600.0);
                     iotRhDailyReport.setRelocationDays(new BigDecimal(totalDays));
                 }
-                iotRhDailyReportMapper.updateById(iotRhDailyReport);
+                iotRhDailyReportMapper.updateById(iotRhDailyReport); */
             }
         }
 
@@ -364,6 +365,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         return capacity.get();
     }
 
+
+
     @Override
     public PageResult<IotRhDailyReportDO> dailyReportSummary(IotRhDailyReportPageReqVO pageReqVO) {
         // 查询 瑞恒兴域 下所有项目部级别的部门
@@ -440,4 +443,9 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         return dailyReports;
     }
 
+    @Override
+    public List<IotRhDailyReportDO> relocationDays(IotRhDailyReportPageReqVO reqVO) {
+        return iotRhDailyReportMapper.relocationDays(reqVO);
+    }
+
 }

+ 15 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -13,6 +13,7 @@
         <result column="construction_status" property="constructionStatus" />
         <result column="construction_start_date" property="constructionStartDate" />
         <result column="construction_end_date" property="constructionEndDate" />
+        <result column="relocation_days" property="relocationDays" />
         <!-- 其他字段映射 -->
     </resultMap>
 
@@ -97,4 +98,18 @@
         ORDER BY g.min_start_date ASC
     </select>
 
+    <select id="relocationDays" resultMap="BaseResultMap"
+            parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO">
+        SELECT
+            task_id,
+            DATEDIFF(
+                    MIN(CASE WHEN construction_status = 3 THEN construction_start_date END),
+                    MIN(CASE WHEN construction_status = 1 THEN construction_start_date END)
+            ) AS relocation_days
+        FROM rq_iot_rh_daily_report
+        WHERE construction_status IN (1, 3)
+          AND deleted = 0
+        GROUP BY task_id;
+    </select>
+
 </mapper>