|
@@ -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.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
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.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdailyreportattrs.vo.IotDailyReportAttrsPageReqVO;
|
|
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.IotRdDailyReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportSaveReqVO;
|
|
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.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
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 java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
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.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 = "管理后台 - 瑞都日报")
|
|
@Tag(name = "管理后台 - 瑞都日报")
|
|
|
@RestController
|
|
@RestController
|
|
@@ -176,7 +179,108 @@ public class IotRdDailyReportController {
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
|
|
|
public CommonResult<PageResult<IotRdDailyReportRespVO>> getIotRdDailyReportPage(@Valid IotRdDailyReportPageReqVO pageReqVO) {
|
|
public CommonResult<PageResult<IotRdDailyReportRespVO>> getIotRdDailyReportPage(@Valid IotRdDailyReportPageReqVO pageReqVO) {
|
|
|
PageResult<IotRdDailyReportDO> pageResult = iotRdDailyReportService.getIotRdDailyReportPage(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")
|
|
@GetMapping("/export-excel")
|