|
@@ -75,6 +75,7 @@ import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -2321,6 +2322,12 @@ public class IotRdDailyReportController {
|
|
|
constructStatusPair.put(data.getValue(), data.getLabel());
|
|
constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ // 设置非生产时间标识
|
|
|
|
|
+ Map<String, Boolean> reportNonProductFlagPair = new HashMap<>();
|
|
|
|
|
+ // key平台井标识 value非生产时间累计和列表
|
|
|
|
|
+ Map<String, List<BigDecimal>> platformNonProductPair = new HashMap<>();
|
|
|
|
|
+ // key平台井标识 value平台井非生产时效集合
|
|
|
|
|
+ Map<String, BigDecimal> platformNptPair = new HashMap<>();
|
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
|
// 查询日报关联的项目信息
|
|
// 查询日报关联的项目信息
|
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
@@ -2389,6 +2396,7 @@ public class IotRdDailyReportController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 平台井 主井施工完成 需要显示 关联井的施工状态 井号
|
|
// 平台井 主井施工完成 需要显示 关联井的施工状态 井号
|
|
|
if (CollUtil.isNotEmpty(relatedWellReports)) {
|
|
if (CollUtil.isNotEmpty(relatedWellReports)) {
|
|
|
Map<String, IotRdDailyReportDO> relatedPlatformGroupPair = new HashMap<>();
|
|
Map<String, IotRdDailyReportDO> relatedPlatformGroupPair = new HashMap<>();
|
|
@@ -2398,6 +2406,27 @@ public class IotRdDailyReportController {
|
|
|
if (!relatedPlatformGroupPair.containsKey(report.getPlatformGroup())) {
|
|
if (!relatedPlatformGroupPair.containsKey(report.getPlatformGroup())) {
|
|
|
relatedPlatformGroupPair.put(report.getPlatformGroup(), report);
|
|
relatedPlatformGroupPair.put(report.getPlatformGroup(), report);
|
|
|
}
|
|
}
|
|
|
|
|
+ // 查询关联井的 非生产时间填写情况 只要有1个关联井填写了 非生产时间 就显示为 已填写
|
|
|
|
|
+ IotRdDailyReportRespVO reportRespVO = BeanUtils.toBean(report, IotRdDailyReportRespVO.class);
|
|
|
|
|
+ Boolean flag = setNoProductFlag(reportRespVO);
|
|
|
|
|
+ if (flag) {
|
|
|
|
|
+ reportNonProductFlagPair.put(report.getPlatformGroup(), true);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设置平台井 的非生产时效 所有 井数据 累加平均
|
|
|
|
|
+ if (CollUtil.isNotEmpty(report.getExtProperty()) || StrUtil.isNotBlank(report.getRdStatus())) {
|
|
|
|
|
+ // 说明当前日报设置过 工作量 施工状态
|
|
|
|
|
+ IotRdDailyReportRespVO rdDailyReportResp = BeanUtils.toBean(report, IotRdDailyReportRespVO.class);
|
|
|
|
|
+ BigDecimal nonProductTime = calculateNonProductTime(rdDailyReportResp);
|
|
|
|
|
+ if (platformNonProductPair.containsKey(report.getPlatformGroup())) {
|
|
|
|
|
+ List<BigDecimal> tempSumNpts = platformNonProductPair.get(report.getPlatformGroup());
|
|
|
|
|
+ tempSumNpts.add(nonProductTime);
|
|
|
|
|
+ platformNonProductPair.put(report.getPlatformGroup(), tempSumNpts);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<BigDecimal> tempSumNpts = new ArrayList<>();
|
|
|
|
|
+ tempSumNpts.add(nonProductTime);
|
|
|
|
|
+ platformNonProductPair.put(report.getPlatformGroup(), tempSumNpts);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
relatedWellReports.forEach(report -> {
|
|
relatedWellReports.forEach(report -> {
|
|
@@ -2479,6 +2508,25 @@ public class IotRdDailyReportController {
|
|
|
taskSubmitterPair.put(task.getId(), submitterNames);
|
|
taskSubmitterPair.put(task.getId(), submitterNames);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ // 统计计算出平台井中每个井的 非生产时效
|
|
|
|
|
+ if (CollUtil.isNotEmpty(platformNonProductPair)) {
|
|
|
|
|
+ platformNonProductPair.forEach((platformGroup, npts) -> {
|
|
|
|
|
+ // npts是各平台井的非生产时间累计和集合
|
|
|
|
|
+ // 1. 计算分子:集合中所有BigDecimal元素的总和
|
|
|
|
|
+ BigDecimal numerator = npts.stream()
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ int denominatorInt = npts.size() * 24;
|
|
|
|
|
+ BigDecimal denominator = BigDecimal.valueOf(denominatorInt);
|
|
|
|
|
+ BigDecimal nonProductionRate;
|
|
|
|
|
+ if (denominator.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
+ nonProductionRate = BigDecimal.ZERO; // 分母为0时比率设为0
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 除法:指定精度(保留4位小数)和舍入模式(四舍五入),可根据业务调整
|
|
|
|
|
+ nonProductionRate = numerator.divide(denominator, 4, RoundingMode.HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ platformNptPair.put(platformGroup, nonProductionRate);
|
|
|
|
|
+ } );
|
|
|
|
|
+ }
|
|
|
// 查询所有任务的工作量数据 单位相同的工作量属性值合并处理
|
|
// 查询所有任务的工作量数据 单位相同的工作量属性值合并处理
|
|
|
for (IotRdDailyReportDO report : reports) {
|
|
for (IotRdDailyReportDO report : reports) {
|
|
|
// 设置每个任务的工作量数据 单位相同的工作量值作合并处理
|
|
// 设置每个任务的工作量数据 单位相同的工作量值作合并处理
|
|
@@ -2564,29 +2612,17 @@ public class IotRdDailyReportController {
|
|
|
reportVO.setRdStatusLabel(constructStatusPair.get(reportVO.getRdStatus()));
|
|
reportVO.setRdStatusLabel(constructStatusPair.get(reportVO.getRdStatus()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- BigDecimal accidentTime = reportVO.getAccidentTime();
|
|
|
|
|
- BigDecimal repairTime = reportVO.getRepairTime();
|
|
|
|
|
- BigDecimal selfStopTime = reportVO.getSelfStopTime();
|
|
|
|
|
- BigDecimal complexityTime = reportVO.getComplexityTime();
|
|
|
|
|
- BigDecimal relocationTime = reportVO.getRelocationTime();
|
|
|
|
|
- BigDecimal rectificationTime = reportVO.getRectificationTime();
|
|
|
|
|
- BigDecimal waitingStopTime = reportVO.getWaitingStopTime();
|
|
|
|
|
- BigDecimal winterBreakTime = reportVO.getWinterBreakTime();
|
|
|
|
|
- BigDecimal partyaDesignTime = reportVO.getPartyaDesign();
|
|
|
|
|
- BigDecimal partyaPrepareTime = reportVO.getPartyaPrepare();
|
|
|
|
|
- BigDecimal partyaResourceTime = reportVO.getPartyaResource();
|
|
|
|
|
- BigDecimal otherNptTime = reportVO.getOtherNptTime();
|
|
|
|
|
- if (accidentTime.compareTo(BigDecimal.ZERO) > 0 || repairTime.compareTo(BigDecimal.ZERO) > 0 || selfStopTime.compareTo(BigDecimal.ZERO) > 0
|
|
|
|
|
- || complexityTime.compareTo(BigDecimal.ZERO) > 0 || relocationTime.compareTo(BigDecimal.ZERO) > 0 || rectificationTime.compareTo(BigDecimal.ZERO) > 0
|
|
|
|
|
- || waitingStopTime.compareTo(BigDecimal.ZERO) > 0 || winterBreakTime.compareTo(BigDecimal.ZERO) > 0 || partyaDesignTime.compareTo(BigDecimal.ZERO) > 0
|
|
|
|
|
- || partyaPrepareTime.compareTo(BigDecimal.ZERO) > 0 || partyaResourceTime.compareTo(BigDecimal.ZERO) > 0 || otherNptTime.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
- // 设置非生产时间填写标识
|
|
|
|
|
- reportVO.setNonProductFlag(true);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 计算非生产时效 如果是平台井 需要计算 所有平台井 的 非生产时效
|
|
|
|
|
+ BigDecimal nonProductionTimes = calculateNonProductTime(reportVO);
|
|
|
|
|
+ reportVO.setNonProductionRate(nonProductionTimes.divide(BigDecimal.valueOf(24), 4, RoundingMode.HALF_UP ));
|
|
|
|
|
+ // 设置非生产时间填写标识 noProductFlag 为 true 或者 processInstanceId 为 2 的时候 显示 已填写
|
|
|
|
|
+ reportVO.setNonProductFlag(setNoProductFlag(reportVO));
|
|
|
// 创建时间 格式化 yyyy-MM-dd
|
|
// 创建时间 格式化 yyyy-MM-dd
|
|
|
if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
|
|
if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
|
|
|
reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
|
|
reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
|
|
|
}
|
|
}
|
|
|
|
|
+ // 平台井 非生产时效
|
|
|
|
|
+ findAndThen(platformNptPair, reportVO.getPlatformGroup(), npt -> reportVO.setNonProductionRate(npt));
|
|
|
// 部门信息 任务中关联的施工队伍
|
|
// 部门信息 任务中关联的施工队伍
|
|
|
findAndThen(taskTeamsPair, reportVO.getTaskId(), deptNames -> reportVO.setDeptName(deptNames));
|
|
findAndThen(taskTeamsPair, reportVO.getTaskId(), deptNames -> reportVO.setDeptName(deptNames));
|
|
|
// 日报关联的项目信息
|
|
// 日报关联的项目信息
|
|
@@ -2595,6 +2631,8 @@ public class IotRdDailyReportController {
|
|
|
findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
|
|
findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
|
|
|
// 日报关联的任务信息(兼容主井完工 关联井未完工的情况)
|
|
// 日报关联的任务信息(兼容主井完工 关联井未完工的情况)
|
|
|
findAndThen(relatedPlatformPair, reportVO.getPlatformGroup(), relatedTaskName -> reportVO.setTaskName(relatedTaskName));
|
|
findAndThen(relatedPlatformPair, reportVO.getPlatformGroup(), relatedTaskName -> reportVO.setTaskName(relatedTaskName));
|
|
|
|
|
+ // 平台井相关的非生产时间标识
|
|
|
|
|
+ findAndThen(reportNonProductFlagPair, reportVO.getPlatformGroup(), nonProductFlag -> reportVO.setNonProductFlag(nonProductFlag));
|
|
|
// 日报关联的任务施工状态(兼容主井完工 关联井未完工的情况)
|
|
// 日报关联的任务施工状态(兼容主井完工 关联井未完工的情况)
|
|
|
findAndThen(relatedWellStatusPair, reportVO.getPlatformGroup(), rdStatus -> reportVO.setRdStatus(rdStatus));
|
|
findAndThen(relatedWellStatusPair, reportVO.getPlatformGroup(), rdStatus -> reportVO.setRdStatus(rdStatus));
|
|
|
// 日报关联的责任人
|
|
// 日报关联的责任人
|
|
@@ -2604,6 +2642,60 @@ public class IotRdDailyReportController {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检测是否已经维护了生产时效
|
|
|
|
|
+ * @param dailyReport
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private Boolean setNoProductFlag(IotRdDailyReportRespVO dailyReport){
|
|
|
|
|
+ BigDecimal accidentTime = dailyReport.getAccidentTime();
|
|
|
|
|
+ BigDecimal repairTime = dailyReport.getRepairTime();
|
|
|
|
|
+ BigDecimal selfStopTime = dailyReport.getSelfStopTime();
|
|
|
|
|
+ BigDecimal complexityTime = dailyReport.getComplexityTime();
|
|
|
|
|
+ BigDecimal relocationTime = dailyReport.getRelocationTime();
|
|
|
|
|
+ BigDecimal rectificationTime = dailyReport.getRectificationTime();
|
|
|
|
|
+ BigDecimal waitingStopTime = dailyReport.getWaitingStopTime();
|
|
|
|
|
+ BigDecimal winterBreakTime = dailyReport.getWinterBreakTime();
|
|
|
|
|
+ BigDecimal partyaDesignTime = dailyReport.getPartyaDesign();
|
|
|
|
|
+ BigDecimal partyaPrepareTime = dailyReport.getPartyaPrepare();
|
|
|
|
|
+ BigDecimal partyaResourceTime = dailyReport.getPartyaResource();
|
|
|
|
|
+ BigDecimal otherNptTime = dailyReport.getOtherNptTime();
|
|
|
|
|
+ if (accidentTime.compareTo(BigDecimal.ZERO) > 0 || repairTime.compareTo(BigDecimal.ZERO) > 0 || selfStopTime.compareTo(BigDecimal.ZERO) > 0
|
|
|
|
|
+ || complexityTime.compareTo(BigDecimal.ZERO) > 0 || relocationTime.compareTo(BigDecimal.ZERO) > 0 || rectificationTime.compareTo(BigDecimal.ZERO) > 0
|
|
|
|
|
+ || waitingStopTime.compareTo(BigDecimal.ZERO) > 0 || winterBreakTime.compareTo(BigDecimal.ZERO) > 0 || partyaDesignTime.compareTo(BigDecimal.ZERO) > 0
|
|
|
|
|
+ || partyaPrepareTime.compareTo(BigDecimal.ZERO) > 0 || partyaResourceTime.compareTo(BigDecimal.ZERO) > 0 || otherNptTime.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ // 设置非生产时间填写标识
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计算非生产时间累加值 计算非生产时效
|
|
|
|
|
+ * @param dailyReport
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private BigDecimal calculateNonProductTime(IotRdDailyReportRespVO dailyReport){
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ dailyReport.getAccidentTime(),
|
|
|
|
|
+ dailyReport.getRepairTime(),
|
|
|
|
|
+ dailyReport.getSelfStopTime(),
|
|
|
|
|
+ dailyReport.getComplexityTime(),
|
|
|
|
|
+ dailyReport.getRelocationTime(),
|
|
|
|
|
+ dailyReport.getRectificationTime(),
|
|
|
|
|
+ dailyReport.getWaitingStopTime(),
|
|
|
|
|
+ dailyReport.getWinterBreakTime(),
|
|
|
|
|
+ dailyReport.getPartyaDesign(), // 注:字段名虽无Time但属于非生产时间,保留
|
|
|
|
|
+ dailyReport.getPartyaPrepare(),
|
|
|
|
|
+ dailyReport.getPartyaResource(),
|
|
|
|
|
+ dailyReport.getOtherNptTime()
|
|
|
|
|
+ )
|
|
|
|
|
+ // 处理null值,避免调用add()时抛出NullPointerException
|
|
|
|
|
+ .map(bd -> Objects.isNull(bd) ? BigDecimal.ZERO : bd)
|
|
|
|
|
+ // Stream.reduce:从初始值0开始,依次累加所有元素
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@GetMapping("/taskActualProgress")
|
|
@GetMapping("/taskActualProgress")
|
|
|
@Operation(summary = "查询日报所属任务的实际进度")
|
|
@Operation(summary = "查询日报所属任务的实际进度")
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
|