|
@@ -488,10 +488,10 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
result = statisticsByProjectDept(pageReqVO, dailyReports, pageReqVO.getDeptId());
|
|
result = statisticsByProjectDept(pageReqVO, dailyReports, pageReqVO.getDeptId());
|
|
|
} else if ("2".equals(selectedDept.getType())) {
|
|
} else if ("2".equals(selectedDept.getType())) {
|
|
|
// 以队伍为维度汇总数据
|
|
// 以队伍为维度汇总数据
|
|
|
- result = statisticsByProjectDepartment(pageReqVO, dailyReports, pageReqVO.getDeptId());
|
|
|
|
|
|
|
+ result = statisticsByProjectDepartment(pageReqVO, dailyReports);
|
|
|
} else if ("3".equals(selectedDept.getType())) {
|
|
} else if ("3".equals(selectedDept.getType())) {
|
|
|
// 显示单个队伍的汇总数据
|
|
// 显示单个队伍的汇总数据
|
|
|
- result = statisticsByProjectDepartment(pageReqVO, dailyReports, pageReqVO.getDeptId());
|
|
|
|
|
|
|
+ result = statisticsByProjectDepartment(pageReqVO, dailyReports);
|
|
|
} else {
|
|
} else {
|
|
|
// 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
|
|
// 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
|
|
|
// 以项目部为维度汇总数据
|
|
// 以项目部为维度汇总数据
|
|
@@ -1018,15 +1018,28 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
Map<Long, List<BigDecimal>> cumulativeNonProductionTimePair = new HashMap<>();
|
|
Map<Long, List<BigDecimal>> cumulativeNonProductionTimePair = new HashMap<>();
|
|
|
// key队伍id/项目部id value非生产时效
|
|
// key队伍id/项目部id value非生产时效
|
|
|
Map<Long, BigDecimal> cumulativeNonProductionPair = new HashMap<>();
|
|
Map<Long, BigDecimal> cumulativeNonProductionPair = new HashMap<>();
|
|
|
|
|
+ // key队伍id/项目部id value设备利用率
|
|
|
|
|
+ Map<Long, BigDecimal> deviceUtilizationPair = new HashMap<>();
|
|
|
|
|
|
|
|
- // key部门id-任务id
|
|
|
|
|
- Set<String> deptTaskConstrcts = new HashSet<>();
|
|
|
|
|
- // key部门id-任务id
|
|
|
|
|
- Set<String> deptTaskFinishes = new HashSet<>();
|
|
|
|
|
|
|
+ // 钻井或修井部门 队伍
|
|
|
|
|
+ List<Long> zjOrXjDeptIds = new ArrayList<>();
|
|
|
|
|
+ // 1钻井 2修井
|
|
|
|
|
+ String projectClassification = pageReqVO.getProjectClassification();
|
|
|
|
|
+ // 查询钻井部门 修井 部门
|
|
|
|
|
+ IotDeptTypePageReqVO deptTypeReqVO = new IotDeptTypePageReqVO();
|
|
|
|
|
+ if ("1".equals(projectClassification)) {
|
|
|
|
|
+ deptTypeReqVO.setType("zj");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ deptTypeReqVO.setType("xj");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<IotDeptTypeDO> deptTypes = iotDeptTypeMapper.selectList(deptTypeReqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(deptTypes)) {
|
|
|
|
|
+ deptTypes.forEach(dept -> {
|
|
|
|
|
+ zjOrXjDeptIds.add(dept.getDeptId());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 以项目部为维度统计数据
|
|
|
|
|
- // 找到所有项目部与队伍的对应关系
|
|
|
|
|
- // 查询指定根部门下的所有子部门
|
|
|
|
|
|
|
+ // 以项目部为维度统计数据 找到所有项目部与队伍的对应关系 查询指定根部门下的所有子部门
|
|
|
Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(rootDeptId);
|
|
Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(rootDeptId);
|
|
|
DeptListReqVO reqVO = new DeptListReqVO();
|
|
DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
reqVO.setDeptIds(allRhChildDeptIds);
|
|
reqVO.setDeptIds(allRhChildDeptIds);
|
|
@@ -1042,12 +1055,38 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // key项目部id value项目部包含的钻井or修井队伍id集合
|
|
|
|
|
+ Map<Long, Set<Long>> projectTeamPair = new HashMap<>();
|
|
|
|
|
+ // 筛选项目部下包含的队伍
|
|
|
|
|
+ depts.forEach(dept -> {
|
|
|
|
|
+ Long deptId = dept.getId();
|
|
|
|
|
+ Long parentId = dept.getParentId();
|
|
|
|
|
+ if (projectDeptIds.contains(parentId)) {
|
|
|
|
|
+ // 获得当前部门的上级项目部
|
|
|
|
|
+ projectDeptIds.forEach(projectDeptId -> {
|
|
|
|
|
+ // 统计各钻井或修井项目部下队伍数量
|
|
|
|
|
+ if (projectDeptId.equals(parentId) && zjOrXjDeptIds.contains(deptId)) {
|
|
|
|
|
+ if (projectTeamPair.containsKey(projectDeptId)) {
|
|
|
|
|
+ Set<Long> tempTeamIds = projectTeamPair.get(projectDeptId);
|
|
|
|
|
+ tempTeamIds.add(deptId);
|
|
|
|
|
+ projectTeamPair.put(projectDeptId, tempTeamIds);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Set<Long> tempTeamIds = new HashSet<>();
|
|
|
|
|
+ tempTeamIds.add(deptId);
|
|
|
|
|
+ projectTeamPair.put(projectDeptId, tempTeamIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
// key施工队伍id value施工井数量
|
|
// key施工队伍id value施工井数量
|
|
|
Map<Long, Integer> totalTasksPair = new HashMap<>();
|
|
Map<Long, Integer> totalTasksPair = new HashMap<>();
|
|
|
// key施工队伍id value完工井数量
|
|
// key施工队伍id value完工井数量
|
|
|
Map<Long, Integer> completedTasksPair = new HashMap<>();
|
|
Map<Long, Integer> completedTasksPair = new HashMap<>();
|
|
|
// key任务id value额定生产时间
|
|
// key任务id value额定生产时间
|
|
|
Map<Long, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
|
|
Map<Long, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
|
|
|
|
|
+
|
|
|
if ("2".equals(pageReqVO.getProjectClassification())) {
|
|
if ("2".equals(pageReqVO.getProjectClassification())) {
|
|
|
// 查询修井 累计施工井数 累计完工井数
|
|
// 查询修井 累计施工井数 累计完工井数
|
|
|
if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
|
|
if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
|
|
@@ -1081,9 +1120,28 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 统计各项目部的设备利用率
|
|
|
|
|
+ // key项目部id value项目部包含的队伍指定时间区域内日报数量
|
|
|
|
|
+ Map<Long, Integer> projectReportPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
// 累计计算各项指标
|
|
// 累计计算各项指标
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
dailyReports.forEach(report -> {
|
|
|
|
|
+ // 统计各项目部的日报数量
|
|
|
|
|
+ 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 (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
Long projectDeptId = teamProjectIdPair.get(report.getDeptId());
|
|
Long projectDeptId = teamProjectIdPair.get(report.getDeptId());
|
|
|
if (ObjUtil.isNotEmpty(projectDeptId) && projectDeptPair.containsKey(projectDeptId)) {
|
|
if (ObjUtil.isNotEmpty(projectDeptId) && projectDeptPair.containsKey(projectDeptId)) {
|
|
@@ -1201,7 +1259,6 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
cumulativeNonProductionPair.put(projectDeptId, nonProductionEfficiency);
|
|
cumulativeNonProductionPair.put(projectDeptId, nonProductionEfficiency);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Long days;
|
|
Long days;
|
|
@@ -1219,6 +1276,25 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
days = 0l;
|
|
days = 0l;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 计算各项目部的平均设备利用率
|
|
|
|
|
+ if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
|
|
+ projectTeamPair.forEach((projectDeptId, resultTeamIds) -> {
|
|
|
|
|
+ double rate = 0.0;
|
|
|
|
|
+ Integer currentTeamNum = resultTeamIds.size();
|
|
|
|
|
+ if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
|
|
+ Integer reportCount = projectReportPair.getOrDefault(projectDeptId, 0);
|
|
|
|
|
+ // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum * daysCount)
|
|
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
|
|
+ if (currentTeamNum > 0 && days > 0) {
|
|
|
|
|
+ rate = new BigDecimal((double) reportCount / (currentTeamNum * days))
|
|
|
|
|
+ .setScale(4, RoundingMode.HALF_UP) // 保留4位小数,四舍五入
|
|
|
|
|
+ .doubleValue();
|
|
|
|
|
+ deviceUtilizationPair.put(projectDeptId, BigDecimal.valueOf(rate));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 生成返回的数据列表集合
|
|
// 生成返回的数据列表集合
|
|
|
projectDeptPair.forEach((deptId, dept) -> {
|
|
projectDeptPair.forEach((deptId, dept) -> {
|
|
|
IotRyDailyReportStatisticsRespVO statistics = new IotRyDailyReportStatisticsRespVO();
|
|
IotRyDailyReportStatisticsRespVO statistics = new IotRyDailyReportStatisticsRespVO();
|
|
@@ -1226,6 +1302,7 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
statistics.setProjectDeptName(dept.getName());
|
|
statistics.setProjectDeptName(dept.getName());
|
|
|
statistics.setSort(dept.getSort());
|
|
statistics.setSort(dept.getSort());
|
|
|
statistics.setType("2");
|
|
statistics.setType("2");
|
|
|
|
|
+ statistics.setUtilizationRate(deviceUtilizationPair.get(deptId));
|
|
|
statistics.setCumulativeFootage(cumulativeFootagePair.get(deptId));
|
|
statistics.setCumulativeFootage(cumulativeFootagePair.get(deptId));
|
|
|
statistics.setCumulativeConstructWells(cumulativeConstructWellsPair.get(deptId));
|
|
statistics.setCumulativeConstructWells(cumulativeConstructWellsPair.get(deptId));
|
|
|
statistics.setCumulativeCompletedWells(cumulativeCompletedWellsPair.get(deptId));
|
|
statistics.setCumulativeCompletedWells(cumulativeCompletedWellsPair.get(deptId));
|
|
@@ -1451,11 +1528,11 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
* 按 队伍 维度统计数据
|
|
* 按 队伍 维度统计数据
|
|
|
* @param pageReqVO 日报数据请求对象
|
|
* @param pageReqVO 日报数据请求对象
|
|
|
* @param dailyReports 日报数据列表
|
|
* @param dailyReports 日报数据列表
|
|
|
- * @param deptId 项目部ID 或 队伍id(塔河项目部 HY-A1)
|
|
|
|
|
|
|
+ * @param pageReqVO.deptId 项目部ID 或 队伍id(塔河项目部 HY-A1)
|
|
|
* @return 队伍 维度统计结果列表
|
|
* @return 队伍 维度统计结果列表
|
|
|
*/
|
|
*/
|
|
|
private List<IotRyDailyReportStatisticsRespVO> statisticsByProjectDepartment(IotRyDailyReportPageReqVO pageReqVO,
|
|
private List<IotRyDailyReportStatisticsRespVO> statisticsByProjectDepartment(IotRyDailyReportPageReqVO pageReqVO,
|
|
|
- List<IotRyDailyReportDO> dailyReports, Long deptId) {
|
|
|
|
|
|
|
+ List<IotRyDailyReportDO> dailyReports) {
|
|
|
List<IotRyDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
List<IotRyDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
|
|
|
|
|
|
Set<Long> projectDeptIds = new HashSet<>();
|
|
Set<Long> projectDeptIds = new HashSet<>();
|
|
@@ -1482,13 +1559,33 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
Map<Long, BigDecimal> cumulativeRatedTimePair = new HashMap<>();
|
|
Map<Long, BigDecimal> cumulativeRatedTimePair = new HashMap<>();
|
|
|
// key队伍id value累计运行时效
|
|
// key队伍id value累计运行时效
|
|
|
Map<Long, BigDecimal> cumulativeTransitTimePair = new HashMap<>();
|
|
Map<Long, BigDecimal> cumulativeTransitTimePair = new HashMap<>();
|
|
|
|
|
+ // key队伍id/项目部id value设备利用率
|
|
|
|
|
+ Map<Long, BigDecimal> deviceUtilizationPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 钻井或修井部门 队伍
|
|
|
|
|
+ List<Long> zjOrXjDeptIds = new ArrayList<>();
|
|
|
|
|
+ // 1钻井 2修井
|
|
|
|
|
+ String projectClassification = pageReqVO.getProjectClassification();
|
|
|
|
|
+ // 查询钻井部门 修井 部门
|
|
|
|
|
+ IotDeptTypePageReqVO deptTypeReqVO = new IotDeptTypePageReqVO();
|
|
|
|
|
+ if ("1".equals(projectClassification)) {
|
|
|
|
|
+ deptTypeReqVO.setType("zj");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ deptTypeReqVO.setType("xj");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<IotDeptTypeDO> deptTypes = iotDeptTypeMapper.selectList(deptTypeReqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(deptTypes)) {
|
|
|
|
|
+ deptTypes.forEach(dept -> {
|
|
|
|
|
+ zjOrXjDeptIds.add(dept.getDeptId());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 以 队伍 为维度统计数据
|
|
// 以 队伍 为维度统计数据
|
|
|
// 找到所有项目部与队伍的对应关系
|
|
// 找到所有项目部与队伍的对应关系
|
|
|
// 查询指定根部门下的所有子部门
|
|
// 查询指定根部门下的所有子部门
|
|
|
- Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
|
|
|
|
+ Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
DeptListReqVO reqVO = new DeptListReqVO();
|
|
DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
- allRhChildDeptIds.add(deptId); // 查询某支队伍
|
|
|
|
|
|
|
+ allRhChildDeptIds.add(pageReqVO.getDeptId()); // 查询某支队伍
|
|
|
reqVO.setDeptIds(allRhChildDeptIds);
|
|
reqVO.setDeptIds(allRhChildDeptIds);
|
|
|
List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
|
|
|
|
|
@@ -1539,10 +1636,22 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 统计各队伍的设备利用率
|
|
|
|
|
+ // key队伍id value队伍指定时间区域内日报数量
|
|
|
|
|
+ Map<Long, Integer> teamReportPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
// 累计计算各项指标
|
|
// 累计计算各项指标
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
dailyReports.forEach(report -> {
|
|
|
- if (ObjUtil.isNotEmpty(report.getDeptId())) {
|
|
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(report.getDeptId()) && zjOrXjDeptIds.contains(report.getDeptId())) {
|
|
|
|
|
+ // 统计各个队伍的日报数量
|
|
|
|
|
+ if (teamReportPair.containsKey(report.getDeptId())) {
|
|
|
|
|
+ Integer tempCount = teamReportPair.get(report.getDeptId());
|
|
|
|
|
+ teamReportPair.put(report.getDeptId(), ++tempCount);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ teamReportPair.put(report.getDeptId(), 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 累计进尺
|
|
// 累计进尺
|
|
|
cumulativeFootagePair.merge(report.getDeptId(), report.getDailyFootage(), BigDecimal::add);
|
|
cumulativeFootagePair.merge(report.getDeptId(), report.getDailyFootage(), BigDecimal::add);
|
|
|
// 累计油耗
|
|
// 累计油耗
|
|
@@ -1597,6 +1706,22 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
days = 0l;
|
|
days = 0l;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 计算各队伍的平均设备利用率
|
|
|
|
|
+ if (CollUtil.isNotEmpty(teamReportPair)) {
|
|
|
|
|
+ teamReportPair.forEach((teamDeptId, reportCount) -> {
|
|
|
|
|
+ double rate = 0.0;
|
|
|
|
|
+ Integer currentTeamNum = 1;
|
|
|
|
|
+ // 当前项目部 设备利用率 公式 reportCount/(currentTeamNum * daysCount)
|
|
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
|
|
+ if (currentTeamNum > 0 && days > 0) {
|
|
|
|
|
+ rate = new BigDecimal((double) reportCount / (currentTeamNum * days))
|
|
|
|
|
+ .setScale(4, RoundingMode.HALF_UP) // 保留4位小数,四舍五入
|
|
|
|
|
+ .doubleValue();
|
|
|
|
|
+ deviceUtilizationPair.put(teamDeptId, BigDecimal.valueOf(rate));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 生成返回的数据列表集合
|
|
// 生成返回的数据列表集合
|
|
|
teamDeptPair.forEach((teamDeptId, dept) -> {
|
|
teamDeptPair.forEach((teamDeptId, dept) -> {
|
|
|
IotRyDailyReportStatisticsRespVO statistics = new IotRyDailyReportStatisticsRespVO();
|
|
IotRyDailyReportStatisticsRespVO statistics = new IotRyDailyReportStatisticsRespVO();
|
|
@@ -1604,6 +1729,7 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
statistics.setTeamName(dept.getName());
|
|
statistics.setTeamName(dept.getName());
|
|
|
statistics.setSort(dept.getSort());
|
|
statistics.setSort(dept.getSort());
|
|
|
statistics.setType("3");
|
|
statistics.setType("3");
|
|
|
|
|
+ statistics.setUtilizationRate(deviceUtilizationPair.get(teamDeptId));
|
|
|
statistics.setCumulativeFootage(cumulativeFootagePair.get(teamDeptId));
|
|
statistics.setCumulativeFootage(cumulativeFootagePair.get(teamDeptId));
|
|
|
statistics.setCumulativeConstructWells(totalTasksPair.get(teamDeptId));
|
|
statistics.setCumulativeConstructWells(totalTasksPair.get(teamDeptId));
|
|
|
statistics.setCumulativeCompletedWells(completedTasksPair.get(teamDeptId));
|
|
statistics.setCumulativeCompletedWells(completedTasksPair.get(teamDeptId));
|