|
|
@@ -1,6 +1,8 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
@@ -23,7 +25,9 @@ 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.iotrydailyreport.IotRyDailyReportService;
|
|
|
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.service.dept.DeptService;
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -65,6 +69,8 @@ public class IotRyDailyReportController {
|
|
|
private IotProjectTaskService iotProjectTaskService;
|
|
|
@Resource
|
|
|
private IotRyDailyReportMapper iotRyDailyReportMapper;
|
|
|
+ @Resource
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建瑞鹰日报")
|
|
|
@@ -190,7 +196,7 @@ public class IotRyDailyReportController {
|
|
|
|
|
|
PageResult<IotRyDailyReportDO> pageResult = iotRyDailyReportService.getIotRyDailyReportPage(pageReqVO);
|
|
|
|
|
|
- return success(new PageResult<>(buildRyDailyReports(pageResult.getList(), pageReqVO), pageResult.getTotal()));
|
|
|
+ return success(new PageResult<>(buildRyDailyReports(pageResult.getList(), pageReqVO, "list"), pageResult.getTotal()));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/teamReports")
|
|
|
@@ -302,7 +308,7 @@ public class IotRyDailyReportController {
|
|
|
* @param reports
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<IotRyDailyReportRespVO> buildRyDailyReports(List<IotRyDailyReportDO> reports, IotRyDailyReportPageReqVO pageReqVO) {
|
|
|
+ private List<IotRyDailyReportRespVO> buildRyDailyReports(List<IotRyDailyReportDO> reports, IotRyDailyReportPageReqVO pageReqVO, String type) {
|
|
|
if (CollUtil.isEmpty(reports)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
@@ -334,6 +340,36 @@ public class IotRyDailyReportController {
|
|
|
Map<Long, Integer> totalTasksPair = new HashMap<>();
|
|
|
// key施工队伍id value完工井数量
|
|
|
Map<Long, Integer> completedTasksPair = new HashMap<>();
|
|
|
+ // key非生产时间原因数据字典value value非生产时间原因数据字典label
|
|
|
+ Map<String, String> nptReasonPair = new HashMap<>();
|
|
|
+ // key施工状态数据字典value value施工状态数据字典label
|
|
|
+ Map<String, String> constructStatusPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 钻井 施工状态 字典数据
|
|
|
+ List<DictDataDO> rigStatusDictData = dictDataService.getDictDataListByDictType("rigStatus");
|
|
|
+ // 修井 施工状态 字典数据
|
|
|
+ List<DictDataDO> repairStatusDictData = dictDataService.getDictDataListByDictType("repairStatus");
|
|
|
+ // 非生产时间原因 字典数据
|
|
|
+ List<DictDataDO> nptReasonDictData = dictDataService.getDictDataListByDictType("ryNptReason");
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(nptReasonDictData)) {
|
|
|
+ nptReasonDictData.forEach(data -> {
|
|
|
+ nptReasonPair.put(data.getValue(), data.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 钻井施工状态
|
|
|
+ if ("1".equals(pageReqVO.getProjectClassification()) && CollUtil.isNotEmpty(rigStatusDictData)) {
|
|
|
+ rigStatusDictData.forEach(data -> {
|
|
|
+ constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 修井施工状态
|
|
|
+ if ("2".equals(pageReqVO.getProjectClassification()) && CollUtil.isNotEmpty(repairStatusDictData)) {
|
|
|
+ repairStatusDictData.forEach(data -> {
|
|
|
+ constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
|
// 查询日报关联的项目信息
|
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
|
@@ -416,6 +452,14 @@ public class IotRyDailyReportController {
|
|
|
.divide(BigDecimal.valueOf(1), 2, RoundingMode.HALF_UP);
|
|
|
reportVO.setDailyFuel(fuel);
|
|
|
}
|
|
|
+ // 日报生成日期 格式化时间为 yyyy-MM-dd
|
|
|
+ if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
|
|
|
+ reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
|
|
|
+ }
|
|
|
+ // 上井次完井时间 格式化时间为 yyyy-MM-dd
|
|
|
+ if (ObjUtil.isNotEmpty(reportVO.getLatestWellDoneTime())) {
|
|
|
+ reportVO.setLatestWellDoneTimeStr(LocalDateTimeUtil.format(reportVO.getLatestWellDoneTime(), DatePattern.NORM_DATE_PATTERN));
|
|
|
+ }
|
|
|
// 2.1 拼接部门信息
|
|
|
findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
|
// 2.2 日报关联的项目信息
|
|
|
@@ -443,6 +487,20 @@ public class IotRyDailyReportController {
|
|
|
// 2.8 总施工井数 完工井数
|
|
|
findAndThen(totalTasksPair, reportVO.getDeptId(), totalTaskCount -> reportVO.setTotalConstructionWells(totalTaskCount));
|
|
|
findAndThen(completedTasksPair, reportVO.getDeptId(), completedTaskCount -> reportVO.setCompletedWells(completedTaskCount));
|
|
|
+ // 钻井 施工状态 数据字典
|
|
|
+ findAndThen(constructStatusPair, reportVO.getRigStatus(), statusLabel -> {
|
|
|
+ if ("1".equals(pageReqVO.getProjectClassification())) {
|
|
|
+ reportVO.setConstructionStatusName(statusLabel);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 修井 施工状态 数据字典
|
|
|
+ findAndThen(constructStatusPair, reportVO.getRepairStatus(), statusLabel -> {
|
|
|
+ if ("2".equals(pageReqVO.getProjectClassification())) {
|
|
|
+ reportVO.setConstructionStatusName(statusLabel);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 非生产时间原因 数据字典
|
|
|
+ findAndThen(nptReasonPair, reportVO.getRyNptReason(), statusLabel -> reportVO.setRyNptReason(statusLabel));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -1354,16 +1412,41 @@ public class IotRyDailyReportController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
|
- @Operation(summary = "导出瑞鹰日报 Excel")
|
|
|
+ @Operation(summary = "导出瑞鹰 钻井 修井 日报 Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:export')")
|
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
|
public void exportIotRyDailyReportExcel(@Valid IotRyDailyReportPageReqVO pageReqVO,
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
|
|
|
+ Set<Long> projectIds = new HashSet<>();
|
|
|
+ Set<Long> taskIds = new HashSet<>();
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getContractName())) {
|
|
|
+ IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
|
+ reqVO.setContractName(pageReqVO.getContractName());
|
|
|
+ List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(projects)) {
|
|
|
+ projects.forEach(project -> {
|
|
|
+ projectIds.add(project.getId());
|
|
|
+ });
|
|
|
+ pageReqVO.setProjectIds(projectIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getTaskName())) {
|
|
|
+ IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
|
|
|
+ reqVO.setSearchKey(pageReqVO.getTaskName());
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
+ tasks.forEach(task -> {
|
|
|
+ taskIds.add(task.getId());
|
|
|
+ });
|
|
|
+ pageReqVO.setTaskIds(taskIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<IotRyDailyReportDO> list = iotRyDailyReportService.getIotRyDailyReportPage(pageReqVO).getList();
|
|
|
// 导出 Excel
|
|
|
ExcelUtils.write(response, "瑞鹰日报.xls", "数据", IotRyDailyReportRespVO.class,
|
|
|
- BeanUtils.toBean(list, IotRyDailyReportRespVO.class));
|
|
|
+ buildRyDailyReports(list, pageReqVO, "export"));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/exportStatistics")
|