Quellcode durchsuchen

pms 瑞都日报 汇总

zhangcl vor 5 Tagen
Ursprung
Commit
acb16a9a82

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/IotRdDailyReportController.java

@@ -221,10 +221,10 @@ public class IotRdDailyReportController {
     @Operation(summary = "瑞都日报 统计")
     @PreAuthorize("@ss.hasPermission('pms:iot-rd-daily-report:query')")
     public CommonResult<List<IotRdDailyReportStatisticsRespVO>> statistics(@Valid IotRdDailyReportPageReqVO pageReqVO) {
-        List<IotRdDailyReportStatisticsRespVO> pageResult = iotRdDailyReportService.statistics(pageReqVO);
+        List<IotRdDailyReportStatisticsRespVO> result = iotRdDailyReportService.statistics(pageReqVO);
         // 瑞都日报 按照项目部统计
         List<IotRdDailyReportStatisticsRespVO> projectReports = new ArrayList<>();
-        return success(projectReports);
+        return success(result);
     }
 
     /**

+ 3 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/vo/IotRdDailyReportStatisticsItemVO.java

@@ -5,6 +5,8 @@ import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 @Schema(description = "管理后台 - 瑞都日报 统计 Response VO")
 @Data
 @ExcelIgnoreUnannotated
@@ -16,7 +18,7 @@ public class IotRdDailyReportStatisticsItemVO {
 
     @Schema(description = "工作量", example = "2")
     @ExcelProperty("工作量")
-    private String workload;
+    private BigDecimal workload;
 
     @Schema(description = "单位")
     @ExcelProperty("单位")

+ 295 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrddailyreport/IotRdDailyReportServiceImpl.java

@@ -2,30 +2,43 @@ package cn.iocoder.yudao.module.pms.service.iotrddailyreport;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.iotattachment.vo.IotAttachmentSaveReqVO;
+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.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsItemVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsRespVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotattachment.IotAttachmentDO;
+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.iotattachment.IotAttachmentMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotprojectinfo.IotProjectInfoMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotrddailyreport.IotRdDailyReportMapper;
 import cn.iocoder.yudao.module.pms.enums.AttachmentCategoryEnum;
 import cn.iocoder.yudao.module.pms.enums.AttachmentTypeEnum;
 import cn.iocoder.yudao.module.supplier.enums.common.SupplierAuditStatusEnum;
 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 com.google.common.collect.ImmutableMap;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
 import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_RD_DAILY_REPORT_NOT_EXISTS;
 
 /**
@@ -39,10 +52,15 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
 
     @Resource
     private IotRdDailyReportMapper iotRdDailyReportMapper;
-
+    @Resource
+    private IotProjectInfoMapper iotProjectInfoMapper;
+    @Resource
+    private IotProjectTaskMapper iotProjectTaskMapper;
     @Resource
     private IotAttachmentMapper iotAttachmentMapper;
     @Resource
+    private DictDataService dictDataService;
+    @Resource
     private DeptService deptService;
 
     @Override
@@ -145,14 +163,17 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
 
     @Override
     public List<IotRdDailyReportStatisticsRespVO> statistics(IotRdDailyReportPageReqVO pageReqVO) {
-        // 按照项目部统计日报
-        // 先查询瑞都所有部门 163l
+        List<IotRdDailyReportStatisticsRespVO> result = new ArrayList<>();
+        // 按照项目部统计日报 先查询瑞都所有部门 163l
         Set<Long> rdChildDeptIds = deptService.getChildDeptIdListFromCache(163l);
         List<DeptDO> depts =deptService.getDeptList(rdChildDeptIds);
         // key队伍id      value队伍所属项目部id
         Map<Long, Long> teamProjectPair = new HashMap<>();
         Set<Long> projectDeptIds = new HashSet<>();
+        // key项目部id     value项目部名称
         Map<Long, String> projectDeptPair = new HashMap<>();
+        // key队伍id     value队伍名称
+        Map<Long, String> teamDeptPair = new HashMap<>();
         if (CollUtil.isNotEmpty(depts)) {
             depts.forEach(dept -> {
                 if (dept.getName().contains("项目部")) {
@@ -160,15 +181,284 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                     projectDeptPair.put(dept.getId(), dept.getName());
                 } else {
                     teamProjectPair.put(dept.getId(), dept.getParentId());
+                    teamDeptPair.put(dept.getId(), dept.getName());
                 }
             });
-
         }
         // 查询所有瑞都日报
         IotRdDailyReportPageReqVO reqVO = new IotRdDailyReportPageReqVO();
         List<IotRdDailyReportDO> dailyReports = iotRdDailyReportMapper.dailyReports(reqVO);
+        // key项目id   value项目甲方名称
+        Map<Long, String> projectPair = new HashMap<>();
+        //  key任务id     value任务井号
+        Map<Long, String> taskPair = new HashMap<>();
+        //  施工工艺 key字典键值     value字典标签
+        Map<String, String> techniqueDictPair = new HashMap<>();
+        //  key任务id     value任务工作量
+        Map<Long, BigDecimal> taskWorkloadPair = new HashMap<>();
+        //  key任务id     value任务工艺名称
+        Map<Long, String> taskTechniquePair = new HashMap<>();
+        if (CollUtil.isNotEmpty(dailyReports)) {
+            // 查询施工工艺字典数据
+            List<DictDataDO> rdTechniques = dictDataService.getDictDataListByDictType("rq_iot_project_technology_rd");
+            if (CollUtil.isNotEmpty(rdTechniques)) {
+                rdTechniques.forEach(tech -> {
+                    techniqueDictPair.put(tech.getValue(), tech.getLabel());
+                });
+            }
+
+            // 查询日报关联的项目信息
+            IotProjectInfoPageReqVO projectReqVO = new IotProjectInfoPageReqVO();
+            projectReqVO.setProjectIds(convertList(dailyReports, IotRdDailyReportDO::getProjectId));
+            List<IotProjectInfoDO> projects = iotProjectInfoMapper.selectList(projectReqVO);
+            if (CollUtil.isNotEmpty(projects)) {
+                projects.forEach(project -> {
+                    projectPair.put(project.getId(), project.getManufactureName());
+                });
+            }
+            // 查询日报关联的任务信息
+            IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
+            taskReqVO.setTaskIds(convertList(dailyReports, IotRdDailyReportDO::getTaskId));
+            List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(taskReqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    taskPair.put(task.getId(), task.getWellName());
+                    // 获取所有任务的工作量数据
+                    taskWorkloadPair.put(task.getId(), new BigDecimal(task.getWorkloadDesign()));
+                    if (techniqueDictPair.containsKey(task.getTechnique())) {
+                        String techniqueName = techniqueDictPair.get(task.getTechnique());
+                        taskTechniquePair.put(task.getId(), techniqueName);
+                    }
+                });
+            }
+            // 设置 小队 任务已经完成的工作量集合 (按照不同的单位统计任务的不同工作量)
+            // 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<>();
 
-        return List.of();
+            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.getDeptId())) {
+                                BigDecimal tempBridgePlug = bridgePlugPair.get(report.getDeptId());
+                                bridgePlugPair.put(report.getDeptId(), tempTotalBridgePlug.add(tempBridgePlug));
+                            } else {
+                                bridgePlugPair.put(report.getDeptId(), tempTotalBridgePlug);
+                            }
+                        }
+                        if ("趟数".equals(unit)) {
+                            tempTotalRunCount = tempTotalRunCount.add(actualValue);
+                            if (runCountPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempRunCount = runCountPair.get(report.getDeptId());
+                                runCountPair.put(report.getDeptId(), tempTotalRunCount.add(tempRunCount));
+                            } else {
+                                runCountPair.put(report.getDeptId(), tempTotalRunCount);
+                            }
+                        }
+                        if ("小时".equals(unit)) {
+                            tempTotalHourCount = tempTotalHourCount.add(actualValue);
+                            if (hourCountPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempHourCount = hourCountPair.get(report.getDeptId());
+                                hourCountPair.put(report.getDeptId(), tempTotalHourCount.add(tempHourCount));
+                            } else {
+                                hourCountPair.put(report.getDeptId(), tempTotalHourCount);
+                            }
+                        }
+                        if ("天数".equals(unit)) {
+                            // 将 actualValue 换算成 H
+                            BigDecimal hours = actualValue.multiply(new BigDecimal("24"));
+                            tempTotalHourCount = tempTotalHourCount.add(hours);
+                            if (hourCountPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempHourCount = hourCountPair.get(report.getDeptId());
+                                hourCountPair.put(report.getDeptId(), tempTotalHourCount.add(tempHourCount));
+                            } else {
+                                hourCountPair.put(report.getDeptId(), tempTotalHourCount);
+                            }
+                        }
+                        if ("方".equals(unit)) {
+                            tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
+                            if (waterVolumePair.containsKey(report.getDeptId())) {
+                                BigDecimal tempWaterVolume = waterVolumePair.get(report.getDeptId());
+                                waterVolumePair.put(report.getDeptId(), tempTotalWaterVolume.add(tempWaterVolume));
+                            } else {
+                                waterVolumePair.put(report.getDeptId(), tempTotalWaterVolume);
+                            }
+                        }
+                        if ("井数".equals(unit)) {
+                            tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
+                            if (cumulativeWorkingWellPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get(report.getDeptId());
+                                cumulativeWorkingWellPair.put(report.getDeptId(), tempTotalCumulativeWorkingWell.add(tempWorkingWell));
+                            } else {
+                                cumulativeWorkingWellPair.put(report.getDeptId(), tempTotalCumulativeWorkingWell);
+                            }
+                        }
+                        if ("段数".equals(unit)) {
+                            // 累计施工层
+                            tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
+                            if (cumulativeWorkingLayersPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempWorkingLayer = cumulativeWorkingLayersPair.get(report.getDeptId());
+                                cumulativeWorkingLayersPair.put(report.getDeptId(), tempTotalCumulativeWorkingLayers.add(tempWorkingLayer));
+                            } else {
+                                cumulativeWorkingLayersPair.put(report.getDeptId(), tempTotalCumulativeWorkingLayers);
+                            }
+                        }
+                        if ("台次".equals(unit) && "当日泵车台次".equals(attr.getName())) {
+                            tempTotalPumpTrips = tempTotalPumpTrips.add(actualValue);
+                            if (pumpTripsPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempPumpTrips = pumpTripsPair.get(report.getDeptId());
+                                pumpTripsPair.put(report.getDeptId(), tempTotalPumpTrips.add(tempPumpTrips));
+                            } else {
+                                pumpTripsPair.put(report.getDeptId(), tempTotalPumpTrips);
+                            }
+                        }
+                        if ("台次".equals(unit) && ("当日仪表".equals(attr.getName()) || "当日混砂".equals(attr.getName()))) {
+                            tempTotalMixSand = tempTotalMixSand.add(actualValue);
+                            if (mixSandPair.containsKey(report.getDeptId())) {
+                                BigDecimal tempMixSand = mixSandPair.get(report.getDeptId());
+                                mixSandPair.put(report.getDeptId(), tempTotalMixSand.add(tempMixSand));
+                            } else {
+                                mixSandPair.put(report.getDeptId(), tempTotalMixSand);
+                            }
+                        }
+                    }
+                }
+            });
+            // 循环遍历所有瑞都日报后 重新组装每个队伍的工作量数据
+            // 将 deptId-projectId-taskId 作为唯一键 生成汇总统计报表
+            Set<String> deptIdTaskIds = new HashSet<>();
+            dailyReports.forEach(report -> {
+                // uniqueKey = deptId-taskId
+                String uniqueKey = StrUtil.join("-", report.getDeptId(), report.getProjectId(), report.getTaskId());
+                deptIdTaskIds.add(uniqueKey);
+            });
+            // deptIdTaskIds 集合中就是要显示的汇总报表数据
+            if (CollUtil.isNotEmpty(deptIdTaskIds)) {
+                deptIdTaskIds.forEach(dt -> {
+                    // 拆分 uniqueKey
+                    String[] deptIdTaskIdArray = dt.split("-");
+                    Long deptId = Long.valueOf(deptIdTaskIdArray[0]);
+                    Long projectId = Long.valueOf(deptIdTaskIdArray[1]);
+                    Long taskId = Long.valueOf(deptIdTaskIdArray[2]);
+                    IotRdDailyReportStatisticsRespVO uniqueReport = new IotRdDailyReportStatisticsRespVO();
+                    List<IotRdDailyReportStatisticsItemVO> items = new ArrayList<>();
+                    if (teamDeptPair.containsKey(deptId)) {
+                        uniqueReport.setDeptName(teamDeptPair.get(deptId));
+                    }
+                    if (teamProjectPair.containsKey(deptId)) {
+                        Long parentId = teamProjectPair.get(deptId);
+                        if (projectDeptPair.containsKey(parentId)) {
+                            uniqueReport.setProjectDeptName(projectDeptPair.get(parentId));
+                        }
+                    }
+                    if (projectPair.containsKey(projectId)) {
+                        uniqueReport.setManufactureName(projectPair.get(projectId));
+                    }
+                    if (taskPair.containsKey(taskId)) {
+                        uniqueReport.setWellName(taskPair.get(taskId));
+                    }
+                    if (taskTechniquePair.containsKey(taskId)) {
+                        uniqueReport.setTechniques(taskTechniquePair.get(taskId));
+                    }
+                    // 总工作量
+                    if (taskWorkloadPair.containsKey(taskId)) {
+                        uniqueReport.setWorkloadDesign(taskWorkloadPair.get(taskId));
+                    }
+                    // 以队伍为维度 设置每种施工工艺的工作量 总和
+                    if (bridgePlugPair.containsKey(deptId)) {
+                        // 钻可溶桥塞  钻复合桥塞
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("个数");
+                        item.setWorkload(bridgePlugPair.get(deptId));
+                        items.add(item);
+                    }
+                    if (runCountPair.containsKey(deptId)) {
+                        // 通刮洗  冲砂
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("趟数");
+                        item.setWorkload(runCountPair.get(deptId));
+                        items.add(item);
+                    }
+                    if (hourCountPair.containsKey(deptId)) {
+                        // 液氮泵车(时间D)  千型泵车(时间H)
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("小时");
+                        item.setWorkload(hourCountPair.get(deptId));
+                        items.add(item);
+                    }
+                    if (waterVolumePair.containsKey(deptId)) {
+                        // 注水
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("方");
+                        item.setWorkload(waterVolumePair.get(deptId));
+                        items.add(item);
+                    }
+                    if (cumulativeWorkingWellPair.containsKey(deptId)) {
+                        // 连续油管常规作业
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("井数");
+                        item.setWorkload(cumulativeWorkingWellPair.get(deptId));
+                        items.add(item);
+                    }
+                    if (cumulativeWorkingLayersPair.containsKey(deptId)) {
+                        // 压裂大包 压裂总包
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("段数");
+                        item.setWorkload(cumulativeWorkingLayersPair.get(deptId));
+                        items.add(item);
+                    }
+                    if (pumpTripsPair.containsKey(deptId)) {
+                        // 主压裂车 当日泵车台次
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("台次");
+                        item.setWorkload(pumpTripsPair.get(deptId));
+                        items.add(item);
+                    }
+                    if (mixSandPair.containsKey(deptId)) {
+                        // 当日仪表/混砂 台次
+                        IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
+                        item.setUnit("台次");
+                        item.setWorkload(mixSandPair.get(deptId));
+                        items.add(item);
+                    }
+                    uniqueReport.setItems(items);
+                    result.add(uniqueReport);
+                });
+            }
+        }
+        return result;
     }
 
 }