Przeglądaj źródła

pms 瑞恒日报 列表 添加 年累计 井累计

zhangcl 1 tydzień temu
rodzic
commit
ef8773b554

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

@@ -25,6 +25,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskD
 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.dataobject.iotrhdailyreport.IotRhDailyReportDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
 import cn.iocoder.yudao.module.pms.service.iotdailyreportfuel.IotDailyReportFuelService;
 import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
 import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
@@ -49,6 +50,7 @@ import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -79,6 +81,8 @@ public class IotRhDailyReportController {
     private IotDailyReportFuelService iotDailyReportFuelService;
     @Resource
     private DictDataService dictDataService;
+    @Resource
+    private IotRhDailyReportMapper iotRhDailyReportMapper;
 
     @PostMapping("/create")
     @Operation(summary = "创建瑞恒日报")
@@ -179,7 +183,7 @@ public class IotRhDailyReportController {
             }
         }
         PageResult<IotRhDailyReportDO> pageResult = iotRhDailyReportService.getIotRhDailyReportPage(pageReqVO);
-        return success(new PageResult<>(buildRhDailyReports(pageResult.getList()), pageResult.getTotal()));
+        return success(new PageResult<>(buildRhDailyReports(pageResult.getList(), pageReqVO), pageResult.getTotal()));
     }
 
     @GetMapping("/completeRate")
@@ -448,7 +452,7 @@ public class IotRhDailyReportController {
         PageResult<IotRhDailyReportDO> pageResult = iotRhDailyReportService.dailyReportSummary(pageReqVO);
 
         // List<IotRhDailyReportRespVO> rhDailyReports = IotRhDailyReportConvert.INSTANCE.convertList(pageResult.getList(), deptMap);
-        return success(new PageResult<>(buildRhDailyReports(pageResult.getList()), pageResult.getTotal()));
+        return success(new PageResult<>(buildRhDailyReports(pageResult.getList(), pageReqVO), pageResult.getTotal()));
         // return success(new PageResult<>(rhDailyReports, pageResult.getTotal()));
     }
 
