|
@@ -1,6 +1,8 @@
|
|
|
package cn.iocoder.yudao.module.pms.service.iotrhdailyreport;
|
|
package cn.iocoder.yudao.module.pms.service.iotrhdailyreport;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
@@ -8,10 +10,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportStatisticsRespVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportStatisticsVO;
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
@@ -315,6 +314,58 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<IotRhDailyReportPolylineVO> polylineStatistics(IotRhDailyReportPageReqVO pageReqVO) {
|
|
|
|
|
+ List<IotRhDailyReportPolylineVO> result = new ArrayList<>();
|
|
|
|
|
+ // 不分页统计所有数据
|
|
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
|
|
+ if (Objects.nonNull(pageReqVO.getDeptId())) {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
|
|
+ // 找到所有子部门对象集合
|
|
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
|
|
+ pageReqVO.setDeptIds(ids);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查contractName不为空但projectIds为空的情况
|
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getContractName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查taskName不为空但taskIds为空的情况
|
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ IPage<IotRhDailyReportDO> page = iotRhDailyReportMapper.rhReportStatistics(
|
|
|
|
|
+ new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO,
|
|
|
|
|
+ pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
|
|
|
|
|
+ List<IotRhDailyReportDO> dailyReports = page.getRecords();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
|
|
+ // 默认显示所有项目部的汇总数据(新疆分公司也展示 下属各项目部的数据)
|
|
|
|
|
+ // 点击项目部 显示 下属队伍的数据
|
|
|
|
|
+ // 首先判断点击的部门是属于 公司 还是 队伍 如果没有点击任何部门 默认查询所有项目部数据
|
|
|
|
|
+ if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
|
|
|
|
|
+ result = polylineStatisticsByProjectDept(dailyReports, 157L, pageReqVO.getCreateTime());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
|
|
|
|
|
+ DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
|
|
|
|
|
+ if ("1".equals(selectedDept.getType())) {
|
|
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
|
|
+ result = polylineStatisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
|
|
+ } else if ("2".equals(selectedDept.getType())) {
|
|
|
|
|
+ // 以队伍为维度汇总数据
|
|
|
|
|
+ result = polylineStatisticsByProjectDepartment(dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
|
|
+ } else if ("3".equals(selectedDept.getType())) {
|
|
|
|
|
+ // 显示单个队伍的汇总数据
|
|
|
|
|
+ result = polylineStatisticsByProjectDepartment(dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
|
|
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
|
|
+ result = polylineStatisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void updateIotRhDailyReport(IotRhDailyReportSaveReqVO updateReqVO) {
|
|
public void updateIotRhDailyReport(IotRhDailyReportSaveReqVO updateReqVO) {
|
|
|
// 校验存在
|
|
// 校验存在
|
|
@@ -527,6 +578,121 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按项目部 日期 维度统计 折线 数据
|
|
|
|
|
+ * @param dailyReports 日报数据列表
|
|
|
|
|
+ * @param rootDeptId 根部门ID(如157L为瑞恒根部门,或其他公司级部门ID)
|
|
|
|
|
+ * @return 项目部维度统计结果列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<IotRhDailyReportPolylineVO> polylineStatisticsByProjectDept(List<IotRhDailyReportDO> dailyReports, Long rootDeptId, LocalDateTime[] createTimes) {
|
|
|
|
|
+ List<IotRhDailyReportPolylineVO> result = new ArrayList<>();
|
|
|
|
|
+ // 按照日期维度统计数据
|
|
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
|
|
+ // key项目部id value项目部名称
|
|
|
|
|
+ Map<Long, DeptDO> projectDeptPair = new HashMap<>();
|
|
|
|
|
+ // key部门id value部门parentId
|
|
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 按照日期维度统计各工作量数据
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计注气量
|
|
|
|
|
+ Map<String, BigDecimal> dateGasInjectionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计注水量
|
|
|
|
|
+ Map<String, BigDecimal> dateWaterInjectionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计用电量
|
|
|
|
|
+ Map<String, BigDecimal> datePowerConsumptionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计油耗
|
|
|
|
|
+ Map<String, BigDecimal> dateFuelConsumptionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计运行时效 累计注气量/累计产能
|
|
|
|
|
+ Map<String, BigDecimal> dateTransitTimePair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value对应日报部门的总产能
|
|
|
|
|
+ Map<String, BigDecimal> dateCapacityPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 以项目部为维度统计数据
|
|
|
|
|
+ // 找到所有项目部与队伍的对应关系
|
|
|
|
|
+ // 查询指定根部门下的所有子部门
|
|
|
|
|
+ Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(rootDeptId);
|
|
|
|
|
+ DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
|
|
+ reqVO.setDeptIds(allRhChildDeptIds);
|
|
|
|
|
+ List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建项目部映射和父子部门关系
|
|
|
|
|
+ depts.forEach(dept -> {
|
|
|
|
|
+ if ("2".equals(dept.getType())) {
|
|
|
|
|
+ projectDeptIds.add(dept.getId());
|
|
|
|
|
+ projectDeptPair.put(dept.getId(), dept);
|
|
|
|
|
+ }
|
|
|
|
|
+ teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 查询指定部门下相关设备的产能
|
|
|
|
|
+ // key队伍id value队伍下相关设备产能
|
|
|
|
|
+ Map<Long, BigDecimal> teamCapacityPair = queryCapacities(new ArrayList<>(allRhChildDeptIds));
|
|
|
|
|
+
|
|
|
|
|
+ // 累计计算各项指标
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
|
|
+ // 按照日期维度统计各 工作量数据 累计用电量 累计油耗 累计注气量 累计注水量
|
|
|
|
|
+ LocalDateTime reportLocalDate = report.getCreateTime();
|
|
|
|
|
+ // 将日期格式转换成 字符串
|
|
|
|
|
+ String reportDateStr = LocalDateTimeUtil.format(reportLocalDate, DatePattern.NORM_DATE_PATTERN);
|
|
|
|
|
+ // 累计注气量
|
|
|
|
|
+ dateGasInjectionPair.merge(reportDateStr, report.getDailyGasInjection(), BigDecimal::add);
|
|
|
|
|
+ // 累计注水量
|
|
|
|
|
+ dateWaterInjectionPair.merge(reportDateStr, report.getDailyWaterInjection(), BigDecimal::add);
|
|
|
|
|
+ // 累计用电量
|
|
|
|
|
+ datePowerConsumptionPair.merge(reportDateStr, report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
|
|
+ // todo 累计油耗
|
|
|
|
|
+ // 累计产能
|
|
|
|
|
+ if (teamCapacityPair.containsKey(report.getDeptId())) {
|
|
|
|
|
+ BigDecimal tempCapacity = teamCapacityPair.get(report.getDeptId());
|
|
|
|
|
+ dateCapacityPair.merge(reportDateStr, tempCapacity, BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 根据 累计注气量 累计产能 计算指定日期范围的平均产能
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dateGasInjectionPair) && CollUtil.isNotEmpty(dateCapacityPair)) {
|
|
|
|
|
+ dateGasInjectionPair.forEach((reportDateStr, dateGasInjection) -> {
|
|
|
|
|
+ if (dateCapacityPair.containsKey(reportDateStr)) {
|
|
|
|
|
+ BigDecimal tempCapacity = dateCapacityPair.get(reportDateStr);
|
|
|
|
|
+ if (tempCapacity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ // 指日期范围的累计运行时效
|
|
|
|
|
+ BigDecimal tempTransitTime = dateGasInjection.divide(tempCapacity, 4, RoundingMode.HALF_UP);
|
|
|
|
|
+ dateTransitTimePair.put(reportDateStr, tempTransitTime);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dateTransitTimePair.put(reportDateStr, BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 新增:日期字符串集合
|
|
|
|
|
+ List<String> dateRangeList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ if (createTimes.length >= 2) {
|
|
|
|
|
+ LocalDate startDate = createTimes[0].toLocalDate();
|
|
|
|
|
+ LocalDate endDate = createTimes[1].toLocalDate();
|
|
|
|
|
+ // 生成从起始日期到结束日期的所有日期
|
|
|
|
|
+ for (LocalDate date = startDate;
|
|
|
|
|
+ !date.isAfter(endDate); // 使用 isAfter 而不是 <= 判断
|
|
|
|
|
+ date = date.plusDays(1)) {
|
|
|
|
|
+ dateRangeList.add(date.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dateRangeList)) {
|
|
|
|
|
+ dateRangeList.forEach(date -> {
|
|
|
|
|
+ IotRhDailyReportPolylineVO statistics = new IotRhDailyReportPolylineVO();
|
|
|
|
|
+ statistics.setReportDate(date);
|
|
|
|
|
+ statistics.setCumulativeGasInjection(dateGasInjectionPair.get(date));
|
|
|
|
|
+ statistics.setCumulativeWaterInjection(dateWaterInjectionPair.get(date));
|
|
|
|
|
+ statistics.setCumulativePowerConsumption(datePowerConsumptionPair.get(date));
|
|
|
|
|
+ statistics.setTransitTime(dateTransitTimePair.get(date));
|
|
|
|
|
+ result.add(statistics);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 按 队伍 维度统计数据
|
|
* 按 队伍 维度统计数据
|
|
|
* @param dailyReports 日报数据列表
|
|
* @param dailyReports 日报数据列表
|
|
@@ -625,6 +791,146 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按 队伍 维度统计数据
|
|
|
|
|
+ * @param dailyReports 日报数据列表
|
|
|
|
|
+ * @param deptId 项目部ID 或 队伍id(塔河项目部 HY-A1)
|
|
|
|
|
+ * @return 队伍 维度统计结果列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<IotRhDailyReportPolylineVO> polylineStatisticsByProjectDepartment(List<IotRhDailyReportDO> dailyReports, Long deptId, LocalDateTime[] createTimes) {
|
|
|
|
|
+ List<IotRhDailyReportPolylineVO> result = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
|
|
+ // key项目部id value项目部名称
|
|
|
|
|
+ Map<Long, DeptDO> projectDeptPair = new HashMap<>();
|
|
|
|
|
+ // key队伍id value队伍名称
|
|
|
|
|
+ Map<Long, DeptDO> teamDeptPair = new HashMap<>();
|
|
|
|
|
+ // key部门id value部门parentId
|
|
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // key队伍id value累计注气量
|
|
|
|
|
+ Map<Long, BigDecimal> cumulativeGasInjectionPair = new HashMap<>();
|
|
|
|
|
+ // key队伍id value累计注水量
|
|
|
|
|
+ Map<Long, BigDecimal> cumulativeWaterInjectionPair = new HashMap<>();
|
|
|
|
|
+ // key队伍id value累计用电
|
|
|
|
|
+ Map<Long, BigDecimal> cumulativePowerConsumptionPair = new HashMap<>();
|
|
|
|
|
+ // key队伍id/项目部id value对应项目部的总产能
|
|
|
|
|
+ Map<Long, BigDecimal> cumulativeCapacityPair = new HashMap<>();
|
|
|
|
|
+ // key队伍id/项目部id value累计运行时效 累计注气量/累计产能
|
|
|
|
|
+ Map<Long, BigDecimal> cumulativeTransitTimePair = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 按照日期维度统计各工作量数据
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计注气量
|
|
|
|
|
+ Map<String, BigDecimal> dateGasInjectionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计注水量
|
|
|
|
|
+ Map<String, BigDecimal> dateWaterInjectionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计用电量
|
|
|
|
|
+ Map<String, BigDecimal> datePowerConsumptionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计油耗
|
|
|
|
|
+ Map<String, BigDecimal> dateFuelConsumptionPair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value累计运行时效 累计注气量/累计产能
|
|
|
|
|
+ Map<String, BigDecimal> dateTransitTimePair = new HashMap<>();
|
|
|
|
|
+ // key日期yyyy-MM-dd value对应日报部门的总产能
|
|
|
|
|
+ Map<String, BigDecimal> dateCapacityPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 以 队伍 为维度统计数据
|
|
|
|
|
+ // 找到所有项目部与队伍的对应关系
|
|
|
|
|
+ // 查询指定根部门下的所有子部门
|
|
|
|
|
+ Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
|
|
+ DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
|
|
+ allRhChildDeptIds.add(deptId); // 查询某支队伍
|
|
|
|
|
+ reqVO.setDeptIds(allRhChildDeptIds);
|
|
|
|
|
+ List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建项目部映射和父子部门关系
|
|
|
|
|
+ depts.forEach(dept -> {
|
|
|
|
|
+ if ("3".equals(dept.getType())) {
|
|
|
|
|
+ projectDeptIds.add(dept.getId());
|
|
|
|
|
+ teamDeptPair.put(dept.getId(), dept);
|
|
|
|
|
+ }
|
|
|
|
|
+ teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 查询指定部门下相关设备的产能
|
|
|
|
|
+ // key队伍id value队伍下相关设备产能
|
|
|
|
|
+ Map<Long, BigDecimal> teamCapacityPair = queryCapacities(new ArrayList<>(allRhChildDeptIds));
|
|
|
|
|
+
|
|
|
|
|
+ // 累计计算各项指标
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
|
|
+ // 按照日期维度统计各 工作量数据 累计用电量 累计油耗 累计注气量 累计注水量
|
|
|
|
|
+ LocalDateTime reportLocalDate = report.getCreateTime();
|
|
|
|
|
+ // 将日期格式转换成 字符串
|
|
|
|
|
+ String reportDateStr = LocalDateTimeUtil.format(reportLocalDate, DatePattern.NORM_DATE_PATTERN);
|
|
|
|
|
+ // 累计注气量
|
|
|
|
|
+ dateGasInjectionPair.merge(reportDateStr, report.getDailyGasInjection(), BigDecimal::add);
|
|
|
|
|
+ // 累计注水量
|
|
|
|
|
+ dateWaterInjectionPair.merge(reportDateStr, report.getDailyWaterInjection(), BigDecimal::add);
|
|
|
|
|
+ // 累计用电量
|
|
|
|
|
+ datePowerConsumptionPair.merge(reportDateStr, report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
|
|
+ // todo 累计油耗
|
|
|
|
|
+ // 累计产能
|
|
|
|
|
+ if (teamCapacityPair.containsKey(report.getDeptId())) {
|
|
|
|
|
+ BigDecimal tempCapacity = teamCapacityPair.get(report.getDeptId());
|
|
|
|
|
+ dateCapacityPair.merge(reportDateStr, tempCapacity, BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(report.getDeptId())) {
|
|
|
|
|
+ // 累计注气量
|
|
|
|
|
+ cumulativeGasInjectionPair.merge(report.getDeptId(), report.getDailyGasInjection(), BigDecimal::add);
|
|
|
|
|
+ // 累计注水量
|
|
|
|
|
+ cumulativeWaterInjectionPair.merge(report.getDeptId(), report.getDailyWaterInjection(), BigDecimal::add);
|
|
|
|
|
+ // 累计用电量
|
|
|
|
|
+ cumulativePowerConsumptionPair.merge(report.getDeptId(), report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
|
|
+ if (teamCapacityPair.containsKey(report.getDeptId())) {
|
|
|
|
|
+ BigDecimal tempCapacity = teamCapacityPair.get(report.getDeptId());
|
|
|
|
|
+ cumulativeCapacityPair.merge(report.getDeptId(), tempCapacity, BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 根据 累计注气量 累计产能 计算指定队伍下的平均产能
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dateGasInjectionPair) && CollUtil.isNotEmpty(dateCapacityPair)) {
|
|
|
|
|
+ dateGasInjectionPair.forEach((teamDeptId, dateGasInjection) -> {
|
|
|
|
|
+ if (dateCapacityPair.containsKey(teamDeptId)) {
|
|
|
|
|
+ BigDecimal tempCapacity = dateCapacityPair.get(teamDeptId);
|
|
|
|
|
+ if (tempCapacity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ // 指定队伍的累计运行时效
|
|
|
|
|
+ BigDecimal tempTransitTime = dateGasInjection.divide(tempCapacity, 4, RoundingMode.HALF_UP);
|
|
|
|
|
+ dateTransitTimePair.put(teamDeptId, tempTransitTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 新增:日期字符串集合
|
|
|
|
|
+ List<String> dateRangeList = new ArrayList<>();
|
|
|
|
|
+ if (createTimes.length >= 2) {
|
|
|
|
|
+ LocalDate startDate = createTimes[0].toLocalDate();
|
|
|
|
|
+ LocalDate endDate = createTimes[1].toLocalDate();
|
|
|
|
|
+ // 生成从起始日期到结束日期的所有日期
|
|
|
|
|
+ for (LocalDate date = startDate;
|
|
|
|
|
+ !date.isAfter(endDate); // 使用 isAfter 而不是 <= 判断
|
|
|
|
|
+ date = date.plusDays(1)) {
|
|
|
|
|
+ dateRangeList.add(date.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dateRangeList)) {
|
|
|
|
|
+ dateRangeList.forEach(date -> {
|
|
|
|
|
+ IotRhDailyReportPolylineVO statistics = new IotRhDailyReportPolylineVO();
|
|
|
|
|
+ statistics.setReportDate(date);
|
|
|
|
|
+ statistics.setCumulativeGasInjection(dateGasInjectionPair.get(date));
|
|
|
|
|
+ statistics.setCumulativeWaterInjection(dateWaterInjectionPair.get(date));
|
|
|
|
|
+ statistics.setCumulativePowerConsumption(datePowerConsumptionPair.get(date));
|
|
|
|
|
+ statistics.setTransitTime(dateTransitTimePair.get(date));
|
|
|
|
|
+ result.add(statistics);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<IotRhDailyReportStatisticsVO> rhDailyReportStatistics(IotRhDailyReportPageReqVO reqVO) {
|
|
public List<IotRhDailyReportStatisticsVO> rhDailyReportStatistics(IotRhDailyReportPageReqVO reqVO) {
|
|
|
if (reqVO.getCreateTime().length == 0) {
|
|
if (reqVO.getCreateTime().length == 0) {
|