Преглед изворни кода

pms 瑞鹰单井队统计导出

zhangcl пре 2 дана
родитељ
комит
5f9ef24f6d

+ 159 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/IotRyDailyReportController.java

@@ -727,6 +727,26 @@ public class IotRyDailyReportController {
             }
         });
 
+        // key施工状态数据字典value   value施工状态数据字典label
+        Map<String, String> constructStatusPair = new HashMap<>();
+
+        // 钻井 施工状态 字典数据
+        List<DictDataDO> rigStatusDictData = dictDataService.getDictDataListByDictType("rigStatus");
+        // 修井 施工状态 字典数据
+        List<DictDataDO> repairStatusDictData = dictDataService.getDictDataListByDictType("repairStatus");
+        // 钻井施工状态
+        if ("1".equals(pageReqVO.getProjectClassification()) && CollUtil.isNotEmpty(rigStatusDictData)) {
+            rigStatusDictData.forEach(data -> {
+                constructStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+        // 修井施工状态
+        if ("2".equals(pageReqVO.getProjectClassification()) && CollUtil.isNotEmpty(repairStatusDictData)) {
+            repairStatusDictData.forEach(data -> {
+                constructStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+
         DataPermissionUtils.executeIgnore(() -> {
             // 查询日报关联的项目信息
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
@@ -806,8 +826,30 @@ public class IotRyDailyReportController {
             // 2.1 拼接部门信息
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
 
+            findAndThen(completedTasksPair, reportVO.getDeptId(), completedTaskCount -> reportVO.setCompletedWells(completedTaskCount));
+            // 钻井 施工状态 数据字典
+            findAndThen(constructStatusPair, reportVO.getRigStatus(), statusLabel -> {
+                if ("1".equals(pageReqVO.getProjectClassification())) {
+                    reportVO.setConstructionStatusName(statusLabel);
+                }
+            });
+            // 修井 施工状态 数据字典
+            findAndThen(constructStatusPair, reportVO.getRepairStatus(), statusLabel -> {
+                if ("2".equals(pageReqVO.getProjectClassification())) {
+                    reportVO.setConstructionStatusName(statusLabel);
+                }
+            });
+            // 创建时间 格式化 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
+                reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
+            }
+
+            // 上井次完井时间 格式化时间为 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getLatestWellDoneTime())) {
+                reportVO.setLatestWellDoneTimeStr(LocalDateTimeUtil.format(reportVO.getLatestWellDoneTime(), DatePattern.NORM_DATE_PATTERN));
+            }
+
             // 转换用电量 单位 kWh 转换成 MWh
-            // 用电量 kWh 转换单位 MWh
             if (reportVO.getDailyPowerUsage().compareTo(BigDecimal.ZERO) > 0) {
                 BigDecimal powerW = reportVO.getDailyPowerUsage()
                         .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
@@ -1100,6 +1142,25 @@ public class IotRyDailyReportController {
             }
         });
 
+        // key施工状态数据字典value   value施工状态数据字典label
+        Map<String, String> constructStatusPair = new HashMap<>();
+        // 钻井 施工状态 字典数据
+        List<DictDataDO> rigStatusDictData = dictDataService.getDictDataListByDictType("rigStatus");
+        // 修井 施工状态 字典数据
+        List<DictDataDO> repairStatusDictData = dictDataService.getDictDataListByDictType("repairStatus");
+        // 钻井施工状态
+        if ("1".equals(pageReqVO.getProjectClassification()) && CollUtil.isNotEmpty(rigStatusDictData)) {
+            rigStatusDictData.forEach(data -> {
+                constructStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+        // 修井施工状态
+        if ("2".equals(pageReqVO.getProjectClassification()) && CollUtil.isNotEmpty(repairStatusDictData)) {
+            repairStatusDictData.forEach(data -> {
+                constructStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+
         DataPermissionUtils.executeIgnore(() -> {
             // 查询日报关联的项目信息
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
@@ -1179,8 +1240,16 @@ public class IotRyDailyReportController {
             // 2.1 拼接部门信息
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
 
+            // 日报生成日期 格式化时间为 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
+                reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
+            }
+            // 上井次完井时间 格式化时间为 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getLatestWellDoneTime())) {
+                reportVO.setLatestWellDoneTimeStr(LocalDateTimeUtil.format(reportVO.getLatestWellDoneTime(), DatePattern.NORM_DATE_PATTERN));
+            }
+
             // 转换用电量 单位 kWh 转换成 MWh
-            // 用电量 kWh 转换单位 MWh
             if (reportVO.getDailyPowerUsage().compareTo(BigDecimal.ZERO) > 0) {
                 BigDecimal powerW = reportVO.getDailyPowerUsage()
                         .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
@@ -1246,6 +1315,18 @@ public class IotRyDailyReportController {
             // 2.8 总施工井数 完工井数
             findAndThen(totalTasksPair, reportVO.getDeptId(), totalTaskCount -> reportVO.setTotalConstructionWells(totalTaskCount));
             findAndThen(completedTasksPair, reportVO.getDeptId(), completedTaskCount -> reportVO.setCompletedWells(completedTaskCount));
+            // 钻井 施工状态 数据字典
+            findAndThen(constructStatusPair, reportVO.getRigStatus(), statusLabel -> {
+                if ("1".equals(pageReqVO.getProjectClassification())) {
+                    reportVO.setConstructionStatusName(statusLabel);
+                }
+            });
+            // 修井 施工状态 数据字典
+            findAndThen(constructStatusPair, reportVO.getRepairStatus(), statusLabel -> {
+                if ("2".equals(pageReqVO.getProjectClassification())) {
+                    reportVO.setConstructionStatusName(statusLabel);
+                }
+            });
         });
     }
 
@@ -1535,4 +1616,80 @@ public class IotRyDailyReportController {
         }
     }
 
+    @GetMapping("/exportSingleWells")
+    @Operation(summary = "导出瑞鹰 日报 单井统计 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportSingleWells(@Valid IotRyDailyReportPageReqVO pageReqVO,
+                                            HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
+        Set<Long> projectIds = new HashSet<>();
+        Set<Long> taskIds = new HashSet<>();
+        if (StrUtil.isNotBlank(pageReqVO.getContractName())) {
+            IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
+            reqVO.setContractName(pageReqVO.getContractName());
+            List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
+            if (CollUtil.isNotEmpty(projects)) {
+                projects.forEach(project -> {
+                    projectIds.add(project.getId());
+                });
+                pageReqVO.setProjectIds(projectIds);
+            }
+        }
+        if (StrUtil.isNotBlank(pageReqVO.getTaskName())) {
+            IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
+            reqVO.setSearchKey(pageReqVO.getTaskName());
+            List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(reqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    taskIds.add(task.getId());
+                });
+                pageReqVO.setTaskIds(taskIds);
+            }
+        }
+        List<IotRyDailyReportDO> list = iotRyDailyReportService.teamReports(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "瑞鹰日报单井统计.xls", "瑞鹰日报单井统计数据", IotRyDailyReportRespVO.class,
+                buildSubtotalRyDailyReports(list, pageReqVO));
+    }
+
+    @GetMapping("/exportSingleTeams")
+    @Operation(summary = "导出瑞鹰 日报 单队伍 统计 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportSingleTeams(@Valid IotRyDailyReportPageReqVO pageReqVO,
+                                  HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
+        Set<Long> projectIds = new HashSet<>();
+        Set<Long> taskIds = new HashSet<>();
+        if (StrUtil.isNotBlank(pageReqVO.getContractName())) {
+            IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
+            reqVO.setContractName(pageReqVO.getContractName());
+            List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
+            if (CollUtil.isNotEmpty(projects)) {
+                projects.forEach(project -> {
+                    projectIds.add(project.getId());
+                });
+                pageReqVO.setProjectIds(projectIds);
+            }
+        }
+        if (StrUtil.isNotBlank(pageReqVO.getTaskName())) {
+            IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
+            reqVO.setSearchKey(pageReqVO.getTaskName());
+            List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(reqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    taskIds.add(task.getId());
+                });
+                pageReqVO.setTaskIds(taskIds);
+            }
+        }
+        List<IotRyDailyReportDO> list = iotRyDailyReportService.wellReports(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "瑞鹰日报单队伍统计.xls", "瑞鹰日报单队伍统计数据", IotRyDailyReportRespVO.class,
+                buildWellRyDailyReports(list, pageReqVO));
+    }
+
 }

+ 5 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportRespVO.java

@@ -32,6 +32,10 @@ public class IotRyDailyReportRespVO {
     @ExcelProperty("任务")
     private String taskName;
 
+    @Schema(description = "施工状态 对应的数据字典 label")
+    @ExcelProperty("施工状态")
+    private String constructionStatusName;
+
     @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25152")
     private Long id;
 
@@ -148,21 +152,15 @@ public class IotRyDailyReportRespVO {
     private String otherNptReason;
 
     @Schema(description = "施工开始日期")
-    @ExcelProperty("施工开始日期")
     private LocalDateTime constructionStartDate;
 
     @Schema(description = "施工结束日期")
-    @ExcelProperty("施工结束日期")
     private LocalDateTime constructionEndDate;
 
     @Schema(description = "当日生产情况生产动态", example = "1")
-    @ExcelProperty("当日生产情况生产动态")
+    @ExcelProperty("当日生产动态")
     private String productionStatus;
 
-    @Schema(description = "施工状态 对应的数据字典 label")
-    @ExcelProperty("施工状态")
-    private String constructionStatusName;
-
     @Schema(description = "目前工序")
     @ExcelProperty("目前工序")
     private String currentOperation;