Przeglądaj źródła

pms 瑞都 生产时效分析 代码初始化

zhangcl 4 dni temu
rodzic
commit
574081c407

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

@@ -1074,6 +1074,44 @@ public class IotRdDailyReportController {
         return success(resultMap);
     }
 
+    @GetMapping("/nptStatistics")
+    @Operation(summary = "瑞都日报 非生产时效 分析")
+    @PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
+    public CommonResult<Map<String, Object>> nptStatistics(@Valid IotRdDailyReportPageReqVO pageReqVO) {
+        List<IotRdDailyReportNptStatisticsRespVO> result = new ArrayList<>();
+        Map<String, Object> resultMap = new HashMap<>();
+        // 根据查询参数筛选出 符合条件 的记录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<IotRdDailyReportNptStatisticsRespVO> statistics = iotRdDailyReportService.nptStatistics(pageReqVO);
+        result.addAll(statistics);
+        resultMap.put("list", result);
+        resultMap.put("total", result.size());
+        return success(resultMap);
+    }
+
     @GetMapping("/abnormalAlert")
     @Operation(summary = "瑞都日报 看板 异常警示")
     @PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")

+ 108 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/vo/IotRdDailyReportNptStatisticsRespVO.java

@@ -0,0 +1,108 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Schema(description = "管理后台 - 瑞都日报 统计 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotRdDailyReportNptStatisticsRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13853")
+    private Long id;
+
+    @Schema(description = "项目部id", example = "125")
+    private Long deptId;
+
+    @Schema(description = "项目部id", example = "125")
+    private Long projectDeptId;
+
+    @Schema(description = "项目部名称", example = "西南压裂项目部")
+    @ExcelProperty("项目部名称")
+    private String projectDeptName;
+
+    @Schema(description = "队伍名称", example = "压裂二队")
+    @ExcelProperty("队伍名称")
+    private String deptName;
+
+    @Schema(description = "队伍id", example = "125")
+    private Long teamId;
+
+    @Schema(description = "队伍名称", example = "HY-A1")
+    @ExcelProperty("队伍名称")
+    private String teamName;
+
+    @Schema(description = "部门类型(公司级1 项目部2 队伍3)", example = "1")
+    private String type;
+
+    @Schema(description = "任务id", example = "15678")
+    private Long taskId;
+
+    @Schema(description = "井号")
+    @ExcelProperty("井号")
+    private String wellName;
+
+    @Schema(description = "排序", example = "1")
+    private Integer sort;
+
+    @Schema(description = "事故非生产时间(H)")
+    @ExcelProperty("工程质量H")
+    private BigDecimal accidentTime;
+
+    @Schema(description = "修理非生产时间(H)")
+    @ExcelProperty("设备故障H")
+    private BigDecimal repairTime;
+
+    @Schema(description = "自停非生产时间(H)")
+    @ExcelProperty("设备保养H")
+    private BigDecimal selfStopTime;
+
+    @Schema(description = "复杂非生产时间(H)")
+    @ExcelProperty("技术受限H")
+    private BigDecimal complexityTime;
+
+    @Schema(description = "搬迁非生产时间(H)")
+    @ExcelProperty("生产配合H")
+    private BigDecimal relocationTime;
+
+    @Schema(description = "整改非生产时间(H)")
+    @ExcelProperty("生产组织H")
+    private BigDecimal rectificationTime;
+
+    @Schema(description = "等停非生产时间(H)")
+    @ExcelProperty("不可抗力H")
+    private BigDecimal waitingStopTime;
+
+    @Schema(description = "冬休非生产时间(H)")
+    @ExcelProperty("待命T")
+    private BigDecimal winterBreakTime;
+
+    @Schema(description = "甲方设计-非生产时间")
+    @ExcelProperty("甲方设计H")
+    private BigDecimal partyaDesign;
+
+    @Schema(description = "甲方准备-非生产时间")
+    @ExcelProperty("甲方准备H")
+    private BigDecimal partyaPrepare;
+
+    @Schema(description = "甲方资源-非生产时间")
+    @ExcelProperty("甲方资源H")
+    private BigDecimal partyaResource;
+
+    @Schema(description = "其它非生产时间H")
+    @ExcelProperty("其它非生产时间H")
+    private BigDecimal otherNptTime;
+
+    @Schema(description = "自然时间H")
+    private BigDecimal calendarTime;
+
+    @Schema(description = "非生产时效")
+    private BigDecimal nptRate = BigDecimal.ZERO;
+
+    @Schema(description = "NPT合计")
+    private BigDecimal nptTotal;
+}

