|
@@ -1,6 +1,7 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
@@ -12,14 +13,18 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportSaveReqVO;
|
|
|
|
|
+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.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
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.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
|
|
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.iotprojectinfo.IotProjectInfoDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
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.service.iotfivedailyreport.IotFiveDailyReportService;
|
|
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.iotprojectinfo.IotProjectInfoService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
|
|
|
+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.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
@@ -35,10 +40,11 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.YearMonth;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
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;
|
|
@@ -62,6 +68,9 @@ public class IotFiveDailyReportController {
|
|
|
private IotProjectTaskService iotProjectTaskService;
|
|
private IotProjectTaskService iotProjectTaskService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private DictDataService dictDataService;
|
|
private DictDataService dictDataService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IotProjectTaskScheduleService iotProjectTaskScheduleService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建5#国日报")
|
|
@Operation(summary = "创建5#国日报")
|
|
@@ -93,7 +102,90 @@ public class IotFiveDailyReportController {
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:query')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:query')")
|
|
|
public CommonResult<IotFiveDailyReportRespVO> getIotFiveDailyReport(@RequestParam("id") Long id) {
|
|
public CommonResult<IotFiveDailyReportRespVO> getIotFiveDailyReport(@RequestParam("id") Long id) {
|
|
|
IotFiveDailyReportDO iotFiveDailyReport = iotFiveDailyReportService.getIotFiveDailyReport(id);
|
|
IotFiveDailyReportDO iotFiveDailyReport = iotFiveDailyReportService.getIotFiveDailyReport(id);
|
|
|
- return success(BeanUtils.toBean(iotFiveDailyReport, IotFiveDailyReportRespVO.class));
|
|
|
|
|
|
|
+ return success(buildDailyReport(iotFiveDailyReport));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询日报对应的项目 任务信息
|
|
|
|
|
+ * @param dailyReport
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private IotFiveDailyReportRespVO buildDailyReport(IotFiveDailyReportDO dailyReport) {
|
|
|
|
|
+ // 如果 dailyReport 为空 返回空对象 有可能任务中安排的人员部门 与日报所在部门不同
|
|
|
|
|
+ if (ObjUtil.isEmpty(dailyReport)) {
|
|
|
|
|
+ return new IotFiveDailyReportRespVO();
|
|
|
|
|
+ }
|
|
|
|
|
+ IotFiveDailyReportRespVO dailyReportVO = BeanUtils.toBean(dailyReport, IotFiveDailyReportRespVO.class);
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime reportTime = dailyReportVO.getCreateTime();
|
|
|
|
|
+ // 当月计划工作量,默认0
|
|
|
|
|
+ BigDecimal monthPlanLayers = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ // 设置 日报 的项目 任务 等信息
|
|
|
|
|
+ // key施工状态数据字典value value施工状态数据字典label
|
|
|
|
|
+ Map<String, String> constructStatusPair = new HashMap<>();
|
|
|
|
|
+ // 施工状态 字典数据
|
|
|
|
|
+ List<DictDataDO> rdStatusData = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
|
|
+ if (CollUtil.isNotEmpty(rdStatusData)) {
|
|
|
|
|
+ rdStatusData.forEach(data -> {
|
|
|
|
|
+ constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(constructStatusPair)) {
|
|
|
|
|
+ String statusLabel = constructStatusPair.get(dailyReportVO.getFiveStatus());
|
|
|
|
|
+ dailyReportVO.setFiveStatusLabel(statusLabel);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 当前日报的设备利用率 作业泵车数量 / 主设备泵车数量
|
|
|
|
|
+ BigDecimal mainDeviceNum = dailyReportVO.getMainDeviceNum();
|
|
|
|
|
+ BigDecimal wokDeviceNum = dailyReportVO.getWokDeviceNum();
|
|
|
|
|
+ if (mainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ BigDecimal utilizationRate = wokDeviceNum.divide(mainDeviceNum, 4, RoundingMode.HALF_UP );
|
|
|
|
|
+ dailyReportVO.setUtilizationRate(utilizationRate);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 当前日报的 施工队伍
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(dailyReportVO.getDeptId())) {
|
|
|
|
|
+ DeptDO dept = deptService.getDept(dailyReportVO.getDeptId());
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(dept)) {
|
|
|
|
|
+ dailyReportVO.setDeptName(dept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 当前日报的 项目信息
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(dailyReportVO.getProjectId())) {
|
|
|
|
|
+ IotProjectInfoDO projectInfo = iotProjectInfoService.getIotProjectInfo(dailyReportVO.getProjectId());
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(projectInfo)) {
|
|
|
|
|
+ dailyReportVO.setProjectName(projectInfo.getContractName());
|
|
|
|
|
+ dailyReportVO.setCustomer(projectInfo.getManufactureName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 查询当前日报关联的 任务信息
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(dailyReportVO.getTaskId())) {
|
|
|
|
|
+ IotProjectTaskDO projectTask = iotProjectTaskService.getIotProjectTask(dailyReportVO.getTaskId());
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(projectTask)) {
|
|
|
|
|
+ dailyReportVO.setLocation(projectTask.getLocation());
|
|
|
|
|
+ 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;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@@ -123,6 +215,8 @@ public class IotFiveDailyReportController {
|
|
|
Map<Long, String> taskLocationPair = new HashMap<>();
|
|
Map<Long, String> taskLocationPair = new HashMap<>();
|
|
|
// key施工状态数据字典value value施工状态数据字典label
|
|
// key施工状态数据字典value value施工状态数据字典label
|
|
|
Map<String, String> constructStatusPair = new HashMap<>();
|
|
Map<String, String> constructStatusPair = new HashMap<>();
|
|
|
|
|
+ // key日报id value日报设备利用率
|
|
|
|
|
+ Map<Long, BigDecimal> reportRatePair = new HashMap<>();
|
|
|
// 设备部门信息
|
|
// 设备部门信息
|
|
|
Map<Long, DeptDO> tempDeptMap = deptService.getDeptMap(convertList(reports, IotFiveDailyReportDO::getDeptId));
|
|
Map<Long, DeptDO> tempDeptMap = deptService.getDeptMap(convertList(reports, IotFiveDailyReportDO::getDeptId));
|
|
|
// 施工状态 字典数据
|
|
// 施工状态 字典数据
|
|
@@ -132,6 +226,16 @@ public class IotFiveDailyReportController {
|
|
|
constructStatusPair.put(data.getValue(), data.getLabel());
|
|
constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ // 计算每个日报的 设备利用率
|
|
|
|
|
+ reports.forEach(report -> {
|
|
|
|
|
+ // 设备利用率 作业泵车数量 / 主设备泵车数量
|
|
|
|
|
+ BigDecimal mainDeviceNum = report.getMainDeviceNum();
|
|
|
|
|
+ BigDecimal wokDeviceNum = report.getWokDeviceNum();
|
|
|
|
|
+ if (mainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ BigDecimal utilizationRate = wokDeviceNum.divide(mainDeviceNum, 4, RoundingMode.HALF_UP );
|
|
|
|
|
+ reportRatePair.put(report.getId(), utilizationRate);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
|
// 查询日报关联的项目信息
|
|
// 查询日报关联的项目信息
|
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
@@ -161,7 +265,9 @@ public class IotFiveDailyReportController {
|
|
|
reportVO.setFiveStatusLabel(constructStatusPair.get(reportVO.getFiveStatus()));
|
|
reportVO.setFiveStatusLabel(constructStatusPair.get(reportVO.getFiveStatus()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 临时新建的日报的 施工队伍
|
|
|
|
|
|
|
+ // 日报的 设备利用率
|
|
|
|
|
+ findAndThen(reportRatePair, reportVO.getId(), utilizationRate -> reportVO.setUtilizationRate(utilizationRate));
|
|
|
|
|
+ // 日报的 施工队伍
|
|
|
findAndThen(tempDeptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
findAndThen(tempDeptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
|
// 日报关联的项目信息
|
|
// 日报关联的项目信息
|
|
|
findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setProjectName(contractName));
|
|
findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setProjectName(contractName));
|
|
@@ -174,6 +280,39 @@ public class IotFiveDailyReportController {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @GetMapping("/totalWorkload")
|
|
|
|
|
+ @Operation(summary = "5#国日报 汇总 统计 卡片")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:query')")
|
|
|
|
|
+ public CommonResult<IotFiveDailyReportStatisticsRespVO> totalWorkload(@Valid IotFiveDailyReportPageReqVO pageReqVO) {
|
|
|
|
|
+ // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
|
|
|
|
|
+ Set<Long> projectIds = new HashSet<>();
|
|
|
|
|
+ Set<Long> taskIds = new HashSet<>();
|
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getProjectName())) {
|
|
|
|
|
+ IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
|
|
|
+ reqVO.setContractName(pageReqVO.getProjectName());
|
|
|
|
|
+ List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(projects)) {
|
|
|
|
|
+ projects.forEach(project -> {
|
|
|
|
|
+ projectIds.add(project.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ pageReqVO.setProjectIds(projectIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getWellName())) {
|
|
|
|
|
+ IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
|
|
|
|
|
+ reqVO.setSearchKey(pageReqVO.getWellName());
|
|
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(reqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
|
|
+ tasks.forEach(task -> {
|
|
|
|
|
+ taskIds.add(task.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ pageReqVO.setTaskIds(taskIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ IotFiveDailyReportStatisticsRespVO statistics = iotFiveDailyReportService.totalWorkload(pageReqVO);
|
|
|
|
|
+ return success(statistics);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@GetMapping("/export-excel")
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出5#国日报 Excel")
|
|
@Operation(summary = "导出5#国日报 Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:export')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:export')")
|