@@ -466,7 +470,7 @@ public class IotRhDailyReportController {
      * @param reports
      * @return
      */
-    private List<IotRhDailyReportRespVO> buildRhDailyReports(List<IotRhDailyReportDO> reports) {
+    private List<IotRhDailyReportRespVO> buildRhDailyReports(List<IotRhDailyReportDO> reports, IotRhDailyReportPageReqVO pageReqVO) {
         if (CollUtil.isEmpty(reports)) {
             return Collections.emptyList();
         }
@@ -484,6 +488,116 @@ public class IotRhDailyReportController {
         Map<String, String> nptReasonPair = new HashMap<>();
         // 搬迁安装天数
         Map<Long, BigDecimal> relocationDaysPair = new HashMap<>();
+
+        // key队伍id   value 队伍当年累计注气量
+        Map<Long, BigDecimal> yearGasInjectionPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计注水量
+        Map<Long, BigDecimal> yearWaterInjectionPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计用电量
+        Map<Long, BigDecimal> yearPowerPair = new HashMap<>();
+        // key队伍id   value 队伍当年累计油耗
+        Map<Long, BigDecimal> yearFuelPair = new HashMap<>();
+
+        // key任务井id    value 井累计注气量
+        Map<Long, BigDecimal> wellGasInjectionPair = new HashMap<>();
+        // key任务井id    value 井累计注水量
+        Map<Long, BigDecimal> wellWaterInjectionPair = new HashMap<>();
+        // key任务井id    value 井累计用电量
+        Map<Long, BigDecimal> wellPowerPair = new HashMap<>();
+        // key任务井id    value 井累计油耗
+        Map<Long, BigDecimal> wellFuelPair = new HashMap<>();
+
+        // 查询所有井日报数据
+        IotRhDailyReportPageReqVO currentTaskReqVO = new IotRhDailyReportPageReqVO();
+        currentTaskReqVO.setTaskIds(convertList(reports, IotRhDailyReportDO::getTaskId));
+        List<IotRhDailyReportDO> taskDailyReports = iotRhDailyReportMapper.dailyReports(currentTaskReqVO);
+        if (CollUtil.isNotEmpty(taskDailyReports)) {
+            taskDailyReports.forEach(report -> {
+                // 注气量
+                if (wellGasInjectionPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempGasInjection = wellGasInjectionPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempGasInjection.add(report.getDailyGasInjection());
+                    wellGasInjectionPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellGasInjectionPair.put(report.getTaskId(), report.getDailyGasInjection());
+                }
+                // 注水量
+                if (wellWaterInjectionPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempWaterInjection = wellWaterInjectionPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempWaterInjection.add(report.getDailyWaterInjection());
+                    wellWaterInjectionPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellWaterInjectionPair.put(report.getTaskId(), report.getDailyWaterInjection());
+                }
+                // 电量
+                if (wellPowerPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempPower = wellPowerPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                    wellPowerPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellPowerPair.put(report.getTaskId(), report.getDailyPowerUsage());
+                }
+                // 油耗
+                if (wellFuelPair.containsKey(report.getTaskId())) {
+                    BigDecimal tempFuel = wellFuelPair.get(report.getTaskId());
+                    BigDecimal tempResult = tempFuel.add(report.getDailyOilUsage());
+                    wellFuelPair.put(report.getTaskId(), tempResult);
+                } else {
+                    wellFuelPair.put(report.getTaskId(), report.getDailyOilUsage());
+                }
+            });
+        }
+
+        // 根据传递的时间筛选获取要查询的 yyyy
+        if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime())) {
+            // 只有传递了 时间查询条件 才会查询 当年累计的工作量数据
+            LocalDateTime[] createTimeAttr = pageReqVO.getCreateTime();
+            if (createTimeAttr.length > 0) {
+                LocalDateTime startTime = createTimeAttr[0];
+                String year = String.valueOf(startTime.getYear());
+                IotRhDailyReportPageReqVO reqVO = new IotRhDailyReportPageReqVO();
+                reqVO.setYear(year);
+                reqVO.setDeptIds(convertList(reports, IotRhDailyReportDO::getDeptId));
+                List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
+                if (CollUtil.isNotEmpty(dailyReports)) {
+                    dailyReports.forEach(report -> {
+                        // 注气量
+                        if (yearGasInjectionPair.containsKey(report.getDeptId())) {
+                            BigDecimal tempGasInjection = yearGasInjectionPair.get(report.getDeptId());
+                            BigDecimal tempResult = tempGasInjection.add(report.getDailyGasInjection());
+                            yearGasInjectionPair.put(report.getDeptId(), tempResult);
+                        } else {
+                            yearGasInjectionPair.put(report.getDeptId(), report.getDailyGasInjection());
+                        }
+                        // 注水量
+                        if (yearWaterInjectionPair.containsKey(report.getDeptId())) {
+                            BigDecimal tempWaterInjection = yearWaterInjectionPair.get(report.getDeptId());
+                            BigDecimal tempResult = tempWaterInjection.add(report.getDailyWaterInjection());
+                            yearWaterInjectionPair.put(report.getDeptId(), tempResult);
+                        } else {
+                            yearWaterInjectionPair.put(report.getDeptId(), report.getDailyWaterInjection());
+                        }
+                        // 电量
+                        if (yearPowerPair.containsKey(report.getDeptId())) {
+                            BigDecimal tempPower = yearPowerPair.get(report.getDeptId());
+                            BigDecimal tempResult = tempPower.add(report.getDailyPowerUsage());
+                            yearPowerPair.put(report.getDeptId(), tempResult);
+                        } else {
+                            yearPowerPair.put(report.getDeptId(), report.getDailyPowerUsage());
+                        }
+                        // 油耗
+                        if (yearFuelPair.containsKey(report.getDeptId())) {
+                            BigDecimal tempFuel = yearFuelPair.get(report.getDeptId());
+                            BigDecimal tempResult = tempFuel.add(report.getDailyOilUsage());
+                            yearFuelPair.put(report.getDeptId(), tempResult);
+                        } else {
+                            yearFuelPair.put(report.getDeptId(), report.getDailyOilUsage());
+                        }
+                    });
+                }
+            }
+        }
+
         // key部门id  value产能
         AtomicReference<Map<Long, BigDecimal>> capacityPair = new AtomicReference<>(new HashMap<>());
         // 施工状态 字典数据
@@ -555,6 +669,22 @@ public class IotRhDailyReportController {
             }
             // 2.1 拼接部门信息
             findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
+            // 队伍当年累计注气量
+            findAndThen(yearGasInjectionPair, reportVO.getDeptId(), gasInjection -> reportVO.setYearTotalGasInjection(gasInjection));
+            // 队伍当年累计注水量
+            findAndThen(yearWaterInjectionPair, reportVO.getDeptId(), waterInjection -> reportVO.setYearTotalWaterInjection(waterInjection));
+            // 队伍当年累计用电量
+            findAndThen(yearPowerPair, reportVO.getDeptId(), power -> reportVO.setYearTotalPower(power));
+            // 队伍当年累计油耗
+            findAndThen(yearFuelPair, reportVO.getDeptId(), fuel -> reportVO.setYearTotalFuel(fuel));
+            // 井当年累计注气量
+            findAndThen(wellGasInjectionPair, reportVO.getTaskId(), gasInjection -> reportVO.setWellTotalGasInjection(gasInjection));
+            // 井当年累计注水量
+            findAndThen(wellWaterInjectionPair, reportVO.getTaskId(), waterInjection -> reportVO.setWellTotalWaterInjection(waterInjection));
+            // 井当年累计用电量
+            findAndThen(wellPowerPair, reportVO.getTaskId(), power -> reportVO.setWellTotalPower(power));
+            // 井当年累计油耗
+            findAndThen(wellFuelPair, reportVO.getTaskId(), fuel -> reportVO.setWellTotalFuel(fuel));
             // 2.2 日报关联的项目信息
             findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setContractName(contractName));
             // 2.3 日报关联的任务信息
@@ -607,7 +737,7 @@ public class IotRhDailyReportController {
         List<IotRhDailyReportDO> list = iotRhDailyReportService.getIotRhDailyReportPage(pageReqVO).getList();
         // 导出 Excel
         ExcelUtils.write(response, "瑞恒日报.xls", "数据", IotRhDailyReportRespVO.class,
-                buildRhDailyReports(list));
+                buildRhDailyReports(list, pageReqVO));
     }
 
     @GetMapping("/exportStatistics")

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