+ 6 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotoperationmeeting/IotOperationMeetingServiceImpl.java

@@ -122,12 +122,14 @@ public class IotOperationMeetingServiceImpl implements IotOperationMeetingServic
             meeting.setDeptId(loginUserDeptId);
         }
         List<Long> meetingIds = new ArrayList<>();
+        long resultId = 0l;
         if (ObjUtil.isNotEmpty(meeting.getId())) {
             // 更新
             // 校验存在
             validateIotOperationMeetingExists(meeting.getId());
             IotOperationMeetingDO updateObj = BeanUtils.toBean(meeting, IotOperationMeetingDO.class);
-            iotOperationMeetingMapper.updateById(updateObj);
+            int id = iotOperationMeetingMapper.updateById(updateObj);
+            resultId = id;
             // 删除主表对应的明细
             int count = iotOperationMeetingDetailMapper.deleteByMap(ImmutableMap.of(
                     "meeting_id", meeting.getId()
@@ -136,7 +138,8 @@ public class IotOperationMeetingServiceImpl implements IotOperationMeetingServic
         } else {
             // 新增
             IotOperationMeetingDO iotOperationMeeting = BeanUtils.toBean(meeting, IotOperationMeetingDO.class);
-            iotOperationMeetingMapper.insert(iotOperationMeeting);
+            int id = iotOperationMeetingMapper.insert(iotOperationMeeting);
+            resultId = id;
             meetingIds.add(iotOperationMeeting.getId());
         }
         // 编辑时先删除明细 再新增明细
@@ -152,7 +155,7 @@ public class IotOperationMeetingServiceImpl implements IotOperationMeetingServic
             });
             iotOperationMeetingDetailMapper.insertBatch(meetingDetails);
         }
-        return 0l;
+        return resultId;
     }
 
 }

+ 8 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrddailyreport/IotRdDailyReportService.java

@@ -180,4 +180,12 @@ public interface IotRdDailyReportService {
      * @return
      */
     void repairHistoryProdStatus();
+
+    /**
+     * 瑞都日报 非生产时效 分析
+     *
+     * @param pageReqVO 无分页查询
+     * @return 瑞都日报 非生产时效分析 列表
+     */
+    List<IotRdDailyReportNptStatisticsRespVO> nptStatistics(IotRdDailyReportPageReqVO pageReqVO);
 }

+ 410 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrddailyreport/IotRdDailyReportServiceImpl.java

@@ -3366,6 +3366,416 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         }
     }
 
