|
|
@@ -1086,6 +1086,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
Map<Long, BigDecimal> cumulativeNonProductionPair = new HashMap<>();
|
|
|
// key队伍id/项目部id value设备利用率
|
|
|
Map<Long, BigDecimal> deviceUtilizationPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value设备利用率(按小时统计)
|
|
|
+ Map<Long, BigDecimal> hourDeviceUtilizationPair = new HashMap<>();
|
|
|
|
|
|
// 以项目部为维度统计数据
|
|
|
// 找到所有项目部与队伍的对应关系
|
|
|
@@ -1229,26 +1231,47 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
// key队伍id value队伍下相关设备产能
|
|
|
Map<Long, BigDecimal> teamCapacityPair = queryCapacities(new ArrayList<>(allRhChildDeptIds));
|
|
|
|
|
|
+ // key项目部id value项目部下包含设备的队伍注气时间或注水时间总和
|
|
|
+ Map<Long, BigDecimal> projectWorkTimePair = new HashMap<>();
|
|
|
+
|
|
|
// 累计计算各项指标
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
|
- // 统计各项目部的日报数量
|
|
|
+ Long deptId = report.getDeptId();
|
|
|
+ // 统计各项目部的日报数量 注气量 或 注水量 >0 的日报数量
|
|
|
if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
- projectTeamPair.forEach((projectDeptId, teamDeptIds) -> {
|
|
|
- if (teamDeptIds.contains(report.getDeptId())) {
|
|
|
- // 项目部日报数量
|
|
|
- if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
- Integer tempCount = projectReportPair.get(projectDeptId);
|
|
|
- projectReportPair.put(projectDeptId, ++tempCount);
|
|
|
- } else {
|
|
|
- projectReportPair.put(projectDeptId, 1);
|
|
|
+ if (report.getDailyGasInjection().compareTo(BigDecimal.ZERO)>0 || report.getDailyWaterInjection().compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ projectTeamPair.forEach((projectDeptId, teamDeptIds) -> {
|
|
|
+ if (teamDeptIds.contains(deptId)) {
|
|
|
+ // 项目部日报数量
|
|
|
+ if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
+ Integer tempCount = projectReportPair.get(projectDeptId);
|
|
|
+ projectReportPair.put(projectDeptId, ++tempCount);
|
|
|
+ } else {
|
|
|
+ projectReportPair.put(projectDeptId, 1);
|
|
|
+ }
|
|
|
}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按小时数 统计设备利用率
|
|
|
+ BigDecimal gasInjectionTime = ObjUtil.defaultIfNull(report.getDailyInjectGasTime(), BigDecimal.ZERO);
|
|
|
+ BigDecimal waterInjectionTime = ObjUtil.defaultIfNull(report.getDailyInjectWaterTime(), BigDecimal.ZERO);
|
|
|
+ BigDecimal maxWorkTime = gasInjectionTime.max(waterInjectionTime);
|
|
|
+ if (maxWorkTime.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ // 取 注气时间 注水时间 的较大者
|
|
|
+ // 直接获取队伍对应的项目部ID
|
|
|
+ Long projectDeptId = teamProjectIdPair.get(deptId);
|
|
|
+ // 校验:项目部ID不为空 + 该项目部存在有效队伍
|
|
|
+ if (ObjUtil.isNotEmpty(projectDeptId) && projectTeamPair.containsKey(projectDeptId)) {
|
|
|
+ // 存在则累加,不存在则赋值
|
|
|
+ projectWorkTimePair.merge(projectDeptId, maxWorkTime, BigDecimal::add);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
- Long projectDeptId = teamProjectIdPair.get(report.getDeptId());
|
|
|
+ if (ObjUtil.isNotEmpty(deptId) && teamProjectIdPair.containsKey(deptId)) {
|
|
|
+ Long projectDeptId = teamProjectIdPair.get(deptId);
|
|
|
if (ObjUtil.isNotEmpty(projectDeptId) && projectDeptPair.containsKey(projectDeptId)) {
|
|
|
// 累计注气量
|
|
|
cumulativeGasInjectionPair.merge(projectDeptId, report.getDailyGasInjection(), BigDecimal::add);
|
|
|
@@ -1258,8 +1281,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
cumulativePowerConsumptionPair.merge(projectDeptId, report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
// 累计油耗
|
|
|
cumulativeOilConsumptionPair.merge(projectDeptId, report.getDailyOilUsage(), BigDecimal::add);
|
|
|
- if (teamCapacityPair.containsKey(report.getDeptId())) {
|
|
|
- BigDecimal tempCapacity = teamCapacityPair.get(report.getDeptId());
|
|
|
+ if (teamCapacityPair.containsKey(deptId)) {
|
|
|
+ BigDecimal tempCapacity = teamCapacityPair.get(deptId);
|
|
|
cumulativeCapacityPair.merge(projectDeptId, tempCapacity, BigDecimal::add);
|
|
|
}
|
|
|
// 非生产时间 用于计算非生产时效
|
|
|
@@ -1329,6 +1352,27 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ // 计算各项目部的平均设备利用率(按照小时统计)
|
|
|
+ projectTeamPair.forEach((projectDeptId, resultTeamIds) -> {
|
|
|
+ Integer currentTeamNum = resultTeamIds.size();
|
|
|
+ if (projectWorkTimePair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal reportWorkTime = projectWorkTimePair.getOrDefault(projectDeptId, BigDecimal.ZERO);
|
|
|
+ // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum * daysCount)
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
+ if (currentTeamNum > 0 && CollUtil.isNotEmpty(daysCounts)) {
|
|
|
+ long daysCount = daysCounts.get(0);
|
|
|
+ // 分母 = 队伍数 * 天数 * 24小时
|
|
|
+ BigDecimal denominator = new BigDecimal(currentTeamNum * daysCount * 24);
|
|
|
+ // 安全计算,避免除0
|
|
|
+ BigDecimal utilization = BigDecimal.ZERO;
|
|
|
+ if (denominator.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ utilization = reportWorkTime.divide(denominator, 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ hourDeviceUtilizationPair.put(projectDeptId, utilization);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
if (CollUtil.isNotEmpty(cumulativeNonProductionTimePair)) {
|
|
|
@@ -1355,6 +1399,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
statistics.setSort(dept.getSort());
|
|
|
statistics.setType("2");
|
|
|
statistics.setUtilizationRate(deviceUtilizationPair.get(deptId));
|
|
|
+ // 按小时统计 设备利用率
|
|
|
+ statistics.setHourUtilizationRate(hourDeviceUtilizationPair.get(deptId));
|
|
|
statistics.setCumulativeGasInjection(cumulativeGasInjectionPair.get(deptId));
|
|
|
statistics.setCumulativeWaterInjection(cumulativeWaterInjectionPair.get(deptId));
|
|
|
statistics.setCumulativePowerConsumption(cumulativePowerConsumptionPair.get(deptId));
|
|
|
@@ -1885,6 +1931,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
Map<Long, BigDecimal> cumulativeNonProductionPair = new HashMap<>();
|
|
|
// key队伍id/项目部id value设备利用率
|
|
|
Map<Long, BigDecimal> deviceUtilizationPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value设备利用率(按小时统计)
|
|
|
+ Map<Long, BigDecimal> hourDeviceUtilizationPair = new HashMap<>();
|
|
|
|
|
|
// 以 队伍 为维度统计数据
|
|
|
// 找到所有项目部与队伍的对应关系
|
|
|
@@ -1948,29 +1996,47 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
// 统计各队伍的设备利用率
|
|
|
// key队伍id value队伍指定时间区域内日报数量
|
|
|
Map<Long, Integer> teamReportPair = new HashMap<>();
|
|
|
+ // key队伍id value包含设备的队伍注气时间或注水时间总和
|
|
|
+ Map<Long, BigDecimal> teamWorkTimePair = new HashMap<>();
|
|
|
+
|
|
|
// 累计计算各项指标
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
|
- if (ObjUtil.isNotEmpty(report.getDeptId())) {
|
|
|
- // 统计各个队伍的日报数量
|
|
|
- if (teamReportPair.containsKey(report.getDeptId())) {
|
|
|
- Integer tempCount = teamReportPair.get(report.getDeptId());
|
|
|
- teamReportPair.put(report.getDeptId(), ++tempCount);
|
|
|
- } else {
|
|
|
- teamReportPair.put(report.getDeptId(), 1);
|
|
|
+ Long deptId = report.getDeptId();
|
|
|
+ if (ObjUtil.isNotEmpty(deptId)) {
|
|
|
+ if (haveDeviceDeptIds.contains(deptId)) {
|
|
|
+ // 统计各个队伍的日报数量 筛选 注气量 或 注水量 >0 的日报
|
|
|
+ if (report.getDailyGasInjection().compareTo(BigDecimal.ZERO)>0 || report.getDailyWaterInjection().compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ if (teamReportPair.containsKey(deptId)) {
|
|
|
+ Integer tempCount = teamReportPair.get(deptId);
|
|
|
+ teamReportPair.put(deptId, ++tempCount);
|
|
|
+ } else {
|
|
|
+ teamReportPair.put(deptId, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 按照时间H统计设备利用率
|
|
|
+ BigDecimal gasInjectionTime = ObjUtil.defaultIfNull(report.getDailyInjectGasTime(), BigDecimal.ZERO);
|
|
|
+ BigDecimal waterInjectionTime = ObjUtil.defaultIfNull(report.getDailyInjectWaterTime(), BigDecimal.ZERO);
|
|
|
+ BigDecimal maxWorkTime = gasInjectionTime.max(waterInjectionTime);
|
|
|
+ if (maxWorkTime.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ // 取 注气时间 注水时间 的较大者
|
|
|
+ // 校验:项目部ID不为空 + 该项目部存在有效队伍
|
|
|
+ // 存在则累加,不存在则赋值
|
|
|
+ teamWorkTimePair.merge(deptId, maxWorkTime, BigDecimal::add);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 累计注气量
|
|
|
- cumulativeGasInjectionPair.merge(report.getDeptId(), report.getDailyGasInjection(), BigDecimal::add);
|
|
|
+ cumulativeGasInjectionPair.merge(deptId, report.getDailyGasInjection(), BigDecimal::add);
|
|
|
// 累计注水量
|
|
|
- cumulativeWaterInjectionPair.merge(report.getDeptId(), report.getDailyWaterInjection(), BigDecimal::add);
|
|
|
+ cumulativeWaterInjectionPair.merge(deptId, report.getDailyWaterInjection(), BigDecimal::add);
|
|
|
// 累计用电量
|
|
|
- cumulativePowerConsumptionPair.merge(report.getDeptId(), report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
+ cumulativePowerConsumptionPair.merge(deptId, report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
// 累计油耗
|
|
|
- cumulativeOilConsumptionPair.merge(report.getDeptId(), report.getDailyOilUsage(), BigDecimal::add);
|
|
|
- if (teamCapacityPair.containsKey(report.getDeptId())) {
|
|
|
- BigDecimal tempCapacity = teamCapacityPair.get(report.getDeptId());
|
|
|
- cumulativeCapacityPair.merge(report.getDeptId(), tempCapacity, BigDecimal::add);
|
|
|
+ cumulativeOilConsumptionPair.merge(deptId, report.getDailyOilUsage(), BigDecimal::add);
|
|
|
+ if (teamCapacityPair.containsKey(deptId)) {
|
|
|
+ BigDecimal tempCapacity = teamCapacityPair.get(deptId);
|
|
|
+ cumulativeCapacityPair.merge(deptId, tempCapacity, BigDecimal::add);
|
|
|
}
|
|
|
// 非生产时效
|
|
|
// NPT 归类 设备故障repair_time 工程质量accident_time 技术受限complexity_time 生产组织rectification_time 不可抗力waiting_stop_time
|
|
|
@@ -1990,14 +2056,14 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
.map(time -> ObjUtil.defaultIfNull(time, BigDecimal.ZERO))
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (nonProductionTimeSum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if (cumulativeNonProductionTimePair.containsKey(report.getDeptId())) {
|
|
|
- List<BigDecimal> tempNonProductionTimes = cumulativeNonProductionTimePair.get(report.getDeptId());
|
|
|
+ if (cumulativeNonProductionTimePair.containsKey(deptId)) {
|
|
|
+ List<BigDecimal> tempNonProductionTimes = cumulativeNonProductionTimePair.get(deptId);
|
|
|
tempNonProductionTimes.add(nonProductionTimeSum);
|
|
|
- cumulativeNonProductionTimePair.put(report.getDeptId(), tempNonProductionTimes);
|
|
|
+ cumulativeNonProductionTimePair.put(deptId, tempNonProductionTimes);
|
|
|
} else {
|
|
|
List<BigDecimal> tempNonProductionTimes = new ArrayList<>();
|
|
|
tempNonProductionTimes.add(nonProductionTimeSum);
|
|
|
- cumulativeNonProductionTimePair.put(report.getDeptId(), tempNonProductionTimes);
|
|
|
+ cumulativeNonProductionTimePair.put(deptId, tempNonProductionTimes);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2046,6 +2112,27 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 计算各队伍的平均设备利用率 按照小时H统计
|
|
|
+ if (CollUtil.isNotEmpty(teamWorkTimePair)) {
|
|
|
+ teamWorkTimePair.forEach((teamDeptId, workTime) -> {
|
|
|
+ BigDecimal reportWorkTime = teamWorkTimePair.getOrDefault(teamDeptId, BigDecimal.ZERO);
|
|
|
+ Integer currentTeamNum = 1;
|
|
|
+ // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum * daysCount)
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
+ if (currentTeamNum > 0 && CollUtil.isNotEmpty(daysCounts)) {
|
|
|
+ long daysCount = daysCounts.get(0);
|
|
|
+ // 分母 = 队伍数 * 天数 * 24小时
|
|
|
+ BigDecimal denominator = new BigDecimal(currentTeamNum * daysCount * 24);
|
|
|
+ // 安全计算,避免除0
|
|
|
+ BigDecimal utilization = BigDecimal.ZERO;
|
|
|
+ if (denominator.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ utilization = reportWorkTime.divide(denominator, 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ hourDeviceUtilizationPair.put(teamDeptId, utilization);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 生成返回的数据列表集合
|
|
|
@@ -2055,7 +2142,10 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
statistics.setTeamName(dept.getName());
|
|
|
statistics.setSort(dept.getSort());
|
|
|
statistics.setType("3");
|
|
|
+ // 按天统计的设备利用率
|
|
|
statistics.setUtilizationRate(deviceUtilizationPair.get(teamDeptId));
|
|
|
+ // 按小时统计的设备利用率
|
|
|
+ statistics.setHourUtilizationRate(hourDeviceUtilizationPair.get(teamDeptId));
|
|
|
statistics.setCumulativeGasInjection(cumulativeGasInjectionPair.get(teamDeptId));
|
|
|
statistics.setCumulativeWaterInjection(cumulativeWaterInjectionPair.get(teamDeptId));
|
|
|
statistics.setCumulativePowerConsumption(cumulativePowerConsumptionPair.get(teamDeptId));
|