Bläddra i källkod

pms 瑞都 瑞恒 瑞鹰 非生产时效统计

zhangcl 5 dagar sedan
förälder
incheckning
4726467295

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

@@ -549,7 +549,7 @@ public class IotRhDailyReportController {
                 // 遍历所有部门 只筛选出有设备的队伍
                 // 遍历所有部门 只筛选出有设备的队伍
                 allDeptPair.forEach((departmentId, dept) -> {
                 allDeptPair.forEach((departmentId, dept) -> {
                     // 不需要找出每个项目部下的队伍 根据筛选的日期和部门 统计数据
                     // 不需要找出每个项目部下的队伍 根据筛选的日期和部门 统计数据
-                    if (projectPair.containsKey(dept.getParentId())) {
+                    if (projectPair.containsKey(dept.getParentId()) && haveDeviceDeptIds.contains(departmentId)) {
                         // 获得队伍的上级项目部(LY状态的项目部)
                         // 获得队伍的上级项目部(LY状态的项目部)
                         teamProjectIdPair.put(dept.getId(), dept.getParentId());
                         teamProjectIdPair.put(dept.getId(), dept.getParentId());
                     }
                     }
@@ -594,7 +594,9 @@ public class IotRhDailyReportController {
 
 
             for (IotRhDailyReportDO report : list) {
             for (IotRhDailyReportDO report : list) {
                 // 统计出状态为 LY 的项目部下的施工队伍的日报数量
                 // 统计出状态为 LY 的项目部下的施工队伍的日报数量
-                if (teamProjectIdPair.containsKey(report.getDeptId())) {
+                // 20260604 设备利用率计算逻辑调整 分子 注气量或注水量>0 的日报数量
+                if (teamProjectIdPair.containsKey(report.getDeptId()) &&
+                        (report.getDailyGasInjection().compareTo(BigDecimal.ZERO)>0 || report.getDailyWaterInjection().compareTo(BigDecimal.ZERO)>0)) {
                     ++reportCount;
                     ++reportCount;
                 }
                 }
                 BigDecimal dailyGasInjection = report.getDailyGasInjection();
                 BigDecimal dailyGasInjection = report.getDailyGasInjection();
@@ -640,7 +642,7 @@ public class IotRhDailyReportController {
             }
             }
             // 所有LY状态的项目部包含的队伍数量>0 并且 指定时间区间天数大于0
             // 所有LY状态的项目部包含的队伍数量>0 并且 指定时间区间天数大于0
             if (daysCount > 0 && teamProjectIdPair.size() > 0) {
             if (daysCount > 0 && teamProjectIdPair.size() > 0) {
-                // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum*daysCount)
+                // 指定部门(公司or项目部or队伍) 设备利用率 公式 reportCount/(currentTeamNum*daysCount)
                 // 计算设备利用率(处理除数为0的情况)
                 // 计算设备利用率(处理除数为0的情况)
                 rate = new BigDecimal((double) reportCount / (teamProjectIdPair.size() * daysCount))
                 rate = new BigDecimal((double) reportCount / (teamProjectIdPair.size() * daysCount))
                         .setScale(4, RoundingMode.HALF_UP)  // 保留4位小数,四舍五入
                         .setScale(4, RoundingMode.HALF_UP)  // 保留4位小数,四舍五入

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

@@ -1126,6 +1126,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         // key工作量标识   value累计 台次 当日泵车台次
         // key工作量标识   value累计 台次 当日泵车台次
         Map<String, BigDecimal> cumulativePumpTripsPair = new HashMap<>();
         Map<String, BigDecimal> cumulativePumpTripsPair = new HashMap<>();
 
 
+
+
         // 查询 瑞都 施工状态 字典数据 筛选出施工设备为 LY 的记录
         // 查询 瑞都 施工状态 字典数据 筛选出施工设备为 LY 的记录
         Set<String> lyStatuses = new HashSet<>();
         Set<String> lyStatuses = new HashSet<>();
         List<DictDataDO> rdStatuses = dictDataService.getDictDataListByDictType("rdStatus");
         List<DictDataDO> rdStatuses = dictDataService.getDictDataListByDictType("rdStatus");
@@ -1140,7 +1142,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         // 查询瑞都所有 A B 类设备 计算总的设备利用率
         // 查询瑞都所有 A B 类设备 计算总的设备利用率
         Set<Long> abDeviceCategoryIds = new HashSet<>();
         Set<Long> abDeviceCategoryIds = new HashSet<>();
         // 查询所有瑞都产品类别包含 A B 类
         // 查询所有瑞都产品类别包含 A B 类
-        IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
+        /* IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
         List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
         List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
         if (CollUtil.isNotEmpty(allDeviceCategories)) {
         if (CollUtil.isNotEmpty(allDeviceCategories)) {
             allDeviceCategories.forEach(category -> {
             allDeviceCategories.forEach(category -> {
@@ -1148,10 +1150,11 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                     abDeviceCategoryIds.add(category.getId());
                     abDeviceCategoryIds.add(category.getId());
                 }
                 }
             });
             });
-        }
+        } */
         // 查询瑞都所有查询到的设备
         // 查询瑞都所有查询到的设备
+        // 过滤掉 封存 的 压裂 连油 主设备
         Set<Long> abDeviceIds = new HashSet<>();
         Set<Long> abDeviceIds = new HashSet<>();
-        IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
+        /* IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
         deviceReqVO.setDeptIds(new ArrayList<>(ids));
         deviceReqVO.setDeptIds(new ArrayList<>(ids));
         List<IotDeviceDO> rdDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
         List<IotDeviceDO> rdDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
         if (CollUtil.isNotEmpty(rdDevices)) {
         if (CollUtil.isNotEmpty(rdDevices)) {
@@ -1160,7 +1163,42 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                     abDeviceIds.add(device.getId());
                     abDeviceIds.add(device.getId());
                 }
                 }
             });
             });
+        } */
+
+        // 20260604 修改设备利用率统计逻辑 统计 压裂 连油 主设备 rq_iot_device_associate
+        // 队伍日报中关联的主设备数量 /(队伍下所有主设备数量-封存设备数量)
+        Set<Long> mainDeviceIds = new HashSet<>();
+        Set<Long> fcMainDeviceIds = new HashSet<>();
+        // key设备id   value设备所属部门id
+        Map<Long, Long> mainDeviceIdPair = new HashMap<>();
+        IotDeviceAssociatePageReqVO deviceAssocReqVO = new IotDeviceAssociatePageReqVO();
+        deviceAssocReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        deviceAssocReqVO.setDeptIds(ids);
+        PageResult<IotDeviceAssociateDO> pageResult = iotDeviceAssociateMapper.selectPage(deviceAssocReqVO);
+        if (ObjUtil.isNotEmpty(pageResult)) {
+            List<IotDeviceAssociateDO> deviceAssociates = pageResult.getList();
+            // 查询出所有瑞都压裂 连油主设备
+            deviceAssociates.forEach(assoc -> {
+                mainDeviceIds.add(assoc.getDeviceId());
+                mainDeviceIdPair.put(assoc.getDeviceId(), assoc.getDeptId());
+            });
+        }
+
+        // 查询瑞都 压裂 连油 主设备详情信息
+        IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
+        deviceReqVO.setDeviceIds(new ArrayList<>(mainDeviceIds));
+        List<IotDeviceDO> mainDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
+        // 过滤掉 封存 的 压裂 连油 主设备
+        if (CollUtil.isNotEmpty(mainDevices)) {
+            mainDevices.forEach(device -> {
+                if ("fc".equals(device.getDeviceStatus())) {
+                    fcMainDeviceIds.add(device.getId());
+                } else {
+                    abDeviceIds.add(device.getId());
+                }
+            });
         }
         }
+
         // 日报涉及到的施工设备id集合
         // 日报涉及到的施工设备id集合
         Set<Long> reportDeviceIds = new HashSet<>();
         Set<Long> reportDeviceIds = new HashSet<>();
 
 
@@ -1901,7 +1939,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         // 查询瑞都所有 A B 类设备 计算总的设备利用率
         // 查询瑞都所有 A B 类设备 计算总的设备利用率
         Set<Long> abDeviceCategoryIds = new HashSet<>();
         Set<Long> abDeviceCategoryIds = new HashSet<>();
         // 查询所有瑞都产品类别包含 A B 类
         // 查询所有瑞都产品类别包含 A B 类
-        IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
+        /* IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
         List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
         List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
         if (CollUtil.isNotEmpty(allDeviceCategories)) {
         if (CollUtil.isNotEmpty(allDeviceCategories)) {
             allDeviceCategories.forEach(category -> {
             allDeviceCategories.forEach(category -> {
@@ -1909,7 +1947,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                     abDeviceCategoryIds.add(category.getId());
                     abDeviceCategoryIds.add(category.getId());
                 }
                 }
             });
             });
-        }
+        } */
 
 
         // key队伍id   value 日报中A+B类设备id集合
         // key队伍id   value 日报中A+B类设备id集合
         Map<Long, Set<Long>> teamReportABDeviceIdPair = new HashMap<>();
         Map<Long, Set<Long>> teamReportABDeviceIdPair = new HashMap<>();

+ 48 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -1487,6 +1487,18 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         reqVO.setDeptIds(allRhChildDeptIds);
         reqVO.setDeptIds(allRhChildDeptIds);
         List<DeptDO> depts = deptService.getDeptList(reqVO);
         List<DeptDO> depts = deptService.getDeptList(reqVO);
 
 
+        // 包含设备的部门id集合
+        Set<Long> haveDeviceDeptIds = new HashSet<>();
+        IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
+        deviceReqVO.setDeptIds(new ArrayList<>(allRhChildDeptIds));
+        List<IotDeviceDO> devices = iotDeviceMapper.selectListAlone(deviceReqVO);
+        if (CollUtil.isNotEmpty(devices)) {
+            // 筛选出包含设备的队伍部门集合
+            devices.forEach(device -> {
+                haveDeviceDeptIds.add(device.getDeptId());
+            });
+        }
+
         // 构建项目部映射和父子部门关系
         // 构建项目部映射和父子部门关系
         depts.forEach(dept -> {
         depts.forEach(dept -> {
             // 暂时过滤掉 欧洲项目部 克拉玛依项目部
             // 暂时过滤掉 欧洲项目部 克拉玛依项目部
@@ -1502,6 +1514,31 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             teamProjectIdPair.put(dept.getId(), dept.getParentId());
             teamProjectIdPair.put(dept.getId(), dept.getParentId());
         });
         });
 
 
+        // 筛选出每个项目部下有多少支队伍 自然日时间 = 队伍数量*24
+        // key项目部id   value项目部包含的队伍id集合
+        Map<Long, Set<Long>> projectTeamPair = new HashMap<>();
+        // 筛选项目部下包含的队伍
+        depts.forEach(dept -> {
+            Long deptId = dept.getId();
+            Long parentId = dept.getParentId();
+            if (projectDeptIds.contains(parentId)) {
+                // 获得当前部门的上级项目部
+                projectDeptIds.forEach(projectDeptId -> {
+                    if (projectDeptId.equals(parentId) && haveDeviceDeptIds.contains(deptId) && teamIds.contains(deptId)) {
+                        if (projectTeamPair.containsKey(projectDeptId)) {
+                            Set<Long> tempTeamIds = projectTeamPair.get(projectDeptId);
+                            tempTeamIds.add(deptId);
+                            projectTeamPair.put(projectDeptId, tempTeamIds);
+                        } else {
+                            Set<Long> tempTeamIds = new HashSet<>();
+                            tempTeamIds.add(deptId);
+                            projectTeamPair.put(projectDeptId, tempTeamIds);
+                        }
+                    }
+                });
+            }
+        });
+
         // 计算日期查询区间有多少小时
         // 计算日期查询区间有多少小时
         LocalDateTime[] createTimes = pageReqVO.getCreateTime();
         LocalDateTime[] createTimes = pageReqVO.getCreateTime();
         List<Long> totalHours = new ArrayList<>();
         List<Long> totalHours = new ArrayList<>();
@@ -1744,8 +1781,12 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                     if (CollUtil.isNotEmpty(totalHours)) {
                     if (CollUtil.isNotEmpty(totalHours)) {
                         Long totalHour = totalHours.get(0);
                         Long totalHour = totalHours.get(0);
                         if (ObjUtil.isNotEmpty(totalHour) && totalHour > 0) {
                         if (ObjUtil.isNotEmpty(totalHour) && totalHour > 0) {
-                            BigDecimal nptRate = tempNptSum.divide(new BigDecimal(totalHour), 4, RoundingMode.HALF_UP);
-                            subtotalNptRatePair.put(projectDeptId, nptRate);
+                            // 查询每个项目部下的队伍数量
+                            if (projectTeamPair.containsKey(projectDeptId)) {
+                                Set<Long> projectTeamIds = projectTeamPair.get(projectDeptId);
+                                BigDecimal nptRate = tempNptSum.divide(new BigDecimal(totalHour * projectTeamIds.size()), 4, RoundingMode.HALF_UP);
+                                subtotalNptRatePair.put(projectDeptId, nptRate);
+                            }
                         }
                         }
                     }
                     }
                 });
                 });
@@ -1775,7 +1816,11 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             statistics.setNptRate(subtotalNptRatePair.get(deptId));
             statistics.setNptRate(subtotalNptRatePair.get(deptId));
             if (CollUtil.isNotEmpty(totalHours)) {
             if (CollUtil.isNotEmpty(totalHours)) {
                 Long totalHour = totalHours.get(0);
                 Long totalHour = totalHours.get(0);
-                statistics.setCalendarTime(new BigDecimal(totalHour));
+                // 自然时间 考虑进 项目部下的队伍数量
+                if (projectTeamPair.containsKey(deptId)) {
+                    Set<Long> tempTeamIds = projectTeamPair.get(deptId);
+                    statistics.setCalendarTime(new BigDecimal(totalHour * tempTeamIds.size()));
+                }
             }
             }
             result.add(statistics);
             result.add(statistics);
         });
         });

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

