|
|
@@ -14,10 +14,16 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProject
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPlatformVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotTaskSaveVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsItemVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttaskattrs.IotTaskAttrModelProperty;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrddailyreport.IotRdDailyReportDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotrddailyreport.IotRdDailyReportMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotrddailyreport.IotRdDailyReportService;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
@@ -31,6 +37,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
@@ -52,6 +59,10 @@ public class IotProjectTaskController {
|
|
|
|
|
|
@Resource
|
|
|
private IotProjectInfoService iotProjectInfoService;
|
|
|
+ @Resource
|
|
|
+ private IotRdDailyReportMapper iotRdDailyReportMapper;
|
|
|
+ @Resource
|
|
|
+ private IotRdDailyReportService iotRdDailyReportService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建项目信息任务拆分")
|
|
|
@@ -110,6 +121,138 @@ public class IotProjectTaskController {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
Map<Long, List<IotProjectTaskPlatformVO>> platformWellPair = new HashMap<>();
|
|
|
+ // 查询每口井的已完成工作量
|
|
|
+ IotRdDailyReportPageReqVO reportReqVO = new IotRdDailyReportPageReqVO();
|
|
|
+ reportReqVO.setTaskIds(convertList(pagedTasks, IotProjectTaskDO::getId));
|
|
|
+ List<IotRdDailyReportDO> dailyReports = iotRdDailyReportMapper.dailyReports(reportReqVO);
|
|
|
+ // key任务井id value队伍工作量数据
|
|
|
+ Map<Long, BigDecimal> bridgePlugPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> runCountPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> cumulativeWorkingWellPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> hourCountPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> waterVolumePair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> pumpTripsPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> cumulativeWorkingLayersPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> mixSandPair = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ // 设置每个任务的工作量数据 单位相同的工作量值作合并处理
|
|
|
+ List<IotTaskAttrModelProperty> taskAttrs = report.getExtProperty();
|
|
|
+ // 暂存不同单位的工作量属性值
|
|
|
+ BigDecimal tempTotalBridgePlug = BigDecimal.ZERO; // 桥塞(个数)
|
|
|
+ BigDecimal tempTotalRunCount = BigDecimal.ZERO; // 趟数
|
|
|
+ BigDecimal tempTotalCumulativeWorkingWell = BigDecimal.ZERO; // 井数
|
|
|
+ BigDecimal tempTotalHourCount = BigDecimal.ZERO; // 小时H
|
|
|
+ BigDecimal tempTotalWaterVolume = BigDecimal.ZERO; // 水方量(方)
|
|
|
+ BigDecimal tempTotalPumpTrips = BigDecimal.ZERO;
|
|
|
+ BigDecimal tempTotalCumulativeWorkingLayers = BigDecimal.ZERO; // 段数 累计施工-层
|
|
|
+ BigDecimal tempTotalMixSand = BigDecimal.ZERO; // 台次 当日泵车台次 当日仪表/混砂
|
|
|
+ if (CollUtil.isNotEmpty(taskAttrs)) {
|
|
|
+ for (IotTaskAttrModelProperty attr : taskAttrs) {
|
|
|
+ String unit = attr.getUnit(); // 工作量单位
|
|
|
+ String actualValueStr = attr.getActualValue(); // 工作量属性的实际值
|
|
|
+ // 处理实际值:避免null或非数字字符串导致的异常
|
|
|
+ BigDecimal actualValue = BigDecimal.ZERO;
|
|
|
+ if (StrUtil.isNotBlank(actualValueStr)) { // 假设使用Hutool的StrUtil,或自行判断null/空
|
|
|
+ try {
|
|
|
+ actualValue = new BigDecimal(actualValueStr);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 若字符串格式错误,默认按0处理(可根据业务调整)
|
|
|
+ actualValue = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("个数".equals(unit)) {
|
|
|
+ // 钻可溶桥塞 钻复合桥塞
|
|
|
+ tempTotalBridgePlug = tempTotalBridgePlug.add(actualValue);
|
|
|
+ if (bridgePlugPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempBridgePlug = bridgePlugPair.get(report.getTaskId());
|
|
|
+ bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug.add(tempBridgePlug));
|
|
|
+ } else {
|
|
|
+ bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("趟数".equals(unit)) {
|
|
|
+ tempTotalRunCount = tempTotalRunCount.add(actualValue);
|
|
|
+ if (runCountPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempRunCount = runCountPair.get(report.getTaskId());
|
|
|
+ runCountPair.put(report.getTaskId(), tempTotalRunCount.add(tempRunCount));
|
|
|
+ } else {
|
|
|
+ runCountPair.put(report.getTaskId(), tempTotalRunCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("小时".equals(unit)) {
|
|
|
+ tempTotalHourCount = tempTotalHourCount.add(actualValue);
|
|
|
+ if (hourCountPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempHourCount = hourCountPair.get(report.getTaskId());
|
|
|
+ hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
|
|
|
+ } else {
|
|
|
+ hourCountPair.put(report.getTaskId(), tempTotalHourCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("天数".equals(unit)) {
|
|
|
+ // 将 actualValue 换算成 H
|
|
|
+ BigDecimal hours = actualValue.multiply(new BigDecimal("24"));
|
|
|
+ tempTotalHourCount = tempTotalHourCount.add(hours);
|
|
|
+ if (hourCountPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempHourCount = hourCountPair.get(report.getTaskId());
|
|
|
+ hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
|
|
|
+ } else {
|
|
|
+ hourCountPair.put(report.getTaskId(), tempTotalHourCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("方".equals(unit)) {
|
|
|
+ tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
|
|
|
+ if (waterVolumePair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempWaterVolume = waterVolumePair.get(report.getTaskId());
|
|
|
+ waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume.add(tempWaterVolume));
|
|
|
+ } else {
|
|
|
+ waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("井数".equals(unit)) {
|
|
|
+ tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
|
|
|
+ if (cumulativeWorkingWellPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get(report.getTaskId());
|
|
|
+ cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell.add(tempWorkingWell));
|
|
|
+ } else {
|
|
|
+ cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("段数".equals(unit)) {
|
|
|
+ // 累计施工层
|
|
|
+ tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
|
|
|
+ if (cumulativeWorkingLayersPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempWorkingLayer = cumulativeWorkingLayersPair.get(report.getTaskId());
|
|
|
+ cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers.add(tempWorkingLayer));
|
|
|
+ } else {
|
|
|
+ cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("台次".equals(unit) && "当日泵车台次".equals(attr.getName())) {
|
|
|
+ tempTotalPumpTrips = tempTotalPumpTrips.add(actualValue);
|
|
|
+ if (pumpTripsPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempPumpTrips = pumpTripsPair.get(report.getTaskId());
|
|
|
+ pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips.add(tempPumpTrips));
|
|
|
+ } else {
|
|
|
+ pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("台次".equals(unit) && ("当日仪表/混砂".equals(attr.getName())
|
|
|
+ || "当日混砂".equals(attr.getName()) || "当日仪表".equals(attr.getName()))) {
|
|
|
+ tempTotalMixSand = tempTotalMixSand.add(actualValue);
|
|
|
+ if (mixSandPair.containsKey(report.getTaskId())) {
|
|
|
+ BigDecimal tempMixSand = mixSandPair.get(report.getTaskId());
|
|
|
+ mixSandPair.put(report.getTaskId(), tempTotalMixSand.add(tempMixSand));
|
|
|
+ } else {
|
|
|
+ mixSandPair.put(report.getTaskId(), tempTotalMixSand);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // key任务id value任务已经完成的工作量集合
|
|
|
+ Map<Long, List<IotRdDailyReportStatisticsItemVO>> taskFinishedWorkloadPair = new HashMap<>();
|
|
|
// 循环每个任务 找到任务 关联的平台井
|
|
|
if (CollUtil.isNotEmpty(pagedTasks)) {
|
|
|
pagedTasks.forEach(task -> {
|
|
|
@@ -131,12 +274,74 @@ public class IotProjectTaskController {
|
|
|
});
|
|
|
platformWellPair.put(task.getId(), platforms);
|
|
|
}
|
|
|
+ // 设置每个任务的已完成工作量信息
|
|
|
+ List<IotRdDailyReportStatisticsItemVO> items = new ArrayList<>();
|
|
|
+ // 以队伍为维度 设置每种施工工艺的工作量 总和
|
|
|
+ if (bridgePlugPair.containsKey(task.getId())) {
|
|
|
+ // 钻可溶桥塞 钻复合桥塞
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("个数");
|
|
|
+ item.setWorkload(bridgePlugPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (runCountPair.containsKey(task.getId())) {
|
|
|
+ // 通刮洗 冲砂
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("趟数");
|
|
|
+ item.setWorkload(runCountPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (hourCountPair.containsKey(task.getId())) {
|
|
|
+ // 液氮泵车(时间D) 千型泵车(时间H)
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("小时");
|
|
|
+ item.setWorkload(hourCountPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (waterVolumePair.containsKey(task.getId())) {
|
|
|
+ // 注水
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("方");
|
|
|
+ item.setWorkload(waterVolumePair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (cumulativeWorkingWellPair.containsKey(task.getId())) {
|
|
|
+ // 连续油管常规作业
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("井数");
|
|
|
+ item.setWorkload(cumulativeWorkingWellPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (cumulativeWorkingLayersPair.containsKey(task.getId())) {
|
|
|
+ // 压裂大包 压裂总包
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("段数");
|
|
|
+ item.setWorkload(cumulativeWorkingLayersPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (pumpTripsPair.containsKey(task.getId())) {
|
|
|
+ // 主压裂车 当日泵车台次
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("台次");
|
|
|
+ item.setWorkload(pumpTripsPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ if (mixSandPair.containsKey(task.getId())) {
|
|
|
+ // 当日仪表/混砂 台次
|
|
|
+ IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
|
|
|
+ item.setUnit("台次");
|
|
|
+ item.setWorkload(mixSandPair.get(task.getId()));
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ taskFinishedWorkloadPair.put(task.getId(), items);
|
|
|
});
|
|
|
}
|
|
|
// 2. 拼接数据
|
|
|
return BeanUtils.toBean(pagedTasks, IotProjectTaskRespVO.class, (taskVO) -> {
|
|
|
- // 2.1 拼接平台井信息
|
|
|
+ // 拼接平台井信息
|
|
|
findAndThen(platformWellPair, taskVO.getId(), tasks -> taskVO.setPlatformWells(tasks));
|
|
|
+ // 任务已经完成的工作量
|
|
|
+ findAndThen(taskFinishedWorkloadPair, taskVO.getId(), workloads -> taskVO.setItems(workloads));
|
|
|
});
|
|
|
}
|
|
|
|