|
|
@@ -19,10 +19,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotdailyreportfuel.vo.IotDai
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPlatformVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportRespVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportSaveReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSimpleRespVO;
|
|
|
@@ -70,6 +67,7 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -205,14 +203,60 @@ public class IotRdDailyReportController {
|
|
|
if (CollUtil.isNotEmpty(reportFuels)) {
|
|
|
hasFuels = true;
|
|
|
dailyReportVO.setReportedFuels(reportFuels);
|
|
|
- } else {
|
|
|
}
|
|
|
+ // 查询施工工艺字典数据
|
|
|
+ List<DictDataDO> rdTechniquesDicts = dictDataService.getDictDataListByDictType("rq_iot_project_technology_rd");
|
|
|
+ // 工作量单位 数据字典
|
|
|
+ List<DictDataDO> measureUnitDicts = dictDataService.getDictDataListByDictType("rq_iot_project_measure_unit");
|
|
|
+ // 施工状态 数据字典
|
|
|
+ List<DictDataDO> rdStatusDicts = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
+ // 施工状态 key字典键值 value字典标签
|
|
|
+ Map<String, String> statusDictPair = new HashMap<>();
|
|
|
+ // 停待状态 的字典数据集合
|
|
|
+ Set<String> tdStatuses = new HashSet<>();
|
|
|
+ // 施工工艺 key字典键值 value字典标签
|
|
|
+ Map<String, String> techniqueDictPair = new HashMap<>();
|
|
|
+ // 工作量单位 key字典键值 value字典标签
|
|
|
+ Map<String, String> unitDictPair = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(rdTechniquesDicts)) {
|
|
|
+ rdTechniquesDicts.forEach(tech -> {
|
|
|
+ techniqueDictPair.put(tech.getValue(), tech.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(measureUnitDicts)) {
|
|
|
+ measureUnitDicts.forEach(tech -> {
|
|
|
+ unitDictPair.put(tech.getValue(), tech.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(rdStatusDicts)) {
|
|
|
+ rdStatusDicts.forEach(status -> {
|
|
|
+ statusDictPair.put(status.getValue(), status.getLabel());
|
|
|
+ // 找到属于 停待状态 的字典数据
|
|
|
+ if ("TD".equals(status.getRemark())) {
|
|
|
+ tdStatuses.add(status.getValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
// 查询日报对应的任务信息
|
|
|
if (ObjUtil.isNotEmpty(dailyReport.getTaskId())) {
|
|
|
IotProjectTaskDO task = iotProjectTaskService.getIotProjectTask(dailyReport.getTaskId());
|
|
|
dailyReportVO.setTaskName(StrUtil.join("-", task.getWellName(), task.getLocation()));
|
|
|
dailyReportVO.setWellName(task.getWellName());
|
|
|
dailyReportVO.setLocation(task.getLocation());
|
|
|
+ // 任务施工工艺
|
|
|
+ String techniqueValue = task.getTechnique();
|
|
|
+ if (StrUtil.isNotBlank(techniqueValue)) {
|
|
|
+ dailyReportVO.setTechniqueNames(techniqueDictPair.get(techniqueValue));
|
|
|
+ }
|
|
|
+ // 任务工作量
|
|
|
+ String workloadDesign = task.getWorkloadDesign();
|
|
|
+ // 任务工作量单位
|
|
|
+ String workloadDesignUnit = task.getWorkloadUnit();
|
|
|
+ if (StrUtil.isNotBlank(workloadDesignUnit)) {
|
|
|
+ dailyReportVO.setWorkloadDesign(StrUtil.join(" ", workloadDesign, unitDictPair.get(workloadDesignUnit)));
|
|
|
+ }
|
|
|
+
|
|
|
Set<Long> deviceIds = task.getDeviceIds();
|
|
|
Set<Long> responsiblePersonIds = task.getResponsiblePerson();
|
|
|
// 日报对应的任务中的设备列表
|
|
|
@@ -281,6 +325,85 @@ public class IotRdDailyReportController {
|
|
|
List<IotDeviceSimpleRespVO> simpleDevices = BeanUtils.toBean(selectedDevices, IotDeviceSimpleRespVO.class);
|
|
|
dailyReportVO.setSelectedDevices(simpleDevices);
|
|
|
}
|
|
|
+ // 查询相同任务id的日报 查询开工日期 完工日期 施工周期
|
|
|
+ IotRdDailyReportPageReqVO reportReqVO = new IotRdDailyReportPageReqVO();
|
|
|
+ reportReqVO.setTaskId(dailyReport.getTaskId());
|
|
|
+ List<IotRdDailyReportDO> reports = iotRdDailyReportService.dailyReports(reportReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(reports)) {
|
|
|
+ // 找出开工日期:最早创建时间
|
|
|
+ Optional<LocalDateTime> startDateOpt = reports.stream()
|
|
|
+ .filter(report -> StrUtil.isNotBlank(report.getRdStatus()))
|
|
|
+ .map(IotRdDailyReportDO::getCreateTime)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .min(LocalDateTime::compareTo);
|
|
|
+ // 找出完工日期:rdStatus='wg' 的日报创建时间(取最早的一个)
|
|
|
+ Optional<LocalDateTime> endDateOpt = reports.stream()
|
|
|
+ .filter(report -> "wg".equals(report.getRdStatus()))
|
|
|
+ .map(IotRdDailyReportDO::getCreateTime)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .min(LocalDateTime::compareTo);
|
|
|
+ startDateOpt.ifPresent(startDate ->
|
|
|
+ dailyReportVO.setCommencementDate(LocalDateTimeUtil.format(startDate, DatePattern.NORM_DATE_PATTERN))
|
|
|
+ );
|
|
|
+ endDateOpt.ifPresent(finishDate ->
|
|
|
+ dailyReportVO.setCompletionDate(LocalDateTimeUtil.format(finishDate, DatePattern.NORM_DATE_PATTERN))
|
|
|
+ );
|
|
|
+ // 计算施工周期(包含开工和完工日期)
|
|
|
+ if (startDateOpt.isPresent() && endDateOpt.isPresent()) {
|
|
|
+ LocalDateTime startDate = startDateOpt.get();
|
|
|
+ LocalDateTime endDate = endDateOpt.get();
|
|
|
+
|
|
|
+ // 将LocalDateTime转换为LocalDate进行计算
|
|
|
+ LocalDate startLocalDate = startDate.toLocalDate();
|
|
|
+ LocalDate endLocalDate = endDate.toLocalDate();
|
|
|
+
|
|
|
+ // 计算天数(包含起始和结束日期)
|
|
|
+ long daysBetween = ChronoUnit.DAYS.between(startLocalDate, endLocalDate) + 1;
|
|
|
+ dailyReportVO.setConstructionPeriod(String.valueOf(daysBetween));
|
|
|
+ }
|
|
|
+ // 找到处于停待状态 的日报数据
|
|
|
+ long tdStatusCount = reports.stream()
|
|
|
+ .filter(report -> StrUtil.isNotBlank(report.getRdStatus()) && tdStatuses.contains(report.getRdStatus()))
|
|
|
+ .count();
|
|
|
+ dailyReportVO.setIdleTime(String.valueOf(tdStatusCount));
|
|
|
+ // 当前日报关联任务的施工进度
|
|
|
+ if (CollUtil.isNotEmpty(statusDictPair)) {
|
|
|
+ // 1. 过滤有效数据并排序(按时间升序)
|
|
|
+ List<IotRdDailyReportDO> validReports = reports.stream()
|
|
|
+ .filter(report -> StrUtil.isNotBlank(report.getRdStatus())
|
|
|
+ && ObjUtil.isNotEmpty(report.getCreateTime())
|
|
|
+ && statusDictPair.containsKey(report.getRdStatus()))
|
|
|
+ .sorted(Comparator.comparing(IotRdDailyReportDO::getCreateTime))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Map<String, List<IotRdDailyReportDO>> rdStatusReportPair = new HashMap<>();
|
|
|
+ List<IotRdDailyReportDO> uniqueRdStatusReports = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(validReports)) {
|
|
|
+ validReports.forEach(report -> {
|
|
|
+ // 获取集合中的最后一个元素 如果最后一个元素的rdStatus 与当前日报 rdStatus 不同
|
|
|
+ // 则将 当前report 加入 集合 uniqueRdStatusReports
|
|
|
+ if (CollUtil.isEmpty(uniqueRdStatusReports)) {
|
|
|
+ uniqueRdStatusReports.add(report);
|
|
|
+ } else {
|
|
|
+ IotRdDailyReportDO lastElement = uniqueRdStatusReports.get(uniqueRdStatusReports.size() - 1);
|
|
|
+ if (ObjUtil.isNotEmpty(lastElement) && !lastElement.getRdStatus().equals(report.getRdStatus())) {
|
|
|
+ uniqueRdStatusReports.add(report);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ List<IotRdDailyReportTaskProgressVO> progresses = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(uniqueRdStatusReports)) {
|
|
|
+ uniqueRdStatusReports.forEach(report -> {
|
|
|
+ IotRdDailyReportTaskProgressVO progress = new IotRdDailyReportTaskProgressVO();
|
|
|
+ progress.setRdStatusLabel(statusDictPair.get(report.getRdStatus()));
|
|
|
+ progress.setCreateTime(LocalDateTimeUtil.format(report.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
|
|
|
+ progresses.add(progress);
|
|
|
+ });
|
|
|
+ dailyReportVO.setTaskProgresses(progresses);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (CollUtil.isNotEmpty(responsiblePersonIds)) {
|
|
|
List<AdminUserRespDTO> users = adminUserApi.getUserList(responsiblePersonIds);
|
|
|
String userNames = users.stream()
|
|
|
@@ -330,7 +453,7 @@ public class IotRdDailyReportController {
|
|
|
reportFuel.setZhbdFuel(tempOil);
|
|
|
// 将字符串转换为LocalDateTime
|
|
|
try {
|
|
|
- LocalDateTime queryDate = LocalDate.parse(carFuel.getCreatetime(), formatter).atStartOfDay();;
|
|
|
+ LocalDateTime queryDate = LocalDate.parse(yesterdayDateStr, formatter).atStartOfDay();;
|
|
|
reportFuel.setQueryDate(queryDate);
|
|
|
} catch (DateTimeParseException e) {
|
|
|
log.error("瑞都日报-中航北斗油耗-日期格式解析失败: {}", e);
|
|
|
@@ -362,24 +485,7 @@ public class IotRdDailyReportController {
|
|
|
DeptDO dept = deptService.getDept(dailyReport.getDeptId());
|
|
|
dailyReportVO.setDeptName(dept.getName());
|
|
|
}
|
|
|
- // 查询施工工艺字典数据
|
|
|
- List<DictDataDO> rdStatusDicts = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
- // 查询施工工艺字典数据
|
|
|
- List<DictDataDO> rdTechniquesDicts = dictDataService.getDictDataListByDictType("rq_iot_project_technology_rd");
|
|
|
- // 施工状态 key字典键值 value字典标签
|
|
|
- Map<String, String> statusDictPair = new HashMap<>();
|
|
|
- // 施工工艺 key字典键值 value字典标签
|
|
|
- Map<String, String> techniqueDictPair = new HashMap<>();
|
|
|
- if (CollUtil.isNotEmpty(rdStatusDicts)) {
|
|
|
- rdStatusDicts.forEach(tech -> {
|
|
|
- statusDictPair.put(tech.getValue(), tech.getLabel());
|
|
|
- });
|
|
|
- }
|
|
|
- if (CollUtil.isNotEmpty(rdTechniquesDicts)) {
|
|
|
- rdTechniquesDicts.forEach(tech -> {
|
|
|
- techniqueDictPair.put(tech.getValue(), tech.getLabel());
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
// 日报任务对应的平台井列表
|
|
|
if (1 == dailyReport.getPlatformWell()) {
|
|
|
// 查询未施工完成的平台井 关联井列表
|
|
|
@@ -393,15 +499,19 @@ public class IotRdDailyReportController {
|
|
|
List<IotRdDailyReportDO> reports = iotRdDailyReportService.dailyReports(reportReqVO);
|
|
|
// key任务id value日报id
|
|
|
Map<Long, Long> reportPair = new HashMap<>();
|
|
|
+ // key任务id value任务井对应日报当日油耗
|
|
|
+ Map<Long, BigDecimal> reportFuelPair = new HashMap<>();
|
|
|
// key任务id value平台井日报已经设置的多种属性
|
|
|
Map<Long, IotProjectTaskPlatformVO> platformPair = new HashMap<>();
|
|
|
+ Set<Long> reportIds = new HashSet<>();
|
|
|
if (CollUtil.isNotEmpty(reports)) {
|
|
|
reports.forEach(report -> {
|
|
|
+ reportIds.add(report.getId());
|
|
|
// 保养平台井关联的多个日报使用
|
|
|
reportPair.put(report.getTaskId(), report.getId());
|
|
|
// 设置 平台关联井 已经设置的 属性 施工状态 施工工艺 工作量属性
|
|
|
// 查询 平台关联井详情使用
|
|
|
-
|
|
|
+ reportFuelPair.put(report.getTaskId(), report.getDailyFuel());
|
|
|
IotProjectTaskPlatformVO platformVO = new IotProjectTaskPlatformVO();
|
|
|
platformVO.setRdStatus(report.getRdStatus());
|
|
|
if (StrUtil.isNotBlank(report.getRdStatus()) && statusDictPair.containsKey(report.getRdStatus())) {
|
|
|
@@ -421,6 +531,27 @@ public class IotRdDailyReportController {
|
|
|
platformPair.put(report.getTaskId(), platformVO);
|
|
|
});
|
|
|
}
|
|
|
+ // 查询多个日报id 对应的 已经保存的油耗记录
|
|
|
+ IotDailyReportFuelPageReqVO fuelReqVO = new IotDailyReportFuelPageReqVO();
|
|
|
+ fuelReqVO.setType("RD");
|
|
|
+ fuelReqVO.setReportIds(reportIds);
|
|
|
+ List<IotDailyReportFuelDO> relatedReportFuels = iotDailyReportFuelService.getIotDailyReportFuels(fuelReqVO);
|
|
|
+ Map<Long, List<IotDailyReportFuelDO>> reportFuelsPair = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(relatedReportFuels)) {
|
|
|
+ relatedReportFuels.forEach(fuel -> {
|
|
|
+ if (reportFuelsPair.containsKey(fuel.getReportId())) {
|
|
|
+ List<IotDailyReportFuelDO> tempFuels = reportFuelsPair.get(fuel.getReportId());
|
|
|
+ tempFuels.add(fuel);
|
|
|
+ reportFuelsPair.put(fuel.getReportId(), tempFuels);
|
|
|
+ } else {
|
|
|
+ List<IotDailyReportFuelDO> tempFuels = new ArrayList<>();
|
|
|
+ tempFuels.add(fuel);
|
|
|
+ reportFuelsPair.put(fuel.getReportId(), tempFuels);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 返回已经填报的油耗记录
|
|
|
+
|
|
|
List<IotProjectTaskPlatformVO> platforms = new ArrayList<>();
|
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
|
tasks.forEach(task -> {
|
|
|
@@ -431,6 +562,7 @@ public class IotRdDailyReportController {
|
|
|
platform.setWellName(task.getWellName());
|
|
|
platform.setWorkloadDesign(task.getWorkloadDesign());
|
|
|
platform.setReportId(reportPair.get(task.getId()));
|
|
|
+ platform.setDailyFuel(reportFuelPair.get(task.getId()));
|
|
|
if (platformPair.containsKey(task.getId())) {
|
|
|
IotProjectTaskPlatformVO tempPlatform = platformPair.get(task.getId());
|
|
|
platform.setRdStatus(tempPlatform.getRdStatus());
|
|
|
@@ -448,6 +580,8 @@ public class IotRdDailyReportController {
|
|
|
List<IotProjectTaskPlatformVO> finishedPlatforms = new ArrayList<>();
|
|
|
// key任务井id value任务井名称
|
|
|
Map<Long, String> wellNamePair = new HashMap<>();
|
|
|
+ // key任务id value任务井对应日报当日油耗
|
|
|
+ Map<Long, BigDecimal> finishedReportFuelPair = new HashMap<>();
|
|
|
// 查询当前任务关联的平台井任务列表
|
|
|
IotProjectTaskPageReqVO currentPlatformTaskReqVO = new IotProjectTaskPageReqVO();
|
|
|
currentPlatformTaskReqVO.setPlatformGroup(dailyReport.getTaskPlatform());
|
|
|
@@ -469,9 +603,14 @@ public class IotRdDailyReportController {
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(currentRelatedReports)) {
|
|
|
currentRelatedReports.forEach(report -> {
|
|
|
+ if (reportFuelsPair.containsKey(report.getId())) {
|
|
|
+ List<IotDailyReportFuelDO> finishedReportFuels = reportFuelsPair.get(report.getId());
|
|
|
+ dailyReportVO.setReportedFuels(finishedReportFuels);
|
|
|
+ }
|
|
|
if (StrUtil.isNotBlank(report.getRdStatus())) {
|
|
|
IotProjectTaskPlatformVO platform = new IotProjectTaskPlatformVO();
|
|
|
platform.setId(report.getTaskId());
|
|
|
+ platform.setDailyFuel(report.getDailyFuel());
|
|
|
if (wellNamePair.containsKey(report.getTaskId())) {
|
|
|
platform.setWellName(wellNamePair.get(report.getTaskId()));
|
|
|
}
|