Explorar o código

pms 瑞恒日报 当天只能生成一条日报 重复编辑时 更新

zhangcl hai 3 semanas
pai
achega
ff4d3043f2

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

@@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDai
 import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttaskattrs.IotTaskAttrModelProperty;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
 import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
@@ -113,8 +114,12 @@ public class IotRhDailyReportController {
         }
         // 设备部门信息
         Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(reports, IotRhDailyReportDO::getDeptId));
+        // key项目id   value项目合同号
         Map<Long, String> projectPair = new HashMap<>();
+        //  key任务id     value任务井号-施工区域
         Map<Long, String> taskPair = new HashMap<>();
+        // key任务id   value设计注气量
+        Map<Long, String> taskExtPropertyPair = new HashMap<>();
         DataPermissionUtils.executeIgnore(() -> {
             // 查询日报关联的项目信息
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
@@ -132,8 +137,21 @@ public class IotRhDailyReportController {
             if (CollUtil.isNotEmpty(tasks)) {
                 tasks.forEach(task -> {
                     taskPair.put(task.getId(), StrUtil.join(" - ", task.getWellName(), task.getLocation()));
+                    if (CollUtil.isNotEmpty(task.getExtProperty())) {
+                        List<IotTaskAttrModelProperty> taskAttrs = task.getExtProperty();
+                        if (CollUtil.isNotEmpty(taskAttrs)) {
+                            // 找到 设计注气量 属性 对应的值
+                            taskAttrs.forEach(attr -> {
+                                if ("设计注气量".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskExtPropertyPair.put(task.getId(), attr.getActualValue());
+                                }
+                            });
+                        }
+                    }
                 });
             }
+            // 查询任务中维护的 设计注气量
+
         });
         // 2. 拼接数据
         return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {
@@ -143,6 +161,8 @@ public class IotRhDailyReportController {
             findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setContractName(contractName));
             // 2.3 日报关联的任务信息
             findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
+            // 2.4 设计注气量
+            findAndThen(taskExtPropertyPair, reportVO.getTaskId(), designInjection -> reportVO.setDesignInjection(designInjection));
         });
     }
 

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

@@ -145,4 +145,7 @@ public class IotRhDailyReportRespVO {
     @Schema(description = "任务 井号-施工地点")
     private String taskName;
 
+    @Schema(description = "设计注气量")
+    private String designInjection;
+
 }

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

@@ -7,6 +7,9 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDai
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
 /**
  * 瑞恒日报 Mapper
  *
@@ -48,4 +51,21 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
                 .orderByDesc(IotRhDailyReportDO::getId));
     }
 
+    /**
+     * 根据条件查询单个OTA升级记录
+     *
+     * @param deptId     施工队伍id
+     * @param taskId     任务ID,可选参数,用于筛选任务ID匹配的记录
+     * @param dateTime   当前时间
+     * @return 返回符合条件的瑞恒日报记录
+     */
+    default IotRhDailyReportDO selectExistReport(Long deptId, Long taskId, LocalDateTime dateTime) {
+        String dateStr = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        // 使用LambdaQueryWrapperX构建查询条件,根据传入的参数动态添加查询条件
+        return selectOne(new LambdaQueryWrapperX<IotRhDailyReportDO>()
+                .eqIfPresent(IotRhDailyReportDO::getDeptId, deptId)
+                .eqIfPresent(IotRhDailyReportDO::getTaskId, taskId)
+                .apply("DATE(create_time) = {0}", dateStr));
+    }
+
 }

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

@@ -69,6 +69,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
         // 根据日报的施工状态 更新 对应任务的 状态
         if (ObjUtil.isNotEmpty(createReqVO.getDeptId())) {
+            Long taskId = Long.MIN_VALUE;
             Set<Long> deviceIds = new HashSet<>();
             IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
             reqVO.setDeptId(createReqVO.getDeptId());
@@ -79,6 +80,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                 // 暂时只考虑1个施工队伍只属于1个任务
                 iotRhDailyReport.setProjectId(task.getProjectId());
                 iotRhDailyReport.setTaskId(task.getId());
+                taskId = task.getId();
                 // 根据日报状态 查新 日报所属任务的状态
                 if (ObjUtil.isNotEmpty(createReqVO.getConstructionStatus())) {
                     task.setStatus(createReqVO.getConstructionStatus());
@@ -127,7 +129,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                 }
             }
 
-            // 根据当日注气量 计算累计注气量
+            // todo 根据当日注气量 计算累计注气量
 
             // 查询当前日报所属任务关联的设备
             if (CollUtil.isNotEmpty(deviceIds)) {
@@ -168,19 +170,28 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                     });
                 }
             }
+
+            // 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
+            // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录
+            IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, LocalDateTime.now());
+            if (ObjUtil.isEmpty(existReport)) {
+                // 设置任务时间范围 昨天下午4点到今天下午4点
+                // 设置任务时间范围 昨天下午4点到今天下午4点
+                LocalDateTime now = LocalDateTime.now();
+                // 今天下午4点
+                LocalDateTime today4pm = now.withHour(16).withMinute(0).withSecond(0).withNano(0);
+                // 昨天下午4点
+                LocalDateTime yesterday4pm = today4pm.minusDays(1);
+                iotRhDailyReport.setConstructionStartDate(yesterday4pm);
+                iotRhDailyReport.setConstructionEndDate(today4pm);
+
+                iotRhDailyReportMapper.insert(iotRhDailyReport);
+            } else {
+                // 修改现有记录
+                iotRhDailyReport.setId(existReport.getId());
+                iotRhDailyReportMapper.updateById(iotRhDailyReport);
+            }
         }
-        // 设置任务时间范围 昨天下午4点到今天下午4点
-        // 设置任务时间范围 昨天下午4点到今天下午4点
-        LocalDateTime now = LocalDateTime.now();
-        // 今天下午4点
-        LocalDateTime today4pm = now.withHour(16).withMinute(0).withSecond(0).withNano(0);
-        // 昨天下午4点
-        LocalDateTime yesterday4pm = today4pm.minusDays(1);
-        iotRhDailyReport.setConstructionStartDate(yesterday4pm);
-        iotRhDailyReport.setConstructionEndDate(today4pm);
-        iotRhDailyReportMapper.insert(iotRhDailyReport);
-        // 当天如果已经有此小队的记录 新增
-        // 当天如果没有此小队的日报记录 修改
 
         // 返回
         return iotRhDailyReport.getId();