Explorar o código

pms 瑞鹰日报 单井或 队伍统计数据。

zhangcl hai 1 semana
pai
achega
e13e4c92ce

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

@@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.iotdailyreportfuel.vo.IotDailyReportFuelPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
@@ -888,6 +889,7 @@ public class IotRhDailyReportController {
             });
         }
 
+        currentTaskReqVO.setDeptIds(pageReqVO.getDeptIds());
         // 查询 deptId-taskId 分组内最后1条记录id 设置展开列标识
         List<IotRhDailyReportDO> currentGroupIds = iotRhDailyReportService.rhWellNameDailyReportsGroupIds(currentTaskReqVO);
         // key部门id-任务id   value小组内最后1条记录id
@@ -997,7 +999,7 @@ public class IotRhDailyReportController {
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
 
             // 小组内最后1条记录标识
-            findAndThen(groupIdGasInjectionPair, reportVO.getId(), gasInjection -> reportVO.setLastGroupIdFlag("Y"));
+            findAndThen(groupIdGasInjectionPair, reportVO.getId(), gasInjection -> reportVO.setLastGroupIdFlag(true));
             // 小组内累计注气量
             findAndThen(groupIdGasInjectionPair, reportVO.getId(), gasInjection -> reportVO.setGroupIdGasInjection(gasInjection));
             // 小组内累计注水量
@@ -1084,7 +1086,6 @@ public class IotRhDailyReportController {
         // key小组最后1条记录id    value 任务井小计平均运行时效
         Map<Long, BigDecimal> groupIdTransTimePair = new HashMap<>();
 
-
         // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
         IotRhDailyReportPageReqVO currentTaskReqVO = new IotRhDailyReportPageReqVO();
         currentTaskReqVO.setTaskIds(convertSet(reports, IotRhDailyReportDO::getTaskId));
@@ -1149,41 +1150,44 @@ public class IotRhDailyReportController {
             });
         }
 
-        // 查询 deptId-taskId 分组内最后1条记录id 设置展开列标识
-        List<IotRhDailyReportDO> currentGroupIds = iotRhDailyReportService.rhDeptDailyReportsGroupIds(currentTaskReqVO);
-        // key部门id-任务id   value小组内最后1条记录id
-        Map<String, Long> groupIdPair = new HashMap<>();
-        if (CollUtil.isNotEmpty(currentGroupIds)) {
-            currentGroupIds.forEach(groupId -> {
-                String uniqueKey = StrUtil.join("-", groupId.getDeptId(), groupId.getTaskId());
-                groupIdPair.put(uniqueKey, groupId.getId());
-            });
-        }
+        TenantUtils.executeIgnore(() -> {
+            currentTaskReqVO.setDeptId(pageReqVO.getDeptId());
+            // 查询 deptId-taskId 分组内最后1条记录id 设置展开列标识
+            List<IotRhDailyReportDO> currentGroupIds = iotRhDailyReportService.rhDeptDailyReportsGroupIds(currentTaskReqVO);
+            // key部门id-任务id   value小组内最后1条记录id
+            Map<String, Long> groupIdPair = new HashMap<>();
+            if (CollUtil.isNotEmpty(currentGroupIds)) {
+                currentGroupIds.forEach(groupId -> {
+                    String uniqueKey = StrUtil.join("-", groupId.getDeptId(), groupId.getTaskId());
+                    groupIdPair.put(uniqueKey, groupId.getId());
+                });
+            }
 
-        // 设置 分组内最后1条记录id 与 deptId-taskId 唯一键的对应关系
-        if (CollUtil.isNotEmpty(groupIdPair)) {
-            groupIdPair.forEach((uniqueKey, groupId) -> {
-                if (groupGasInjectionPair.containsKey(uniqueKey)) {
-                    groupIdGasInjectionPair.put(groupId, groupGasInjectionPair.get(uniqueKey));
-                }
-                if (groupWaterInjectionPair.containsKey(uniqueKey)) {
-                    groupIdWaterInjectionPair.put(groupId, groupWaterInjectionPair.get(uniqueKey));
-                }
-                if (groupPowerPair.containsKey(uniqueKey)) {
-                    groupIdPowerPair.put(groupId, groupPowerPair.get(uniqueKey));
-                }
-                if (groupFuelPair.containsKey(uniqueKey)) {
-                    groupIdFuelPair.put(groupId, groupFuelPair.get(uniqueKey));
-                }
-                if (groupGasTimePair.containsKey(uniqueKey)) {
-                    groupIdGasTimePair.put(groupId, groupGasTimePair.get(uniqueKey));
-                }
-                if (groupNoProductTimePair.containsKey(uniqueKey)) {
-                    groupIdNoProductTimePair.put(groupId, groupNoProductTimePair.get(uniqueKey));
-                }
+            // 设置 分组内最后1条记录id 与 deptId-taskId 唯一键的对应关系
+            if (CollUtil.isNotEmpty(groupIdPair)) {
+                groupIdPair.forEach((uniqueKey, groupId) -> {
+                    if (groupGasInjectionPair.containsKey(uniqueKey)) {
+                        groupIdGasInjectionPair.put(groupId, groupGasInjectionPair.get(uniqueKey));
+                    }
+                    if (groupWaterInjectionPair.containsKey(uniqueKey)) {
+                        groupIdWaterInjectionPair.put(groupId, groupWaterInjectionPair.get(uniqueKey));
+                    }
+                    if (groupPowerPair.containsKey(uniqueKey)) {
+                        groupIdPowerPair.put(groupId, groupPowerPair.get(uniqueKey));
+                    }
+                    if (groupFuelPair.containsKey(uniqueKey)) {
+                        groupIdFuelPair.put(groupId, groupFuelPair.get(uniqueKey));
+                    }
+                    if (groupGasTimePair.containsKey(uniqueKey)) {
+                        groupIdGasTimePair.put(groupId, groupGasTimePair.get(uniqueKey));
+                    }
+                    if (groupNoProductTimePair.containsKey(uniqueKey)) {
+                        groupIdNoProductTimePair.put(groupId, groupNoProductTimePair.get(uniqueKey));
+                    }
 
-            });
-        }
+                });
+            }
+        });
 
         // key部门id  value产能
         AtomicReference<Map<Long, BigDecimal>> capacityPair = new AtomicReference<>(new HashMap<>());
@@ -1258,7 +1262,7 @@ public class IotRhDailyReportController {
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
 
             // 小组内最后1条记录标识
-            findAndThen(groupIdGasInjectionPair, reportVO.getId(), gasInjection -> reportVO.setLastGroupIdFlag("Y"));
+            findAndThen(groupIdGasInjectionPair, reportVO.getId(), gasInjection -> reportVO.setLastGroupIdFlag(true));
             // 小组内累计注气量
             findAndThen(groupIdGasInjectionPair, reportVO.getId(), gasInjection -> reportVO.setGroupIdGasInjection(gasInjection));
             // 小组内累计注水量

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

@@ -201,6 +201,6 @@ public class IotRhDailyReportRespVO {
     @Schema(description = "小组内平均运行时效")
     private BigDecimal groupIdTransitTime;
 
-    @Schema(description = "小组内最后1条记录标识 Y N")
-    private String lastGroupIdFlag = "N";
+    @Schema(description = "小组内最后1条记录标识 true false")
+    private boolean lastGroupIdFlag = false;
 }

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

@@ -10,6 +10,7 @@ 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.framework.tenant.core.util.TenantUtils;
 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.*;
@@ -43,6 +44,7 @@ import java.util.concurrent.atomic.AtomicReference;
 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.CollectionUtils.convertSet;
 import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
 
 @Tag(name = "管理后台 - 瑞鹰日报")
@@ -189,6 +191,72 @@ public class IotRyDailyReportController {
         return success(new PageResult<>(buildRyDailyReports(pageResult.getList(), pageReqVO), pageResult.getTotal()));
     }
 
+    @GetMapping("/teamReports")
+    @Operation(summary = "根据井号查询瑞鹰日报列表 按照队伍分组统计工作量")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
+    public CommonResult<PageResult<IotRyDailyReportRespVO>> teamReports(@Valid IotRyDailyReportPageReqVO pageReqVO) {
+        // 根据查询参数筛选出 符合条件 的记录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);
+            }
+        }
+        PageResult<IotRyDailyReportDO> pageResult = iotRyDailyReportService.teamReports(pageReqVO);
+        return success(new PageResult<>(buildSubtotalRyDailyReports(pageResult.getList(), pageReqVO), pageResult.getTotal()));
+    }
+
+    @GetMapping("/wellReports")
+    @Operation(summary = "根据井号查询瑞鹰日报列表 按照队伍分组统计工作量")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
+    public CommonResult<PageResult<IotRyDailyReportRespVO>> wellReports(@Valid IotRyDailyReportPageReqVO pageReqVO) {
+        // 根据查询参数筛选出 符合条件 的记录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);
+            }
+        }
+        PageResult<IotRyDailyReportDO> pageResult = iotRyDailyReportService.wellReports(pageReqVO);
+        return success(new PageResult<>(buildWellRyDailyReports(pageResult.getList(), pageReqVO), pageResult.getTotal()));
+    }
+
     @GetMapping("/statistics")
     @Operation(summary = "获得瑞鹰日报汇总统计")
     @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
