|
|
@@ -1,6 +1,8 @@
|
|
|
package cn.iocoder.yudao.module.pms.service.iotrydailyreport;
|
|
|
|
|
|
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.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
@@ -581,6 +583,58 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IotRyDailyReportPolylineVO> polylineStatistics(IotRyDailyReportPageReqVO pageReqVO) {
|
|
|
+ List<IotRyDailyReportPolylineVO> 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<>();
|
|
|
+ }
|
|
|
+ PageResult<IotRyDailyReportDO> page = iotRyDailyReportMapper.selectPage(pageReqVO);
|
|
|
+ List<IotRyDailyReportDO> dailyReports = page.getList();
|
|
|
+ if (CollUtil.isEmpty(dailyReports)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ // 默认显示所有项目部的汇总数据
|
|
|
+ // 点击项目部 显示 下属队伍的数据
|
|
|
+ // 首先判断点击的部门是属于 公司 还是 队伍 如果没有点击任何部门 默认查询所有项目部数据
|
|
|
+ if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
|
|
|
+ result = polylineStatisticsByProjectDept(pageReqVO, dailyReports, 158L, pageReqVO.getCreateTime());
|
|
|
+ } else {
|
|
|
+ // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
|
|
|
+ DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
|
|
|
+ if ("1".equals(selectedDept.getType())) {
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
+ result = polylineStatisticsByProjectDept(pageReqVO, dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
+ } else if ("2".equals(selectedDept.getType())) {
|
|
|
+ // 以队伍为维度汇总数据
|
|
|
+ result = polylineStatisticsByProjectDepartment(pageReqVO, dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
+ } else if ("3".equals(selectedDept.getType())) {
|
|
|
+ // 显示单个队伍的汇总数据
|
|
|
+ result = polylineStatisticsByProjectDepartment(pageReqVO, dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
+ } else {
|
|
|
+ // 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
+ result = polylineStatisticsByProjectDept(pageReqVO, dailyReports, pageReqVO.getDeptId(), pageReqVO.getCreateTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 根据result集合内对象的 日期 属性正序排列
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private List<IotDeviceDO> devices() {
|
|
|
// 查询 瑞鹰158l 所有存在设备的队伍
|
|
|
// 查询 瑞鹰 下所有部门
|
|
|
@@ -770,6 +824,186 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按项目部维度统计数据 折线图
|
|
|
+ * @param pageReqVO 日报查询对象
|
|
|
+ * @param dailyReports 日报数据列表
|
|
|
+ * @param rootDeptId 根部门ID(如158L为 瑞鹰 根部门,或其他公司级部门ID)
|
|
|
+ * @return 项目部维度统计结果折线图 钻井 修井
|
|
|
+ */
|
|
|
+ private List<IotRyDailyReportPolylineVO> polylineStatisticsByProjectDept(IotRyDailyReportPageReqVO pageReqVO,
|
|
|
+ List<IotRyDailyReportDO> dailyReports, Long rootDeptId, LocalDateTime[] createTimes) {
|
|
|
+ List<IotRyDailyReportPolylineVO> 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> dateFootagePair = new HashMap<>();
|
|
|
+ // key日期yyy-MM-dd value去重后的施工任务集合
|
|
|
+ Map<String, Set<Long>> dateConstructTaskPair = new HashMap<>();
|
|
|
+ // key日期yyy-MM-dd value去重后的完工任务集合
|
|
|
+ Map<String, Set<Long>> dateFinishTaskPair = 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生产时间(H)
|
|
|
+ Map<String, BigDecimal> dateProductTimePair = new HashMap<>();
|
|
|
+ // key日期yyyy-MM-dd value额定生产时间(H)
|
|
|
+ Map<String, BigDecimal> dateRatedTimePair = 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, Integer> totalTasksPair = new HashMap<>();
|
|
|
+ // key施工队伍id value完工井数量
|
|
|
+ Map<Long, Integer> completedTasksPair = new HashMap<>();
|
|
|
+ // key任务id value额定生产时间
|
|
|
+ Map<Long, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
|
|
|
+ if ("2".equals(pageReqVO.getProjectClassification())) {
|
|
|
+ // 查询 指定时间范围内的 修井 累计施工井数 累计完工井数
|
|
|
+ // 每天的任务数量 taskId 去重后的数量
|
|
|
+ // 每天完工任务数量 taskId 去重后 状态为 wg 的数量
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ String dateStr = LocalDateTimeUtil.format(report.getCreateTime(), DatePattern.NORM_DATE_PATTERN);
|
|
|
+ if (dateConstructTaskPair.containsKey(dateStr)) {
|
|
|
+ Set<Long> tempUniqueTaskIds = dateConstructTaskPair.get(dateStr);
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateConstructTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempUniqueTaskIds = new HashSet<>();
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateConstructTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ }
|
|
|
+ // 组装完工任务集合
|
|
|
+ if ("wg".equals(report.getRepairStatus())) {
|
|
|
+ if (dateFinishTaskPair.containsKey(dateStr)) {
|
|
|
+ Set<Long> tempUniqueTaskIds = dateFinishTaskPair.get(dateStr);
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateFinishTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempUniqueTaskIds = new HashSet<>();
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateFinishTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 计算 运行时效 累计生产时间/累计额定生产时间
|
|
|
+ // 查询日报关联的任务信息
|
|
|
+ IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
|
|
|
+ taskReqVO.setTaskIds(convertList(dailyReports, IotRyDailyReportDO::getTaskId));
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(taskReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
+ tasks.forEach(task -> {
|
|
|
+ if (CollUtil.isNotEmpty(task.getExtProperty())) {
|
|
|
+ List<IotTaskAttrModelProperty> taskAttrs = task.getExtProperty();
|
|
|
+ if (CollUtil.isNotEmpty(taskAttrs)) {
|
|
|
+ // 找到 额定生产时间 属性 对应的值
|
|
|
+ taskAttrs.forEach(attr -> {
|
|
|
+ if ("额定生产时间".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
|
|
|
+ taskRatedProductionTimePair.put(task.getId(), new BigDecimal(attr.getActualValue()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 累计计算各项指标
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ // 按照日期维度统计各 工作量数据 累计用电量 累计油耗 累计注气量 累计注水量
|
|
|
+ LocalDateTime reportLocalDate = report.getCreateTime();
|
|
|
+ // 将日期格式转换成 字符串
|
|
|
+ String reportDateStr = LocalDateTimeUtil.format(reportLocalDate, DatePattern.NORM_DATE_PATTERN);
|
|
|
+ // 累计进尺
|
|
|
+ dateFootagePair.merge(reportDateStr, report.getDailyFootage(), BigDecimal::add);
|
|
|
+ // 累计用电量
|
|
|
+ datePowerConsumptionPair.merge(reportDateStr, report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
+ // 累计油耗
|
|
|
+ dateFuelConsumptionPair.merge(reportDateStr, report.getDailyFuel(), BigDecimal::add);
|
|
|
+ // 生产时间
|
|
|
+ dateProductTimePair.merge(reportDateStr, report.getProductionTime(), BigDecimal::add);
|
|
|
+ // 额定生产时间
|
|
|
+ if (taskRatedProductionTimePair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal ratedTime = taskRatedProductionTimePair.get(report.getTaskId());
|
|
|
+ dateRatedTimePair.merge(reportDateStr, ratedTime, BigDecimal::add);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 根据 生产时间 额定生产时间 计算指定日期范围的 平均运行时效
|
|
|
+ if (CollUtil.isNotEmpty(dateProductTimePair) && CollUtil.isNotEmpty(dateRatedTimePair)) {
|
|
|
+ dateProductTimePair.forEach((reportDateStr, productTime) -> {
|
|
|
+ if (dateRatedTimePair.containsKey(reportDateStr)) {
|
|
|
+ BigDecimal ratedTime = dateRatedTimePair.get(reportDateStr);
|
|
|
+ if (ratedTime.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ // 指日期范围的累计运行时效
|
|
|
+ BigDecimal tempTransitTime = productTime.divide(ratedTime, 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 -> {
|
|
|
+ IotRyDailyReportPolylineVO statistics = new IotRyDailyReportPolylineVO();
|
|
|
+ statistics.setReportDate(date);
|
|
|
+ statistics.setCumulativeFootage(dateFootagePair.get(date));
|
|
|
+ statistics.setCumulativeConstructWells(dateConstructTaskPair.containsKey(date) ? dateConstructTaskPair.get(date).size() : 0);
|
|
|
+ statistics.setCumulativeCompletedWells(dateFinishTaskPair.containsKey(date) ? dateFinishTaskPair.get(date).size() : 0);
|
|
|
+ statistics.setCumulativePowerConsumption(datePowerConsumptionPair.get(date));
|
|
|
+ statistics.setCumulativeFuelConsumption(dateFuelConsumptionPair.get(date));
|
|
|
+ statistics.setTransitTime(dateTransitTimePair.get(date));
|
|
|
+ result.add(statistics);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按 队伍 维度统计数据
|
|
|
* @param pageReqVO 日报数据请求对象
|
|
|
@@ -924,4 +1158,186 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按 队伍 维度统计数据 折线图
|
|
|
+ * @param pageReqVO 日报数据请求对象
|
|
|
+ * @param dailyReports 日报数据列表
|
|
|
+ * @param deptId 项目部ID 或 队伍id(新疆项目部 7009队)
|
|
|
+ * @return 队伍 维度统计结果 折线图
|
|
|
+ */
|
|
|
+ private List<IotRyDailyReportPolylineVO> polylineStatisticsByProjectDepartment(IotRyDailyReportPageReqVO pageReqVO,
|
|
|
+ List<IotRyDailyReportDO> dailyReports, Long deptId, LocalDateTime[] createTimes) {
|
|
|
+ List<IotRyDailyReportPolylineVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
+ // key队伍id value队伍名称
|
|
|
+ Map<Long, DeptDO> teamDeptPair = new HashMap<>();
|
|
|
+ // key部门id value部门parentId
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 按照日期维度统计各工作量数据
|
|
|
+ // key日期yyyy-MM-dd value累计进尺
|
|
|
+ Map<String, BigDecimal> dateFootagePair = new HashMap<>();
|
|
|
+ // key日期yyy-MM-dd value去重后的施工任务集合
|
|
|
+ Map<String, Set<Long>> dateConstructTaskPair = new HashMap<>();
|
|
|
+ // key日期yyy-MM-dd value去重后的完工任务集合
|
|
|
+ Map<String, Set<Long>> dateFinishTaskPair = 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生产时间(H)
|
|
|
+ Map<String, BigDecimal> dateProductTimePair = new HashMap<>();
|
|
|
+ // key日期yyyy-MM-dd value额定生产时间(H)
|
|
|
+ Map<String, BigDecimal> dateRatedTimePair = 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, Integer> totalTasksPair = new HashMap<>();
|
|
|
+ // key施工队伍id value完工井数量
|
|
|
+ Map<Long, Integer> completedTasksPair = new HashMap<>();
|
|
|
+ // key任务id value额定生产时间
|
|
|
+ Map<Long, BigDecimal> taskRatedProductionTimePair = new HashMap<>();
|
|
|
+ if ("2".equals(pageReqVO.getProjectClassification())) {
|
|
|
+ // 查询 指定时间范围内的 修井 累计施工井数 累计完工井数
|
|
|
+ // 每天的任务数量 taskId 去重后的数量
|
|
|
+ // 每天完工任务数量 taskId 去重后 状态为 wg 的数量
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ String dateStr = LocalDateTimeUtil.format(report.getCreateTime(), DatePattern.NORM_DATE_PATTERN);
|
|
|
+ if (dateConstructTaskPair.containsKey(dateStr)) {
|
|
|
+ Set<Long> tempUniqueTaskIds = dateConstructTaskPair.get(dateStr);
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateConstructTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempUniqueTaskIds = new HashSet<>();
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateConstructTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ }
|
|
|
+ // 组装完工任务集合
|
|
|
+ if ("wg".equals(report.getRepairStatus())) {
|
|
|
+ if (dateFinishTaskPair.containsKey(dateStr)) {
|
|
|
+ Set<Long> tempUniqueTaskIds = dateFinishTaskPair.get(dateStr);
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateFinishTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempUniqueTaskIds = new HashSet<>();
|
|
|
+ tempUniqueTaskIds.add(report.getTaskId());
|
|
|
+ dateFinishTaskPair.put(dateStr, tempUniqueTaskIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 计算 运行时效 累计生产时间/累计额定生产时间
|
|
|
+ // 查询日报关联的任务信息
|
|
|
+ IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
|
|
|
+ taskReqVO.setTaskIds(convertList(dailyReports, IotRyDailyReportDO::getTaskId));
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(taskReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
+ tasks.forEach(task -> {
|
|
|
+ if (CollUtil.isNotEmpty(task.getExtProperty())) {
|
|
|
+ List<IotTaskAttrModelProperty> taskAttrs = task.getExtProperty();
|
|
|
+ if (CollUtil.isNotEmpty(taskAttrs)) {
|
|
|
+ // 找到 额定生产时间 属性 对应的值
|
|
|
+ taskAttrs.forEach(attr -> {
|
|
|
+ if ("额定生产时间".equals(attr.getName()) && StrUtil.isNotBlank(attr.getActualValue())) {
|
|
|
+ taskRatedProductionTimePair.put(task.getId(), new BigDecimal(attr.getActualValue()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 累计计算各项指标
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ if (ObjUtil.isNotEmpty(report.getCreateTime())) {
|
|
|
+ // 按照日期维度统计各 工作量数据 累计用电量 累计油耗 累计注气量 累计注水量
|
|
|
+ LocalDateTime reportLocalDate = report.getCreateTime();
|
|
|
+ // 将日期格式转换成 字符串
|
|
|
+ String reportDateStr = LocalDateTimeUtil.format(reportLocalDate, DatePattern.NORM_DATE_PATTERN);
|
|
|
+ // 累计进尺
|
|
|
+ dateFootagePair.merge(reportDateStr, report.getDailyFootage(), BigDecimal::add);
|
|
|
+ // 累计用电量
|
|
|
+ datePowerConsumptionPair.merge(reportDateStr, report.getDailyPowerUsage(), BigDecimal::add);
|
|
|
+ // 累计油耗
|
|
|
+ dateFuelConsumptionPair.merge(reportDateStr, report.getDailyFuel(), BigDecimal::add);
|
|
|
+ // 生产时间
|
|
|
+ dateProductTimePair.merge(reportDateStr, report.getProductionTime(), BigDecimal::add);
|
|
|
+ // 额定生产时间
|
|
|
+ if (taskRatedProductionTimePair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal ratedTime = taskRatedProductionTimePair.get(report.getTaskId());
|
|
|
+ dateRatedTimePair.merge(reportDateStr, ratedTime, BigDecimal::add);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 根据 生产时间 额定生产时间 计算指定日期范围的 平均运行时效
|
|
|
+ if (CollUtil.isNotEmpty(dateProductTimePair) && CollUtil.isNotEmpty(dateRatedTimePair)) {
|
|
|
+ dateProductTimePair.forEach((reportDateStr, productTime) -> {
|
|
|
+ if (dateRatedTimePair.containsKey(reportDateStr)) {
|
|
|
+ BigDecimal ratedTime = dateRatedTimePair.get(reportDateStr);
|
|
|
+ if (ratedTime.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ // 指日期范围的累计运行时效
|
|
|
+ BigDecimal tempTransitTime = productTime.divide(ratedTime, 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 -> {
|
|
|
+ IotRyDailyReportPolylineVO statistics = new IotRyDailyReportPolylineVO();
|
|
|
+ statistics.setReportDate(date);
|
|
|
+ statistics.setCumulativeFootage(dateFootagePair.get(date));
|
|
|
+ statistics.setCumulativeConstructWells(dateConstructTaskPair.containsKey(date) ? dateConstructTaskPair.get(date).size() : 0);
|
|
|
+ statistics.setCumulativeCompletedWells(dateFinishTaskPair.containsKey(date) ? dateFinishTaskPair.get(date).size() : 0);
|
|
|
+ statistics.setCumulativePowerConsumption(datePowerConsumptionPair.get(date));
|
|
|
+ statistics.setCumulativeFuelConsumption(dateFuelConsumptionPair.get(date));
|
|
|
+ statistics.setTransitTime(dateTransitTimePair.get(date));
|
|
|
+ result.add(statistics);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|