Просмотр исходного кода

pms 瑞恒 报表统计 单井队伍统计导出

zhangcl 5 дней назад
Родитель
Сommit
864cb3fd3f

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

@@ -2160,6 +2160,15 @@ public class IotRdDailyReportController {
         Map<String, String> relatedWellStatusPair = new HashMap<>();
         // key关联井任务id     value关联井号
         Map<Long, String> relatedPlatformsPair = new HashMap<>();
+        // key施工状态数据字典value   value施工状态数据字典label
+        Map<String, String> constructStatusPair = new HashMap<>();
+        // 施工状态 字典数据
+        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();
@@ -2397,6 +2406,16 @@ public class IotRdDailyReportController {
             }
         });
         return BeanUtils.toBean(reports, IotRdDailyReportRespVO.class, (reportVO) -> {
+            // 施工状态 导出使用
+            if (StrUtil.isNotBlank(reportVO.getRdStatus())) {
+                if (constructStatusPair.containsKey(reportVO.getRdStatus())) {
+                    reportVO.setRdStatusLabel(constructStatusPair.get(reportVO.getRdStatus()));
+                }
+            }
+            // 创建时间 格式化 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
+                reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
+            }
             // 部门信息 任务中关联的施工队伍
             findAndThen(taskTeamsPair, reportVO.getTaskId(), deptNames -> reportVO.setDeptName(deptNames));
             // 日报关联的项目信息
@@ -2555,4 +2574,42 @@ public class IotRdDailyReportController {
                 IotRdDailyReportStatisticsRespExportVO.class, BeanUtils.toBean(statistics, IotRdDailyReportStatisticsRespExportVO.class));
     }
 
+    @GetMapping("/export-detail")
+    @Operation(summary = "导出瑞都日报明细 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotRdDailyReportExcelDetail(@Valid IotRdDailyReportPageReqVO 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<IotRdDailyReportDO> result = iotRdDailyReportService.getIotRdDailyReportPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "瑞都日报明细.xls", "日报明细", IotRdDailyReportRespVO.class,
+                buildDailyReportList(result));
+    }
+
 }

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

