فهرست منبع

pms 5#国日报汇总 代码初始化

zhangcl 2 هفته پیش
والد
کامیت
372f8bd2e4

+ 145 - 6
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotfivedailyreport/IotFiveDailyReportController.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@@ -12,14 +13,18 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportStatisticsRespVO;
 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.iotprojecttaskschedule.vo.IotProjectTaskSchedulePageReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
 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.iotprojecttaskschedule.IotProjectTaskScheduleDO;
 import cn.iocoder.yudao.module.pms.service.iotfivedailyreport.IotFiveDailyReportService;
 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.iotprojecttaskschedule.IotProjectTaskScheduleService;
 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;
@@ -35,10 +40,11 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.util.*;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -62,6 +68,9 @@ public class IotFiveDailyReportController {
     private IotProjectTaskService iotProjectTaskService;
     @Resource
     private DictDataService dictDataService;
+    @Resource
+    private IotProjectTaskScheduleService iotProjectTaskScheduleService;
+
 
     @PostMapping("/create")
     @Operation(summary = "创建5#国日报")
@@ -93,7 +102,90 @@ public class IotFiveDailyReportController {
     @PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:query')")
     public CommonResult<IotFiveDailyReportRespVO> getIotFiveDailyReport(@RequestParam("id") Long id) {
         IotFiveDailyReportDO iotFiveDailyReport = iotFiveDailyReportService.getIotFiveDailyReport(id);
-        return success(BeanUtils.toBean(iotFiveDailyReport, IotFiveDailyReportRespVO.class));
+        return success(buildDailyReport(iotFiveDailyReport));
+    }
+
+    /**
+     * 查询日报对应的项目 任务信息
+     * @param dailyReport
+     * @return
+     */
+    private IotFiveDailyReportRespVO buildDailyReport(IotFiveDailyReportDO dailyReport) {
+        // 如果 dailyReport 为空 返回空对象 有可能任务中安排的人员部门 与日报所在部门不同
+        if (ObjUtil.isEmpty(dailyReport)) {
+            return new IotFiveDailyReportRespVO();
+        }
+        IotFiveDailyReportRespVO dailyReportVO = BeanUtils.toBean(dailyReport, IotFiveDailyReportRespVO.class);
+
+        LocalDateTime reportTime = dailyReportVO.getCreateTime();
+        // 当月计划工作量,默认0
+        BigDecimal monthPlanLayers = BigDecimal.ZERO;
+
+        // 设置 日报 的项目 任务 等信息
+        // key施工状态数据字典value   value施工状态数据字典label
+        Map<String, String> constructStatusPair = new HashMap<>();
+        // 施工状态 字典数据
+        List<DictDataDO> rdStatusData = dictDataService.getDictDataListByDictType("rdStatus");
+        if (CollUtil.isNotEmpty(rdStatusData)) {
+            rdStatusData.forEach(data -> {
+                constructStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+        if (CollUtil.isNotEmpty(constructStatusPair)) {
+            String statusLabel = constructStatusPair.get(dailyReportVO.getFiveStatus());
+            dailyReportVO.setFiveStatusLabel(statusLabel);
+        }
+        // 当前日报的设备利用率 作业泵车数量 / 主设备泵车数量
+        BigDecimal mainDeviceNum = dailyReportVO.getMainDeviceNum();
+        BigDecimal wokDeviceNum = dailyReportVO.getWokDeviceNum();
+        if (mainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
+            BigDecimal utilizationRate = wokDeviceNum.divide(mainDeviceNum, 4, RoundingMode.HALF_UP );
+            dailyReportVO.setUtilizationRate(utilizationRate);
+        }
+        // 当前日报的 施工队伍
+        if (ObjUtil.isNotEmpty(dailyReportVO.getDeptId())) {
+            DeptDO dept = deptService.getDept(dailyReportVO.getDeptId());
+            if (ObjUtil.isNotEmpty(dept)) {
+                dailyReportVO.setDeptName(dept.getName());
+            }
+        }
+        // 当前日报的 项目信息
+        if (ObjUtil.isNotEmpty(dailyReportVO.getProjectId())) {
+            IotProjectInfoDO projectInfo = iotProjectInfoService.getIotProjectInfo(dailyReportVO.getProjectId());
+            if (ObjUtil.isNotEmpty(projectInfo)) {
+                dailyReportVO.setProjectName(projectInfo.getContractName());
+                dailyReportVO.setCustomer(projectInfo.getManufactureName());
+            }
+        }
+        // 查询当前日报关联的 任务信息
+        if (ObjUtil.isNotEmpty(dailyReportVO.getTaskId())) {
+            IotProjectTaskDO projectTask = iotProjectTaskService.getIotProjectTask(dailyReportVO.getTaskId());
+            if (ObjUtil.isNotEmpty(projectTask)) {
+                dailyReportVO.setLocation(projectTask.getLocation());
+                dailyReportVO.setWellName(projectTask.getWellName());
+            }
+            // 查询当前日报施工队伍部门对应的 任务计划信息
+            IotProjectTaskSchedulePageReqVO pageReqVO = new IotProjectTaskSchedulePageReqVO();
+            pageReqVO.setTaskId(dailyReportVO.getTaskId());
+            List<IotProjectTaskScheduleDO> taskSchedules = iotProjectTaskScheduleService.getIotProjectTaskSchedules(pageReqVO);
+            if (CollUtil.isNotEmpty(taskSchedules) && ObjUtil.isNotEmpty(reportTime)) {
+                // 获取日报所属年月
+                YearMonth reportYearMonth = YearMonth.from(reportTime);
+                // Stream过滤:计划开始时间年月 和 日报年月一致,累加planLayers
+                monthPlanLayers = taskSchedules.stream()
+                        // 过滤计划开始时间不为空,且年月匹配
+                        .filter(schedule -> ObjUtil.isNotEmpty(schedule.getStartTime()))
+                        .filter(schedule -> YearMonth.from(schedule.getStartTime()).equals(reportYearMonth))
+                        // 提取计划层数,空值替换0
+                        .map(schedule -> ObjUtil.defaultIfNull(schedule.getPlanLayers(), BigDecimal.ZERO))
+                        // 累加求和
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+            }
+        }
+        // 赋值当月计划压裂层数
+        dailyReportVO.setPlanWorkingLayers(monthPlanLayers);
+
+        return dailyReportVO;
     }
 
     @GetMapping("/page")
@@ -123,6 +215,8 @@ public class IotFiveDailyReportController {
         Map<Long, String> taskLocationPair = new HashMap<>();
         // key施工状态数据字典value   value施工状态数据字典label
         Map<String, String> constructStatusPair = new HashMap<>();
+        //  key日报id     value日报设备利用率
+        Map<Long, BigDecimal> reportRatePair = new HashMap<>();
         // 设备部门信息
         Map<Long, DeptDO> tempDeptMap = deptService.getDeptMap(convertList(reports, IotFiveDailyReportDO::getDeptId));
         // 施工状态 字典数据
@@ -132,6 +226,16 @@ public class IotFiveDailyReportController {
                 constructStatusPair.put(data.getValue(), data.getLabel());
             });
         }
+        // 计算每个日报的 设备利用率
+        reports.forEach(report -> {
+            // 设备利用率 作业泵车数量 / 主设备泵车数量
+            BigDecimal mainDeviceNum = report.getMainDeviceNum();
+            BigDecimal wokDeviceNum = report.getWokDeviceNum();
+            if (mainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal utilizationRate = wokDeviceNum.divide(mainDeviceNum, 4, RoundingMode.HALF_UP );
+                reportRatePair.put(report.getId(), utilizationRate);
+            }
+        });
         DataPermissionUtils.executeIgnore(() -> {
             // 查询日报关联的项目信息
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
@@ -161,7 +265,9 @@ public class IotFiveDailyReportController {
                     reportVO.setFiveStatusLabel(constructStatusPair.get(reportVO.getFiveStatus()));
                 }
             }
-            // 临时新建的日报的 施工队伍
+            // 日报的 设备利用率
+            findAndThen(reportRatePair, reportVO.getId(), utilizationRate -> reportVO.setUtilizationRate(utilizationRate));
+            // 日报的 施工队伍
             findAndThen(tempDeptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
             // 日报关联的项目信息
             findAndThen(projectPair, reportVO.getProjectId(), contractName -> reportVO.setProjectName(contractName));
@@ -174,6 +280,39 @@ public class IotFiveDailyReportController {
         });
     }
 
+    @GetMapping("/totalWorkload")
+    @Operation(summary = "5#国日报 汇总 统计 卡片")
+    @PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:query')")
+    public CommonResult<IotFiveDailyReportStatisticsRespVO> totalWorkload(@Valid IotFiveDailyReportPageReqVO pageReqVO) {
+        // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
+        Set<Long> projectIds = new HashSet<>();
+        Set<Long> taskIds = new HashSet<>();
+        if (StrUtil.isNotBlank(pageReqVO.getProjectName())) {
+            IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
+            reqVO.setContractName(pageReqVO.getProjectName());
+            List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
+            if (CollUtil.isNotEmpty(projects)) {
+                projects.forEach(project -> {
+                    projectIds.add(project.getId());
+                });
+                pageReqVO.setProjectIds(projectIds);
+            }
+        }
+        if (StrUtil.isNotBlank(pageReqVO.getWellName())) {
+            IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
+            reqVO.setSearchKey(pageReqVO.getWellName());
+            List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(reqVO);
+            if (CollUtil.isNotEmpty(tasks)) {
+                tasks.forEach(task -> {
+                    taskIds.add(task.getId());
+                });
+                pageReqVO.setTaskIds(taskIds);
+            }
+        }
+        IotFiveDailyReportStatisticsRespVO statistics = iotFiveDailyReportService.totalWorkload(pageReqVO);
+        return success(statistics);
+    }
+
     @GetMapping("/export-excel")
     @Operation(summary = "导出5#国日报 Excel")
     @PreAuthorize("@ss.hasPermission('pms:iot-five-daily-report:export')")

+ 9 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotfivedailyreport/vo/IotFiveDailyReportPageReqVO.java

@@ -218,4 +218,13 @@ public class IotFiveDailyReportPageReqVO extends PageParam {
     @Schema(description = "部门id集合", example = "[123,223]")
     private Collection<Long> deptIds;
 
+    /**
+     * 扩展字段
+     *
+     */
+    @Schema(description = "项目id集合", example = "测试")
+    private Collection<Long> projectIds;
+
+    @Schema(description = "任务id集合", example = "测试")
+    private Collection<Long> taskIds;
 }

+ 4 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotfivedailyreport/vo/IotFiveDailyReportRespVO.java

@@ -273,6 +273,10 @@ public class IotFiveDailyReportRespVO {
     @ExcelProperty("当月完成主压层数(层)")
     private BigDecimal monthWorkingLayers;
 
+    @Schema(description = "当月 作业井数(井)")
+    @ExcelProperty("当月 作业井数(井)")
+    private BigDecimal monthWorkingWells;
+
     @Schema(description = "当年 累计加砂量(吨)")
     @ExcelProperty("累计加砂量(吨)")
     private BigDecimal totalSandVolume;

+ 141 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotfivedailyreport/vo/IotFiveDailyReportStatisticsRespVO.java

@@ -0,0 +1,141 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo;
+
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsItemVO;
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Schema(description = "管理后台 - 5#国日报 统计 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotFiveDailyReportStatisticsRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13853")
+    private Long id;
+
+    @Schema(description = "项目部id", example = "125")
+    private Long deptId;
+
+    @Schema(description = "项目部id", example = "125")
+    private Long projectDeptId;
+
+    @Schema(description = "项目部名称", example = "西南压裂项目部")
+    @ExcelProperty("项目部名称")
+    private String projectDeptName;
+
+    @Schema(description = "队伍名称", example = "压裂二队")
+    @ExcelProperty("队伍名称")
+    private String deptName;
+
+    @Schema(description = "队伍id", example = "125")
+    private Long teamId;
+
+    @Schema(description = "队伍名称", example = "HY-A1")
+    @ExcelProperty("队伍名称")
+    private String teamName;
+
+    @Schema(description = "部门类型(公司级1 项目部2 队伍3)", example = "1")
+    private String type;
+
+    @Schema(description = "任务id", example = "15678")
+    private Long taskId;
+
+    @Schema(description = "甲方")
+    @ExcelProperty("甲方")
+    private String manufactureName;
+
+    @Schema(description = "井号")
+    @ExcelProperty("井号")
+    private String wellName;
+
+    @Schema(description = "施工周期 天")
+    @ExcelProperty("施工周期(D)")
+    private String period;
+
+    @Schema(description = "任务开始日期")
+    @ExcelProperty("任务开始日期")
+    private String taskStartDate;
+
+    @Schema(description = "施工状态")
+    private String rdStatus;
+
+    @Schema(description = "施工状态")
+    @ExcelProperty("施工状态")
+    private String rdStatusLabel;
+
+    @Schema(description = "施工工艺 多个逗号分隔")
+    @ExcelProperty("施工工艺")
+    private String techniques;
+
+    @Schema(description = "总工作量")
+    @ExcelProperty("总工作量")
+    private BigDecimal workloadDesign;
+
+    @Schema(description = "已完成工作量")
+    private BigDecimal finishedWorkload;
+
+    @Schema(description = "任务创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "油耗L")
+    @ExcelProperty("油耗L")
+    private BigDecimal totalDailyFuel;
+
+    @Schema(description = "排序", example = "1")
+    private Integer sort;
+
+    @Schema(description = "工作量明细")
+    private List<IotRdDailyReportStatisticsItemVO> items;
+
+    // 汇总统计 工作量
+    @Schema(description = "桥塞(个数)")
+    @ExcelProperty("桥塞(个数)")
+    private BigDecimal cumulativeBridgePlug;
+    @Schema(description = "趟数")
+    @ExcelProperty("趟数")
+    private BigDecimal cumulativeRunCount;
+    @Schema(description = "井数")
+    @ExcelProperty("井数")
+    private BigDecimal cumulativeWorkingWell;
+    @Schema(description = "小时H")
+    @ExcelProperty("小时H")
+    private BigDecimal cumulativeHourCount;
+    @Schema(description = "水方量(方)")
+    @ExcelProperty("水方量(方)")
+    private BigDecimal cumulativeWaterVolume;
+    @Schema(description = "段数  累计施工-层")
+    @ExcelProperty("段数")
+    private BigDecimal cumulativeWorkingLayers;
+    @Schema(description = "台次 当日仪表/混砂")
+    private BigDecimal cumulativeMixSand;
+    @Schema(description = "台次 当日泵车台次")
+    private BigDecimal cumulativePumpTrips;
+
+    @Schema(description = "当日注液")
+    private BigDecimal cumulativeLiquidVolume;
+
+    @Schema(description = "非生产时间")
+    private BigDecimal cumulativeNptTime;
+
+    @Schema(description = "台次 泵车台次 仪表/混砂")
+    @ExcelProperty("台次")
+    private BigDecimal taici;
+
+    @Schema(description = "连油井数")
+    @ExcelProperty("连油井数")
+    private Integer lyWellCount;
+    @Schema(description = "压裂井数")
+    @ExcelProperty("压裂井数")
+    private Integer ylWellCount;
+
+    @Schema(description = "非生产时效")
+    private BigDecimal nonProductionRate;
+
+    @Schema(description = "设备利用率")
+    private BigDecimal utilizationRate;
+}

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

@@ -987,60 +987,59 @@ public class IotStaticController {
         return dateMap;
     }
 
-    public static LinkedHashMap<String, Double> sumTotalByDates(List<Map<String, Object>> records, int days, String key) {
+    /**
+     * 根据外部传入的有序日期轴汇总每日数据,统一转万方保留两位小数
+     * @param records 原始报表数据
+     * @param dateAxis 自定义有序日期列表(昨日起7天)
+     * @param key 汇总字段名
+     * @return 有序日期-汇总值Map,无数据默认0.0
+     */
+    public static LinkedHashMap<String, Double> sumTotalByDates(List<Map<String, Object>> records, List<String> dateAxis, String key) {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        LocalDate today = LocalDate.now();
-
-        // 生成近days天的日期列表,初始值为0
+        List<String> sortedDateAxis = dateAxis.stream()
+                .map(LocalDate::parse)
+                .sorted()
+                .map(d -> d.format(formatter))
+                .collect(Collectors.toList());
+        // 1. 使用外部传入的日期初始化有序Map,默认0
         LinkedHashMap<String, Double> dateMap = new LinkedHashMap<>();
-        for (int i = days - 1; i >= 0; i--) {
-            LocalDate date = today.minusDays(i);
-            dateMap.put(date.format(formatter), 0.0);
-        }
+        sortedDateAxis.forEach(date -> dateMap.put(date, 0.0));
 
-        // 统计每天的total字段之
-        Map<String, Double> sumMap = records.stream()
+        // 2. 按日期分组求和
+        Map<String, Double> dateSum = records.stream()
                 .collect(Collectors.groupingBy(
                         record -> {
                             try {
-                                // 提取日期部分(假设createTime格式为yyyy-MM-dd...)
-                                return String.valueOf(record.get("createTime")).substring(0, 10);
+                                String timeStr = String.valueOf(record.get("createTime"));
+                                return timeStr.substring(0, 10);
                             } catch (Exception e) {
-                                System.err.println("日期格式错误: " + record.get("createTime"));
+                                System.err.println("日期解析异常:" + record.get("createTime"));
                                 return "invalid_date";
                             }
                         },
-                        // 累加每天的total字段值,处理可能的格式问题
                         Collectors.summingDouble(record -> {
                             try {
-                                Object totalObj = record.get(key);
-                                if (totalObj instanceof Number) {
-                                    return ((Number) totalObj).doubleValue();
-                                } else if (totalObj instanceof String) {
-                                    return Double.parseDouble((String) totalObj);
-                                } else {
-                                    return Double.parseDouble(String.valueOf(totalObj));
+                                Object val = record.get(key);
+                                if (val instanceof Number) {
+                                    return ((Number) val).doubleValue();
                                 }
+                                return Double.parseDouble(String.valueOf(val));
                             } catch (Exception e) {
-                                System.err.println("处理total字段出错: " + e.getMessage());
+                                System.err.println("数值转换异常:" + e.getMessage());
                                 return 0.0;
                             }
                         })
                 ));
 
-        // 合并结果,转为“万方”并保留两位小数
-        dateMap.forEach((date, defaultValue) -> {
-            if (sumMap.containsKey(date)) {
-                double totalFang = sumMap.get(date);          // 原始值,单位:方
-                double totalWanFang = totalFang / 10000.0;    // 转换为万方
-                // 四舍五入保留两位小数
-                double rounded = Math.round(totalWanFang * 100.0) / 100.0;
-                dateMap.put(date, rounded);
-            } else {
-                dateMap.put(date, 0.0);
+        // 3. 填充数据,单位转换万方,保留两位小数,使用Java8 replaceAll简化循环
+        dateMap.replaceAll((date, oldVal) -> {
+            if (!dateSum.containsKey(date)) {
+                return 0.0;
             }
+            double cubic = dateSum.get(date);
+            double tenThousandCubic = cubic / 10000.0;
+            return Math.round(tenThousandCubic * 100.0) / 100.0;
         });
-
         return dateMap;
     }
 
@@ -1305,7 +1304,13 @@ public class IotStaticController {
     @PermitAll
     public CommonResult<Map<String, Object>> rhOrderDaily(@PathVariable("dept") String dept) {
         Set<Long> ids = getDeptIds(dept);
-        List<String> lastSevenDays = getLastSevenDays();
+        List<String> originSevenDays = getLastSevenDays();
+        List<String> lastSevenDays = originSevenDays.stream()
+                .map(dateStr -> LocalDate.parse(dateStr))
+                .map(day -> day.minusDays(1))
+                .map(day -> day.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                .collect(Collectors.toList());
+        // List<String> lastSevenDays = getLastSevenDays();
         String first = lastSevenDays.get(0);
         String last = lastSevenDays.get(lastSevenDays.size() - 1);
         LocalDateTime startOfDay = getStartOfDay(last);
@@ -1322,7 +1327,7 @@ public class IotStaticController {
             abc.put("today", e.getDailyGasInjection());
             return abc;
         }).collect(Collectors.toList());
-        LinkedHashMap<String, Double> fillMap = sumTotalByDates(fills, 7,"today");
+        LinkedHashMap<String, Double> fillMap = sumTotalByDates(fills, lastSevenDays,"today");
         LinkedList<Object> xAxis = new LinkedList<>();
         LinkedList<Object> fillData = new LinkedList<>();
         fillMap.forEach( (k,v)->{
@@ -1357,8 +1362,13 @@ public class IotStaticController {
     @GetMapping("/rh/device/sevenDayUtilization")
     @PermitAll
     public CommonResult<Map<String, Object>> sevenDayUtilization() {
-
-        List<String> lastSevenDays = getLastSevenDays();
+        List<String> originSevenDays = getLastSevenDays();
+        List<String> lastSevenDays = originSevenDays.stream()
+                .map(dateStr -> LocalDate.parse(dateStr))
+                .map(day -> day.minusDays(1))
+                .map(day -> day.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                .collect(Collectors.toList());
+        // List<String> lastSevenDays = getLastSevenDays();
         String first = lastSevenDays.get(0);
         String last = lastSevenDays.get(lastSevenDays.size() - 1);
         LocalDateTime startOfDay = getStartOfDay(last);

+ 9 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotfivedailyreport/IotFiveDailyReportService.java

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pms.service.iotfivedailyreport;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportStatisticsRespVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
 
 import javax.validation.Valid;
@@ -59,4 +60,12 @@ public interface IotFiveDailyReportService {
      * @param
      */
     void batchAddDailyReports(List<IotFiveDailyReportDO> reports);
+
+    /**
+     * 5#国 日报 汇总统计 卡片
+     *
+     * @param pageReqVO 列表查询
+     * @return 5#国日报汇总统计
+     */
+    IotFiveDailyReportStatisticsRespVO totalWorkload(IotFiveDailyReportPageReqVO pageReqVO);
 }

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

@@ -1,9 +1,13 @@
 package cn.iocoder.yudao.module.pms.service.iotfivedailyreport;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
 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.iotfivedailyreport.vo.IotFiveDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportStatisticsRespVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotfivedailyreport.IotFiveDailyReportMapper;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
@@ -11,10 +15,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_FIVE_DAILY_REPORT_NOT_EXISTS;
@@ -48,6 +51,8 @@ public class IotFiveDailyReportServiceImpl implements IotFiveDailyReportService
         validateIotFiveDailyReportExists(updateReqVO.getId());
         // 更新
         IotFiveDailyReportDO updateObj = BeanUtils.toBean(updateReqVO, IotFiveDailyReportDO.class);
+        // 填报 保存后 修改日报 状态
+        updateObj.setStatus(1);
         iotFiveDailyReportMapper.updateById(updateObj);
     }
 
@@ -87,4 +92,93 @@ public class IotFiveDailyReportServiceImpl implements IotFiveDailyReportService
         iotFiveDailyReportMapper.insertBatch(reports);
     }
 
+    @Override
+    public IotFiveDailyReportStatisticsRespVO totalWorkload(IotFiveDailyReportPageReqVO pageReqVO) {
+        IotFiveDailyReportStatisticsRespVO result = new IotFiveDailyReportStatisticsRespVO();
+        // 不分页统计所有数据
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            // 找到所有子部门对象集合
+            ids.add(pageReqVO.getDeptId());
+            pageReqVO.setDeptIds(ids);
+        }
+        // 检查contractName不为空但projectIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getProjectName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
+            return result;
+        }
+        // 检查taskName不为空但taskIds为空的情况
+        if (StrUtil.isNotBlank(pageReqVO.getWellName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
+            return result;
+        }
+
+        // key工作量标识   value累计 油耗
+        Map<String, BigDecimal> cumulativeFuelsPair = new HashMap<>();
+        // key工作量标识   value累计 段数 累计施工-层
+        Map<String, BigDecimal> cumulativeWorkingLayersPair = new HashMap<>();
+        // key工作量标识   value累计 井数
+        Map<String, BigDecimal> cumulativeWorkingWellPair = new HashMap<>();
+
+        // 查询时间区间内日报的 主设备泵车数量 累加
+        BigDecimal totalMainDeviceNum = BigDecimal.ZERO;
+        // 查询时间区间内日报的 作业泵车数量 累加
+        BigDecimal totalWokDeviceNum = BigDecimal.ZERO;
+        // 查询时间区间内日报的 压裂层 累加
+        BigDecimal totalLayers = BigDecimal.ZERO;
+        // 查询时间区间内日报的 注砂 累加
+        BigDecimal totalSand = BigDecimal.ZERO;
+        // 查询时间区间内日报的 注液 累加
+        BigDecimal totalLiquid = BigDecimal.ZERO;
+        // 查询时间区间内日报的 油耗 累加
+        BigDecimal totalFuel = BigDecimal.ZERO;
+        // 查询时间区间内日报的 非生产时间 累加
+        BigDecimal totalNptTime = BigDecimal.ZERO;
+
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        PageResult<IotFiveDailyReportDO> pageReports = iotFiveDailyReportMapper.selectPage(pageReqVO);
+        List<IotFiveDailyReportDO> reports = pageReports.getList();
+        if (CollUtil.isNotEmpty(reports)) {
+            for (IotFiveDailyReportDO report : reports) {
+                // 当日主压层数(层)
+                BigDecimal dailyLayers = report.getDailyWorkingLayers();
+                // 当日加砂
+                BigDecimal dailySand = report.getDailySandVolume();
+                // 当日注液
+                BigDecimal dailyLiquid = report.getDailyLiquidVolume();
+                // 当日油耗
+                BigDecimal dailyFuel = report.getDailyFuel();
+                // 非生产时间
+                BigDecimal nonProductionTime = report.getNonProductionTime();
+                // 设备利用率  作业泵车数量/主设备泵车数量
+                BigDecimal wokDeviceNum = report.getWokDeviceNum();
+                BigDecimal mainDeviceNum = report.getMainDeviceNum();
+                totalMainDeviceNum = totalMainDeviceNum.add(mainDeviceNum);
+                totalWokDeviceNum = totalWokDeviceNum.add(wokDeviceNum);
+                totalLayers = totalLayers.add(dailyLayers);
+                totalSand = totalSand.add(dailySand);
+                totalLiquid = totalLiquid.add(dailyLiquid);
+                totalFuel = totalFuel.add(dailyFuel);
+                totalNptTime = totalNptTime.add(nonProductionTime);
+            }
+            // 计算总的 设备利用率
+            if (totalMainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal totalUtilizationRate = totalWokDeviceNum.divide(totalMainDeviceNum, 4, RoundingMode.HALF_UP );
+                result.setUtilizationRate(totalUtilizationRate);
+            }
+            result.setTotalDailyFuel(totalFuel);
+            result.setCumulativeWorkingLayers(totalLayers);
+            result.setCumulativeMixSand(totalSand);
+            result.setCumulativeLiquidVolume(totalLiquid);
+            result.setCumulativeNptTime(totalNptTime);
+
+        }
+
+        // 查询全年的 工作量数据 默认当前时间所在年份
+
+        // 查询当月完成的工作量
+
+
+        return result;
+    }
+
 }