@@ -370,6 +438,705 @@ public class IotRyDailyReportController {
         });
     }
 
+    /**
+     * 瑞鹰日报分页 设置关联查询信息
+     * @param reports
+     * @return
+     */
+    private List<IotRyDailyReportRespVO> buildSubtotalRyDailyReports(List<IotRyDailyReportDO> reports, IotRyDailyReportPageReqVO pageReqVO) {
+        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, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
+        // key任务id   value套生段产管尺寸
+        Map<Long, String> taskCasingPipeSizePair = new HashMap<>();
+        // key任务id   value井控级别
+        Map<Long, String> taskWellControlLevelPair = new HashMap<>();
+        // key任务id   value施工工艺
+        Map<Long, String> taskTechniquePair = new HashMap<>();
+        // key任务id   value井别
+        Map<Long, String> taskWellCategoryPair = new HashMap<>();
+        // key任务id   value设计井身结构
+        Map<Long, String> taskWellStructPair = new HashMap<>();
+        // key部门id  value设备型号编号
+        AtomicReference<Map<Long, String>> equipmentTypePair = new AtomicReference<>(new HashMap<>());
+        // key施工队伍id    value最近完工日期
+        Map<Long, LocalDateTime> latestWellDoneTimePair = new HashMap<>();
+        // key施工队伍id    value施工井数量
+        Map<Long, Integer> totalTasksPair = new HashMap<>();
+        // key施工队伍id    value完工井数量
+        Map<Long, Integer> completedTasksPair = new HashMap<>();
+
+        // key部门id-队伍id   value 队伍累计进尺
+        Map<String, BigDecimal> groupFootagePair = new HashMap<>();
+        // key部门id-队伍id   value 队伍当年累计用电量
+        Map<String, BigDecimal> groupPowerPair = new HashMap<>();
+        // key部门id-队伍id   value 队伍当年累计油耗
+        Map<String, BigDecimal> groupFuelPair = new HashMap<>();
+        // key部门id-队伍id    value 进尺工作时间小计
+        Map<String, BigDecimal> groupFootageTimePair = new HashMap<>();
+        // key部门id-队伍id    value 钻井 其他生产时间小计
+        Map<String, BigDecimal> groupOtherProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 修井 生产时间小计
+        Map<String, BigDecimal> groupProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 修井 非生产时间小计
+        Map<String, BigDecimal> groupNoProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 钻井非生产时间小计
+        Map<String, BigDecimal> groupZjNoProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 小计平均运行时效
+        Map<String, BigDecimal> groupTransTimePair = new HashMap<>();
+
+        // key小组最后1条记录id   value 队伍累计进尺
+        Map<Long, BigDecimal> groupIdFootagePair = new HashMap<>();
+        // key小组最后1条记录id   value 队伍累计用电量
+        Map<Long, BigDecimal> groupIdPowerPair = new HashMap<>();
+        // key小组最后1条记录id   value 队伍累计油耗
+        Map<Long, BigDecimal> groupIdFuelPair = new HashMap<>();
+        // key小组最后1条记录id    value 进尺工作时间小计
+        Map<Long, BigDecimal> groupIdFootageTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 钻井 其他生产时间小计
+        Map<Long, BigDecimal> groupIdOtherProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 修井 生产时间小计
+        Map<Long, BigDecimal> groupIdProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 修井 非生产时间小计
+        Map<Long, BigDecimal> groupIdNoProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 钻井 非生产时间小计
+        Map<Long, BigDecimal> groupIdZjNoProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 小计平均运行时效
+        Map<Long, BigDecimal> groupIdTransTimePair = new HashMap<>();
+
+        // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
+        IotRyDailyReportPageReqVO currentTaskReqVO = new IotRyDailyReportPageReqVO();
+        currentTaskReqVO.setTaskIds(convertSet(reports, IotRyDailyReportDO::getTaskId));
+        currentTaskReqVO.setDeptIds(convertSet(reports, IotRyDailyReportDO::getDeptId));
+        currentTaskReqVO.setCreateTime(pageReqVO.getCreateTime());
+        currentTaskReqVO.setProjectIds(pageReqVO.getProjectIds());
+        currentTaskReqVO.setTaskIds(pageReqVO.getTaskIds());
+        List<IotRyDailyReportDO> deptTaskDailyReports = iotRyDailyReportMapper.dailyReports(currentTaskReqVO);
+
+        // 以 deptId-taskId 为唯一键 小计日报工作量
+        if (CollUtil.isNotEmpty(deptTaskDailyReports)) {
+            deptTaskDailyReports.forEach(report -> {
+                String uniqueKey = StrUtil.join("-", report.getDeptId(), report.getTaskId());
+                // 进尺
+                if (groupFootagePair.containsKey(uniqueKey)) {
+                    BigDecimal tempFootage = groupFootagePair.get(uniqueKey);
+                    BigDecimal tempResult = tempFootage.add(report.getDailyFootage());
+                    groupFootagePair.put(uniqueKey, tempResult);
+                } else {
+                    groupFootagePair.put(uniqueKey, report.getDailyFootage());
+                }
+                // 进尺工作时间
+                if (groupFootageTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempFootageTime = groupFootageTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempFootageTime.add(report.getDrillingWorkingTime());
+                    groupFootageTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupFootageTimePair.put(uniqueKey, report.getDrillingWorkingTime());
+                }
+                // 电量
+                if (groupPowerPair.containsKey(uniqueKey)) {
+                    BigDecimal tempPower = groupPowerPair.get(uniqueKey);
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    groupPowerPair.put(uniqueKey, tempResult);
+                } else {
+                    groupPowerPair.put(uniqueKey, report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (groupFuelPair.containsKey(uniqueKey)) {
+                    BigDecimal tempFuel = groupFuelPair.get(uniqueKey);
+                    BigDecimal tempResult = tempFuel.add(report.getDailyFuel());
+                    groupFuelPair.put(uniqueKey, tempResult);
+                } else {
+                    groupFuelPair.put(uniqueKey, report.getDailyFuel());
+                }
+                // 其他生产时间 钻井
+                if (groupOtherProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempNoProductTime = groupOtherProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempNoProductTime.add(report.getOtherProductionTime());
+                    groupOtherProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupOtherProductTimePair.put(uniqueKey, report.getOtherProductionTime());
+                }
+                // 生产时间 修井
+                if (groupProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempProductTime = groupProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempProductTime.add(report.getProductionTime());
+                    groupProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupProductTimePair.put(uniqueKey, report.getProductionTime());
+                }
+                // 非生产时间 修井
+                if (groupNoProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempNoProductTime = groupNoProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempNoProductTime.add(report.getNonProductionTime());
+                    groupNoProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupNoProductTimePair.put(uniqueKey, report.getNonProductionTime());
+                }
+                // 钻井 非生产时间 事故 修理 自停 复杂 搬迁 整改 等停 冬休
+                BigDecimal accidentTime = report.getAccidentTime();
+                BigDecimal repairTime = report.getRepairTime();
+                BigDecimal selfStopTime = report.getSelfStopTime();
+                BigDecimal complexityTime = report.getComplexityTime();
+                BigDecimal relocationTime = report.getRelocationTime();
+                BigDecimal rectificationTime = report.getRectificationTime();
+                BigDecimal waitingStopTime = report.getWaitingStopTime();
+                BigDecimal winterBreakTime = report.getWinterBreakTime();
+                BigDecimal totalNonProductionTime = Arrays.asList(
+                                accidentTime,
+                                repairTime,
+                                selfStopTime,
+                                complexityTime,
+                                relocationTime,
+                                rectificationTime,
+                                waitingStopTime,
+                                winterBreakTime
+                        ).stream()
+                // 将null转换为BigDecimal.ZERO,避免空指针
+                        .map(bd -> bd == null ? BigDecimal.ZERO : bd)
+                // 累加所有元素,初始值为BigDecimal.ZERO
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                // 非生产时间 钻井
+                if (groupZjNoProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempZjNoProductTime = groupZjNoProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempZjNoProductTime.add(totalNonProductionTime);
+                    groupZjNoProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupZjNoProductTimePair.put(uniqueKey, totalNonProductionTime);
+                }
+            });
+        }
+
+        TenantUtils.executeIgnore(() -> {
+            currentTaskReqVO.setDeptId(pageReqVO.getDeptId());
+            // 查询 deptId-taskId 分组内最后1条记录id 设置展开列标识
+            List<IotRyDailyReportDO> currentGroupIds = iotRyDailyReportService.ryWellNameDailyReportsGroupIds(currentTaskReqVO);
+            // key部门id-任务id   value小组内最后1条记录id
+            Map<String, Long> groupIdPair = new HashMap<>();
+            if (CollUtil.isNotEmpty(currentGroupIds)) {
+                currentGroupIds.forEach(groupId -> {
+                    String uniqueKey = StrUtil.join("-", groupId.getDeptId(), groupId.getTaskId());
+                    groupIdPair.put(uniqueKey, groupId.getId());
+                });
+            }
+
+            // 设置 分组内最后1条记录id 与 deptId-taskId 唯一键的对应关系
+            if (CollUtil.isNotEmpty(groupIdPair)) {
+                groupIdPair.forEach((uniqueKey, groupId) -> {
+                    if (groupFootagePair.containsKey(uniqueKey)) {
+                        groupIdFootagePair.put(groupId, groupFootagePair.get(uniqueKey));
+                    }
+                    if (groupFootageTimePair.containsKey(uniqueKey)) {
+                        groupIdFootageTimePair.put(groupId, groupFootageTimePair.get(uniqueKey));
+                    }
+                    if (groupOtherProductTimePair.containsKey(uniqueKey)) {
+                        groupIdOtherProductTimePair.put(groupId, groupOtherProductTimePair.get(uniqueKey));
+                    }
+                    if (groupProductTimePair.containsKey(uniqueKey)) {
+                        groupIdProductTimePair.put(groupId, groupProductTimePair.get(uniqueKey));
+                    }
+                    if (groupFuelPair.containsKey(uniqueKey)) {
+                        groupIdFuelPair.put(groupId, groupFuelPair.get(uniqueKey));
+                    }
+                    if (groupPowerPair.containsKey(uniqueKey)) {
+                        groupIdPowerPair.put(groupId, groupPowerPair.get(uniqueKey));
+                    }
+                    if (groupNoProductTimePair.containsKey(uniqueKey)) {
+                        groupIdNoProductTimePair.put(groupId, groupNoProductTimePair.get(uniqueKey));
+                    }
+                    if (groupZjNoProductTimePair.containsKey(uniqueKey)) {
+                        groupIdZjNoProductTimePair.put(groupId, groupZjNoProductTimePair.get(uniqueKey));
+                    }
+                });
+            }
+        });
+
+        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(), task.getWellName());
+                    taskTechniquePair.put(task.getId(), task.getTechnique());
+                    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());
+                                }
+                                if ("额定生产时间".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskRatedProductionTimePair.put(task.getId(), new BigDecimal(attr.getActualValue()));
+                                }
+                                if ("套生段产管尺寸".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskCasingPipeSizePair.put(task.getId(), attr.getActualValue());
+                                }
+                                if ("井控级别".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskWellControlLevelPair.put(task.getId(), attr.getActualValue());
+                                }
+                                if ("井别".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskWellCategoryPair.put(task.getId(), attr.getActualValue());
+                                }
+                            });
+                        }
+                    }
+                });
+            }
+            // 查询当前日报所属施工队伍中包含 井架 的型号
+            equipmentTypePair.set(iotRyDailyReportService.queryEquipmentType(convertList(reports, IotRyDailyReportDO::getDeptId)));
+            // 查询当前日报所属部门的 上井次完井时间 已经绑定任务的情况下
+            List<IotRyDailyReportDO> latestWellDoneTimes = iotRyDailyReportService.latestWellDoneTimes(null);
+            if (CollUtil.isNotEmpty(latestWellDoneTimes)) {
+                latestWellDoneTimes.forEach(time -> {
+                    latestWellDoneTimePair.put(time.getDeptId(), time.getConstructionStartDate());
+                });
+            }
+            // 按施工队伍统计 钻井日报 施工井数 完工井数
+            List<IotRyDailyReportTaskCountVO> deptTasks = iotRyDailyReportService.countTasksByDept();
+            // 修井日报 不存在既填写钻井日报 又填写修井日报的队伍
+            if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+                List<IotRyDailyReportTaskCountVO> repairDeptTasks = iotRyDailyReportService.countRepairTasksByDept(pageReqVO);
+                if (CollUtil.isNotEmpty(repairDeptTasks)) {
+                    repairDeptTasks.forEach(task -> {
+                        totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
+                        completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
+                    });
+                }
+            }
+            if (CollUtil.isNotEmpty(deptTasks)) {
+                deptTasks.forEach(task -> {
+                    totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
+                    completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
+                });
+            }
+        });
+        // 2. 拼接数据
+        return BeanUtils.toBean(reports, IotRyDailyReportRespVO.class, (reportVO) -> {
+            // 2.1 拼接部门信息
+            findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
+
+            // 小组内最后1条记录标识
+            findAndThen(groupIdFootagePair, reportVO.getId(), footage -> reportVO.setLastGroupIdFlag(true));
+            // 小组内累计进尺
+            findAndThen(groupIdFootagePair, reportVO.getId(), footage -> reportVO.setGroupIdFootage(footage));
+            // 小组内累计 进尺工作时间
+            findAndThen(groupIdFootageTimePair, reportVO.getId(), footageTime -> reportVO.setGroupIdFootageTime(footageTime));
+            // 小组内累计 其他生产时间
+            findAndThen(groupIdOtherProductTimePair, reportVO.getId(), otherProductTime -> reportVO.setGroupIdOtherProductTime(otherProductTime));
+            // 小组内累计 钻井 非生产时间
+            findAndThen(groupIdZjNoProductTimePair, reportVO.getId(), zjNoProductTime -> reportVO.setGroupIdZjNoProductTime(zjNoProductTime));
+            // 小组内累计用电量
+            findAndThen(groupIdPowerPair, reportVO.getId(), power -> reportVO.setGroupIdPower(power));
+            // 小组内累计油耗
+            findAndThen(groupIdFuelPair, reportVO.getId(), fuel -> reportVO.setGroupIdFuel(fuel));
+            // 修井 非生产时间
+            findAndThen(groupIdNoProductTimePair, reportVO.getId(), noProductTime -> reportVO.setNonProductionTime(noProductTime));
+            // 修井 生产时间
+            findAndThen(groupIdProductTimePair, reportVO.getId(), productTime -> reportVO.setGroupIdProductTime(productTime));
+
+            // 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));
+            // 施工工艺
+            findAndThen(taskTechniquePair, reportVO.getTaskId(), technique -> reportVO.setTechnique(technique));
+            // 井别
+            findAndThen(taskWellCategoryPair, reportVO.getTaskId(), wellCategory -> reportVO.setWellCategory(wellCategory));
+            // 额定生产时间
+            findAndThen(taskRatedProductionTimePair, reportVO.getTaskId(), ratedProductionTime -> reportVO.setRatedProductionTime(ratedProductionTime));
+            // 套生段产管尺寸
+            findAndThen(taskCasingPipeSizePair, reportVO.getTaskId(), casingPipeSize -> reportVO.setCasingPipeSize(casingPipeSize));
+            // 井控级别
+            findAndThen(taskWellControlLevelPair, reportVO.getTaskId(), wellControlLevel -> reportVO.setWellControlLevel(wellControlLevel));
+            // 2.5 设计井身结构
+            findAndThen(taskWellStructPair, reportVO.getTaskId(), wellStruct -> reportVO.setDesignWellStruct(wellStruct));
+            // 2.6 设备型号
+            findAndThen(equipmentTypePair.get(), reportVO.getDeptId(), equipmentType -> reportVO.setEquipmentType(equipmentType));
+            // 2.7 上井次完井时间
+            findAndThen(latestWellDoneTimePair, reportVO.getDeptId(), latestWellDoneTime -> reportVO.setLatestWellDoneTime(latestWellDoneTime));
+            // 2.8 总施工井数 完工井数
+            findAndThen(totalTasksPair, reportVO.getDeptId(), totalTaskCount -> reportVO.setTotalConstructionWells(totalTaskCount));
+            findAndThen(completedTasksPair, reportVO.getDeptId(), completedTaskCount -> reportVO.setCompletedWells(completedTaskCount));
+        });
+    }
+
+    /**
+     * 瑞鹰日报分页 设置关联查询信息
+     * @param reports
+     * @return
+     */
+    private List<IotRyDailyReportRespVO> buildWellRyDailyReports(List<IotRyDailyReportDO> reports, IotRyDailyReportPageReqVO pageReqVO) {
+        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, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
+        // key任务id   value套生段产管尺寸
+        Map<Long, String> taskCasingPipeSizePair = new HashMap<>();
+        // key任务id   value井控级别
+        Map<Long, String> taskWellControlLevelPair = new HashMap<>();
+        // key任务id   value施工工艺
+        Map<Long, String> taskTechniquePair = new HashMap<>();
+        // key任务id   value井别
+        Map<Long, String> taskWellCategoryPair = new HashMap<>();
+        // key任务id   value设计井身结构
+        Map<Long, String> taskWellStructPair = new HashMap<>();
+        // key部门id  value设备型号编号
+        AtomicReference<Map<Long, String>> equipmentTypePair = new AtomicReference<>(new HashMap<>());
+        // key施工队伍id    value最近完工日期
+        Map<Long, LocalDateTime> latestWellDoneTimePair = new HashMap<>();
+        // key施工队伍id    value施工井数量
+        Map<Long, Integer> totalTasksPair = new HashMap<>();
+        // key施工队伍id    value完工井数量
+        Map<Long, Integer> completedTasksPair = new HashMap<>();
+
+        // key部门id-队伍id   value 队伍累计进尺
+        Map<String, BigDecimal> groupFootagePair = new HashMap<>();
+        // key部门id-队伍id   value 队伍当年累计用电量
+        Map<String, BigDecimal> groupPowerPair = new HashMap<>();
+        // key部门id-队伍id   value 队伍当年累计油耗
+        Map<String, BigDecimal> groupFuelPair = new HashMap<>();
+        // key部门id-队伍id    value 进尺工作时间小计
+        Map<String, BigDecimal> groupFootageTimePair = new HashMap<>();
+        // key部门id-队伍id    value 钻井 其他生产时间小计
+        Map<String, BigDecimal> groupOtherProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 修井 生产时间小计
+        Map<String, BigDecimal> groupProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 修井 非生产时间小计
+        Map<String, BigDecimal> groupNoProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 钻井非生产时间小计
+        Map<String, BigDecimal> groupZjNoProductTimePair = new HashMap<>();
+        // key部门id-队伍id    value 小计平均运行时效
+        Map<String, BigDecimal> groupTransTimePair = new HashMap<>();
+
+        // key小组最后1条记录id   value 队伍累计进尺
+        Map<Long, BigDecimal> groupIdFootagePair = new HashMap<>();
+        // key小组最后1条记录id   value 队伍累计用电量
+        Map<Long, BigDecimal> groupIdPowerPair = new HashMap<>();
+        // key小组最后1条记录id   value 队伍累计油耗
+        Map<Long, BigDecimal> groupIdFuelPair = new HashMap<>();
+        // key小组最后1条记录id    value 进尺工作时间小计
+        Map<Long, BigDecimal> groupIdFootageTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 钻井 其他生产时间小计
+        Map<Long, BigDecimal> groupIdOtherProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 修井 生产时间小计
+        Map<Long, BigDecimal> groupIdProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 修井 非生产时间小计
+        Map<Long, BigDecimal> groupIdNoProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 钻井 非生产时间小计
+        Map<Long, BigDecimal> groupIdZjNoProductTimePair = new HashMap<>();
+        // key小组最后1条记录id    value 小计平均运行时效
+        Map<Long, BigDecimal> groupIdTransTimePair = new HashMap<>();
+
+        // 查询 当前分页 所有部门 任务井 日报数据 小计工作量
+        IotRyDailyReportPageReqVO currentTaskReqVO = new IotRyDailyReportPageReqVO();
+        currentTaskReqVO.setTaskIds(convertSet(reports, IotRyDailyReportDO::getTaskId));
+        currentTaskReqVO.setDeptIds(convertSet(reports, IotRyDailyReportDO::getDeptId));
+        currentTaskReqVO.setCreateTime(pageReqVO.getCreateTime());
+        currentTaskReqVO.setProjectIds(pageReqVO.getProjectIds());
+        currentTaskReqVO.setTaskIds(pageReqVO.getTaskIds());
+        List<IotRyDailyReportDO> deptTaskDailyReports = iotRyDailyReportMapper.dailyReports(currentTaskReqVO);
+
+        // 以 deptId-taskId 为唯一键 小计日报工作量
+        if (CollUtil.isNotEmpty(deptTaskDailyReports)) {
+            deptTaskDailyReports.forEach(report -> {
+                String uniqueKey = StrUtil.join("-", report.getDeptId(), report.getTaskId());
+                // 进尺
+                if (groupFootagePair.containsKey(uniqueKey)) {
+                    BigDecimal tempFootage = groupFootagePair.get(uniqueKey);
+                    BigDecimal tempResult = tempFootage.add(report.getDailyFootage());
+                    groupFootagePair.put(uniqueKey, tempResult);
+                } else {
+                    groupFootagePair.put(uniqueKey, report.getDailyFootage());
+                }
+                // 进尺工作时间
+                if (groupFootageTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempFootageTime = groupFootageTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempFootageTime.add(report.getDrillingWorkingTime());
+                    groupFootageTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupFootageTimePair.put(uniqueKey, report.getDrillingWorkingTime());
+                }
+                // 电量
+                if (groupPowerPair.containsKey(uniqueKey)) {
+                    BigDecimal tempPower = groupPowerPair.get(uniqueKey);
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    groupPowerPair.put(uniqueKey, tempResult);
+                } else {
+                    groupPowerPair.put(uniqueKey, report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (groupFuelPair.containsKey(uniqueKey)) {
+                    BigDecimal tempFuel = groupFuelPair.get(uniqueKey);
+                    BigDecimal tempResult = tempFuel.add(report.getDailyFuel());
+                    groupFuelPair.put(uniqueKey, tempResult);
+                } else {
+                    groupFuelPair.put(uniqueKey, report.getDailyFuel());
+                }
+                // 其他生产时间 钻井
+                if (groupOtherProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempNoProductTime = groupOtherProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempNoProductTime.add(report.getOtherProductionTime());
+                    groupOtherProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupOtherProductTimePair.put(uniqueKey, report.getOtherProductionTime());
+                }
+                // 生产时间 修井
+                if (groupProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempProductTime = groupProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempProductTime.add(report.getProductionTime());
+                    groupProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupProductTimePair.put(uniqueKey, report.getProductionTime());
+                }
+                // 非生产时间 修井
+                if (groupNoProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempNoProductTime = groupNoProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempNoProductTime.add(report.getNonProductionTime());
+                    groupNoProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupNoProductTimePair.put(uniqueKey, report.getNonProductionTime());
+                }
+                // 钻井 非生产时间 事故 修理 自停 复杂 搬迁 整改 等停 冬休
+                BigDecimal accidentTime = report.getAccidentTime();
+                BigDecimal repairTime = report.getRepairTime();
+                BigDecimal selfStopTime = report.getSelfStopTime();
+                BigDecimal complexityTime = report.getComplexityTime();
+                BigDecimal relocationTime = report.getRelocationTime();
+                BigDecimal rectificationTime = report.getRectificationTime();
+                BigDecimal waitingStopTime = report.getWaitingStopTime();
+                BigDecimal winterBreakTime = report.getWinterBreakTime();
+                BigDecimal totalNonProductionTime = Arrays.asList(
+                                accidentTime,
+                                repairTime,
+                                selfStopTime,
+                                complexityTime,
+                                relocationTime,
+                                rectificationTime,
+                                waitingStopTime,
+                                winterBreakTime
+                        ).stream()
+                        // 将null转换为BigDecimal.ZERO,避免空指针
+                        .map(bd -> bd == null ? BigDecimal.ZERO : bd)
+                        // 累加所有元素,初始值为BigDecimal.ZERO
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                // 非生产时间 钻井
+                if (groupZjNoProductTimePair.containsKey(uniqueKey)) {
+                    BigDecimal tempZjNoProductTime = groupZjNoProductTimePair.get(uniqueKey);
+                    BigDecimal tempResult = tempZjNoProductTime.add(totalNonProductionTime);
+                    groupZjNoProductTimePair.put(uniqueKey, tempResult);
+                } else {
+                    groupZjNoProductTimePair.put(uniqueKey, totalNonProductionTime);
+                }
+            });
+        }
+
+        // 查询 deptId-taskId 分组内最后1条记录id 设置展开列标识
+        // 暂时过滤掉租户
+        TenantUtils.executeIgnore(() -> {
+            currentTaskReqVO.setDeptId(pageReqVO.getDeptId());
+            List<IotRyDailyReportDO> currentGroupIds = iotRyDailyReportService.ryDeptDailyReportsGroupIds(currentTaskReqVO);
+            // key部门id-任务id   value小组内最后1条记录id
+            Map<String, Long> groupIdPair = new HashMap<>();
+            if (CollUtil.isNotEmpty(currentGroupIds)) {
+                currentGroupIds.forEach(groupId -> {
+                    String uniqueKey = StrUtil.join("-", groupId.getDeptId(), groupId.getTaskId());
+                    groupIdPair.put(uniqueKey, groupId.getId());
+                });
+            }
+
+            // 设置 分组内最后1条记录id 与 deptId-taskId 唯一键的对应关系
+            if (CollUtil.isNotEmpty(groupIdPair)) {
+                groupIdPair.forEach((uniqueKey, groupId) -> {
+                    if (groupFootagePair.containsKey(uniqueKey)) {
+                        groupIdFootagePair.put(groupId, groupFootagePair.get(uniqueKey));
+                    }
+                    if (groupFootageTimePair.containsKey(uniqueKey)) {
+                        groupIdFootageTimePair.put(groupId, groupFootageTimePair.get(uniqueKey));
+                    }
+                    if (groupOtherProductTimePair.containsKey(uniqueKey)) {
+                        groupIdOtherProductTimePair.put(groupId, groupOtherProductTimePair.get(uniqueKey));
+                    }
+                    if (groupProductTimePair.containsKey(uniqueKey)) {
+                        groupIdProductTimePair.put(groupId, groupProductTimePair.get(uniqueKey));
+                    }
+                    if (groupFuelPair.containsKey(uniqueKey)) {
+                        groupIdFuelPair.put(groupId, groupFuelPair.get(uniqueKey));
+                    }
+                    if (groupPowerPair.containsKey(uniqueKey)) {
+                        groupIdPowerPair.put(groupId, groupPowerPair.get(uniqueKey));
+                    }
+                    if (groupNoProductTimePair.containsKey(uniqueKey)) {
+                        groupIdNoProductTimePair.put(groupId, groupNoProductTimePair.get(uniqueKey));
+                    }
+                    if (groupZjNoProductTimePair.containsKey(uniqueKey)) {
+                        groupIdZjNoProductTimePair.put(groupId, groupZjNoProductTimePair.get(uniqueKey));
+                    }
+                });
+            }
+        });
+
+        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(), task.getWellName());
+                    taskTechniquePair.put(task.getId(), task.getTechnique());
+                    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());
+                                }
+                                if ("额定生产时间".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskRatedProductionTimePair.put(task.getId(), new BigDecimal(attr.getActualValue()));
+                                }
+                                if ("套生段产管尺寸".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskCasingPipeSizePair.put(task.getId(), attr.getActualValue());
+                                }
+                                if ("井控级别".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskWellControlLevelPair.put(task.getId(), attr.getActualValue());
+                                }
+                                if ("井别".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
+                                    taskWellCategoryPair.put(task.getId(), attr.getActualValue());
+                                }
+                            });
+                        }
+                    }
+                });
+            }
+            // 查询当前日报所属施工队伍中包含 井架 的型号
+            equipmentTypePair.set(iotRyDailyReportService.queryEquipmentType(convertList(reports, IotRyDailyReportDO::getDeptId)));
+            // 查询当前日报所属部门的 上井次完井时间 已经绑定任务的情况下
+            List<IotRyDailyReportDO> latestWellDoneTimes = iotRyDailyReportService.latestWellDoneTimes(null);
+            if (CollUtil.isNotEmpty(latestWellDoneTimes)) {
+                latestWellDoneTimes.forEach(time -> {
+                    latestWellDoneTimePair.put(time.getDeptId(), time.getConstructionStartDate());
+                });
+            }
+            // 按施工队伍统计 钻井日报 施工井数 完工井数
+            List<IotRyDailyReportTaskCountVO> deptTasks = iotRyDailyReportService.countTasksByDept();
+            // 修井日报 不存在既填写钻井日报 又填写修井日报的队伍
+            if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+                List<IotRyDailyReportTaskCountVO> repairDeptTasks = iotRyDailyReportService.countRepairTasksByDept(pageReqVO);
+                if (CollUtil.isNotEmpty(repairDeptTasks)) {
+                    repairDeptTasks.forEach(task -> {
+                        totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
+                        completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
+                    });
+                }
+            }
+            if (CollUtil.isNotEmpty(deptTasks)) {
+                deptTasks.forEach(task -> {
+                    totalTasksPair.put(task.getDeptId(), task.getTotalTaskCount());
+                    completedTasksPair.put(task.getDeptId(), task.getCompletedTaskCount());
+                });
+            }
+        });
+        // 2. 拼接数据
+        return BeanUtils.toBean(reports, IotRyDailyReportRespVO.class, (reportVO) -> {
+            // 2.1 拼接部门信息
+            findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
+
+            // 小组内最后1条记录标识
+            findAndThen(groupIdFootagePair, reportVO.getId(), footage -> reportVO.setLastGroupIdFlag(true));
+            // 小组内累计进尺
+            findAndThen(groupIdFootagePair, reportVO.getId(), footage -> reportVO.setGroupIdFootage(footage));
+            // 小组内累计 进尺工作时间
+            findAndThen(groupIdFootageTimePair, reportVO.getId(), footageTime -> reportVO.setGroupIdFootageTime(footageTime));
+            // 小组内累计 钻井 其他生产时间
+            findAndThen(groupIdOtherProductTimePair, reportVO.getId(), otherProductTime -> reportVO.setGroupIdOtherProductTime(otherProductTime));
+            // 小组内累计 钻井 非生产时间
+            findAndThen(groupIdZjNoProductTimePair, reportVO.getId(), zjNoProductTime -> reportVO.setGroupIdZjNoProductTime(zjNoProductTime));
+            // 小组内累计用电量
+            findAndThen(groupIdPowerPair, reportVO.getId(), power -> reportVO.setGroupIdPower(power));
+            // 小组内累计油耗
+            findAndThen(groupIdFuelPair, reportVO.getId(), fuel -> reportVO.setGroupIdFuel(fuel));
+            // 修井 非生产时间
+            findAndThen(groupIdNoProductTimePair, reportVO.getId(), noProductTime -> reportVO.setNonProductionTime(noProductTime));
+            // 修井 生产时间
+            findAndThen(groupIdProductTimePair, reportVO.getId(), productTime -> reportVO.setGroupIdProductTime(productTime));
+
+            // 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));
+            // 施工工艺
+            findAndThen(taskTechniquePair, reportVO.getTaskId(), technique -> reportVO.setTechnique(technique));
+            // 井别
+            findAndThen(taskWellCategoryPair, reportVO.getTaskId(), wellCategory -> reportVO.setWellCategory(wellCategory));
+            // 额定生产时间
+            findAndThen(taskRatedProductionTimePair, reportVO.getTaskId(), ratedProductionTime -> reportVO.setRatedProductionTime(ratedProductionTime));
+            // 套生段产管尺寸
+            findAndThen(taskCasingPipeSizePair, reportVO.getTaskId(), casingPipeSize -> reportVO.setCasingPipeSize(casingPipeSize));
+            // 井控级别
+            findAndThen(taskWellControlLevelPair, reportVO.getTaskId(), wellControlLevel -> reportVO.setWellControlLevel(wellControlLevel));
+            // 2.5 设计井身结构
+            findAndThen(taskWellStructPair, reportVO.getTaskId(), wellStruct -> reportVO.setDesignWellStruct(wellStruct));
+            // 2.6 设备型号
+            findAndThen(equipmentTypePair.get(), reportVO.getDeptId(), equipmentType -> reportVO.setEquipmentType(equipmentType));
+            // 2.7 上井次完井时间
+            findAndThen(latestWellDoneTimePair, reportVO.getDeptId(), latestWellDoneTime -> reportVO.setLatestWellDoneTime(latestWellDoneTime));
+            // 2.8 总施工井数 完工井数
+            findAndThen(totalTasksPair, reportVO.getDeptId(), totalTaskCount -> reportVO.setTotalConstructionWells(totalTaskCount));
+            findAndThen(completedTasksPair, reportVO.getDeptId(), completedTaskCount -> reportVO.setCompletedWells(completedTaskCount));
+        });
+    }
+
     @GetMapping("/polylineStatistics")
     @Operation(summary = "获得瑞鹰日报汇总统计 折线图")
     @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")

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

