|
|
@@ -1,17 +1,29 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
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.iotfivedailyreport.vo.IotFiveDailyReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportSaveReqVO;
|
|
|
+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.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
|
|
|
+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.service.iotfivedailyreport.IotFiveDailyReportService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -24,10 +36,14 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
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 = "管理后台 - 5#国日报")
|
|
|
@RestController
|
|
|
@@ -37,6 +53,15 @@ public class IotFiveDailyReportController {
|
|
|
|
|
|
@Resource
|
|
|
private IotFiveDailyReportService iotFiveDailyReportService;
|
|
|
+ @Resource
|
|
|
+ private DeptService deptService;
|
|
|
+ @Resource
|
|
|
+ private IotProjectInfoService iotProjectInfoService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotProjectTaskService iotProjectTaskService;
|
|
|
+ @Resource
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建5#国日报")
|
|
|
@@ -76,7 +101,7 @@ public class IotFiveDailyReportController {
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:query')")
|
|
|
public CommonResult<PageResult<IotFiveDailyReportRespVO>> getIotFiveDailyReportPage(@Valid IotFiveDailyReportPageReqVO pageReqVO) {
|
|
|
PageResult<IotFiveDailyReportDO> pageResult = iotFiveDailyReportService.getIotFiveDailyReportPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, IotFiveDailyReportRespVO.class));
|
|
|
+ return success(new PageResult<>(buildDailyReportList(pageResult.getList()), pageResult.getTotal()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -88,8 +113,65 @@ public class IotFiveDailyReportController {
|
|
|
if (CollUtil.isEmpty(reports)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
-
|
|
|
- return BeanUtils.toBean(reports, IotFiveDailyReportRespVO.class);
|
|
|
+ // key项目id value项目合同号
|
|
|
+ Map<Long, String> projectPair = new HashMap<>();
|
|
|
+ // key项目id value项目客户名称
|
|
|
+ Map<Long, String> customerPair = new HashMap<>();
|
|
|
+ // key任务id value任务井号
|
|
|
+ Map<Long, String> taskPair = new HashMap<>();
|
|
|
+ // key任务id value任务施工区域
|
|
|
+ Map<Long, String> taskLocationPair = new HashMap<>();
|
|
|
+ // key施工状态数据字典value value施工状态数据字典label
|
|
|
+ Map<String, String> constructStatusPair = new HashMap<>();
|
|
|
+ // 设备部门信息
|
|
|
+ Map<Long, DeptDO> tempDeptMap = deptService.getDeptMap(convertList(reports, IotFiveDailyReportDO::getDeptId));
|
|
|
+ // 施工状态 字典数据
|
|
|
+ List<DictDataDO> rdStatusData = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
+ if (CollUtil.isNotEmpty(rdStatusData)) {
|
|
|
+ rdStatusData.forEach(data -> {
|
|
|
+ constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ DataPermissionUtils.executeIgnore(() -> {
|
|
|
+ // 查询日报关联的项目信息
|
|
|
+ IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
|
+ reqVO.setProjectIds(convertList(reports, IotFiveDailyReportDO::getProjectId));
|
|
|
+ List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(projects)) {
|
|
|
+ projects.forEach(project -> {
|
|
|
+ projectPair.put(project.getId(), project.getContractName());
|
|
|
+ customerPair.put(project.getId(), project.getManufactureName());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询任务 井号 施工区域 信息
|
|
|
+ IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
|
|
|
+ taskReqVO.setTaskIds(convertList(reports, IotFiveDailyReportDO::getTaskId));
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(taskReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
+ tasks.forEach(task -> {
|
|
|
+ taskPair.put(task.getId(), task.getWellName());
|
|
|
+ taskLocationPair.put(task.getId(), task.getLocation());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return BeanUtils.toBean(reports, IotFiveDailyReportRespVO.class, (reportVO) -> {
|
|
|
+ // 施工状态 导出使用
|
|
|
+ if (StrUtil.isNotBlank(reportVO.getFiveStatus())) {
|
|
|
+ if (constructStatusPair.containsKey(reportVO.getFiveStatus())) {
|
|
|
+ reportVO.setFiveStatusLabel(constructStatusPair.get(reportVO.getFiveStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 临时新建的日报的 施工队伍
|
|
|
+ findAndThen(tempDeptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
|
+ // 日报关联的项目信息
|
|
|
+ findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setProjectName(contractName));
|
|
|
+ // 日报关联的项目客户信息
|
|
|
+ findAndThen(customerPair, reportVO.getProjectId(), customerName -> reportVO.setCustomer(customerName));
|
|
|
+ // 日报关联的任务井号
|
|
|
+ findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setWellName(taskName));
|
|
|
+ // 日报关联的任务施工区域
|
|
|
+ findAndThen(taskLocationPair, reportVO.getTaskId(), location -> reportVO.setLocation(location));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|