@@ -133,4 +133,7 @@ public class IotRhDailyReportPageReqVO extends PageParam {
 
     @Schema(description = "统计标识 注气或注水时间不为0才能算是施工", example = "Y N")
     private String statisticFlag;
+
+    @Schema(description = "年", example = "2025")
+    private String year;
 }

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

@@ -165,4 +165,22 @@ public class IotRhDailyReportRespVO {
      */
     @Schema(description = "日报关联的油耗记录")
     private List<IotDailyReportFuelDO> reportFuels;
+
+    @Schema(description = "队伍当年累计注气量")
+    private BigDecimal yearTotalGasInjection;
+    @Schema(description = "队伍当年累计注水量")
+    private BigDecimal yearTotalWaterInjection;
+    @Schema(description = "队伍当年累计用电量")
+    private BigDecimal yearTotalPower;
+    @Schema(description = "队伍当年累计油耗")
+    private BigDecimal yearTotalFuel;
+
+    @Schema(description = "井累计注气量")
+    private BigDecimal wellTotalGasInjection;
+    @Schema(description = "井累计注水量")
+    private BigDecimal wellTotalWaterInjection;
+    @Schema(description = "井累计用电量")
+    private BigDecimal wellTotalPower;
+    @Schema(description = "井累计油耗")
+    private BigDecimal wellTotalFuel;
 }

+ 5 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrhdailyreport/IotRhDailyReportMapper.java

@@ -26,7 +26,9 @@ import java.util.List;
  */
 @Mapper
 public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO> {
+
     List<YearTotalGas> selectYearTotalGas(IotRhDailyReportPageReqVO reqVO);
+
     /**
      * 查询 瑞恒日报列表
      * @param page
@@ -137,6 +139,9 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
                     .gt(IotRhDailyReportDO::getDailyInjectWaterTime, 0)
             );
         }
+        if (StrUtil.isNotBlank(reqVO.getYear())) {
+            queryWrapper.apply("YEAR(create_time) = {0}", reqVO.getYear());
+        }
         return selectList(queryWrapper);
     }