Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

Zimo před 1 měsícem
rodič
revize
2abdb91940

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

@@ -490,6 +490,70 @@ public class IotRyDailyReportController {
         return success(resultMap);
     }
 
+    @GetMapping("/exportNptStatistics")
+    @Operation(summary = "导出 瑞鹰日报 非生产时效 统计")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:export')")
+    public void exportNptStatistics(@Valid IotRyDailyReportPageReqVO pageReqVO,
+                                    HttpServletResponse response) throws IOException {
+        // 根据查询参数筛选出 符合条件 的记录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<IotRyDailyReportNptStatisticsRespVO> statistics = iotRyDailyReportService.nptStatistics(pageReqVO);
+
+        if (CollUtil.isNotEmpty(statistics)) {
+            statistics.forEach(stat -> {
+                // 将npt合计占比转换成 % 形式
+                BigDecimal nptRate = stat.getNptRate();
+                if (ObjUtil.isEmpty(nptRate) || nptRate.compareTo(BigDecimal.ZERO) == 0) {
+                    stat.setNptRateFormat("0.00%");
+                } else {
+                    // 转换逻辑:乘以100 → 保留2位小数(四舍五入)→ 拼接%
+                    BigDecimal percent = nptRate.multiply(new BigDecimal("100"))
+                            .setScale(2, RoundingMode.HALF_UP);
+                    stat.setNptRateFormat(percent + "%");
+                }
+            });
+        }
+
+        String sheetName = StrUtil.EMPTY;
+        if ("1".equals(pageReqVO.getProjectClassification())) {
+            // 钻井日报汇总数据
+            sheetName = "钻井日报NPT汇总";
+            // 导出 Excel
+            ExcelUtils.write(response, "瑞鹰日报非生产时效汇总.xls", sheetName,
+                    IotRyDailyReportNptStatisticsRespVO.class, statistics);
+        } else {
+            // 修井日报汇总数据
+            sheetName = "修井日报NPT汇总";
+            // 导出 Excel
+            ExcelUtils.write(response, "瑞鹰日报非生产时效汇总.xls", sheetName,
+                    IotRyDailyReportNptStatisticsRespVO.class, statistics);
+        }
+
+    }
+
     private List<IotRyDailyReportRespVO> buildProductionBriefs(List<IotRyDailyReportDO> reports, IotRyDailyReportPageReqVO pageReqVO) {
         if (CollUtil.isEmpty(reports)) {
             return Collections.emptyList();

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

@@ -67,7 +67,7 @@ public class IotRyDailyReportNptStatisticsRespVO {
     private BigDecimal waitingStopTime;
 
     @Schema(description = "冬休非生产时间(H)")
-    @ExcelProperty("待命T")
+    @ExcelProperty("待命H")
     private BigDecimal winterBreakTime;
 
     @Schema(description = "甲方设计-非生产时间")
@@ -86,12 +86,19 @@ public class IotRyDailyReportNptStatisticsRespVO {
     @ExcelProperty("其它非生产时间H")
     private BigDecimal otherNptTime;
 
-    @Schema(description = "自然时间H")
-    private BigDecimal calendarTime;
+    @Schema(description = "NPT合计-时长H")
+    @ExcelProperty("NPT合计时长H")
+    private BigDecimal nptTotal;
 
     @Schema(description = "非生产时效")
     private BigDecimal nptRate = BigDecimal.ZERO;
 
-    @Schema(description = "NPT合计")
-    private BigDecimal nptTotal;
+    @Schema(description = "非生产时效 %形式")
+    @ExcelProperty("NPT合计占比")
+    private String nptRateFormat;
+
+    @Schema(description = "自然时间H")
+    @ExcelProperty("自然时间H")
+    private BigDecimal calendarTime;
+
 }

+ 155 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -4060,10 +4060,18 @@ public class IotStaticController {
         Map<Long, Integer> projectReportPair = new HashMap<>();
         // 过滤掉 ‘设备保养、生产配合、待命’ 之外的非生产时间集合
         Map<String, Integer> nptTeamPair = new HashMap<>();
+        // key非生产时间名称  value钻井业务类型数量
+        Map<String, Integer> nptZjPair = new HashMap<>();
+        // key非生产时间名称  value修井业务类型数量
+        Map<String, Integer> nptXjPair = new HashMap<>();
+
         List<NptCountVo> resultNptCounts = new ArrayList<>();
         if (CollUtil.isNotEmpty(dailyReports)) {
             // 整理出每个项目部下的队伍填报的日报数量
             dailyReports.forEach(report -> {
+                // 业务类型 1钻井 2修井
+                String classification = report.getProjectClassification();
+                boolean zjFlag = "1".equals(classification) ? true : false;
                 if (CollUtil.isNotEmpty(projectTeamPair)) {
                     projectTeamPair.forEach((projectDeptId, teamDeptIds) -> {
                         if (teamDeptIds.contains(report.getDeptId())) {
@@ -4082,6 +4090,22 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("工程质量", 1);
                                 }
+                                // 设置不同业务类型的 npt 数量
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("工程质量")) {
+                                        Integer tempCount = nptZjPair.get("工程质量");
+                                        nptZjPair.put("工程质量", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("工程质量", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("工程质量")) {
+                                        Integer tempCount = nptXjPair.get("工程质量");
+                                        nptXjPair.put("工程质量", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("工程质量", 1);
+                                    }
+                                }
                             }
                             BigDecimal repairTime = report.getRepairTime();
                             if (ObjUtil.isNotEmpty(repairTime) && repairTime.compareTo(BigDecimal.ZERO)>0) {
@@ -4091,6 +4115,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("设备故障", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("设备故障")) {
+                                        Integer tempCount = nptZjPair.get("设备故障");
+                                        nptZjPair.put("设备故障", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("设备故障", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("设备故障")) {
+                                        Integer tempCount = nptXjPair.get("设备故障");
+                                        nptXjPair.put("设备故障", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("设备故障", 1);
+                                    }
+                                }
                             }
                             BigDecimal complexityTime = report.getComplexityTime();
                             if (ObjUtil.isNotEmpty(complexityTime) && complexityTime.compareTo(BigDecimal.ZERO)>0) {
@@ -4100,6 +4139,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("技术受限", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("技术受限")) {
+                                        Integer tempCount = nptZjPair.get("技术受限");
+                                        nptZjPair.put("技术受限", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("技术受限", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("技术受限")) {
+                                        Integer tempCount = nptXjPair.get("技术受限");
+                                        nptXjPair.put("技术受限", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("技术受限", 1);
+                                    }
+                                }
                             }
                             BigDecimal rectificationTime = report.getRectificationTime();
                             if (ObjUtil.isNotEmpty(rectificationTime) && rectificationTime.compareTo(BigDecimal.ZERO)>0) {
@@ -4109,6 +4163,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("生产组织", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("生产组织")) {
+                                        Integer tempCount = nptZjPair.get("生产组织");
+                                        nptZjPair.put("生产组织", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("生产组织", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("生产组织")) {
+                                        Integer tempCount = nptXjPair.get("生产组织");
+                                        nptXjPair.put("生产组织", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("生产组织", 1);
+                                    }
+                                }
                             }
                             BigDecimal waitingStopTime = report.getWaitingStopTime();
                             if (ObjUtil.isNotEmpty(waitingStopTime) && waitingStopTime.compareTo(BigDecimal.ZERO)>0) {
@@ -4118,6 +4187,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("不可抗力", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("不可抗力")) {
+                                        Integer tempCount = nptZjPair.get("不可抗力");
+                                        nptZjPair.put("不可抗力", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("不可抗力", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("不可抗力")) {
+                                        Integer tempCount = nptXjPair.get("不可抗力");
+                                        nptXjPair.put("不可抗力", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("不可抗力", 1);
+                                    }
+                                }
                             }
                             BigDecimal partyaDesign = report.getPartyaDesign();
                             if (ObjUtil.isNotEmpty(partyaDesign) && partyaDesign.compareTo(BigDecimal.ZERO)>0) {
@@ -4127,6 +4211,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("甲方设计", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("甲方设计")) {
+                                        Integer tempCount = nptZjPair.get("甲方设计");
+                                        nptZjPair.put("甲方设计", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("甲方设计", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("甲方设计")) {
+                                        Integer tempCount = nptXjPair.get("甲方设计");
+                                        nptXjPair.put("甲方设计", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("甲方设计", 1);
+                                    }
+                                }
                             }
                             BigDecimal partyaPrepare = report.getPartyaPrepare();
                             if (ObjUtil.isNotEmpty(partyaPrepare) && partyaPrepare.compareTo(BigDecimal.ZERO)>0) {
@@ -4136,6 +4235,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("甲方准备", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("甲方准备")) {
+                                        Integer tempCount = nptZjPair.get("甲方准备");
+                                        nptZjPair.put("甲方准备", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("甲方准备", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("甲方准备")) {
+                                        Integer tempCount = nptXjPair.get("甲方准备");
+                                        nptXjPair.put("甲方准备", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("甲方准备", 1);
+                                    }
+                                }
                             }
                             BigDecimal partyaResource = report.getPartyaResource();
                             if (ObjUtil.isNotEmpty(partyaResource) && partyaResource.compareTo(BigDecimal.ZERO)>0) {
@@ -4145,6 +4259,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("甲方资源", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("甲方资源")) {
+                                        Integer tempCount = nptZjPair.get("甲方资源");
+                                        nptZjPair.put("甲方资源", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("甲方资源", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("甲方资源")) {
+                                        Integer tempCount = nptXjPair.get("甲方资源");
+                                        nptXjPair.put("甲方资源", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("甲方资源", 1);
+                                    }
+                                }
                             }
                             BigDecimal otherNptTime = report.getOtherNptTime();
                             if (ObjUtil.isNotEmpty(otherNptTime) && otherNptTime.compareTo(BigDecimal.ZERO)>0) {
@@ -4154,6 +4283,21 @@ public class IotStaticController {
                                 } else {
                                     nptTeamPair.put("其它非生产时间", 1);
                                 }
+                                if (zjFlag) {
+                                    if (nptZjPair.containsKey("其它非生产时间")) {
+                                        Integer tempCount = nptZjPair.get("其它非生产时间");
+                                        nptZjPair.put("其它非生产时间", ++tempCount);
+                                    } else {
+                                        nptZjPair.put("其它非生产时间", 1);
+                                    }
+                                } else {
+                                    if (nptXjPair.containsKey("其它非生产时间")) {
+                                        Integer tempCount = nptXjPair.get("其它非生产时间");
+                                        nptXjPair.put("其它非生产时间", ++tempCount);
+                                    } else {
+                                        nptXjPair.put("其它非生产时间", 1);
+                                    }
+                                }
                             }
                         }
                     });
@@ -4165,6 +4309,17 @@ public class IotStaticController {
                     NptCountVo countVo = new NptCountVo();
                     countVo.setNptName(nptName);
                     countVo.setTeamCount(teamCount);
+                    Map<String, Integer> classificationPair = new HashMap<>();
+                    // 设置每个非生产时间 对应的 业务类型 zj xj
+                    if (nptZjPair.containsKey(nptName)) {
+                        Integer zjCount = nptZjPair.get(nptName);
+                        classificationPair.put("zj", zjCount);
+                    }
+                    if (nptXjPair.containsKey(nptName)) {
+                        Integer xjCount = nptXjPair.get(nptName);
+                        classificationPair.put("xj", xjCount);
+                    }
+                    countVo.setClassificationPair(classificationPair);
                     resultNptCounts.add(countVo);
                 });
             }

+ 6 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/vo/NptCountVo.java

@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.pms.controller.admin.stat.vo;
 import lombok.Data;
 import lombok.ToString;
 
+import java.util.Map;
+
 /**
  * 生产异常 日报非生产时间 返回对象
  */
@@ -18,4 +20,8 @@ public class NptCountVo {
      * 非生产时间队伍数量
      */
     private Integer teamCount;
+    /**
+     * 数据穿透标识 key(zj xj)  value每种类型对应的数量
+     */
+    private Map<String, Integer> classificationPair;
 }