@@ -267,4 +267,33 @@ public class IotRyDailyReportRespVO {
 
     @Schema(description = "上次日报的 当前井深(m)")
     private BigDecimal lastCurrentDepth;
+
+    @Schema(description = "小组内累计进尺")
+    private BigDecimal groupIdFootage;
+    @Schema(description = "小组内累计进尺工作时间")
+    private BigDecimal groupIdFootageTime;
+    @Schema(description = "小组内累计其他生产时间 钻井")
+    private BigDecimal groupIdOtherProductTime;
+    @Schema(description = "小组内累计钻井非生产时间")
+    private BigDecimal groupIdZjNoProductTime;
+    @Schema(description = "小组内累计生产时间 修井")
+    private BigDecimal groupIdProductTime;
+    @Schema(description = "小组内累计钻井非生产时间 修井")
+    private BigDecimal groupIdXjNoProductTime;
+    @Schema(description = "小组内累计用电量")
+    private BigDecimal groupIdPower;
+    @Schema(description = "小组内累计油耗")
+    private BigDecimal groupIdFuel;
+
+    @Schema(description = "小组内平均运行时效")
+    private BigDecimal groupIdTransitTime;
+
+    @Schema(description = "小组内 总施工井数", example = "2")
+    private Integer groupConstructionWells;
+
+    @Schema(description = "小组内 完工井数", example = "2")
+    private Integer groupCompletedWells;
+
+    @Schema(description = "小组内最后1条记录标识 true false")
+    private boolean lastGroupIdFlag = false;
 }

