Prechádzať zdrojové kódy

pms 瑞都日报 列表数据填充

zhangcl 1 týždeň pred
rodič
commit
6a0d6afbf7

+ 4 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotprojecttask/vo/IotProjectTaskRespVO.java

@@ -51,6 +51,10 @@ public class IotProjectTaskRespVO {
     @ExcelProperty("责任人([123,234])")
     private Set<Long> responsiblePerson;
 
+    @Schema(description = "工单填报人([123,234])")
+    @ExcelProperty("工单填报人([123,234])")
+    private Set<Long> submitter;
+
     @Schema(description = "设计工作量")
     @ExcelProperty("设计工作量")
     private String workloadDesign;

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

@@ -38,6 +38,9 @@ public class IotProjectTaskSaveReqVO {
     @Schema(description = "责任人([123,234])")
     private Set<Long> responsiblePerson;
 
+    @Schema(description = "工单填报人([123,234])")
+    private Set<Long> submitter;
+
     @Schema(description = "设计工作量")
     private String workloadDesign;
 

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

@@ -8,8 +8,11 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.iotdailyreportattrs.vo.IotDailyReportAttrsPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportSaveReqVO;
@@ -39,13 +42,13 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
+import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
 
 @Tag(name = "管理后台 - 瑞都日报")
 @RestController
@@ -176,7 +179,108 @@ public class IotRdDailyReportController {
     @PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
     public CommonResult<PageResult<IotRdDailyReportRespVO>> getIotRdDailyReportPage(@Valid IotRdDailyReportPageReqVO pageReqVO) {
         PageResult<IotRdDailyReportDO> pageResult = iotRdDailyReportService.getIotRdDailyReportPage(pageReqVO);
-        return success(BeanUtils.toBean(pageResult, IotRdDailyReportRespVO.class));
+        // 设置日报的关联信息 部门(施工队伍) 项目 任务 带班干部 日报填报人
+        return success(new PageResult<>(buildDailyReportList(pageResult.getList()), pageResult.getTotal()));
+    }
+
+    /**
+     * 设置日报的关联信息 部门(施工队伍) 项目 任务 带班干部 日报填报人
+     * @param reports
+     * @return
+     */
+    private List<IotRdDailyReportRespVO> buildDailyReportList(List<IotRdDailyReportDO> reports) {
+        if (CollUtil.isEmpty(reports)) {
+            return Collections.emptyList();
+        }
+        // 设备部门信息
+        Map<Long, DeptDO> deptMap = deptService.getDeptMap(
+                convertList(reports, IotRdDailyReportDO::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> taskResponsiblePair = new HashMap<>();
+        //  key任务id     value任务关联的填报人名称
+        Map<Long, String> taskSubmitterPair = new HashMap<>();
+        Set<Long> userIds = new HashSet<>();
+        DataPermissionUtils.executeIgnore(() -> {
+            // 查询日报关联的项目信息
+            IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
+            reqVO.setProjectIds(convertList(reports, IotRdDailyReportDO::getProjectId));
+            List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
+            if (CollUtil.isNotEmpty(projects)) {
+                projects.forEach(project -> {
+                    projectPair.put(project.getId(), project.getContractName());
+                });
+            }
+            // 查询日报关联的任务信息
+            IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
+            taskReqVO.setTaskIds(convertList(reports, IotRdDailyReportDO::getTaskId));
+            List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(taskReqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    Set<Long> personIds = task.getResponsiblePerson();
+                    Set<Long> submitterIds = task.getSubmitter();
+                    taskPair.put(task.getId(), task.getWellName());
+                    userIds.addAll(Optional.ofNullable(personIds).orElse(Collections.emptySet()));
+                    userIds.addAll(Optional.ofNullable(submitterIds).orElse(Collections.emptySet()));
+                });
+            }
+            // 查询所有 带班干部 填报人 的姓名
+            Map<Long, AdminUserRespDTO> userMap;
+            if (CollUtil.isNotEmpty(userIds)) {
+                userMap = adminUserApi.getUserMap(userIds);
+            } else {
+                userMap = Collections.emptyMap();
+            }
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    // 安全获取带班干部ID集合(避免null)
+                    Set<Long> responsibleIds = Optional.ofNullable(task.getResponsiblePerson())
+                            .orElse(Collections.emptySet());
+                    // 转换ID集合为姓名字符串(用逗号分隔)
+                    String responsibleNames = responsibleIds.stream()
+                            // 映射ID到姓名(用户不存在时用空字符串)
+                            .map(userId -> Optional.ofNullable(userMap.get(userId))
+                                    .map(AdminUserRespDTO::getNickname)
+                                    .orElse(""))
+                            // 过滤空字符串(避免多余逗号)
+                            .filter(name -> !name.isEmpty())
+                            // 拼接姓名
+                            .collect(Collectors.joining(","));
+                    // 存入映射关系
+                    taskResponsiblePair.put(task.getId(), responsibleNames);
+                    // 工单填报人
+                    Set<Long> submitterIds = Optional.ofNullable(task.getSubmitter())
+                            .orElse(Collections.emptySet());
+                    // 转换ID集合为姓名字符串(用逗号分隔)
+                    String submitterNames = submitterIds.stream()
+                            // 映射ID到姓名(用户不存在时用空字符串)
+                            .map(userId -> Optional.ofNullable(userMap.get(userId))
+                                    .map(AdminUserRespDTO::getNickname)
+                                    .orElse(""))
+                            // 过滤空字符串(避免多余逗号)
+                            .filter(name -> !name.isEmpty())
+                            // 拼接姓名
+                            .collect(Collectors.joining(","));
+                    // 存入映射关系
+                    taskSubmitterPair.put(task.getId(), submitterNames);
+                });
+            }
+        });
+        return BeanUtils.toBean(reports, IotRdDailyReportRespVO.class, (reportVO) -> {
+            // 部门信息
+            findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
+            // 日报关联的项目信息
+            findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setContractName(contractName));
+            // 日报关联的任务信息
+            findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
+            // 日报关联的责任人
+            findAndThen(taskResponsiblePair, reportVO.getTaskId(), responsibleNames -> reportVO.setResponsiblePersonNames(responsibleNames));
+            // 日报关联的填报人
+            findAndThen(taskSubmitterPair, reportVO.getTaskId(), submitterNames -> reportVO.setSubmitterNames(submitterNames));
+        });
     }
 
     @GetMapping("/export-excel")

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

@@ -229,10 +229,14 @@ public class IotRdDailyReportRespVO {
     @ExcelProperty("设备配置")
     private String deviceNames;
 
-    @Schema(description = "带班干部", example = "张三,李四...")
+    @Schema(description = "带班干部姓名", example = "张三,李四...")
     @ExcelProperty("带班干部")
     private String responsiblePersonNames;
 
+    @Schema(description = "填报人姓名", example = "张三,李四...")
+    @ExcelProperty("填报人姓名")
+    private String submitterNames;
+
     @Schema(description = "公司id", example = "125")
     @ExcelProperty("公司id")
     private Long companyId;

+ 2 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotprojecttask/IotProjectTaskDO.java

@@ -69,7 +69,8 @@ public class IotProjectTaskDO extends BaseDO {
     /**
      * 工单填报人([123,234])
      */
-    private String submitter;
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private Set<Long> submitter;
     /**
      * 设计工作量
      */