@@ -1595,6 +1595,31 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
             teamProjectIdPair.put(dept.getId(), dept.getParentId());
             teamProjectIdPair.put(dept.getId(), dept.getParentId());
         });
         });
 
 
+        // key项目部id   value项目部包含的钻井or修井队伍id集合
+        Map<Long, Set<Long>> projectTeamPair = new HashMap<>();
+        // 筛选项目部下包含的队伍
+        depts.forEach(dept -> {
+            Long deptId = dept.getId();
+            Long parentId = dept.getParentId();
+            if (projectDeptIds.contains(parentId)) {
+                // 获得当前部门的上级项目部
+                projectDeptIds.forEach(projectDeptId -> {
+                    // 统计各钻井或修井项目部下队伍数量
+                    if (projectDeptId.equals(parentId) && zjOrXjDeptIds.contains(deptId)) {
+                        if (projectTeamPair.containsKey(projectDeptId)) {
+                            Set<Long> tempTeamIds = projectTeamPair.get(projectDeptId);
+                            tempTeamIds.add(deptId);
+                            projectTeamPair.put(projectDeptId, tempTeamIds);
+                        } else {
+                            Set<Long> tempTeamIds = new HashSet<>();
+                            tempTeamIds.add(deptId);
+                            projectTeamPair.put(projectDeptId, tempTeamIds);
+                        }
+                    }
+                });
+            }
+        });
+
         // 计算日期查询区间有多少小时
         // 计算日期查询区间有多少小时
         LocalDateTime[] createTimes = pageReqVO.getCreateTime();
         LocalDateTime[] createTimes = pageReqVO.getCreateTime();
         List<Long> totalHours = new ArrayList<>();
         List<Long> totalHours = new ArrayList<>();