+ 47 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrydailyreport/IotRyDailyReportMapper.java

@@ -6,9 +6,11 @@ import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportTaskCountVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -416,4 +418,49 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
             "AND (project_classification = 1 OR project_classification = '') " +
             "GROUP BY dept_id")
     List<IotRyDailyReportTaskCountVO> countDateRigTasksByDepartment();
+
+    /**
+     * 根据 井号 查询 瑞鹰日报 按照队伍分组 小计
+     * @param page
+     * @param reqVO
+     * @param projectIds
+     * @return
+     */
+    IPage<IotRyDailyReportDO> ryWellNameDailyReports(IPage<IotRyDailyReportDO> page, @Param("reqVO") IotRyDailyReportPageReqVO reqVO,
+                                                     @Param("taskIds") Collection<Long> taskIds,
+                                                     @Param("projectIds") Collection<Long> projectIds, @Param("deptIds") Collection<Long> deptIds);
+
+    /**
+     * 根据 井号 查询 瑞鹰日报 按照队伍分组 小计 查询小组内最后1条记录id
+     * @param page
+     * @param reqVO
+     * @param projectIds
+     * @return
+     */
+    @TenantIgnore
+    List<IotRyDailyReportDO> ryWellNameDailyReportsGroupIds(IPage<IotRyDailyReportDO> page, @Param("reqVO") IotRyDailyReportPageReqVO reqVO,
+                                                            @Param("taskIds") Collection<Long> taskIds,
+                                                            @Param("projectIds") Collection<Long> projectIds, @Param("deptIds") Collection<Long> deptIds);
+
+    /**
+     * 根据 队伍 查询 瑞鹰日报 按照任务井分组 小计
+     * @param page
+     * @param reqVO
+     * @param projectIds
+     * @return
+     */
+    IPage<IotRyDailyReportDO> ryDeptDailyReports(IPage<IotRyDailyReportDO> page, @Param("reqVO") IotRyDailyReportPageReqVO reqVO,
+                                                 @Param("taskIds") Collection<Long> taskIds,
+                                                 @Param("projectIds") Collection<Long> projectIds, @Param("deptIds") Collection<Long> deptIds);
+
+    /**
+     * 以队伍为维度 查询 井号 分组后的 瑞鹰日报 按照任务井分组 小计 查询小组内最后1条记录id
+     * @param page
+     * @param reqVO
+     * @param projectIds
+     * @return
+     */
+    List<IotRyDailyReportDO> ryDeptDailyReportsGroupIds(IPage<IotRyDailyReportDO> page, @Param("reqVO") IotRyDailyReportPageReqVO reqVO,
+                                                        @Param("taskIds") Collection<Long> taskIds,
+                                                        @Param("projectIds") Collection<Long> projectIds, @Param("deptIds") Collection<Long> deptIds);
 }

