|
|
@@ -2338,6 +2338,7 @@ public class IotStaticController {
|
|
|
throw exception(IOT_DAILY_REPORT_TIME_NOT_EXISTS);
|
|
|
}
|
|
|
List<Long> sortedProjectIds = new ArrayList<>();
|
|
|
+ sortedProjectIds.add(157l);
|
|
|
sortedProjectIds.add(164l); // 塔河项目部
|
|
|
sortedProjectIds.add(165l); // 塔里木项目部
|
|
|
sortedProjectIds.add(160l); // 吐哈项目部
|
|
|
@@ -2360,6 +2361,9 @@ public class IotStaticController {
|
|
|
// 队伍id 集合
|
|
|
Set<Long> teamDepartmentIds = new HashSet<>();
|
|
|
|
|
|
+ // key施工队伍id value状态为LY的项目部id
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
+
|
|
|
// key项目部id value项目部年累计注气量
|
|
|
Map<Long, BigDecimal> projectYearGasInjectionPair = new HashMap<>();
|
|
|
// key项目部id value项目部年累计注水量
|
|
|
@@ -2428,6 +2432,8 @@ public class IotStaticController {
|
|
|
teamIds.add(deptId);
|
|
|
projectTeamPair.put(projectDeptId, teamIds);
|
|
|
}
|
|
|
+ // 设置队伍与上级项目部的关联关系集合
|
|
|
+ teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -2448,6 +2454,10 @@ public class IotStaticController {
|
|
|
yearReqVO.setCreateTime(new LocalDateTime[]{yearBegin, originalEnd});
|
|
|
}
|
|
|
List<IotRhDailyReportDO> yearDailyReports = iotRhDailyReportMapper.dailyReports(yearReqVO);
|
|
|
+
|
|
|
+ // key项目部id value项目部下包含设备的队伍 年度 注气时间 或 注水时间 总和
|
|
|
+ Map<Long, BigDecimal> projectYearWorkTimePair = new HashMap<>();
|
|
|
+
|
|
|
if (CollUtil.isNotEmpty(yearDailyReports)) {
|
|
|
yearDailyReports.forEach(yearReport -> {
|
|
|
if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
@@ -2471,6 +2481,19 @@ public class IotStaticController {
|
|
|
} else {
|
|
|
projectYearWaterInjectionPair.put(projectDeptId, dailyWaterInjection);
|
|
|
}
|
|
|
+ // 各项目部年度 运行时效(按小时统计的设备利用率)
|
|
|
+ // 按小时数 统计设备利用率
|
|
|
+ BigDecimal gasInjectionTime = ObjUtil.defaultIfNull(yearReport.getDailyInjectGasTime(), BigDecimal.ZERO);
|
|
|
+ BigDecimal waterInjectionTime = ObjUtil.defaultIfNull(yearReport.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) {
|
|
|
+ projectYearWorkTimePair.merge(projectDeptId, workTime, BigDecimal::add);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -2590,13 +2613,9 @@ public class IotStaticController {
|
|
|
projectWaterInjectionPair.put(projectDeptId, dailyWaterInjection);
|
|
|
}
|
|
|
|
|
|
- // 项目部 年累计注气量
|
|
|
-
|
|
|
// 日报关联的任务井号
|
|
|
Long reportTaskId = report.getTaskId();
|
|
|
- if (ObjUtil.isNotEmpty(reportTaskId)) {
|
|
|
|
|
|
- }
|
|
|
// 提取 所有日报非生产时间和 = 24H 的队伍
|
|
|
List<BigDecimal> nptTimeList = Arrays.asList(
|
|
|
report.getAccidentTime(),
|
|
|
@@ -2664,6 +2683,23 @@ public class IotStaticController {
|
|
|
} else {
|
|
|
daysCount = 0L;
|
|
|
}
|
|
|
+
|
|
|
+ // 计算年度开始 当前年1.1到指定查询时间区间内包含的天数
|
|
|
+ long yearTotalDay = 0L;
|
|
|
+ List<Long> yearTotalDays = new ArrayList<>();
|
|
|
+ if (ObjUtil.isNotEmpty(reqVO.getCreateTime()) && reqVO.getCreateTime().length >= 2) {
|
|
|
+ // 取查询结束日期
|
|
|
+ LocalDateTime queryEndTime = reqVO.getCreateTime()[1];
|
|
|
+ // 当年1月1日 零点
|
|
|
+ LocalDate yearStartDate = LocalDate.of(queryEndTime.getYear(), 1, 1);
|
|
|
+ LocalDate queryEndDate = queryEndTime.toLocalDate();
|
|
|
+ // 首尾都包含,+1
|
|
|
+ yearTotalDay = ChronoUnit.DAYS.between(yearStartDate, queryEndDate) + 1;
|
|
|
+ yearTotalDays.add(yearTotalDay);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 计算每个项目部的设备利用率
|
|
|
if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
projectTeamPair.forEach((projectDeptId, teamIds) -> {
|
|
|
@@ -2720,6 +2756,7 @@ public class IotStaticController {
|
|
|
Integer zbTeamCount = zbTeamCountPair.getOrDefault(projectDeptId, 0);
|
|
|
// 驻地待命 队伍数量 = 队伍总数 - 施工队伍 - 准备队伍
|
|
|
Integer dmTeamCount = Math.max(currentTeamNum - sgTeamCount - zbTeamCount, 0);
|
|
|
+ zddmTeamCountPair.put(projectDeptId, dmTeamCount);
|
|
|
rateVo.setSgTeamCount(sgTeamCount);
|
|
|
rateVo.setZbTeamCount(zbTeamCount);
|
|
|
rateVo.setDmTeamCount(dmTeamCount);
|
|
|
@@ -2742,6 +2779,7 @@ public class IotStaticController {
|
|
|
// 计算项目部 按小时统计的设备利用率(运行时效)
|
|
|
if (projectWorkTimePair.containsKey(projectDeptId)) {
|
|
|
BigDecimal reportWorkTime = projectWorkTimePair.getOrDefault(projectDeptId, BigDecimal.ZERO);
|
|
|
+ // 统计所有项目部 当日 总工作时间 以便于计算 公司整体的当日运行时效
|
|
|
if (currentTeamNum > 0 && daysCount > 0) {
|
|
|
// 分母 = 队伍数 * 天数 * 24小时
|
|
|
BigDecimal denominator = new BigDecimal(currentTeamNum * daysCount * 24);
|
|
|
@@ -2753,10 +2791,123 @@ public class IotStaticController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 计算项目部 年度运行时效 按小时统计的设备利用率(运行时效)
|
|
|
+ if (projectYearWorkTimePair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal reportWorkTime = projectYearWorkTimePair.getOrDefault(projectDeptId, BigDecimal.ZERO);
|
|
|
+ // 统计所有项目部 年度的 总工作时间 以便于计算 公司整体的当日运行时效
|
|
|
+ if (currentTeamNum > 0 && CollUtil.isNotEmpty(yearTotalDays)) {
|
|
|
+ long tempYearTotalDay = yearTotalDays.get(0);
|
|
|
+ // 分母 = 队伍数 * 天数 * 24小时
|
|
|
+ BigDecimal denominator = new BigDecimal(currentTeamNum * tempYearTotalDay * 24);
|
|
|
+ // 安全计算,避免除0
|
|
|
+ BigDecimal utilization = BigDecimal.ZERO;
|
|
|
+ if (denominator.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ utilization = reportWorkTime.divide(denominator, 4, RoundingMode.HALF_UP);
|
|
|
+ rateVo.setYearHourUtilizationRate(utilization);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
rates.add(rateVo);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 公司汇总的 数据
|
|
|
+ ProjectUtilizationRateVo rateVo = new ProjectUtilizationRateVo();
|
|
|
+ // 计算公司汇总的设备利用率 日平均时效 年平均时效
|
|
|
+ // teamProjectIdPair 有效的队伍集合
|
|
|
+ // 公司当日总运行工时
|
|
|
+ BigDecimal currentTotalWorkTime = projectWorkTimePair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ // 公司年度总运行工时
|
|
|
+ BigDecimal yearTotalWorkTime = projectYearWorkTimePair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(teamProjectIdPair)) {
|
|
|
+ int teamCount = teamProjectIdPair.size();
|
|
|
+ // 公司 当日运行时效 分母 = 队伍数 * 天数 * 24小时
|
|
|
+ BigDecimal denominator = new BigDecimal(teamCount * daysCount * 24);
|
|
|
+ // 安全计算,避免除0
|
|
|
+ BigDecimal utilization = BigDecimal.ZERO;
|
|
|
+ if (denominator.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ utilization = currentTotalWorkTime.divide(denominator, 4, RoundingMode.HALF_UP);
|
|
|
+ rateVo.setHourUtilizationRate(utilization);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 公司 年运行时效 分母 = 队伍数 * 天数 * 24小时
|
|
|
+ long tempYearTotalDay = yearTotalDays.get(0);
|
|
|
+ BigDecimal yearDenominator = new BigDecimal(teamCount * tempYearTotalDay * 24);
|
|
|
+ // 安全计算,避免除0
|
|
|
+ BigDecimal yearUtilization = BigDecimal.ZERO;
|
|
|
+ if (yearDenominator.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ yearUtilization = yearTotalWorkTime.divide(yearDenominator, 4, RoundingMode.HALF_UP);
|
|
|
+ rateVo.setYearHourUtilizationRate(yearUtilization);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 公司年累计注气
|
|
|
+ BigDecimal companyYearGasInjection = projectYearGasInjectionPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ // 单位转换成 万方
|
|
|
+ BigDecimal companyGasInjectionWanFang = companyYearGasInjection
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ // 公司年累计注水
|
|
|
+ BigDecimal companyYearWaterInjection = projectYearWaterInjectionPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ // 单位转换成 万方
|
|
|
+ BigDecimal companyWaterInjectionWanFang = companyYearWaterInjection
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ // 公司当日累计注气
|
|
|
+ BigDecimal companyCurrentGasInjection = projectGasInjectionPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ // 单位转换成 万方
|
|
|
+ BigDecimal currentGasInjectionWanFang = companyCurrentGasInjection
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ // 公司当日累计注水
|
|
|
+ BigDecimal companyCurrentWaterInjection = projectWaterInjectionPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ // 单位转换成 万方
|
|
|
+ BigDecimal currentWaterInjectionWanFang = companyCurrentWaterInjection
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+
|
|
|
+ // 公司队伍总数
|
|
|
+ Integer companyTeamCount = teamProjectIdPair.size();
|
|
|
+ // 公司待命队伍总数
|
|
|
+ Integer companyDmTeamCount = zddmTeamCountPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(0, Integer::sum);
|
|
|
+ // 公司施工准备队伍总数
|
|
|
+ Integer companyZbTeamCount = zbTeamCountPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(0, Integer::sum);
|
|
|
+ // 公司施工队伍总数
|
|
|
+ Integer companySgTeamCount = sgTeamCountPair.values().stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(0, Integer::sum);
|
|
|
+ rateVo.setProjectDeptName("合计");
|
|
|
+ rateVo.setProjectDeptId(157l);
|
|
|
+ rateVo.setSort(0);
|
|
|
+ rateVo.setTeamCount(companyTeamCount);
|
|
|
+ rateVo.setDmTeamCount(companyDmTeamCount);
|
|
|
+ rateVo.setZbTeamCount(companyZbTeamCount);
|
|
|
+ rateVo.setSgTeamCount(companySgTeamCount);
|
|
|
+ rateVo.setGasInjection(currentGasInjectionWanFang);
|
|
|
+ rateVo.setWaterInjection(currentWaterInjectionWanFang);
|
|
|
+ rateVo.setYearGasInjection(companyGasInjectionWanFang);
|
|
|
+ rateVo.setYearWaterInjection(companyWaterInjectionWanFang);
|
|
|
+ rates.add(rateVo);
|
|
|
+
|
|
|
}
|
|
|
// rates.sort(Comparator.comparingDouble(ProjectUtilizationRateVo::getUtilizationRate).reversed());
|
|
|
// 克拉玛依 加入到 吐哈项目部,两个项目部合并
|
|
|
@@ -2820,7 +2971,7 @@ public class IotStaticController {
|
|
|
// 暂时不统计欧洲项目部 352
|
|
|
rates.sort(Comparator.comparingInt(vo -> {
|
|
|
Long deptId = vo.getProjectDeptId();
|
|
|
- // 获取当前projectDeptId在sortedProjectIds中的索引
|
|
|
+ // 获取当前projectDeptId 在 sortedProjectIds中 的索引
|
|
|
int index = sortedProjectIds.indexOf(deptId);
|
|
|
// 若不在集合中,用集合长度作为索引(排在所有指定项目部之后)
|
|
|
return index != -1 ? index : sortedProjectIds.size();
|