|
|
@@ -16,14 +16,17 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiv
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportStatisticsRespVO;
|
|
|
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.iotprojecttaskschedule.vo.IotProjectTaskSchedulePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttaskplan.vo.IotProjectTaskPlanPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
|
|
|
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.iotprojecttaskschedule.IotProjectTaskScheduleDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttaskplan.IotProjectTaskPlanDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotfivedailyreport.IotFiveDailyReportService;
|
|
|
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.iotprojecttaskplan.IotProjectTaskPlanService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotprojecttaskschedule.IotProjectTaskScheduleService;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
@@ -43,8 +46,10 @@ import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.YearMonth;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
@@ -63,7 +68,8 @@ public class IotFiveDailyReportController {
|
|
|
private DeptService deptService;
|
|
|
@Resource
|
|
|
private IotProjectInfoService iotProjectInfoService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private IotDeviceService iotDeviceService;
|
|
|
@Resource
|
|
|
private IotProjectTaskService iotProjectTaskService;
|
|
|
@Resource
|
|
|
@@ -71,6 +77,8 @@ public class IotFiveDailyReportController {
|
|
|
@Resource
|
|
|
private IotProjectTaskScheduleService iotProjectTaskScheduleService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IotProjectTaskPlanService iotProjectTaskPlanService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建5#国日报")
|
|
|
@@ -121,6 +129,20 @@ public class IotFiveDailyReportController {
|
|
|
// 当月计划工作量,默认0
|
|
|
BigDecimal monthPlanLayers = BigDecimal.ZERO;
|
|
|
|
|
|
+ // 设置日报关联的 设备名称 多个逗号分隔
|
|
|
+ Set<Long> deviceIds = dailyReportVO.getDeviceIds();
|
|
|
+ String deviceNames = StrUtil.EMPTY;
|
|
|
+ if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
+ // 查询设备id集合对应的设备编码 设备名称
|
|
|
+ List<IotDeviceRespVO> devices = iotDeviceService.getDeviceList(deviceIds);
|
|
|
+ if (CollUtil.isNotEmpty(devices)) {
|
|
|
+ deviceNames = devices.stream()
|
|
|
+ .map(d -> StrUtil.join("-", d.getDeviceCode(), d.getDeviceName()))
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dailyReportVO.setDeviceNames(deviceNames);
|
|
|
+
|
|
|
// 设置 日报 的项目 任务 等信息
|
|
|
// key施工状态数据字典value value施工状态数据字典label
|
|
|
Map<String, String> constructStatusPair = new HashMap<>();
|
|
|
@@ -160,6 +182,40 @@ public class IotFiveDailyReportController {
|
|
|
deptWellNames.put(task.getId(), task.getWellName());
|
|
|
});
|
|
|
}
|
|
|
+ // 查询当前队伍 当月作业层数
|
|
|
+ LocalDateTime currentDate = LocalDateTime.now();
|
|
|
+ IotFiveDailyReportPageReqVO pageReqVO = new IotFiveDailyReportPageReqVO();
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ pageReqVO.setDeptId(deptId);
|
|
|
+ pageReqVO.setCreateTime(new LocalDateTime[]{
|
|
|
+ currentDate.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN),
|
|
|
+ currentDate.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX)
|
|
|
+ });
|
|
|
+ PageResult<IotFiveDailyReportDO> pageReports = iotFiveDailyReportService.getIotFiveDailyReportPage(pageReqVO);
|
|
|
+ List<IotFiveDailyReportDO> reports = pageReports.getList();
|
|
|
+ if (CollUtil.isNotEmpty(reports)) {
|
|
|
+ BigDecimal monthLayers = reports.stream()
|
|
|
+ .map(IotFiveDailyReportDO::getDailyWorkingLayers)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ dailyReportVO.setMonthWorkingLayers(monthLayers);
|
|
|
+ }
|
|
|
+ // 本月计划压裂层数
|
|
|
+ IotProjectTaskPlanPageReqVO planReqVO = new IotProjectTaskPlanPageReqVO();
|
|
|
+ planReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ planReqVO.setDeptId(deptId);
|
|
|
+ planReqVO.setStartTime(new LocalDateTime[]{
|
|
|
+ currentDate.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN),
|
|
|
+ currentDate.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX)
|
|
|
+ });
|
|
|
+ PageResult<IotProjectTaskPlanDO> pagePlans = iotProjectTaskPlanService.getIotProjectTaskPlanPage(planReqVO);
|
|
|
+ List<IotProjectTaskPlanDO> plans = pagePlans.getList();
|
|
|
+ BigDecimal planLayers = plans.stream()
|
|
|
+ .map(IotProjectTaskPlanDO::getPlanLayers)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ // 赋值当月计划压裂层数
|
|
|
+ dailyReportVO.setPlanWorkingLayers(planLayers);
|
|
|
}
|
|
|
// 当前日报的 项目信息
|
|
|
if (ObjUtil.isNotEmpty(dailyReportVO.getProjectId())) {
|
|
|
@@ -180,25 +236,7 @@ public class IotFiveDailyReportController {
|
|
|
dailyReportVO.setWellName(projectTask.getWellName());
|
|
|
}
|
|
|
// 查询当前日报施工队伍部门对应的 任务计划信息
|
|
|
- IotProjectTaskSchedulePageReqVO pageReqVO = new IotProjectTaskSchedulePageReqVO();
|
|
|
- pageReqVO.setTaskId(dailyReportVO.getTaskId());
|
|
|
- List<IotProjectTaskScheduleDO> taskSchedules = iotProjectTaskScheduleService.getIotProjectTaskSchedules(pageReqVO);
|
|
|
- if (CollUtil.isNotEmpty(taskSchedules) && ObjUtil.isNotEmpty(reportTime)) {
|
|
|
- // 获取日报所属年月
|
|
|
- YearMonth reportYearMonth = YearMonth.from(reportTime);
|
|
|
- // Stream过滤:计划开始时间年月 和 日报年月一致,累加planLayers
|
|
|
- monthPlanLayers = taskSchedules.stream()
|
|
|
- // 过滤计划开始时间不为空,且年月匹配
|
|
|
- .filter(schedule -> ObjUtil.isNotEmpty(schedule.getStartTime()))
|
|
|
- .filter(schedule -> YearMonth.from(schedule.getStartTime()).equals(reportYearMonth))
|
|
|
- // 提取计划层数,空值替换0
|
|
|
- .map(schedule -> ObjUtil.defaultIfNull(schedule.getPlanLayers(), BigDecimal.ZERO))
|
|
|
- // 累加求和
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- }
|
|
|
}
|
|
|
- // 赋值当月计划压裂层数
|
|
|
- dailyReportVO.setPlanWorkingLayers(monthPlanLayers);
|
|
|
|
|
|
return dailyReportVO;
|
|
|
}
|