+    @Override
+    public List<IotRdDailyReportNptStatisticsRespVO> nptStatistics(IotRdDailyReportPageReqVO pageReqVO) {
+        List<IotRdDailyReportNptStatisticsRespVO> result = new ArrayList<>();
+        // 不分页统计所有数据
+        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 ArrayList<>();
+        }
+        // 检查taskName不为空但taskIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
+            return new ArrayList<>();
+        }
+        List<IotRdDailyReportDO> dailyReports = iotRdDailyReportMapper.dailyReports(pageReqVO);
+        // 默认显示所有项目部的汇总数据
+        // 点击项目部 显示 下属队伍的数据
+        // 首先判断点击的部门是属于 公司 还是 队伍 如果没有点击任何部门 默认查询所有项目部数据
+        if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
+            result = nptStatisticsByProjectDept(dailyReports, 163L, pageReqVO);
+        } else {
+            // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
+            DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
+            if ("1".equals(selectedDept.getType())) {
+                // 以项目部为维度汇总数据
+                result = nptStatisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO);
+            } else if ("2".equals(selectedDept.getType())) {
+                // 以队伍为维度汇总数据
+                // result = nptStatisticsByProjectDepartment(dailyReports, pageReqVO.getDeptId());
+            } else if ("3".equals(selectedDept.getType())) {
+                // 显示单个队伍的汇总数据
+                // result = nptStatisticsByProjectDepartment(dailyReports, pageReqVO.getDeptId());
+            } else {
+                // 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
+                // 以项目部为维度汇总数据
+                // result = nptStatisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO);
+            }
+        }
+        // 根据 result 集合内对象的 sort 属性正序排列 sort 类型为 integer 类型
+        if (CollUtil.isNotEmpty(result)) {
+            result.sort(Comparator.comparing(
+                    IotRdDailyReportNptStatisticsRespVO::getSort,
+                    Comparator.nullsLast(Comparator.naturalOrder())
+            ));
+        }
+        return result;
+    }
+
+    /**
+     * 按项目部维度 汇总 统计数据
+     * @param dailyReports 日报数据列表
+     * @param rootDeptId 根部门ID(如 163L为 瑞都 根部门,或其他公司级部门ID)
+     * @return 项目部维度统计结果列表
+     */
+    private List<IotRdDailyReportNptStatisticsRespVO> nptStatisticsByProjectDept(List<IotRdDailyReportDO> dailyReports,
+                                                                           Long rootDeptId, IotRdDailyReportPageReqVO pageReqVO) {
+        List<IotRdDailyReportNptStatisticsRespVO> result = new ArrayList<>();
+
+        Set<Long> projectDeptIds = new HashSet<>();
+        // key项目部id    value项目部名称
+        Map<Long, DeptDO> projectDeptPair = new HashMap<>();
+        // key部门id   value部门parentId
+        Map<Long, Long> teamProjectIdPair = new HashMap<>();
+        // key队伍id    value队伍部门
+        Map<Long, DeptDO> teamDeptPair = new HashMap<>();
+
+        // key队伍id/项目部id   value累计 工程质量npt
+        Map<Long, BigDecimal> subtotalAccidentTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 设备故障npt
+        Map<Long, BigDecimal> subtotalRepairTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 设备保养npt
+        Map<Long, BigDecimal> subtotalSelfStopTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 技术受限npt
+        Map<Long, BigDecimal> subtotalComplexityTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 生产配合npt
+        Map<Long, BigDecimal> subtotalRelocationTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 生产组织npt
+        Map<Long, BigDecimal> subtotalRectificationTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 不可抗力npt
+        Map<Long, BigDecimal> subtotalWaitingStopTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 待命npt
+        Map<Long, BigDecimal> subtotalWinterBreakTimePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 甲方设计npt
+        Map<Long, BigDecimal> subtotalPartyaDesignPair = new HashMap<>();
+        // key队伍id/项目部id   value累计 甲方准备npt
+        Map<Long, BigDecimal> subtotalPartyaPreparePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 甲方资源npt
+        Map<Long, BigDecimal> subtotalPartyaResourcePair = new HashMap<>();
+        // key队伍id/项目部id   value累计 其它非生产时间npt
+        Map<Long, BigDecimal> subtotalOtherNptTimePair = new HashMap<>();
+
+        // key队伍id/项目部id   value npt小计
+        Map<Long, BigDecimal> subtotalNptTimePair = new HashMap<>();
+        // key队伍id/项目部id   value npt时效%
+        Map<Long, BigDecimal> subtotalNptRatePair = new HashMap<>();
+
+        // 队伍id 集合
+        Set<Long> teamIds = new HashSet<>();
+
+        // 以项目部为维度统计数据
+        // 找到所有项目部与队伍的对应关系
+        // 查询指定根部门下的所有子部门
+        Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(rootDeptId);
+        DeptListReqVO reqVO = new DeptListReqVO();
+        reqVO.setDeptIds(allRhChildDeptIds);
+        List<DeptDO> depts = deptService.getDeptList(reqVO);
+
+        // 构建项目部映射和父子部门关系 瑞都存在日报部门是项目部的情况
+        depts.forEach(dept -> {
+            // 项目部
+            if ("2".equals(dept.getType())) {
+                projectDeptIds.add(dept.getId());
+                projectDeptPair.put(dept.getId(), dept);
+            }
+            // 队伍
+            if ("3".equals(dept.getType())) {
+                teamIds.add(dept.getId());
+                teamDeptPair.put(dept.getId(), dept);
+            }
+            // 可能是项目部 也可能是队伍
+            teamProjectIdPair.put(dept.getId(), dept.getParentId());
+        });
+
+        // 计算日期查询区间有多少小时
+        LocalDateTime[] createTimes = pageReqVO.getCreateTime();
+        List<Long> totalHours = new ArrayList<>();
+        if (ObjUtil.isNotEmpty(createTimes) && createTimes.length >= 2) {
+            LocalDate startDate = createTimes[0].toLocalDate();
+            LocalDate endDate = createTimes[1].toLocalDate();
+            // 核心:包含起止两天 → 天数差 +1 再 ×24
+            long days = ChronoUnit.DAYS.between(startDate, endDate) + 1;
+            Long tempTotalHours = days * 24L;
+            totalHours.add(tempTotalHours);
+        }
+
+        // 累计计算各项 工作量
+        if (CollUtil.isNotEmpty(dailyReports)) {
+            dailyReports.forEach(report -> {
+                if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
+                    // projectDeptId可能是项目部 也可能是项目的上级
+                    Long projectDeptId = 0l;
+                    if (teamDeptPair.containsKey(report.getDeptId())) {
+                        // 日报deptId如果是队伍 获取队伍的上级项目部
+                        projectDeptId = teamProjectIdPair.get(report.getDeptId());
+                    }
+                    if (projectDeptPair.containsKey(report.getDeptId())) {
+                        // 日报deptId如果是项目部 使用当前项目部
+                        projectDeptId = report.getDeptId();
+                    }
+                    if (ObjUtil.isNotEmpty(projectDeptId) && (projectDeptId > 0)) {
+                        // 工程质量 npt
+                        BigDecimal accidentTime = report.getAccidentTime();
+                        if (ObjUtil.isNotEmpty(accidentTime)) {
+                            if (subtotalAccidentTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existAccidentTime = subtotalAccidentTimePair.get(projectDeptId);
+                                BigDecimal tempAccidentTime = existAccidentTime.add(accidentTime);
+                                subtotalAccidentTimePair.put(projectDeptId, tempAccidentTime);
+                            } else {
+                                subtotalAccidentTimePair.put(projectDeptId, accidentTime);
+                            }
+                        }
+                        // 设备故障 npt
+                        BigDecimal repairTime = report.getRepairTime();
+                        if (ObjUtil.isNotEmpty(repairTime)) {
+                            if (subtotalRepairTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existRepairTime = subtotalRepairTimePair.get(projectDeptId);
+                                BigDecimal tempRepairTime = existRepairTime.add(repairTime);
+                                subtotalRepairTimePair.put(projectDeptId, tempRepairTime);
+                            } else {
+                                subtotalRepairTimePair.put(projectDeptId, repairTime);
+                            }
+                        }
+                        // 设备保养 npt
+                        BigDecimal selfStopTime = report.getSelfStopTime();
+                        if (ObjUtil.isNotEmpty(selfStopTime)) {
+                            if (subtotalSelfStopTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existSelfStopTime = subtotalSelfStopTimePair.get(projectDeptId);
+                                BigDecimal tempSelfStopTime = existSelfStopTime.add(selfStopTime);
+                                subtotalSelfStopTimePair.put(projectDeptId, tempSelfStopTime);
+                            } else {
+                                subtotalSelfStopTimePair.put(projectDeptId, selfStopTime);
+                            }
+                        }
+                        // 技术受限 npt
+                        BigDecimal complexityTime = report.getComplexityTime();
+                        if (ObjUtil.isNotEmpty(complexityTime)) {
+                            if (subtotalComplexityTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existComplexityTime = subtotalComplexityTimePair.get(projectDeptId);
+                                BigDecimal tempComplexityTime = existComplexityTime.add(complexityTime);
+                                subtotalComplexityTimePair.put(projectDeptId, tempComplexityTime);
+                            } else {
+                                subtotalComplexityTimePair.put(projectDeptId, complexityTime);
+                            }
+                        }
+                        // 生产配合 npt
+                        BigDecimal relocationTime = report.getRelocationTime();
+                        if (ObjUtil.isNotEmpty(relocationTime)) {
+                            if (subtotalRelocationTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existRelocationTime = subtotalRelocationTimePair.get(projectDeptId);
+                                BigDecimal tempRelocationTime = existRelocationTime.add(relocationTime);
+                                subtotalRelocationTimePair.put(projectDeptId, tempRelocationTime);
+                            } else {
+                                subtotalRelocationTimePair.put(projectDeptId, relocationTime);
+                            }
+                        }
+                        // 生产组织 npt
+                        BigDecimal rectificationTime = report.getRectificationTime();
+                        if (ObjUtil.isNotEmpty(rectificationTime)) {
+                            if (subtotalRectificationTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existRectificationTime = subtotalRectificationTimePair.get(projectDeptId);
+                                BigDecimal tempRectificationTime = existRectificationTime.add(rectificationTime);
+                                subtotalRectificationTimePair.put(projectDeptId, tempRectificationTime);
+                            } else {
+                                subtotalRectificationTimePair.put(projectDeptId, rectificationTime);
+                            }
+                        }
+                        // 不可抗力 npt
+                        BigDecimal waitingStopTime = report.getWaitingStopTime();
+                        if (ObjUtil.isNotEmpty(waitingStopTime)) {
+                            if (subtotalWaitingStopTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existWaitingStopTime = subtotalWaitingStopTimePair.get(projectDeptId);
+                                BigDecimal tempWaitingStopTime = existWaitingStopTime.add(waitingStopTime);
+                                subtotalWaitingStopTimePair.put(projectDeptId, tempWaitingStopTime);
+                            } else {
+                                subtotalWaitingStopTimePair.put(projectDeptId, waitingStopTime);
+                            }
+                        }
+                        // 待命 npt
+                        BigDecimal winterBreakTime = report.getWinterBreakTime();
+                        if (ObjUtil.isNotEmpty(winterBreakTime)) {
+                            if (subtotalWinterBreakTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existWinterBreakTime = subtotalWinterBreakTimePair.get(projectDeptId);
+                                BigDecimal tempWinterBreakTime = existWinterBreakTime.add(winterBreakTime);
+                                subtotalWinterBreakTimePair.put(projectDeptId, tempWinterBreakTime);
+                            } else {
+                                subtotalWinterBreakTimePair.put(projectDeptId, winterBreakTime);
+                            }
+                        }
+                        // 甲方设计 npt
+                        BigDecimal partyaDesign = report.getPartyaDesign();
+                        if (ObjUtil.isNotEmpty(partyaDesign)) {
+                            if (subtotalPartyaDesignPair.containsKey(projectDeptId)) {
+                                BigDecimal existPartyaDesign = subtotalPartyaDesignPair.get(projectDeptId);
+                                BigDecimal tempPartyaDesign = existPartyaDesign.add(partyaDesign);
+                                subtotalPartyaDesignPair.put(projectDeptId, tempPartyaDesign);
+                            } else {
+                                subtotalPartyaDesignPair.put(projectDeptId, partyaDesign);
+                            }
+                        }
+                        // 甲方准备 npt
+                        BigDecimal partyaPrepare = report.getPartyaPrepare();
+                        if (ObjUtil.isNotEmpty(partyaPrepare)) {
+                            if (subtotalPartyaPreparePair.containsKey(projectDeptId)) {
+                                BigDecimal existPartyaPrepare = subtotalPartyaPreparePair.get(projectDeptId);
+                                BigDecimal tempPartyaPrepare = existPartyaPrepare.add(partyaPrepare);
+                                subtotalPartyaPreparePair.put(projectDeptId, tempPartyaPrepare);
+                            } else {
+                                subtotalPartyaPreparePair.put(projectDeptId, partyaPrepare);
+                            }
+                        }
+                        // 甲方资源 npt
+                        BigDecimal partyaResource = report.getPartyaResource();
+                        if (ObjUtil.isNotEmpty(partyaResource)) {
+                            if (subtotalPartyaResourcePair.containsKey(projectDeptId)) {
+                                BigDecimal existPartyaResource = subtotalPartyaResourcePair.get(projectDeptId);
+                                BigDecimal tempPartyaResource = existPartyaResource.add(partyaResource);
+                                subtotalPartyaResourcePair.put(projectDeptId, tempPartyaResource);
+                            } else {
+                                subtotalPartyaResourcePair.put(projectDeptId, partyaResource);
+                            }
+                        }
+                        // 其它非生产时间 npt
+                        BigDecimal otherNptTime = report.getOtherNptTime();
+                        if (ObjUtil.isNotEmpty(otherNptTime)) {
+                            if (subtotalOtherNptTimePair.containsKey(projectDeptId)) {
+                                BigDecimal existOtherNptTime = subtotalOtherNptTimePair.get(projectDeptId);
+                                BigDecimal tempOtherNptTime = existOtherNptTime.add(otherNptTime);
+                                subtotalOtherNptTimePair.put(projectDeptId, tempOtherNptTime);
+                            } else {
+                                subtotalOtherNptTimePair.put(projectDeptId, otherNptTime);
+                            }
+                        }
+                    }
+                }
+
+            });
+
+            // 计算每个项目部的 npt小计 npt时效
+            if (CollUtil.isNotEmpty(projectDeptPair)) {
+                projectDeptPair.forEach((projectDeptId, dept) -> {
+                    // 统计当前项目部所有 npt 总和、时效
+                    BigDecimal tempSubtotalNpt = BigDecimal.ZERO;
+                    // 计入 npt时效 的非生产时间小计
+                    BigDecimal tempNptSum = BigDecimal.ZERO;
+                    if (subtotalAccidentTimePair.containsKey(projectDeptId)) {
+                        BigDecimal accidentTime = subtotalAccidentTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(accidentTime);
+                        tempNptSum = tempNptSum.add(accidentTime);
+                    }
+                    if (subtotalRepairTimePair.containsKey(projectDeptId)) {
+                        BigDecimal repairTime = subtotalRepairTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(repairTime);
+                        tempNptSum = tempNptSum.add(repairTime);
+                    }
+                    if (subtotalSelfStopTimePair.containsKey(projectDeptId)) {
+                        BigDecimal selfStopTime = subtotalSelfStopTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(selfStopTime);
+                    }
+                    if (subtotalComplexityTimePair.containsKey(projectDeptId)) {
+                        BigDecimal complexityTime = subtotalComplexityTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(complexityTime);
+                        tempNptSum = tempNptSum.add(complexityTime);
+                    }
+                    if (subtotalRelocationTimePair.containsKey(projectDeptId)) {
+                        BigDecimal relocationTime = subtotalRelocationTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(relocationTime);
+                    }
+                    if (subtotalRectificationTimePair.containsKey(projectDeptId)) {
+                        BigDecimal rectificationTime = subtotalRectificationTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(rectificationTime);
+                        tempNptSum = tempNptSum.add(rectificationTime);
+                    }
+                    if (subtotalWaitingStopTimePair.containsKey(projectDeptId)) {
+                        BigDecimal waitingStopTime = subtotalWaitingStopTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(waitingStopTime);
+                        tempNptSum = tempNptSum.add(waitingStopTime);
+                    }
+                    if (subtotalWinterBreakTimePair.containsKey(projectDeptId)) {
+                        BigDecimal winterBreakTime = subtotalWinterBreakTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(winterBreakTime);
+                    }
+                    if (subtotalPartyaDesignPair.containsKey(projectDeptId)) {
+                        BigDecimal partyaDesign = subtotalPartyaDesignPair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(partyaDesign);
+                        tempNptSum = tempNptSum.add(partyaDesign);
+                    }
+                    if (subtotalPartyaPreparePair.containsKey(projectDeptId)) {
+                        BigDecimal partyaPrepare = subtotalPartyaPreparePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(partyaPrepare);
+                        tempNptSum = tempNptSum.add(partyaPrepare);
+                    }
+                    if (subtotalPartyaResourcePair.containsKey(projectDeptId)) {
+                        BigDecimal partyaResource = subtotalPartyaResourcePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(partyaResource);
+                        tempNptSum = tempNptSum.add(partyaResource);
+                    }
+                    if (subtotalOtherNptTimePair.containsKey(projectDeptId)) {
+                        BigDecimal otherNptTime = subtotalOtherNptTimePair.get(projectDeptId);
+                        tempSubtotalNpt = tempSubtotalNpt.add(otherNptTime);
+                        tempNptSum = tempNptSum.add(otherNptTime);
+                    }
+                    // 项目部 npt 小计
+                    subtotalNptTimePair.put(projectDeptId, tempNptSum);
+                    // 项目部 npt 时效 以下非生产时间计入非生产时效
+                    // 设备故障repair_time
+                    // 工程质量accident_time
+                    // 技术受限complexity_time
+                    // 生产组织rectification_time
+                    // 不可抗力waiting_stop_time
+                    // 甲方设计partya_design
+                    // 甲方准备partya_prepare
+                    // 甲方资源partya_resource
+                    // 其他非生产时间other_npt_time
+                    if (CollUtil.isNotEmpty(totalHours)) {
+                        Long totalHour = totalHours.get(0);
+                        if (ObjUtil.isNotEmpty(totalHour) && totalHour > 0) {
+                            BigDecimal nptRate = tempNptSum.divide(new BigDecimal(totalHour), 4, RoundingMode.HALF_UP);
+                            subtotalNptRatePair.put(projectDeptId, nptRate);
+                        }
+                    }
+                });
+            }
+        }
+
+        // 生成返回的数据列表集合
+        projectDeptPair.forEach((deptId, dept) -> {
+            IotRdDailyReportNptStatisticsRespVO statistics = new IotRdDailyReportNptStatisticsRespVO();
+            statistics.setProjectDeptId(deptId);
+            statistics.setProjectDeptName(dept.getName());
+            statistics.setSort(dept.getSort());
+            statistics.setType("2");
+            statistics.setAccidentTime(subtotalAccidentTimePair.get(deptId));
+            statistics.setRepairTime(subtotalRepairTimePair.get(deptId));
+            statistics.setSelfStopTime(subtotalSelfStopTimePair.get(deptId));
+            statistics.setComplexityTime(subtotalComplexityTimePair.get(deptId));
+            statistics.setRelocationTime(subtotalRelocationTimePair.get(deptId));
+            statistics.setRectificationTime(subtotalRectificationTimePair.get(deptId));
+            statistics.setWaitingStopTime(subtotalWaitingStopTimePair.get(deptId));
+            statistics.setWinterBreakTime(subtotalWinterBreakTimePair.get(deptId));
+            statistics.setPartyaDesign(subtotalPartyaDesignPair.get(deptId));
+            statistics.setPartyaPrepare(subtotalPartyaPreparePair.get(deptId));
+            statistics.setPartyaResource(subtotalPartyaResourcePair.get(deptId));
+            statistics.setOtherNptTime(subtotalOtherNptTimePair.get(deptId));
+            statistics.setNptTotal(subtotalNptTimePair.get(deptId));
+            statistics.setNptRate(subtotalNptRatePair.get(deptId));
+            if (CollUtil.isNotEmpty(totalHours)) {
+                Long totalHour = totalHours.get(0);
+                statistics.setCalendarTime(new BigDecimal(totalHour));
+            }
+            result.add(statistics);
+        });
+
+        return result;
+    }
+
     /**
      * 计算两个LocalTime之间的间隔小时数(处理空值、跨天情况)
      * @param startTime 开始时间