Bläddra i källkod

pms 瑞恒日报 汇总统计 2

zhangcl 5 dagar sedan
förälder
incheckning
34dc4bf0ec

+ 2 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -162,7 +162,8 @@ public class IotRhDailyReportController {
                 pageReqVO.setTaskIds(taskIds);
             }
         }
-        PageResult<IotRhDailyReportDO> pageResult = iotRhDailyReportService.getIotRhDailyReportPage(pageReqVO);
+        List<IotRhDailyReportStatisticsRespVO> statistics = iotRhDailyReportService.statistics(pageReqVO);
+        result.addAll(statistics);
         return success(result);
     }
 

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

@@ -36,20 +36,24 @@ public class IotRhDailyReportStatisticsRespVO {
     @ExcelProperty("任务id")
     private Long taskId;
 
+    @Schema(description = "排序", example = "1")
+    @ExcelProperty("排序")
+    private Integer sort;
+
     @Schema(description = "累计注气量(方)")
     @ExcelProperty("累计注气量(方)")
-    private BigDecimal cumulativeGasInjection;
+    private BigDecimal cumulativeGasInjection = BigDecimal.ZERO;
 
     @Schema(description = "累计注气量(方)")
     @ExcelProperty("累计注气量(方)")
-    private BigDecimal cumulativeWaterInjection;
+    private BigDecimal cumulativeWaterInjection = BigDecimal.ZERO;
 
     @Schema(description = "累计用电量(kWh)")
     @ExcelProperty("累计用电量(kWh)")
-    private BigDecimal cumulativePowerConsumption;
+    private BigDecimal cumulativePowerConsumption = BigDecimal.ZERO;
 
     @Schema(description = "累计油耗(吨)")
     @ExcelProperty("累计油耗(吨)")
-    private BigDecimal cumulativeFuelConsumption;
+    private BigDecimal cumulativeFuelConsumption = BigDecimal.ZERO;
 
 }

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

@@ -396,10 +396,13 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                 pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
         List<IotRhDailyReportDO> dailyReports = page.getRecords();
 
+        // key队伍id/项目部id   value累计注气量
         Map<Long, BigDecimal> cumulativeGasInjectionPair = new HashMap<>();
+        // key队伍id/项目部id   value累计注水量
         Map<Long, BigDecimal> cumulativeWaterInjectionPair = new HashMap<>();
+        // key队伍id/项目部id   value累计用电
         Map<Long, BigDecimal> cumulativePowerConsumptionPair = new HashMap<>();
-        // key项目部id   value累计油耗
+        // key队伍id/项目部id   value累计油耗
         Map<Long, BigDecimal> cumulativeFuelConsumptionPair = new HashMap<>();
         // 默认显示所有项目部的汇总数据(新疆分公司也展示 下属各项目部的数据)
         // 点击项目部 显示 下属队伍的数据
@@ -407,7 +410,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
             Set<Long> projectDeptIds = new HashSet<>();
             // key项目部id    value项目部名称
-            Map<Long, String> projectDeptPair = new HashMap<>();
+            Map<Long, DeptDO> projectDeptPair = new HashMap<>();
             // key部门id   value部门parentId
             Map<Long, Long> teamProjectIdPair = new HashMap<>();
 
@@ -421,7 +424,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             depts.forEach(dept -> {
                 if ("2".equals(dept.getType())) {
                     projectDeptIds.add(dept.getId());
-                    projectDeptPair.put(dept.getId(), dept.getName());
+                    projectDeptPair.put(dept.getId(), dept);
                 }
                 teamProjectIdPair.put(dept.getId(), dept.getParentId());
             });
@@ -429,10 +432,50 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                 dailyReports.forEach(report -> {
                     if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
                         Long projectDeptId = teamProjectIdPair.get(report.getDeptId());
-
+                        if (ObjUtil.isNotEmpty(projectDeptId) && projectDeptPair.containsKey(projectDeptId)) {
+                            DeptDO tempDept = projectDeptPair.get(projectDeptId);
+                            // 累计注气量
+                            if (cumulativeGasInjectionPair.containsKey(projectDeptId)) {
+                                BigDecimal tempGasInjection = cumulativeGasInjectionPair.get(projectDeptId);
+                                cumulativeGasInjectionPair.put(projectDeptId, report.getDailyGasInjection().add(tempGasInjection));
+                            } else {
+                                cumulativeGasInjectionPair.put(projectDeptId, report.getDailyGasInjection());
+                            }
+                            // 累计注水量
+                            if (cumulativeWaterInjectionPair.containsKey(projectDeptId)) {
+                                BigDecimal tempWaterInjection = cumulativeWaterInjectionPair.get(projectDeptId);
+                                cumulativeWaterInjectionPair.put(projectDeptId, report.getDailyWaterInjection().add(tempWaterInjection));
+                            } else {
+                                cumulativeWaterInjectionPair.put(projectDeptId, report.getDailyWaterInjection());
+                            }
+                            // 累计用电量
+                            if (cumulativePowerConsumptionPair.containsKey(projectDeptId)) {
+                                BigDecimal tempPower = cumulativePowerConsumptionPair.get(projectDeptId);
+                                cumulativePowerConsumptionPair.put(projectDeptId, report.getDailyPowerUsage().add(tempPower));
+                            } else {
+                                cumulativePowerConsumptionPair.put(projectDeptId, report.getDailyPowerUsage());
+                            }
+                        }
                     }
                 });
             }
+            // 生成返回的数据列表集合
+            projectDeptPair.forEach((deptId, dept) -> {
+                IotRhDailyReportStatisticsRespVO statistics = new IotRhDailyReportStatisticsRespVO();
+                statistics.setProjectDeptId(deptId);
+                statistics.setProjectDeptName(dept.getName());
+                statistics.setSort(dept.getSort());
+                if (cumulativeGasInjectionPair.containsKey(deptId)) {
+                    statistics.setCumulativeGasInjection(cumulativeGasInjectionPair.get(deptId));
+                }
+                if (cumulativeWaterInjectionPair.containsKey(deptId)) {
+                    statistics.setCumulativeWaterInjection(cumulativeWaterInjectionPair.get(deptId));
+                }
+                if (cumulativePowerConsumptionPair.containsKey(deptId)) {
+                    statistics.setCumulativePowerConsumption(cumulativePowerConsumptionPair.get(deptId));
+                }
+                result.add(statistics);
+            });
         } else {
             // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
             DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
@@ -451,6 +494,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
 
             }
         }
+        // 根据result集合内对象的 sort 属性正序排列 sort 类型为 integer 类型
 
         return result;
     }