|
|
@@ -102,6 +102,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
@@ -1452,6 +1453,15 @@ public class IotStaticController {
|
|
|
if (reqVO.getCreateTime().length < 2) {
|
|
|
throw exception(IOT_DAILY_REPORT_TIME_NOT_EXISTS);
|
|
|
}
|
|
|
+ List<Long> sortedProjectIds = new ArrayList<>();
|
|
|
+ sortedProjectIds.add(164l); // 塔河项目部
|
|
|
+ sortedProjectIds.add(165l); // 塔里木项目部
|
|
|
+ sortedProjectIds.add(160l); // 吐哈项目部
|
|
|
+ sortedProjectIds.add(256l); // 川庆项目部
|
|
|
+ sortedProjectIds.add(269l); // 非洲项目部
|
|
|
+ sortedProjectIds.add(273l); // 南美项目部
|
|
|
+ sortedProjectIds.add(275l); // 中东项目部
|
|
|
+ sortedProjectIds.add(282l); // 中亚项目部
|
|
|
// 各项目部的设备利用率集合
|
|
|
List<ProjectUtilizationRateVo> rates = new ArrayList<>();
|
|
|
// 查询瑞恒 157l 所有项目部
|
|
|
@@ -1504,6 +1514,7 @@ public class IotStaticController {
|
|
|
});
|
|
|
}
|
|
|
// 查询出指定时间区间内 已经填写的日报数量
|
|
|
+ reqVO.setStatisticFlag("Y");
|
|
|
List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
|
|
|
// key项目部id value项目部包含的队伍指定时间区域内日报数量
|
|
|
Map<Long, Integer> projectReportPair = new HashMap<>();
|
|
|
@@ -1545,34 +1556,71 @@ public class IotStaticController {
|
|
|
// 计算每个项目部的设备利用率
|
|
|
if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
projectTeamPair.forEach((projectDeptId, teamIds) -> {
|
|
|
- ProjectUtilizationRateVo rateVo = new ProjectUtilizationRateVo();
|
|
|
- rateVo.setProjectDeptId(projectDeptId);
|
|
|
- if (projectPair.containsKey(projectDeptId)) {
|
|
|
- rateVo.setProjectDeptName(projectPair.get(projectDeptId));
|
|
|
- }
|
|
|
- // 遍历每个项目部 获取每个项目部下队伍数量
|
|
|
- Integer currentTeamNum = teamIds.size();
|
|
|
- rateVo.setTeamCount(currentTeamNum);
|
|
|
- rateVo.setCumulativeDays(currentTeamNum * daysCount);
|
|
|
- double rate = 0.0;
|
|
|
- // 匹配出当前项目部下 日报数量
|
|
|
- if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
- Integer reportCount = projectReportPair.getOrDefault(projectDeptId, 0);
|
|
|
- rateVo.setConstructionDays(reportCount);
|
|
|
- // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum*daysCount)
|
|
|
- // 计算设备利用率(处理除数为0的情况)
|
|
|
- if (currentTeamNum > 0 && daysCount > 0) {
|
|
|
- rate = new BigDecimal((double) reportCount / (currentTeamNum * daysCount))
|
|
|
- .setScale(4, RoundingMode.HALF_UP) // 保留4位小数,四舍五入
|
|
|
- .doubleValue();;
|
|
|
+ // 暂时不统计欧洲项目部 352
|
|
|
+ if (352 != projectDeptId) {
|
|
|
+ ProjectUtilizationRateVo rateVo = new ProjectUtilizationRateVo();
|
|
|
+ rateVo.setProjectDeptId(projectDeptId);
|
|
|
+ if (projectPair.containsKey(projectDeptId)) {
|
|
|
+ rateVo.setProjectDeptName(projectPair.get(projectDeptId));
|
|
|
}
|
|
|
+ if (allDeptPair.containsKey(projectDeptId)) {
|
|
|
+ DeptDO dept = allDeptPair.get(projectDeptId);
|
|
|
+ rateVo.setSort(dept.getSort());
|
|
|
+ }
|
|
|
+ // 遍历每个项目部 获取每个项目部下队伍数量
|
|
|
+ Integer currentTeamNum = teamIds.size();
|
|
|
+ rateVo.setTeamCount(currentTeamNum);
|
|
|
+ rateVo.setCumulativeDays(currentTeamNum * daysCount);
|
|
|
+ double rate = 0.0;
|
|
|
+ // 匹配出当前项目部下 日报数量
|
|
|
+ if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
+ Integer reportCount = projectReportPair.getOrDefault(projectDeptId, 0);
|
|
|
+ rateVo.setConstructionDays(reportCount);
|
|
|
+ // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum*daysCount)
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
+ if (currentTeamNum > 0 && daysCount > 0) {
|
|
|
+ rate = new BigDecimal((double) reportCount / (currentTeamNum * daysCount))
|
|
|
+ .setScale(4, RoundingMode.HALF_UP) // 保留4位小数,四舍五入
|
|
|
+ .doubleValue();;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rateVo.setUtilizationRate(rate); // 存储计算结果
|
|
|
+ rates.add(rateVo);
|
|
|
}
|
|
|
- rateVo.setUtilizationRate(rate); // 存储计算结果
|
|
|
- rates.add(rateVo);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- rates.sort(Comparator.comparingDouble(ProjectUtilizationRateVo::getUtilizationRate).reversed());
|
|
|
+ // rates.sort(Comparator.comparingDouble(ProjectUtilizationRateVo::getUtilizationRate).reversed());
|
|
|
+ // 克拉玛依 加入到 吐哈项目部,两个项目部合并
|
|
|
+ AtomicReference<Integer> mergeTeamCount = new AtomicReference<>(0);
|
|
|
+ AtomicReference<Integer> mergeConstructionDays = new AtomicReference<>(0);
|
|
|
+ AtomicReference<Long> mergeCumulativeDays = new AtomicReference<>(0l);
|
|
|
+ rates.forEach(rate -> {
|
|
|
+ // 克拉玛依 项目部数据
|
|
|
+ if (rate.getProjectDeptId() == 166) {
|
|
|
+ mergeTeamCount.set(rate.getTeamCount());
|
|
|
+ mergeCumulativeDays.set(ObjUtil.isNotEmpty(rate.getCumulativeDays()) ? rate.getCumulativeDays() : 0);
|
|
|
+ mergeConstructionDays.set(ObjUtil.isNotEmpty(rate.getConstructionDays()) ? rate.getConstructionDays() : 0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ rates.forEach(rate -> {
|
|
|
+ // 吐哈项目部 项目部数据
|
|
|
+ if (rate.getProjectDeptId() == 160) {
|
|
|
+ rate.setTeamCount((ObjUtil.isNotEmpty(rate.getTeamCount()) ? rate.getTeamCount() : 0) + mergeTeamCount.get());
|
|
|
+ rate.setCumulativeDays((ObjUtil.isNotEmpty(rate.getCumulativeDays()) ? rate.getCumulativeDays() : 0l) + mergeCumulativeDays.get());
|
|
|
+ rate.setConstructionDays((ObjUtil.isNotEmpty(rate.getConstructionDays()) ? rate.getConstructionDays() : 0) + mergeConstructionDays.get());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 删除projectDeptId为166的对象 克拉玛依项目部
|
|
|
+ rates.removeIf(rate -> rate.getProjectDeptId() == 166);
|
|
|
+ // 暂时不统计欧洲项目部 352
|
|
|
+ rates.sort(Comparator.comparingInt(vo -> {
|
|
|
+ Long deptId = vo.getProjectDeptId();
|
|
|
+ // 获取当前projectDeptId在sortedProjectIds中的索引
|
|
|
+ int index = sortedProjectIds.indexOf(deptId);
|
|
|
+ // 若不在集合中,用集合长度作为索引(排在所有指定项目部之后)
|
|
|
+ return index != -1 ? index : sortedProjectIds.size();
|
|
|
+ }));
|
|
|
return success(rates);
|
|
|
}
|
|
|
|
|
|
@@ -1654,6 +1702,7 @@ public class IotStaticController {
|
|
|
if (CollUtil.isNotEmpty(projectTeamIds)) {
|
|
|
// 查询出指定时间区间内 指定队伍id集合 已经填写的日报数量
|
|
|
reqVO.setDeptIds(projectTeamIds);
|
|
|
+ reqVO.setStatisticFlag("Y");
|
|
|
List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
|
|
|
// 筛选出每个队伍的日报
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|