|
|
@@ -1402,8 +1402,12 @@ public class IotStaticController {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- // key日期2026-06-08 value日期对应的日报数量
|
|
|
+ // key日期2026-06-08 value日期对应的注气或注水 > 0 的日报数量
|
|
|
Map<String, Integer> dateReportCountPair = new HashMap<>();
|
|
|
+
|
|
|
+ // key日期2026-06-08 value日期对应的日报总数量
|
|
|
+ Map<String, Integer> dateTotalReportCountPair = new HashMap<>();
|
|
|
+
|
|
|
reports.forEach(report -> {
|
|
|
// 按照日期维度统计各 工作量数据 累计用电量 累计油耗 累计注气量 累计注水量
|
|
|
LocalDateTime reportLocalDate = report.getCreateTime();
|
|
|
@@ -1420,13 +1424,23 @@ public class IotStaticController {
|
|
|
dateReportCountPair.put(reportDateStr, 1);
|
|
|
}
|
|
|
}
|
|
|
+ // 统计每天的日报数量
|
|
|
+ if (dateTotalReportCountPair.containsKey(reportDateStr)) {
|
|
|
+ Integer tempNum = dateTotalReportCountPair.get(reportDateStr);
|
|
|
+ dateTotalReportCountPair.put(reportDateStr, ++tempNum);
|
|
|
+ } else {
|
|
|
+ dateTotalReportCountPair.put(reportDateStr, 1);
|
|
|
+ }
|
|
|
});
|
|
|
// 计算每天的设备利用率
|
|
|
Map<String, BigDecimal> dateReportUtilizationPair = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(dateReportCountPair)) {
|
|
|
+ // 20260915 修改设备利用率 计算逻辑 分母修改为 总日报数量
|
|
|
+ // 原分母 teamIds.size() * 1
|
|
|
dateReportCountPair.forEach((reportDateStr, reportNum) -> {
|
|
|
- if (CollUtil.isNotEmpty(teamIds)) {
|
|
|
- BigDecimal deviceUtilization = new BigDecimal((double) reportNum / (teamIds.size() * 1))
|
|
|
+ if (dateTotalReportCountPair.containsKey(reportDateStr)) {
|
|
|
+ Integer totalReportNum = dateTotalReportCountPair.get(reportDateStr);
|
|
|
+ BigDecimal deviceUtilization = new BigDecimal((double) reportNum / totalReportNum)
|
|
|
.setScale(4, RoundingMode.HALF_UP);
|
|
|
dateReportUtilizationPair.put(reportDateStr, deviceUtilization);
|
|
|
}
|
|
|
@@ -1529,19 +1543,21 @@ public class IotStaticController {
|
|
|
qualifiedCount++;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 计算月利用率:分子=合格日报数,分母=队伍数 × 当月天数
|
|
|
- BigDecimal utilization = BigDecimal.ZERO;
|
|
|
- if (CollUtil.isNotEmpty(teamIds)) {
|
|
|
- int daysInMonth = yearMonth.lengthOfMonth();
|
|
|
- long denominator = (long) teamIds.size() * daysInMonth;
|
|
|
- if (denominator > 0) {
|
|
|
- utilization = BigDecimal.valueOf(qualifiedCount)
|
|
|
- .divide(BigDecimal.valueOf(denominator), 4, RoundingMode.HALF_UP);
|
|
|
+ // 计算月利用率:分子=合格日报数,分母=队伍数 × 当月天数
|
|
|
+ // 20260915 修改设备利用率计算逻辑 分母修改为 日报总数量
|
|
|
+ // 原分母 teamIds.size() * daysInMonth
|
|
|
+ BigDecimal utilization = BigDecimal.ZERO;
|
|
|
+ if (CollUtil.isNotEmpty(teamIds)) {
|
|
|
+ int daysInMonth = yearMonth.lengthOfMonth();
|
|
|
+ long denominator = (long) teamIds.size() * daysInMonth;
|
|
|
+ if (CollUtil.isNotEmpty(reports)) {
|
|
|
+ utilization = BigDecimal.valueOf(qualifiedCount)
|
|
|
+ .divide(BigDecimal.valueOf(reports.size()), 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
}
|
|
|
+ monthUtilizationMap.put(month, utilization);
|
|
|
}
|
|
|
- monthUtilizationMap.put(month, utilization);
|
|
|
}
|
|
|
|
|
|
// 4. 构建返回结果(与 sevenDayUtilization 结构完全一致)
|
|
|
@@ -2779,8 +2795,10 @@ public class IotStaticController {
|
|
|
}
|
|
|
}
|
|
|
// 计算公司总的设备利用率
|
|
|
- if (totalTeamNum > 0 && daysCount > 0) {
|
|
|
- totalDeviceUtilization = new BigDecimal((double) totalReportCount / (totalTeamNum * daysCount))
|
|
|
+ // 20260915 修改设备利用率计算逻辑 分母修改为 总日报数量
|
|
|
+ // 原分母 totalTeamNum * daysCount
|
|
|
+ if (daysCount > 0) {
|
|
|
+ totalDeviceUtilization = new BigDecimal((double) totalReportCount / dailyReports.size())
|
|
|
.setScale(4, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
}
|