|
@@ -1,16 +1,28 @@
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport;
|
|
|
|
|
|
|
|
+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.apilog.core.annotation.ApiAccessLog;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
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.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
|
|
|
|
+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.iotrydailyreport.IotRyDailyReportDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
import cn.iocoder.yudao.module.pms.service.iotrydailyreport.IotRyDailyReportService;
|
|
import cn.iocoder.yudao.module.pms.service.iotrydailyreport.IotRyDailyReportService;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -22,10 +34,16 @@ 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.math.BigDecimal;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
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.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
|
|
@@ -35,6 +53,12 @@ public class IotRyDailyReportController {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private IotRyDailyReportService iotRyDailyReportService;
|
|
private IotRyDailyReportService iotRyDailyReportService;
|
|
|
|
+ @Resource
|
|
|
|
+ private DeptService deptService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IotProjectInfoService iotProjectInfoService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IotProjectTaskService iotProjectTaskService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
@Operation(summary = "创建瑞鹰日报")
|
|
@Operation(summary = "创建瑞鹰日报")
|
|
@@ -74,7 +98,76 @@ public class IotRyDailyReportController {
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
|
|
public CommonResult<PageResult<IotRyDailyReportRespVO>> getIotRyDailyReportPage(@Valid IotRyDailyReportPageReqVO pageReqVO) {
|
|
public CommonResult<PageResult<IotRyDailyReportRespVO>> getIotRyDailyReportPage(@Valid IotRyDailyReportPageReqVO pageReqVO) {
|
|
PageResult<IotRyDailyReportDO> pageResult = iotRyDailyReportService.getIotRyDailyReportPage(pageReqVO);
|
|
PageResult<IotRyDailyReportDO> pageResult = iotRyDailyReportService.getIotRyDailyReportPage(pageReqVO);
|
|
- return success(BeanUtils.toBean(pageResult, IotRyDailyReportRespVO.class));
|
|
|
|
|
|
+
|
|
|
|
+ return success(new PageResult<>(buildRyDailyReports(pageResult.getList()), pageResult.getTotal()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 瑞恒日报分页 设置关联查询信息
|
|
|
|
+ * @param reports
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<IotRyDailyReportRespVO> buildRyDailyReports(List<IotRyDailyReportDO> reports) {
|
|
|
|
+ if (CollUtil.isEmpty(reports)) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+ // 设备部门信息
|
|
|
|
+ Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(reports, IotRyDailyReportDO::getDeptId));
|
|
|
|
+ // key项目id value项目合同号
|
|
|
|
+ Map<Long, String> projectPair = new HashMap<>();
|
|
|
|
+ // key任务id value任务井号-施工区域
|
|
|
|
+ Map<Long, String> taskPair = new HashMap<>();
|
|
|
|
+ // key任务id value设计井深
|
|
|
|
+ Map<Long, BigDecimal> taskExtPropertyPair = new HashMap<>();
|
|
|
|
+ // key任务id value设计井身结构
|
|
|
|
+ Map<Long, String> taskWellStructPair = new HashMap<>();
|
|
|
|
+ DataPermissionUtils.executeIgnore(() -> {
|
|
|
|
+ // 查询日报关联的项目信息
|
|
|
|
+ IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
|
|
+ reqVO.setProjectIds(convertList(reports, IotRyDailyReportDO::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, IotRyDailyReportDO::getTaskId));
|
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(taskReqVO);
|
|
|
|
+ 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(), new BigDecimal(attr.getActualValue()));
|
|
|
|
+ }
|
|
|
|
+ if ("设计井身结构".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
|
|
|
|
+ taskWellStructPair.put(task.getId(), attr.getActualValue());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 2. 拼接数据
|
|
|
|
+ return BeanUtils.toBean(reports, IotRyDailyReportRespVO.class, (reportVO) -> {
|
|
|
|
+ // 2.1 拼接部门信息
|
|
|
|
+ findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
|
|
+ // 2.2 日报关联的项目信息
|
|
|
|
+ findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setContractName(contractName));
|
|
|
|
+ // 2.3 日报关联的任务信息
|
|
|
|
+ findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
|
|
|
|
+ // 2.4 设计井深
|
|
|
|
+ findAndThen(taskExtPropertyPair, reportVO.getTaskId(), wellDepth -> reportVO.setDesignWellDepth(wellDepth));
|
|
|
|
+ // 2.4 设计井身结构
|
|
|
|
+ findAndThen(taskWellStructPair, reportVO.getTaskId(), wellStruct -> reportVO.setDesignWellStruct(wellStruct));
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
@GetMapping("/export-excel")
|