|
|
@@ -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 开始时间
|