+ 34 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportService.java

@@ -1,7 +1,9 @@
 package cn.iocoder.yudao.module.pms.service.iotrydailyreport;
 
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.*;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
 
 import javax.validation.Valid;
@@ -150,4 +152,36 @@ public interface IotRyDailyReportService {
      */
     void approvalRyDailyReport(IotRyDailyReportSaveReqVO updateReqVO);
 
+    /**
+     * 获得瑞鹰日报分页 以井为维度统计工作量
+     *
+     * @param pageReqVO 分页查询
+     * @return 瑞鹰日报分页
+     */
+    PageResult<IotRyDailyReportDO> teamReports(IotRyDailyReportPageReqVO pageReqVO);
+
+    /**
+     * 根据 队伍 查询 瑞鹰日报 按照任务井分组 小计 查询小组内最后1条记录id
+     *
+     * @param pageReqVO 列表查询
+     * @return 瑞鹰日报 列表 小组内最后 的记录
+     */
+    List<IotRyDailyReportDO> ryDeptDailyReportsGroupIds(IotRyDailyReportPageReqVO pageReqVO);
+
+    /**
+     * 根据 井号 查询 瑞鹰日报 按照队伍分组 小计 查询小组内最后1条记录id
+     *
+     * @param pageReqVO 列表查询
+     * @return 瑞鹰日报 列表 小组内最后 的记录
+     */
+    List<IotRyDailyReportDO> ryWellNameDailyReportsGroupIds(IotRyDailyReportPageReqVO pageReqVO);
+
+    /**
+     * 获得瑞鹰日报分页 以队伍为维度统计工作量
+     *
+     * @param pageReqVO 分页查询
+     * @return 瑞鹰日报分页
+     */
+    PageResult<IotRyDailyReportDO> wellReports(IotRyDailyReportPageReqVO pageReqVO);
+
 }

