Jelajahi Sumber

pms 瑞恒日报汇总 添加 队伍数 施工 准备 驻地待命 数量

zhangcl 1 Minggu lalu
induk
melakukan
e5611033ff

+ 8 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportStatisticsRespVO.java

@@ -61,4 +61,12 @@ public class IotRhDailyReportStatisticsRespVO {
     @ExcelProperty("运行时效")
     private String transitTimePercent;
 
+    @Schema(description = "队伍数量")
+    private Integer teamCount = 0;
+    @Schema(description = "施工 队伍数量")
+    private Integer sgTeamCount = 0;
+    @Schema(description = "施工准备 队伍数量")
+    private Integer zbTeamCount = 0;
+    @Schema(description = "驻地待命 队伍数量")
+    private Integer zddmTeamCount = 0;
 }

+ 19 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -1552,23 +1552,34 @@ public class IotStaticController {
                 }
             });
         }
-        // 查询出指定时间区间内 已经填写的日报数量
-        reqVO.setStatisticFlag("Y");
+        // 查询出指定时间区间内 已经填写的日报数量 存在注气时间是0 但是 注气量 不为0的情况
+        // reqVO.setStatisticFlag("Y");
         List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
         // key项目部id     value项目部包含的队伍指定时间区域内日报数量
         Map<Long, Integer> projectReportPair = new HashMap<>();