@@ -22,24 +22,50 @@ import java.util.Set;
 @ExcelIgnoreUnannotated
 public class IotRdDailyReportRespVO {
 
+    @Schema(description = "创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private String createTimeStr;
+
+    @Schema(description = "部门名称", example = "压裂二队,压裂五队")
+    @ExcelProperty("施工队伍")
+    private String deptName;
+
+    @Schema(description = "合同/项目名称", example = "酸化压裂合同")
+    @ExcelProperty("项目")
+    private String contractName;
+
+    @Schema(description = "任务名称", example = "YS45-211平台-山西兴县")
+    @ExcelProperty("任务")
+    private String taskName;
+
+    @Schema(description = "施工状态(动迁上井/动迁下井/施工准备/施工...)", example = "1")
+    @ExcelProperty("施工状态")
+    private String rdStatusLabel;
+
+    @Schema(description = "带班干部姓名", example = "张三,李四...")
+    @ExcelProperty("带班干部")
+    private String responsiblePersonNames;
+
+    @Schema(description = "填报人姓名", example = "张三,李四...")
+    @ExcelProperty("填报人")
+    private String submitterNames;
+
     @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13853")
-    @ExcelProperty("主键id")
     private Long id;
 
     @Schema(description = "施工队伍id", example = "22577")
-    @ExcelProperty("施工队伍id")
     private Long deptId;
 
     @Schema(description = "平台井标识 2非平台井 1平台井 0默认值", example = "1")
-    @ExcelProperty("平台井标识 2非平台井 1平台井 0默认值")
     private Integer platformWell;
 
     @Schema(description = "平台井组", example = "463e3996-be48-4758-8229-c1351cbf3e37")
-    @ExcelProperty("平台井组")
     private String platformGroup;
 
     @Schema(description = "任务平台井标识", example = "463e3996-be48-4758-8229-c1351cbf3e37")
-    @ExcelProperty("任务平台井标识")
     private String taskPlatform;
 
     @Schema(description = "日报名称", example = "西南压裂项目部/2025-10-17日报填报")
@@ -47,31 +73,24 @@ public class IotRdDailyReportRespVO {
     private String reportName;
 
     @Schema(description = "项目id", example = "32587")
-    @ExcelProperty("项目id")
     private Long projectId;
 
     @Schema(description = "任务id", example = "15678")
-    @ExcelProperty("任务id")
     private Long taskId;
 
     @Schema(description = "项目类别(钻井 修井 注氮 酸化压裂... )")
-    @ExcelProperty("项目类别(钻井 修井 注氮 酸化压裂... )")
     private String projectClassification;
 
     @Schema(description = "施工工艺([123,233])")
-    @ExcelProperty("施工工艺([123,233])")
     private Set<Long> techniqueIds;
 
     @Schema(description = "施工设备([123,233])")
-    @ExcelProperty("施工设备([123,233])")
     private Set<Long> deviceIds;
 
     @Schema(description = "时间节点-开始")
-    @ExcelProperty("时间节点-开始")
     private LocalTime startTime;
 
     @Schema(description = "时间节点-结束")
-    @ExcelProperty("时间节点-结束")
     private LocalTime endTime;
 
     @Schema(description = "累计施工井")
@@ -106,27 +125,22 @@ public class IotRdDailyReportRespVO {
     @ExcelProperty("时间H")
     private BigDecimal hourCount;
 
-    @Schema(description = "当日油耗()")
-    @ExcelProperty("当日油耗()")
+    @Schema(description = "当日油耗(L)")
+    @ExcelProperty("当日油耗(L)")
     private BigDecimal dailyFuel;
 
     @Schema(description = "当日用电量(kWh)")
-    @ExcelProperty("当日用电量(kWh)")
     private BigDecimal dailyPowerUsage;
 
     @Schema(description = "生产时间(H)")
-    @ExcelProperty("生产时间(H)")
     private BigDecimal productionTime;
 
     @Schema(description = "非生产时间(H)")
-    @ExcelProperty("非生产时间(H)")
     private BigDecimal nonProductionTime;
 
     @Schema(description = "非生产时间原因", example = "不喜欢")
-    @ExcelProperty("非生产时间原因")
     private String rdNptReason;
 
-
     @Schema(description = "事故非生产时间(H)")
     private BigDecimal accidentTime;
     @Schema(description = "修理非生产时间(H)")
@@ -154,21 +168,18 @@ public class IotRdDailyReportRespVO {
     @Schema(description = "其它非生产时间原因")
     private String otherNptReason;
 
-
     @Schema(description = "施工开始日期")
-    @ExcelProperty("施工开始日期")
     private LocalDateTime constructionStartDate;
 
     @Schema(description = "施工结束日期")
-    @ExcelProperty("施工结束日期")
     private LocalDateTime constructionEndDate;
 
     @Schema(description = "当日生产情况生产动态", example = "2")
-    @ExcelProperty("当日生产情况生产动态")
+    @ExcelProperty("当日生产动态")
     private String productionStatus;
 
     @Schema(description = "外租情况(可能有附件)")
-    @ExcelProperty("外租情况(可能有附件)")
+    @ExcelProperty("外租情况")
     private String externalRental;
 
     @Schema(description = "下步工作计划")
@@ -176,7 +187,6 @@ public class IotRdDailyReportRespVO {
     private String nextPlan;
 
     @Schema(description = "施工状态(动迁上井/动迁下井/施工准备/施工...)", example = "1")
-    @ExcelProperty("施工状态(动迁上井/动迁下井/施工准备/施工...)")
     private String rdStatus;
 
     @Schema(description = "故障情况")
@@ -188,23 +198,18 @@ public class IotRdDailyReportRespVO {
     private BigDecimal faultDowntime;
 
     @Schema(description = "人员情况")
-    @ExcelProperty("人员情况")
     private String personnel;
 
     @Schema(description = "全员数量")
-    @ExcelProperty("全员数量")
     private BigDecimal totalStaffNum;
 
     @Schema(description = "休假人员数量")
-    @ExcelProperty("休假人员数量")
     private BigDecimal leaveStaffNum;
 
     @Schema(description = "不同专业公司的扩展属性值")
-    @ExcelProperty("不同专业公司的扩展属性值")
     private List<IotTaskAttrModelProperty> extProperty;
 
     @Schema(description = "排序值")
-    @ExcelProperty("排序值")
     private Integer sort;
 
     @Schema(description = "备注", example = "随便")
@@ -212,125 +217,80 @@ public class IotRdDailyReportRespVO {
     private String remark;
 
     @Schema(description = "状态(0启用 1禁用)", example = "2")
-    @ExcelProperty("状态(0启用 1禁用)")
     private Integer status;
 
     @Schema(description = "流程实例id", example = "16415")
-    @ExcelProperty("流程实例id")
     private String processInstanceId;
 
     @Schema(description = "审批状态 未提交、审批中、审批通过、审批不通过、已取消", example = "1")
-    @ExcelProperty("审批状态 未提交、审批中、审批通过、审批不通过、已取消")
     private Integer auditStatus;
 
     @Schema(description = "审批意见", example = "审核通过")
-    @ExcelProperty("审批意见")
     private String opinion;
 
-    @Schema(description = "创建时间")
-    @ExcelProperty("创建时间")
-    private LocalDateTime createTime;
-
     @Schema(description = "日报填写时间")
-    @ExcelProperty("日报填写时间")
     private LocalDateTime fillTime;
 
     @Schema(description = "审批时间")
-    @ExcelProperty("审批时间")
     private LocalDateTime approvalTime;
 
     /**
      * 扩展字段
      */
     @Schema(description = "时间节点区域 startTime-endTime", example = "8:00 - 8:00")
-    @ExcelProperty("时间节点区域")
     private String timeRange;
 
-    @Schema(description = "部门名称", example = "压裂二队,压裂五队")
-    @ExcelProperty("部门名称")
-    private String deptName;
-
-    @Schema(description = "合同/项目名称", example = "酸化压裂合同")
-    @ExcelProperty("合同/项目名称")
-    private String contractName;
-
-    @Schema(description = "任务名称", example = "YS45-211平台-山西兴县")
-    @ExcelProperty("任务名称")
-    private String taskName;
-
     @Schema(description = "井号", example = "YS45-211平台")
-    @ExcelProperty("井号")
     private String wellName;
 
     @Schema(description = "施工地点", example = "山西兴县")
-    @ExcelProperty("施工地点")
     private String location;
 
     @Schema(description = "客户名称", example = "YS45-211平台-山西兴县")
-    @ExcelProperty("客户名称")
     private String manufactureName;
 
     @Schema(description = "施工工艺(多个逗号分隔)", example = "压裂大包,主压裂车...")
-    @ExcelProperty("施工工艺(多个逗号分隔)")
     private String techniqueNames;
 
     @Schema(description = "设备配置", example = "黑EN9500,黑EN7958...")
-    @ExcelProperty("设备配置")
     private String deviceNames;
 
-    @Schema(description = "带班干部姓名", example = "张三,李四...")
-    @ExcelProperty("带班干部")
-    private String responsiblePersonNames;
 
-    @Schema(description = "填报人姓名", example = "张三,李四...")
-    @ExcelProperty("填报人姓名")
-    private String submitterNames;
 
     @Schema(description = "公司id", example = "125")
-    @ExcelProperty("公司id")
     private Long companyId;
 
     @Schema(description = "工作量属性", example = "累计施工-层,当日泵车台次...")
-    @ExcelProperty("工作量属性")
     private List<IotDailyReportAttrsDO> dailyReportAttrs;
 
     @Schema(description = "搬迁日期", example = "125")
-    @ExcelProperty("搬迁日期")
     private String relocationDate;
 
     @Schema(description = "开工日期", example = "125")
-    @ExcelProperty("开工日期")
     private String commencementDate;
 
     @Schema(description = "完工日期", example = "125")
-    @ExcelProperty("完工日期")
     private String completionDate;
 
     @Schema(description = "施工周期D", example = "125")
-    @ExcelProperty("施工周期D")
     private String constructionPeriod;
 
     @Schema(description = "停待时间D", example = "12")
-    @ExcelProperty("停待时间D")
     private String idleTime;
 
     /**
      * 扩展属性
      */
     @Schema(description = "附件列表", example = "https://aims.deepoil.cc/admin-api/infra/file/29/get/人力资源.png")
-    @ExcelProperty("附件列表")
     private List<IotAttachmentDO> attachments;
 
     @Schema(description = "施工设备列表", example = "https://aims.deepoil.cc/admin-api/infra/file/29/get/人力资源.png")
-    @ExcelProperty("施工设备列表")
     private List<IotDeviceSimpleRespVO> selectedDevices;
 
     @Schema(description = "平台井列表", example = "[]")
-    @ExcelProperty("平台井列表")
     private List<IotProjectTaskPlatformVO> platforms;
 
     @Schema(description = "已经施工完成的 平台井列表", example = "[]")
-    @ExcelProperty("已经施工完成的 平台井列表")
     private List<IotProjectTaskPlatformVO> finishedPlatforms;
 
     @Schema(description = "虚拟项目标识", example = "Y N")

+ 419 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -857,6 +857,121 @@ public class IotRhDailyReportController {
         // key小组最后1条记录id    value 小计平均运行时效
         Map<Long, BigDecimal> groupIdTransTimePair = new HashMap<>();
 
+        // key队伍id   value 队伍当年累计注气量
+        Map<Long, BigDecimal> yearGasInjectionPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计注水量
+        Map<Long, BigDecimal> yearWaterInjectionPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计用电量
+        Map<Long, BigDecimal> yearPowerPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计油耗
+        Map<Long, BigDecimal> yearFuelPair = new HashMap<>();
+
+        // key任务井id    value 井累计注气量
+        Map<Long, BigDecimal> wellGasInjectionPair = new HashMap<>();
+        // key任务井id    value 井累计注水量
+        Map<Long, BigDecimal> wellWaterInjectionPair = new HashMap<>();
+        // key任务井id    value 井累计用电量
+        Map<Long, BigDecimal> wellPowerPair = new HashMap<>();
+        // key任务井id    value 井累计油耗
+        Map<Long, BigDecimal> wellFuelPair = new HashMap<>();
+
+        // 查询所有井日报数据
+        IotRhDailyReportPageReqVO wellTaskReqVO = new IotRhDailyReportPageReqVO();
+        wellTaskReqVO.setTaskIds(convertList(reports, IotRhDailyReportDO::getTaskId));
+        List<IotRhDailyReportDO> taskDailyReports = iotRhDailyReportMapper.dailyReports(wellTaskReqVO);
+
+        if (CollUtil.isNotEmpty(taskDailyReports)) {
+            taskDailyReports.forEach(report -> {
+                // 注气量
+                if (wellGasInjectionPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempGasInjection = wellGasInjectionPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempGasInjection.add(report.getDailyGasInjection());
+                    wellGasInjectionPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellGasInjectionPair.put(report.getTaskId(), report.getDailyGasInjection());
+                }
+                // 注水量
+                if (wellWaterInjectionPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempWaterInjection = wellWaterInjectionPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempWaterInjection.add(report.getDailyWaterInjection());
+                    wellWaterInjectionPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellWaterInjectionPair.put(report.getTaskId(), report.getDailyWaterInjection());
+                }
+                // 电量
+                if (wellPowerPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempPower = wellPowerPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    wellPowerPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellPowerPair.put(report.getTaskId(), report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (wellFuelPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempFuel = wellFuelPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempFuel.add(report.getDailyOilUsage());
+                    wellFuelPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellFuelPair.put(report.getTaskId(), report.getDailyOilUsage());
+                }
+            });
+        }
+
+        // 根据传递的时间筛选获取要查询的 yyyy
+        // 如果没有传递时间区间 默认当年
+        LocalDateTime nowDate = LocalDateTime.now();
+        String year = StrUtil.EMPTY;
+        if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+            LocalDateTime[] createTimeAttr = pageReqVO.getCreateTime();
+            if (createTimeAttr.length > 0) {
+                LocalDateTime startTime = createTimeAttr[0];
+                year = String.valueOf(startTime.getYear());
+            }
+        } else {
+            year = String.valueOf(nowDate.getYear());
+        }
+        // 只有传递了 时间查询条件 才会查询 当年累计的工作量数据
+        IotRhDailyReportPageReqVO yearReqVO = new IotRhDailyReportPageReqVO();
+        yearReqVO.setYear(year);
+        yearReqVO.setDeptIds(convertList(reports, IotRhDailyReportDO::getDeptId));
+        List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(yearReqVO);
+        if (CollUtil.isNotEmpty(dailyReports)) {
+            dailyReports.forEach(report -> {
+                // 注气量
+                if (yearGasInjectionPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempGasInjection = yearGasInjectionPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempGasInjection.add(report.getDailyGasInjection());
+                    yearGasInjectionPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearGasInjectionPair.put(report.getDeptId(), report.getDailyGasInjection());
+                }
+                // 注水量
+                if (yearWaterInjectionPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempWaterInjection = yearWaterInjectionPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempWaterInjection.add(report.getDailyWaterInjection());
+                    yearWaterInjectionPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearWaterInjectionPair.put(report.getDeptId(), report.getDailyWaterInjection());
+                }
+                // 电量
+                if (yearPowerPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempPower = yearPowerPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    yearPowerPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearPowerPair.put(report.getDeptId(), report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (yearFuelPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempFuel = yearFuelPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempFuel.add(report.getDailyOilUsage());
+                    yearFuelPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearFuelPair.put(report.getDeptId(), report.getDailyOilUsage());
+                }
+            });
+        }
+
         // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
         IotRhDailyReportPageReqVO currentTaskReqVO = new IotRhDailyReportPageReqVO();
         currentTaskReqVO.setTaskIds(convertSet(reports, IotRhDailyReportDO::getTaskId));
@@ -1028,6 +1143,11 @@ public class IotRhDailyReportController {
                 reportVO.setTransitTimeRate(transitTimeRate);
             }
 
+            // 导出列表时 格式化时间为 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
+                reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
+            }
+
             // 转换用电量 单位 kWh 转换成 MWh
             // 用电量 kWh 转换单位 MWh
             if (reportVO.getDailyPowerUsage().compareTo(BigDecimal.ZERO) > 0) {
@@ -1036,6 +1156,13 @@ public class IotRhDailyReportController {
                 reportVO.setDailyPowerUsage(powerW);
             }
 
+            // 转换当日油耗 原始单位 方 转换成 万方
+            if (reportVO.getDailyGasInjection().compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal gasW = reportVO.getDailyGasInjection()
+                        .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
+                reportVO.setDailyGasInjection(gasW);
+            }
+
             // 2.1 拼接部门信息
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
 
@@ -1071,13 +1198,57 @@ public class IotRhDailyReportController {
             // 2.4 设计注气量
             findAndThen(taskExtPropertyPair, reportVO.getTaskId(), designInjection -> reportVO.setDesignInjection(designInjection));
             // 2.5 搬迁安装天数
-            findAndThen(relocationDaysPair, reportVO.getDeptId(), relocationDays -> reportVO.setRelocationDays(relocationDays));
+            findAndThen(relocationDaysPair, reportVO.getDeptId(), relocationDays -> {
+                if (relocationDays.compareTo(BigDecimal.ZERO) < 0) {
+                    reportVO.setRelocationDays(BigDecimal.ZERO);
+                } else {
+                    reportVO.setRelocationDays(relocationDays);
+                }
+            });
             // 2.6 产能
             findAndThen(capacityPair.get(), reportVO.getDeptId(), capacity -> reportVO.setCapacity(capacity));
             // 施工状态 数据字典
             findAndThen(constructStatusPair, reportVO.getConstructionStatus(), statusLabel -> reportVO.setConstructionStatusName(statusLabel));
             // 非生产时间原因 数据字典
             findAndThen(nptReasonPair, reportVO.getNptReason(), statusLabel -> reportVO.setNptReasonName(statusLabel));
+
+            // 井当年累计注气量
+            findAndThen(wellGasInjectionPair, reportVO.getTaskId(), gasInjection -> {
+                // 转换单位为 万方
+                BigDecimal gasInjectionWanFang = gasInjection
+                        .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
+                reportVO.setWellTotalGasInjection(gasInjectionWanFang);
+            });
+            // 井当年累计注水量
+            findAndThen(wellWaterInjectionPair, reportVO.getTaskId(), waterInjection -> reportVO.setWellTotalWaterInjection(waterInjection));
+            // 井当年累计用电量
+            findAndThen(wellPowerPair, reportVO.getTaskId(), power -> {
+                // 换算单位为 MWh
+                BigDecimal powerW = power
+                        .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
+                reportVO.setWellTotalPower(powerW);
+            });
+            // 井当年累计油耗
+            findAndThen(wellFuelPair, reportVO.getTaskId(), fuel -> reportVO.setWellTotalFuel(fuel));
+
+            // 队伍当年累计注气量
+            findAndThen(yearGasInjectionPair, reportVO.getDeptId(), gasInjection -> {
+                // 转换单位为 万方
+                BigDecimal gasInjectionWanFang = gasInjection
+                        .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
+                reportVO.setYearTotalGasInjection(gasInjectionWanFang);
+            });
+            // 队伍当年累计注水量
+            findAndThen(yearWaterInjectionPair, reportVO.getDeptId(), waterInjection -> reportVO.setYearTotalWaterInjection(waterInjection));
+            // 队伍当年累计用电量
+            findAndThen(yearPowerPair, reportVO.getDeptId(), power -> {
+                // 换算单位为 MWh
+                BigDecimal powerW = power
+                        .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
+                reportVO.setYearTotalPower(powerW);
+            });
+            // 队伍当年累计油耗
+            findAndThen(yearFuelPair, reportVO.getDeptId(), fuel -> reportVO.setYearTotalFuel(fuel));
         });
     }
 
@@ -1135,6 +1306,120 @@ public class IotRhDailyReportController {
         // key小组最后1条记录id    value 任务井小计平均运行时效
         Map<Long, BigDecimal> groupIdTransTimePair = new HashMap<>();
 
+        // key队伍id   value 队伍当年累计注气量
+        Map<Long, BigDecimal> yearGasInjectionPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计注水量
+        Map<Long, BigDecimal> yearWaterInjectionPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计用电量
+        Map<Long, BigDecimal> yearPowerPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计油耗
+        Map<Long, BigDecimal> yearFuelPair = new HashMap<>();
+
+        // key任务井id    value 井累计注气量
+        Map<Long, BigDecimal> wellGasInjectionPair = new HashMap<>();
+        // key任务井id    value 井累计注水量
+        Map<Long, BigDecimal> wellWaterInjectionPair = new HashMap<>();
+        // key任务井id    value 井累计用电量
+        Map<Long, BigDecimal> wellPowerPair = new HashMap<>();
+        // key任务井id    value 井累计油耗
+        Map<Long, BigDecimal> wellFuelPair = new HashMap<>();
+
+        // 查询所有井日报数据
+        IotRhDailyReportPageReqVO teamTaskReqVO = new IotRhDailyReportPageReqVO();
+        teamTaskReqVO.setTaskIds(convertList(reports, IotRhDailyReportDO::getTaskId));
+        List<IotRhDailyReportDO> taskDailyReports = iotRhDailyReportMapper.dailyReports(teamTaskReqVO);
+        if (CollUtil.isNotEmpty(taskDailyReports)) {
+            taskDailyReports.forEach(report -> {
+                // 注气量
+                if (wellGasInjectionPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempGasInjection = wellGasInjectionPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempGasInjection.add(report.getDailyGasInjection());
+                    wellGasInjectionPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellGasInjectionPair.put(report.getTaskId(), report.getDailyGasInjection());
+                }
+                // 注水量
+                if (wellWaterInjectionPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempWaterInjection = wellWaterInjectionPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempWaterInjection.add(report.getDailyWaterInjection());
+                    wellWaterInjectionPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellWaterInjectionPair.put(report.getTaskId(), report.getDailyWaterInjection());
+                }
+                // 电量
+                if (wellPowerPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempPower = wellPowerPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    wellPowerPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellPowerPair.put(report.getTaskId(), report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (wellFuelPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempFuel = wellFuelPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempFuel.add(report.getDailyOilUsage());
+                    wellFuelPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellFuelPair.put(report.getTaskId(), report.getDailyOilUsage());
+                }
+            });
+        }
+
+        // 根据传递的时间筛选获取要查询的 yyyy
+        // 如果没有传递时间区间 默认当年
+        LocalDateTime nowDate = LocalDateTime.now();
+        String year = StrUtil.EMPTY;
+        if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+            LocalDateTime[] createTimeAttr = pageReqVO.getCreateTime();
+            if (createTimeAttr.length > 0) {
+                LocalDateTime startTime = createTimeAttr[0];
+                year = String.valueOf(startTime.getYear());
+            }
+        } else {
+            year = String.valueOf(nowDate.getYear());
+        }
+        // 只有传递了 时间查询条件 才会查询 当年累计的工作量数据
+        IotRhDailyReportPageReqVO yearReqVO = new IotRhDailyReportPageReqVO();
+        yearReqVO.setYear(year);
+        yearReqVO.setDeptIds(convertList(reports, IotRhDailyReportDO::getDeptId));
+        List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(yearReqVO);
+        if (CollUtil.isNotEmpty(dailyReports)) {
+            dailyReports.forEach(report -> {
+                // 注气量
+                if (yearGasInjectionPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempGasInjection = yearGasInjectionPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempGasInjection.add(report.getDailyGasInjection());
+                    yearGasInjectionPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearGasInjectionPair.put(report.getDeptId(), report.getDailyGasInjection());
+                }
+                // 注水量
+                if (yearWaterInjectionPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempWaterInjection = yearWaterInjectionPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempWaterInjection.add(report.getDailyWaterInjection());
+                    yearWaterInjectionPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearWaterInjectionPair.put(report.getDeptId(), report.getDailyWaterInjection());
+                }
+                // 电量
+                if (yearPowerPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempPower = yearPowerPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    yearPowerPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearPowerPair.put(report.getDeptId(), report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (yearFuelPair.containsKey(report.getDeptId())) {
+                    BigDecimal tempFuel = yearFuelPair.get(report.getDeptId());
+                    BigDecimal tempResult = tempFuel.add(report.getDailyOilUsage());
+                    yearFuelPair.put(report.getDeptId(), tempResult);
+                } else {
+                    yearFuelPair.put(report.getDeptId(), report.getDailyOilUsage());
+                }
+            });
+        }
+
         // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
         IotRhDailyReportPageReqVO currentTaskReqVO = new IotRhDailyReportPageReqVO();
         currentTaskReqVO.setTaskIds(convertSet(reports, IotRhDailyReportDO::getTaskId));
@@ -1307,12 +1592,24 @@ public class IotRhDailyReportController {
                 // 赋值
                 reportVO.setTransitTimeRate(transitTimeRate);
             }
+            // 导出列表时 格式化时间为 yyyy-MM-dd
+            if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
+                reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
+            }
             // 用电量 kWh 转换单位 MWh
             if (reportVO.getDailyPowerUsage().compareTo(BigDecimal.ZERO) > 0) {
                 BigDecimal powerW = reportVO.getDailyPowerUsage()
                         .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
                 reportVO.setDailyPowerUsage(powerW);
             }
+
+            // 转换当日油耗 原始单位 方 转换成 万方
+            if (reportVO.getDailyGasInjection().compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal gasW = reportVO.getDailyGasInjection()
+                        .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
+                reportVO.setDailyGasInjection(gasW);
+            }
+
             // 2.1 拼接部门信息
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
 
@@ -1348,13 +1645,57 @@ public class IotRhDailyReportController {
             // 2.4 设计注气量
             findAndThen(taskExtPropertyPair, reportVO.getTaskId(), designInjection -> reportVO.setDesignInjection(designInjection));
             // 2.5 搬迁安装天数
-            findAndThen(relocationDaysPair, reportVO.getDeptId(), relocationDays -> reportVO.setRelocationDays(relocationDays));
+            findAndThen(relocationDaysPair, reportVO.getDeptId(), relocationDays -> {
+                if (relocationDays.compareTo(BigDecimal.ZERO) < 0) {
+                    reportVO.setRelocationDays(BigDecimal.ZERO);
+                } else {
+                    reportVO.setRelocationDays(relocationDays);
+                }
+            });
             // 2.6 产能
             findAndThen(capacityPair.get(), reportVO.getDeptId(), capacity -> reportVO.setCapacity(capacity));
             // 施工状态 数据字典
             findAndThen(constructStatusPair, reportVO.getConstructionStatus(), statusLabel -> reportVO.setConstructionStatusName(statusLabel));
             // 非生产时间原因 数据字典
             findAndThen(nptReasonPair, reportVO.getNptReason(), statusLabel -> reportVO.setNptReasonName(statusLabel));
+
+            // 队伍当年累计注气量
+            findAndThen(yearGasInjectionPair, reportVO.getDeptId(), gasInjection -> {
+                // 转换单位为 万方
+                BigDecimal gasInjectionWanFang = gasInjection
+                        .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
+                reportVO.setYearTotalGasInjection(gasInjectionWanFang);
+            });
+            // 队伍当年累计注水量
+            findAndThen(yearWaterInjectionPair, reportVO.getDeptId(), waterInjection -> reportVO.setYearTotalWaterInjection(waterInjection));
+            // 队伍当年累计用电量
+            findAndThen(yearPowerPair, reportVO.getDeptId(), power -> {
+                // 换算单位为 MWh
+                BigDecimal powerW = power
+                        .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
+                reportVO.setYearTotalPower(powerW);
+            });
+            // 队伍当年累计油耗
+            findAndThen(yearFuelPair, reportVO.getDeptId(), fuel -> reportVO.setYearTotalFuel(fuel));
+
+            // 井当年累计注气量
+            findAndThen(wellGasInjectionPair, reportVO.getTaskId(), gasInjection -> {
+                // 转换单位为 万方
+                BigDecimal gasInjectionWanFang = gasInjection
+                        .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
+                reportVO.setWellTotalGasInjection(gasInjectionWanFang);
+            });
+            // 井当年累计注水量
+            findAndThen(wellWaterInjectionPair, reportVO.getTaskId(), waterInjection -> reportVO.setWellTotalWaterInjection(waterInjection));
+            // 井当年累计用电量
+            findAndThen(wellPowerPair, reportVO.getTaskId(), power -> {
+                // 换算单位为 MWh
+                BigDecimal powerW = power
+                        .divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
+                reportVO.setWellTotalPower(powerW);
+            });
+            // 井当年累计油耗
+            findAndThen(wellFuelPair, reportVO.getTaskId(), fuel -> reportVO.setWellTotalFuel(fuel));
         });
     }
 
@@ -1448,4 +1789,80 @@ public class IotRhDailyReportController {
                 IotRhDailyReportStatisticsRespVO.class, statistics);
     }
 
+    @GetMapping("/exportSingleWells")
+    @Operation(summary = "导出瑞恒日报 报表统计 单井 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportSingleWells(@Valid IotRhDailyReportPageReqVO 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<IotRhDailyReportDO> reports = iotRhDailyReportService.teamReports(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "瑞恒日报单井统计.xls", "日报单井统计",
+                IotRhDailyReportRespVO.class, buildSubtotalRhDailyReports(reports, pageReqVO));
+    }
+
+    @GetMapping("/exportSingleTeams")
+    @Operation(summary = "导出瑞恒日报 报表统计 队伍 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportSingleTeams(@Valid IotRhDailyReportPageReqVO 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<IotRhDailyReportDO> reports = iotRhDailyReportService.wellReports(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "瑞恒日报单队伍统计.xls", "日报单队伍统计",
+                IotRhDailyReportRespVO.class, buildWellRhDailyReports(reports, pageReqVO));
+    }
+
 }

+ 1 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportRespVO.java

@@ -69,7 +69,7 @@ public class IotRhDailyReportRespVO {
     private String transitTimeRate;
 
     @Schema(description = "当日注气量(万方)")
-    @ExcelProperty("当日注气量(方)")
+    @ExcelProperty("当日注气量(方)")
     private BigDecimal dailyGasInjection;
 
     @Schema(description = "当日注水量(方)")
@@ -133,11 +133,9 @@ public class IotRhDailyReportRespVO {
 
 
     @Schema(description = "施工开始日期")
-    @ExcelProperty("施工开始日期")
     private LocalDateTime constructionStartDate;
 
     @Schema(description = "施工结束日期")
-    @ExcelProperty("施工结束日期")
     private LocalDateTime constructionEndDate;
 
     @Schema(description = "生产动态", example = "2")
@@ -151,19 +149,15 @@ public class IotRhDailyReportRespVO {
     private String constructionStatus;
 
     @Schema(description = "人员情况")
-    @ExcelProperty("人员情况")
     private String personnel;
 
     @Schema(description = "累计注气量(方)")
-    @ExcelProperty("累计注气量(方)")
     private BigDecimal totalGasInjection;
 
     @Schema(description = "累计注水量(方)")
-    @ExcelProperty("累计注水量(方)")
     private BigDecimal totalWaterInjection;
 
     @Schema(description = "累计完工井次")
-    @ExcelProperty("累计完工井次")
     private BigDecimal cumulativeCompletion;
 
     @Schema(description = "产能")