+ 79 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportServiceImpl.java

@@ -42,6 +42,8 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
 import cn.iocoder.yudao.module.system.service.permission.RoleService;
 import cn.iocoder.yudao.module.system.service.user.AdminUserService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -876,6 +878,83 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
         iotRyDailyReportMapper.updateById(dailyReport);
     }
 
+    @Override
+    public PageResult<IotRyDailyReportDO> teamReports(IotRyDailyReportPageReqVO pageReqVO) {
+        // 查询选择部门下面所有子部门
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+            pageReqVO.setDeptIds(ids);
+        }
+        // 检查contractName不为空但projectIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getContractName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
+            return new PageResult<>(Collections.emptyList(), 0L);
+        }
+        // 检查taskName不为空但taskIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
+            return new PageResult<>(Collections.emptyList(), 0L);
+        }
+        IPage<IotRyDailyReportDO> page = iotRyDailyReportMapper.ryWellNameDailyReports(
+                new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO,
+                pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
+        return new PageResult<>(page.getRecords(), page.getTotal());
+    }
+
+    @Override
+    public List<IotRyDailyReportDO> ryDeptDailyReportsGroupIds(IotRyDailyReportPageReqVO pageReqVO) {
+        // 查询选择部门下面所有子部门
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+            pageReqVO.setDeptIds(ids);
+        }
+        List<IotRyDailyReportDO> groupIds = iotRyDailyReportMapper.ryDeptDailyReportsGroupIds(
+                new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO,
+                pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
+        return groupIds;
+    }
+
+    @Override
+    public List<IotRyDailyReportDO> ryWellNameDailyReportsGroupIds(IotRyDailyReportPageReqVO pageReqVO) {
+        // 查询选择部门下面所有子部门
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+            pageReqVO.setDeptIds(ids);
+        }
+        List<IotRyDailyReportDO> groupIds = iotRyDailyReportMapper.ryWellNameDailyReportsGroupIds(
+                new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO,
+                pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
+        return groupIds;
+    }
+
+    @Override
+    public PageResult<IotRyDailyReportDO> wellReports(IotRyDailyReportPageReqVO pageReqVO) {
+        // 查询选择部门下面所有子部门
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+            pageReqVO.setDeptIds(ids);
+        }
+        // 检查contractName不为空但projectIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getContractName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
+            return new PageResult<>(Collections.emptyList(), 0L);
+        }
+        // 检查taskName不为空但taskIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
+            return new PageResult<>(Collections.emptyList(), 0L);
+        }
+        IPage<IotRyDailyReportDO> page = iotRyDailyReportMapper.ryDeptDailyReports(
+                new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO,
+                pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
+
+        return new PageResult<>(page.getRecords(), page.getTotal());
+    }
+
     private List<IotDeviceDO> devices() {
         // 查询 瑞鹰158l 所有存在设备的队伍
         // 查询 瑞鹰 下所有部门

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -22,6 +22,7 @@
         <result column="daily_inject_gas_time" property="dailyInjectGasTime" />
         <result column="daily_inject_water_time" property="dailyInjectWaterTime" />
         <result column="daily_power_usage" property="dailyPowerUsage" />
+        <result column="daily_oil_usage" property="dailyOilUsage" />
         <!-- 其他字段映射 -->
         <result column="non_production_time" property="nonProductionTime" />
         <result column="npt_reason" property="nptReason" />

+ 249 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRyDailyReportMapper.xml

@@ -14,6 +14,45 @@
         <result column="construction_end_date" property="constructionEndDate" />
         <result column="relocation_days" property="relocationDays" />
         <!-- 其他字段映射 -->
+        <result column="project_classification" property="projectClassification" />
+        <result column="current_depth" property="currentDepth" />
+        <result column="daily_footage" property="dailyFootage" />
+        <result column="monthly_footage" property="monthlyFootage" />
+        <result column="annual_footage" property="annualFootage" />
+        <result column="daily_power_usage" property="dailyPowerUsage" />
+        <result column="daily_fuel" property="dailyFuel" />
+        <result column="production_time" property="productionTime" />
+        <result column="non_production_time" property="nonProductionTime" />
+        <result column="ry_npt_reason" property="ryNptReason" />
+        <result column="drilling_working_time" property="drillingWorkingTime" />
+        <result column="other_production_time" property="otherProductionTime" />
+        <result column="accident_time" property="accidentTime" />
+        <result column="repair_time" property="repairTime" />
+        <result column="self_stop_time" property="selfStopTime" />
+        <result column="complexity_time" property="complexityTime" />
+        <result column="relocation_time" property="relocationTime" />
+        <result column="rectification_time" property="rectificationTime" />
+        <result column="waiting_stop_time" property="waitingStopTime" />
+        <result column="winter_break_time" property="winterBreakTime" />
+        <result column="production_status" property="productionStatus" />
+
+        <result column="current_operation" property="currentOperation" />
+        <result column="next_plan" property="nextPlan" />
+        <result column="rig_status" property="rigStatus" />
+        <result column="repair_status" property="repairStatus" />
+        <result column="personnel" property="personnel" />
+
+        <result column="total_staff_num" property="totalStaffNum" />
+        <result column="leave_staff_num" property="leaveStaffNum" />
+        <result column="mud_density" property="mudDensity" />
+        <result column="mud_viscosity" property="mudViscosity" />
+        <result column="lateral_length" property="lateralLength" />
+
+        <result column="well_inclination" property="wellInclination" />
+        <result column="azimuth" property="azimuth" />
+        <result column="mud_density" property="mudDensity" />
+        <result column="mud_viscosity" property="mudViscosity" />
+        <result column="lateral_length" property="lateralLength" />
     </resultMap>
 
     <select id="selectListGrouped" resultMap="BaseResultMap"
@@ -81,4 +120,214 @@
         ) r2 ON r1.dept_id = r2.dept_id AND r1.create_time = r2.max_create_time
         WHERE r1.rig_status = 'wg';
     </select>
