|
@@ -1265,6 +1265,32 @@ public class IotStaticController {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Operation(summary = "瑞恒当日注气量 累计注气量")
|
|
|
|
|
+ @GetMapping("/rh/zql")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ public CommonResult<BigDecimal> dailyZql(IotRhDailyReportPageReqVO reqVO) {
|
|
|
|
|
+ BigDecimal result = BigDecimal.ZERO;
|
|
|
|
|
+ if (ObjUtil.isEmpty(reqVO)) {
|
|
|
|
|
+ return success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ PageResult<IotRhDailyReportDO> pageReports = iotRhDailyReportMapper.selectPage(reqVO);
|
|
|
|
|
+ if (ObjUtil.isEmpty(pageReports)) {
|
|
|
|
|
+ return success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<IotRhDailyReportDO> reports = pageReports.getList();
|
|
|
|
|
+ if (CollUtil.isEmpty(reports)) {
|
|
|
|
|
+ return success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (IotRhDailyReportDO report : reports) {
|
|
|
|
|
+ BigDecimal tempGasInjection = report.getDailyGasInjection();
|
|
|
|
|
+ result = result.add(tempGasInjection);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 注气量单位设置成 万方
|
|
|
|
|
+ BigDecimal convertedGasInjection = result.divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
|
|
+ return success(convertedGasInjection);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@PermitAll
|
|
@PermitAll
|
|
|
@GetMapping("/project/{dept}")
|
|
@GetMapping("/project/{dept}")
|
|
|
public CommonResult<List<ImmutableMap<String, ? extends Serializable>>> projectStat(@PathVariable("dept") String dept) {
|
|
public CommonResult<List<ImmutableMap<String, ? extends Serializable>>> projectStat(@PathVariable("dept") String dept) {
|
|
@@ -1962,6 +1988,187 @@ public class IotStaticController {
|
|
|
return success(rates);
|
|
return success(rates);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 瑞恒 公司总体 设备利用率
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/rh/device/totalUtilizationRate")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ public CommonResult<BigDecimal> totalUtilizationRate(IotRhDailyReportPageReqVO reqVO) {
|
|
|
|
|
+ if (ObjUtil.isEmpty(reqVO.getCreateTime())) {
|
|
|
|
|
+ throw exception(IOT_DAILY_REPORT_TIME_NOT_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (reqVO.getCreateTime().length < 2) {
|
|
|
|
|
+ throw exception(IOT_DAILY_REPORT_TIME_NOT_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 计算公司整体的设备利用率
|
|
|
|
|
+ BigDecimal totalDeviceUtilization = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ 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 所有项目部
|
|
|
|
|
+ Set<Long> childDeptIds = deptService.getChildDeptIdListFromCache(157l);
|
|
|
|
|
+ Map<Long, DeptDO> allDeptPair = deptService.getDeptMap(childDeptIds);
|
|
|
|
|
+ Set<String> projectDeptNames = new HashSet<>();
|
|
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
|
|
+ // key项目部id value项目部名称
|
|
|
|
|
+ Map<Long, String> projectPair = new HashMap<>();
|
|
|
|
|
+ // key项目部id value项目部包含的队伍id集合
|
|
|
|
|
+ Map<Long, Set<Long>> projectTeamPair = new HashMap<>();
|
|
|
|
|
+ // 队伍id 集合
|
|
|
|
|
+ Set<Long> teamDepartmentIds = new HashSet<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 筛选瑞恒 主设备 rq_iot_rh_main_device_category
|
|
|
|
|
+ Set<Long> mainDeviceCategoryIds = new HashSet<>();
|
|
|
|
|
+ List<DictDataDO> constructionStatusDictData = dictDataService.getDictDataListByDictType("rq_iot_rh_main_device_category");
|
|
|
|
|
+ if (CollUtil.isNotEmpty(constructionStatusDictData)) {
|
|
|
|
|
+ constructionStatusDictData.forEach(data -> {
|
|
|
|
|
+ String value = data.getValue();
|
|
|
|
|
+ if (NumberUtil.isNumber(value)) {
|
|
|
|
|
+ Long longValue = Long.valueOf(value);
|
|
|
|
|
+ mainDeviceCategoryIds.add(longValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询 瑞恒 所有设备 只统计包含 施工 状态设备的队伍
|
|
|
|
|
+ IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
|
|
|
+ deviceReqVO.setDeptIds(new ArrayList<>(childDeptIds));
|
|
|
|
|
+ List<IotDeviceDO> allRhDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
|
|
+ Set<Long> haveDeviceDeptIds = new HashSet<>();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(allRhDevices)) {
|
|
|
|
|
+ // 筛选出包含设备的队伍部门集合
|
|
|
|
|
+ // 20260608 修改成 包含瑞恒主设备的 部门队伍id集合
|
|
|
|
|
+ allRhDevices.forEach(device -> {
|
|
|
|
|
+ if (mainDeviceCategoryIds.contains(device.getAssetClass())) {
|
|
|
|
|
+ haveDeviceDeptIds.add(device.getDeptId());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(allDeptPair)) {
|
|
|
|
|
+ allDeptPair.forEach((deptId, dept) -> {
|
|
|
|
|
+ // 项目部
|
|
|
|
|
+ if ("2".equals(dept.getType())) {
|
|
|
|
|
+ projectDeptIds.add(deptId);
|
|
|
|
|
+ projectDeptNames.add(dept.getName());
|
|
|
|
|
+ projectPair.put(deptId, dept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 队伍
|
|
|
|
|
+ if ("3".equals(dept.getType())) {
|
|
|
|
|
+ teamDepartmentIds.add(dept.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 遍历所有部门 只筛选出有设备的队伍
|
|
|
|
|
+ allDeptPair.forEach((deptId, dept) -> {
|
|
|
|
|
+ // 找出每个项目部下的队伍
|
|
|
|
|
+ if (projectPair.containsKey(dept.getParentId())) {
|
|
|
|
|
+ // 获得当前部门的上级项目部
|
|
|
|
|
+ projectPair.forEach((projectDeptId, projectDeptName) -> {
|
|
|
|
|
+ if (projectDeptId.equals(dept.getParentId()) && haveDeviceDeptIds.contains(deptId) && teamDepartmentIds.contains(deptId)) {
|
|
|
|
|
+ if (projectTeamPair.containsKey(projectDeptId)) {
|
|
|
|
|
+ Set<Long> teamIds = projectTeamPair.get(projectDeptId);
|
|
|
|
|
+ teamIds.add(deptId);
|
|
|
|
|
+ projectTeamPair.put(projectDeptId, teamIds);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Set<Long> teamIds = new HashSet<>();
|
|
|
|
|
+ teamIds.add(deptId);
|
|
|
|
|
+ projectTeamPair.put(projectDeptId, teamIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 查询出指定时间区间内 已经填写的日报数量 存在注气时间是0 但是 注气量 不为0的情况
|
|
|
|
|
+ // reqVO.setStatisticFlag("Y");
|
|
|
|
|
+ List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
|
|
|
|
|
+ // key项目部id value项目部包含的队伍指定时间区域内日报数量
|
|
|
|
|
+ Map<Long, Integer> projectReportPair = new HashMap<>();
|
|
|
|
|
+ // key项目部id value项目部注气量
|
|
|
|
|
+ Map<Long, BigDecimal> projectGasInjectionPair = new HashMap<>();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
|
|
+ // 整理出每个项目部下的队伍填报的日报数量
|
|
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
|
|
+ if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
|
|
+ projectTeamPair.forEach((projectDeptId, teamDeptIds) -> {
|
|
|
|
|
+ if (teamDeptIds.contains(report.getDeptId())) {
|
|
|
|
|
+ if (report.getDailyGasInjection().compareTo(BigDecimal.ZERO)>0 || report.getDailyWaterInjection().compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
|
+ // 项目部日报数量 20260608 统计 注气量 or 注水量 > 0 的日报数量
|
|
|
|
|
+ if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
|
|
+ Integer tempCount = projectReportPair.get(projectDeptId);
|
|
|
|
|
+ projectReportPair.put(projectDeptId, ++tempCount);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ projectReportPair.put(projectDeptId, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 项目部 注气量
|
|
|
|
|
+ if (projectGasInjectionPair.containsKey(projectDeptId)) {
|
|
|
|
|
+ BigDecimal tempGasInjection = projectGasInjectionPair.get(projectDeptId);
|
|
|
|
|
+ BigDecimal subtotal = tempGasInjection.add(report.getDailyGasInjection());
|
|
|
|
|
+ projectGasInjectionPair.put(projectDeptId, subtotal);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ projectGasInjectionPair.put(projectDeptId, report.getDailyGasInjection());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 计算指定时间区间内包含的天数
|
|
|
|
|
+ long daysCount;
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(reqVO.getCreateTime()) && reqVO.getCreateTime().length >= 2) {
|
|
|
|
|
+ LocalDateTime start = reqVO.getCreateTime()[0];
|
|
|
|
|
+ LocalDateTime end = reqVO.getCreateTime()[1];
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(start) && ObjUtil.isNotEmpty(end) && !end.isBefore(start)) {
|
|
|
|
|
+ // 使用ChronoUnit.DAYS.between计算天数差,并+1包含首尾两天
|
|
|
|
|
+ daysCount = ChronoUnit.DAYS.between(
|
|
|
|
|
+ start.toLocalDate(),
|
|
|
|
|
+ end.toLocalDate()
|
|
|
|
|
+ ) + 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ daysCount = 0L;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ daysCount = 0L;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //时间查询区间内 公司总的日报数量
|
|
|
|
|
+ Integer totalReportCount = 0;
|
|
|
|
|
+ // 时间查询区间内 公司总的队伍数量
|
|
|
|
|
+ Integer totalTeamNum = 0;
|
|
|
|
|
+
|
|
|
|
|
+ // 计算每个项目部的设备利用率
|
|
|
|
|
+ if (CollUtil.isNotEmpty(projectTeamPair)) {
|
|
|
|
|
+ for (Map.Entry<Long, Set<Long>> longSetEntry : projectTeamPair.entrySet()) {
|
|
|
|
|
+ Long projectDeptId = longSetEntry.getKey();
|
|
|
|
|
+ Set<Long> teamIds = longSetEntry.getValue();
|
|
|
|
|
+ Integer currentTeamNum = teamIds.size();
|
|
|
|
|
+ totalTeamNum = totalTeamNum + currentTeamNum;
|
|
|
|
|
+ if (projectReportPair.containsKey(projectDeptId)) {
|
|
|
|
|
+ Integer reportCount = projectReportPair.getOrDefault(projectDeptId, 0);
|
|
|
|
|
+ totalReportCount = totalReportCount + reportCount;
|
|
|
|
|
+ // 公司总的 设备利用率 公式 totalReportCount/(totalTeamNum*daysCount)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 计算公司总的设备利用率
|
|
|
|
|
+ if (totalTeamNum > 0 && daysCount > 0) {
|
|
|
|
|
+ totalDeviceUtilization = new BigDecimal((double) totalReportCount / (totalTeamNum * daysCount))
|
|
|
|
|
+ .setScale(4, RoundingMode.HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(totalDeviceUtilization);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 瑞恒 设备利用率 按 队伍 统计
|
|
* 瑞恒 设备利用率 按 队伍 统计
|
|
|
* @return
|
|
* @return
|