Преглед изворни кода

pms 瑞恒日报 列表 运行时效 按照小时统计的设备利用率

zhangcl пре 3 дана
родитељ
комит
8009e1e9ba

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

@@ -780,6 +780,33 @@ public class IotRhDailyReportController {
             });
         }
 
+        // 筛选瑞恒 主设备 rq_iot_rh_main_device_category
+        Set<Long> mainDeviceCategoryIds = new HashSet<>();
+        List<DictDataDO> mainDeviceCategoryDictData = dictDataService.getDictDataListByDictType("rq_iot_rh_main_device_category");
+        if (CollUtil.isNotEmpty(mainDeviceCategoryDictData)) {
+            mainDeviceCategoryDictData.forEach(data -> {
+                String value = data.getValue();
+                if (NumberUtil.isNumber(value)) {
+                    Long longValue = Long.valueOf(value);
+                    mainDeviceCategoryIds.add(longValue);
+                }
+            });
+        }
+        // 包含设备的部门id集合
+        Set<Long> haveDeviceDeptIds = new HashSet<>();
+        IotDevicePageReqVO mainDeviceReqVO = new IotDevicePageReqVO();
+        mainDeviceReqVO.setDeptIds(new ArrayList<>(teamIds));
+        List<IotDeviceDO> devices = iotDeviceMapper.selectListAlone(mainDeviceReqVO);
+        if (CollUtil.isNotEmpty(devices)) {
+            // 筛选出包含设备的队伍部门集合
+            devices.forEach(device -> {
+                // 20260605 筛选包含主设备的队伍
+                if (mainDeviceCategoryIds.contains(device.getAssetClass())) {
+                    haveDeviceDeptIds.add(device.getDeptId());
+                }
+            });
+        }
+
         // 查询每个队伍的 增压机 类型的设备 查询设备的 型号 device_no
         // 瑞恒 增压机 设备类别 字典数据
         Set<Long> deviceCategories = new HashSet<>();
@@ -806,6 +833,32 @@ public class IotRhDailyReportController {
             });
         }
 
+        // 运行时效 按小时统计的 设备利用率
+        // key日报id     value包含  设备的队伍按小时统计的设备利用率
+        Map<Long, BigDecimal> teamWorkTimePair = new HashMap<>();
+
+        if (CollUtil.isNotEmpty(reports)) {
+            reports.forEach(report -> {
+                teamWorkTimePair.put(report.getId(), BigDecimal.ZERO);
+                if (haveDeviceDeptIds.contains(report.getDeptId())) {
+                    // 按照时间H统计设备利用率
+                    BigDecimal gasInjectionTime = ObjUtil.defaultIfNull(report.getDailyInjectGasTime(), BigDecimal.ZERO);
+                    BigDecimal waterInjectionTime = ObjUtil.defaultIfNull(report.getDailyInjectWaterTime(), BigDecimal.ZERO);
+                    BigDecimal workTime = gasInjectionTime.compareTo(BigDecimal.ZERO) > 0
+                            ? gasInjectionTime
+                            : waterInjectionTime.compareTo(BigDecimal.ZERO) > 0
+                            ? waterInjectionTime
+                            : BigDecimal.ZERO;
+                    if (workTime.compareTo(BigDecimal.ZERO) > 0) {
+                        // 取 注气时间 注水时间 的较大者
+                        BigDecimal denominator = new BigDecimal(1 * 24);
+                        BigDecimal utilization = workTime.divide(denominator, 4, RoundingMode.HALF_UP);
+                        teamWorkTimePair.put(report.getId(), utilization);
+                    }
+                }
+            });
+        }
+
         // key项目id   value项目合同号
         Map<Long, String> projectPair = new HashMap<>();
         //  key任务id     value任务井号
@@ -1054,17 +1107,7 @@ public class IotRhDailyReportController {
         });
         // 2. 拼接数据
         return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {
-            if (ObjUtil.isNotEmpty(reportVO.getTransitTime())) {
-                // 获取原始小数
-                BigDecimal transitTime = reportVO.getTransitTime();
-                // 乘以100转换为百分比数值
-                BigDecimal percentage = transitTime.multiply(BigDecimal.valueOf(100));
-                // 格式化保留2位小数
-                DecimalFormat df = new DecimalFormat("0.00");
-                String transitTimeRate = df.format(percentage) + "%";
-                // 赋值
-                reportVO.setTransitTimeRate(transitTimeRate);
-            }
+
             // 气电比 塔里木、吐哈-气/电   气/电/1.07-其它  气单位:方   电单位:KWh
             if (teamIdProjectNamePair.containsKey(reportVO.getDeptId())) {
                 String deptName = teamIdProjectNamePair.get(reportVO.getDeptId());
@@ -1097,6 +1140,21 @@ public class IotRhDailyReportController {
                 reportVO.setNonProductionRateFormat(nonProductionRate);
             }
 
+            // 运行时效 按小时统计的设备利用率
+            findAndThen(teamWorkTimePair, reportVO.getId(), utilizationRate -> reportVO.setTransitTime(utilizationRate));
+
+            if (ObjUtil.isNotEmpty(reportVO.getTransitTime())) {
+                // 获取原始小数
+                BigDecimal transitTime = reportVO.getTransitTime();
+                // 乘以100转换为百分比数值
+                BigDecimal percentage = transitTime.multiply(BigDecimal.valueOf(100));
+                // 格式化保留2位小数
+                DecimalFormat df = new DecimalFormat("0.00");
+                String transitTimeRate = df.format(percentage) + "%";
+                // 赋值
+                reportVO.setTransitTimeRate(transitTimeRate);
+            }
+
             // 导出列表时 格式化时间为 yyyy-MM-dd
             if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
                 reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));