@@ -1756,7 +1781,6 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
                         }
                         }
                     }
                     }
                 }
                 }
-
             });
             });
 
 
             // 计算每个项目部的 npt小计 npt时效
             // 计算每个项目部的 npt小计 npt时效
@@ -1838,8 +1862,12 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
                     if (CollUtil.isNotEmpty(totalHours)) {
                     if (CollUtil.isNotEmpty(totalHours)) {
                         Long totalHour = totalHours.get(0);
                         Long totalHour = totalHours.get(0);
                         if (ObjUtil.isNotEmpty(totalHour) && totalHour > 0) {
                         if (ObjUtil.isNotEmpty(totalHour) && totalHour > 0) {
-                            BigDecimal nptRate = tempNptSum.divide(new BigDecimal(totalHour), 4, RoundingMode.HALF_UP);
-                            subtotalNptRatePair.put(projectDeptId, nptRate);
+                            // 查询每个项目部下的队伍数量
+                            if (projectTeamPair.containsKey(projectDeptId)) {
+                                Set<Long> projectTeamIds = projectTeamPair.get(projectDeptId);
+                                BigDecimal nptRate = tempNptSum.divide(new BigDecimal(totalHour * projectTeamIds.size()), 4, RoundingMode.HALF_UP);
+                                subtotalNptRatePair.put(projectDeptId, nptRate);
+                            }
                         }
                         }
                     }
                     }
                 });
                 });
@@ -1869,7 +1897,11 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
             statistics.setNptRate(subtotalNptRatePair.get(deptId));
             statistics.setNptRate(subtotalNptRatePair.get(deptId));
             if (CollUtil.isNotEmpty(totalHours)) {
             if (CollUtil.isNotEmpty(totalHours)) {
                 Long totalHour = totalHours.get(0);
                 Long totalHour = totalHours.get(0);
-                statistics.setCalendarTime(new BigDecimal(totalHour));
+                // 自然时间 考虑进 项目部下的队伍数量
+                if (projectTeamPair.containsKey(deptId)) {
+                    Set<Long> tempTeamIds = projectTeamPair.get(deptId);
+                    statistics.setCalendarTime(new BigDecimal(totalHour * tempTeamIds.size()));
+                }
             }
             }
             result.add(statistics);
             result.add(statistics);
         });
         });