+
+    <select id="ryWellNameDailyReports" resultMap="BaseResultMap"
+            parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO">
+        SELECT
+        rdr.*
+        FROM
+        rq_iot_ry_daily_report rdr
+        INNER JOIN system_dept d ON d.id = rdr.dept_id
+        LEFT JOIN system_dept pd ON pd.id = d.parent_id
+        WHERE
+        rdr.deleted = 0
+        AND rdr.dept_id IS NOT NULL
+        <if test="deptIds != null and deptIds.size &gt; 0">
+            AND rdr.dept_id IN
+            <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="projectIds != null and projectIds.size &gt; 0">
+            AND rdr.project_id IN
+            <foreach collection="projectIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="taskIds != null and taskIds.size &gt; 0">
+            AND rdr.task_id IN
+            <foreach collection="taskIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="reqVO.createTime != null and reqVO.createTime.length > 0">
+            <!-- 处理“开始时间”(数组第1位,如 createTime[0] = 2024-01-01 00:00:00) -->
+            <if test="reqVO.createTime[0] != null">
+                AND rdr.create_time &gt;= #{reqVO.createTime[0]}
+            </if>
+            <!-- 处理“结束时间”(数组第2位,如 createTime[1] = 2024-01-31 23:59:59) -->
+            <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
+                AND rdr.create_time &lt;= #{reqVO.createTime[1]}
+            </if>
+        </if>
+        ORDER BY
+        COALESCE(pd.sort, 999999) ASC,
+        d.sort ASC,
+        DATE(rdr.create_time) DESC;
+    </select>
+
+    <select id="ryWellNameDailyReportsGroupIds" resultMap="BaseResultMap"
+            parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO">
+        WITH sorted_data AS (
+        SELECT
+            rdr.id,
+            rdr.dept_id,
+            rdr.task_id,
+            ROW_NUMBER() OVER (
+            PARTITION BY rdr.dept_id, rdr.task_id
+            ORDER BY
+            COALESCE(pd.sort, 999999) DESC,  -- 反转:ASC -> DESC
+            d.sort DESC,                     -- 反转:ASC -> DESC
+            rdr.task_id ASC,                 -- 反转:DESC -> ASC
+            DATE(rdr.create_time) ASC        -- 反转:DESC -> ASC
+            ) AS rn
+        FROM
+            rq_iot_ry_daily_report rdr
+        INNER JOIN system_dept d ON d.id = rdr.dept_id
+        LEFT JOIN system_dept pd ON pd.id = d.parent_id
+        WHERE
+        rdr.deleted = 0
+        AND rdr.dept_id IS NOT NULL
+        <if test="deptIds != null and deptIds.size &gt; 0">
+            AND rdr.dept_id IN
+            <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="projectIds != null and projectIds.size &gt; 0">
+            AND rdr.project_id IN
+            <foreach collection="projectIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="taskIds != null and taskIds.size &gt; 0">
+            AND rdr.task_id IN
+            <foreach collection="taskIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="reqVO.createTime != null and reqVO.createTime.length > 0">
+            <!-- 处理“开始时间”(数组第1位,如 createTime[0] = 2024-01-01 00:00:00) -->
+            <if test="reqVO.createTime[0] != null">
+                AND rdr.create_time &gt;= #{reqVO.createTime[0]}
+            </if>
+            <!-- 处理“结束时间”(数组第2位,如 createTime[1] = 2024-01-31 23:59:59) -->
+            <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
+                AND rdr.create_time &lt;= #{reqVO.createTime[1]}
+            </if>
+        </if>
+        )
+        SELECT
+        id,
+        dept_id,
+        task_id
+        FROM sorted_data
+        WHERE rn = 1
+    </select>
+
+    <select id="ryDeptDailyReports" resultMap="BaseResultMap"
+            parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO">
+        SELECT
+            rdr.*
+        FROM
+            rq_iot_ry_daily_report rdr
+        INNER JOIN system_dept d ON d.id = rdr.dept_id
+        LEFT JOIN system_dept pd ON pd.id = d.parent_id
+        WHERE
+        rdr.deleted = 0
+        AND rdr.dept_id IS NOT NULL
+        <if test="deptIds != null and deptIds.size &gt; 0">
+            AND rdr.dept_id IN
+            <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="projectIds != null and projectIds.size &gt; 0">
+            AND rdr.project_id IN
+            <foreach collection="projectIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="taskIds != null and taskIds.size &gt; 0">
+            AND rdr.task_id IN
+            <foreach collection="taskIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="reqVO.createTime != null and reqVO.createTime.length > 0">
+            <!-- 处理“开始时间”(数组第1位,如 createTime[0] = 2024-01-01 00:00:00) -->
+            <if test="reqVO.createTime[0] != null">
+                AND rdr.create_time &gt;= #{reqVO.createTime[0]}
+            </if>
+            <!-- 处理“结束时间”(数组第2位,如 createTime[1] = 2024-01-31 23:59:59) -->
+            <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
+                AND rdr.create_time &lt;= #{reqVO.createTime[1]}
+            </if>
+        </if>
+        ORDER BY
+            rdr.task_id DESC,
+            COALESCE(pd.sort, 999999) ASC,
+            d.sort ASC,
+            DATE(rdr.create_time) DESC;
+    </select>
+
+    <select id="ryDeptDailyReportsGroupIds" resultMap="BaseResultMap"
+            parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO">
+        WITH sorted_data AS (
+        SELECT
+            rdr.id,
+            rdr.dept_id,
+            rdr.task_id,
+            ROW_NUMBER() OVER (
+            PARTITION BY rdr.dept_id, rdr.task_id
+            ORDER BY
+            rdr.task_id ASC,                 -- 反转:DESC -> ASC
+            COALESCE(pd.sort, 999999) DESC,  -- 反转:ASC -> DESC
+            d.sort DESC,                     -- 反转:ASC -> DESC
+            DATE(rdr.create_time) ASC        -- 反转:DESC -> ASC
+            ) AS rn
+        FROM
+            rq_iot_ry_daily_report rdr
+        INNER JOIN system_dept d ON d.id = rdr.dept_id
+        LEFT JOIN system_dept pd ON pd.id = d.parent_id
+        WHERE
+            rdr.deleted = 0
+        AND rdr.dept_id IS NOT NULL
+        <if test="deptIds != null and deptIds.size &gt; 0">
+            AND rdr.dept_id IN
+            <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="projectIds != null and projectIds.size &gt; 0">
+            AND rdr.project_id IN
+            <foreach collection="projectIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="taskIds != null and taskIds.size &gt; 0">
+            AND rdr.task_id IN
+            <foreach collection="taskIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
+        <if test="reqVO.createTime != null and reqVO.createTime.length > 0">
+            <!-- 处理“开始时间”(数组第1位,如 createTime[0] = 2024-01-01 00:00:00) -->
+            <if test="reqVO.createTime[0] != null">
+                AND rdr.create_time &gt;= #{reqVO.createTime[0]}
+            </if>
+            <!-- 处理“结束时间”(数组第2位,如 createTime[1] = 2024-01-31 23:59:59) -->
+            <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
+                AND rdr.create_time &lt;= #{reqVO.createTime[1]}
+            </if>
+        </if>
+        )
+        SELECT
+            id,
+            dept_id,
+            task_id
+        FROM sorted_data
+        WHERE rn = 1
+    </select>
+
 </mapper>