+        // key项目部id     value项目部注气量
+        Map<Long, BigDecimal> projectGasInjectionPair = new HashMap<>();
         if (CollUtil.isNotEmpty(dailyReports)) {
             // 整理出每个项目部下的队伍填报的日报数量
             dailyReports.forEach(report -> {
                 if (CollUtil.isNotEmpty(projectTeamPair)) {
                     projectTeamPair.forEach((projectDeptId, teamDeptIds) -> {
                         if (teamDeptIds.contains(report.getDeptId())) {
+                            // 项目部日报数量
                             if (projectReportPair.containsKey(projectDeptId)) {
                                 Integer tempCount = projectReportPair.get(projectDeptId);
                                 projectReportPair.put(projectDeptId, ++tempCount);
                             } else {
                                 projectReportPair.put(projectDeptId, 1);
                             }
+                            // 项目部 注气量
+                            if (projectGasInjectionPair.containsKey(projectDeptId)) {
+                                BigDecimal tempGasInjection = projectGasInjectionPair.get(projectDeptId);
+                                BigDecimal subtotal = tempGasInjection.add(report.getDailyGasInjection());
+                                projectGasInjectionPair.put(projectDeptId, subtotal);
+                            } else {
+                                projectGasInjectionPair.put(projectDeptId, report.getDailyGasInjection());
+                            }
                         }
                     });
                 }
@@ -1606,6 +1617,11 @@ public class IotStaticController {
                             DeptDO dept = allDeptPair.get(projectDeptId);
                             rateVo.setSort(dept.getSort());
                         }
+                        // 设置每个项目部的注气量
+                        if (projectGasInjectionPair.containsKey(projectDeptId)) {
+                            BigDecimal gasInjection = projectGasInjectionPair.get(projectDeptId);
+                            rateVo.setGasInjection(gasInjection);
+                        }
                         // 遍历每个项目部 获取每个项目部下队伍数量
                         Integer currentTeamNum = teamIds.size();
                         rateVo.setTeamCount(currentTeamNum);
@@ -1741,7 +1757,7 @@ public class IotStaticController {
         if (CollUtil.isNotEmpty(projectTeamIds)) {
             // 查询出指定时间区间内 指定队伍id集合 已经填写的日报数量
             reqVO.setDeptIds(projectTeamIds);
-            reqVO.setStatisticFlag("Y");
+            // reqVO.setStatisticFlag("Y");
             List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
             // 筛选出每个队伍的日报
             if (CollUtil.isNotEmpty(dailyReports)) {

+ 7 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/vo/ProjectUtilizationRateVo.java

@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.pms.controller.admin.stat.vo;
 import lombok.Data;
 import lombok.ToString;
 
+import java.math.BigDecimal;
+
 /**
  * 项目部维度 设备利用率
  */
@@ -35,6 +37,11 @@ public class ProjectUtilizationRateVo {
      */
     private Double utilizationRate;
 
+    /**
+     * 注气量
+     */
+    private BigDecimal gasInjection;
+
     /**
      * 排序规则
      */

+ 98 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -745,13 +745,13 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // 点击项目部 显示 下属队伍的数据
         // 首先判断点击的部门是属于 公司 还是 队伍 如果没有点击任何部门 默认查询所有项目部数据
         if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
-            result = statisticsByProjectDept(dailyReports, 157L);
+            result = statisticsByProjectDept(dailyReports, 157L, pageReqVO);
         } else {
             // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
             DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
             if ("1".equals(selectedDept.getType())) {
                 // 以项目部为维度汇总数据
-                result = statisticsByProjectDept(dailyReports, pageReqVO.getDeptId());
+                result = statisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO);
             } else if ("2".equals(selectedDept.getType())) {
                 // 以队伍为维度汇总数据
                 result = statisticsByProjectDepartment(dailyReports, pageReqVO.getDeptId());
@@ -761,7 +761,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             } else {
                 // 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
                 // 以项目部为维度汇总数据
-                result = statisticsByProjectDept(dailyReports, pageReqVO.getDeptId());
+                result = statisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO);
             }
         }
         // 根据result集合内对象的 sort 属性正序排列 sort 类型为 integer 类型
@@ -780,7 +780,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
      * @param rootDeptId 根部门ID(如157L为瑞恒根部门,或其他公司级部门ID)
      * @return 项目部维度统计结果列表
      */
-    private List<IotRhDailyReportStatisticsRespVO> statisticsByProjectDept(List<IotRhDailyReportDO> dailyReports, Long rootDeptId) {
+    private List<IotRhDailyReportStatisticsRespVO> statisticsByProjectDept(List<IotRhDailyReportDO> dailyReports,
+                                                                           Long rootDeptId, IotRhDailyReportPageReqVO pageReqVO) {
         List<IotRhDailyReportStatisticsRespVO> result = new ArrayList<>();
 
         Set<Long> projectDeptIds = new HashSet<>();
@@ -801,6 +802,16 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         Map<Long, BigDecimal> cumulativeCapacityPair = new HashMap<>();
         // key队伍id/项目部id   value累计运行时效   累计注气量/累计产能
         Map<Long, BigDecimal> cumulativeTransitTimePair = new HashMap<>();
+        // key项目部id   value项目部下包含的队伍总数
+        Map<Long, Integer> teamCountPair = new HashMap<>();
+        // key项目部id   value项目部下包含的 施工 队伍数量
+        Map<Long, Integer> sgTeamCountPair = new HashMap<>();
+        // key项目部id   value项目部下包含的 施工准备 队伍数量
+        Map<Long, Integer> zbTeamCountPair = new HashMap<>();
+        // key项目部id   value项目部下包含的 驻地待命 队伍数量
+        Map<Long, Integer> zddmTeamCountPair = new HashMap<>();
+        // 队伍id 集合
+        Set<Long> teamIds = new HashSet<>();
 
         // 以项目部为维度统计数据
         // 找到所有项目部与队伍的对应关系
@@ -813,12 +824,79 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // 构建项目部映射和父子部门关系
         depts.forEach(dept -> {
             if ("2".equals(dept.getType())) {
+                // 项目部
                 projectDeptIds.add(dept.getId());
                 projectDeptPair.put(dept.getId(), dept);
             }
+            if ("3".equals(dept.getType())) {
+                // 队伍
+                teamIds.add(dept.getId());
+            }
             teamProjectIdPair.put(dept.getId(), dept.getParentId());
         });
 
+        LocalDateTime[] createTime = pageReqVO.getCreateTime();
+        // 如果 createTime 包含的时间是 1天则查询 这1天时间内的 队伍总数 施工队伍数量 施工准备队伍数量 驻地待命队伍数量
+        if (ObjUtil.isNotEmpty(createTime)) {
+            LocalDateTime startTime = createTime[0];
+            LocalDateTime endTime = createTime[1];
+            if (ObjUtil.isNotEmpty(startTime) && ObjUtil.isNotEmpty(endTime)) {
+                LocalDate startLocalDate = startTime.toLocalDate();
+                LocalDate endLocalDate = endTime.toLocalDate();
+                if (startLocalDate.isEqual(endLocalDate)) {
+                    // 查询日期区间是 同一天
+                    // 设置每个项目部下的队伍数量
+                    projectDeptPair.forEach((projectDeptId, projectDept) -> {
+                        // 找到每个项目部下的队伍
+                        teamProjectIdPair.forEach((deptId, parentDeptId) -> {
+                            if (parentDeptId.equals(projectDeptId)) {
+                                if (teamCountPair.containsKey(projectDeptId)) {
+                                    Integer tempCount = teamCountPair.get(projectDeptId);
+                                    teamCountPair.put(projectDeptId, ++tempCount);
+                                } else {
+                                    teamCountPair.put(projectDeptId, 1);
+                                }
+                            }
+                        });
+                    });
+                    // 找出日报列表中 状态为 施工 施工准备 驻地待命的 记录
+                    if (CollUtil.isNotEmpty(dailyReports)) {
+                        dailyReports.forEach(report -> {
+                            if (teamProjectIdPair.containsKey(report.getDeptId())) {
+                                // 找到队伍所属的上级项目部
+                                Long projectDeptId = teamProjectIdPair.get(report.getDeptId());
+                                // 施工状态
+                                if ("sg".equals(report.getConstructionStatus())) {
+                                    if (sgTeamCountPair.containsKey(projectDeptId)) {
+                                        Integer tempCount = sgTeamCountPair.get(projectDeptId);
+                                        sgTeamCountPair.put(projectDeptId, ++tempCount);
+                                    } else {
+                                        sgTeamCountPair.put(projectDeptId, 1);
+                                    }
+                                }
+                                if ("zb".equals(report.getConstructionStatus())) {
+                                    if (zbTeamCountPair.containsKey(projectDeptId)) {
+                                        Integer tempCount = zbTeamCountPair.get(projectDeptId);
+                                        zbTeamCountPair.put(projectDeptId, ++tempCount);
+                                    } else {
+                                        zbTeamCountPair.put(projectDeptId, 1);
+                                    }
+                                }
+                                if ("zddm".equals(report.getConstructionStatus())) {
+                                    if (zddmTeamCountPair.containsKey(projectDeptId)) {
+                                        Integer tempCount = zddmTeamCountPair.get(projectDeptId);
+                                        zddmTeamCountPair.put(projectDeptId, ++tempCount);
+                                    } else {
+                                        zddmTeamCountPair.put(projectDeptId, 1);
+                                    }
+                                }
+                            }
+                        });
+                    }
+                }
+            }
+        }
+
         // 查询指定部门下相关设备的产能
         // key队伍id   value队伍下相关设备产能
         Map<Long, BigDecimal> teamCapacityPair = queryCapacities(new ArrayList<>(allRhChildDeptIds));
@@ -873,6 +951,22 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             statistics.setCumulativePowerConsumption(cumulativePowerConsumptionPair.get(deptId));
             statistics.setCumulativeFuelConsumption(cumulativeOilConsumptionPair.get(deptId));
             statistics.setTransitTime(cumulativeTransitTimePair.get(deptId));
+            // 队伍数量
+            if (CollUtil.isNotEmpty(teamCountPair)) {
+                statistics.setTeamCount(teamCountPair.get(deptId));
+            }
+            // 施工队伍 数量
+            if (CollUtil.isNotEmpty(sgTeamCountPair)) {
+                statistics.setSgTeamCount(sgTeamCountPair.get(deptId));
+            }
+            // 施工准备队伍数量
+            if (CollUtil.isNotEmpty(zbTeamCountPair)) {
+                statistics.setZbTeamCount(zbTeamCountPair.get(deptId));
+            }
+            // 驻地待命 队伍数量
+            if (CollUtil.isNotEmpty(zddmTeamCountPair)) {
+                statistics.setZddmTeamCount(zddmTeamCountPair.get(deptId));
+            }
             result.add(statistics);
         });