|
|
@@ -3763,6 +3763,116 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IotRdDailyReportSummaryTeamRespVO> reportTeamSummary(IotRdDailyReportPageReqVO pageReqVO) {
|
|
|
+ // 查询选择部门下面所有子部门
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ if (Objects.nonNull(pageReqVO.getDeptId())) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ pageReqVO.setDeptIds(ids);
|
|
|
+ }
|
|
|
+ // searchKey 兼容移动端查询的情况
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getSearchKey())) {
|
|
|
+ if (CollUtil.isEmpty(pageReqVO.getProjectIds()) && CollUtil.isEmpty(pageReqVO.getTaskIds())) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // PC 端 AND 检查:各自条件必须匹配到对应 ID
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getContractName()) && CollUtil.isEmpty(pageReqVO.getProjectIds())) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && CollUtil.isEmpty(pageReqVO.getTaskIds())) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ PageResult<IotRdDailyReportDO> pageReports = iotRdDailyReportMapper.selectPage(pageReqVO);
|
|
|
+ List<IotRdDailyReportDO> dailyReports = pageReports.getList();
|
|
|
+ if (CollUtil.isEmpty(dailyReports)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 按照 年 月 日 汇总统计 日报数据
|
|
|
+ List<IotRdDailyReportSummaryTeamRespVO> result = new ArrayList<>();
|
|
|
+ // 设备部门信息
|
|
|
+ Map<Long, DeptDO> tempDeptMap = deptService.getDeptMap(convertList(dailyReports, IotRdDailyReportDO::getDeptId));
|
|
|
+ // key井id value井名称
|
|
|
+ Map<Long, String> taskPair = new HashMap<>();
|
|
|
+
|
|
|
+ List<Long> taskIds = dailyReports.stream()
|
|
|
+ .map(IotRdDailyReportDO::getTaskId)
|
|
|
+ .filter(Objects::nonNull) // 过滤 null taskId,避免后续查询异常
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(taskIds)) {
|
|
|
+ IotProjectTaskPageReqVO taskReqVO = new IotProjectTaskPageReqVO();
|
|
|
+ taskReqVO.setTaskIds(taskIds);
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(taskReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
+ tasks.forEach(task -> {
|
|
|
+ taskPair.put(task.getId(), task.getWellName());
|
|
|
+ // 大概率集合中只有1个元素 集合中的元素就是 队伍id
|
|
|
+ Set<Long> deptIds = task.getDeptIds();
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 1. 按队伍分组
|
|
|
+ Map<Long, List<IotRdDailyReportDO>> deptGroup = dailyReports.stream()
|
|
|
+ .filter(r -> r.getDeptId() != null)
|
|
|
+ .collect(Collectors.groupingBy(IotRdDailyReportDO::getDeptId));
|
|
|
+
|
|
|
+ deptGroup.forEach((deptId, reportsOfDept) -> {
|
|
|
+ // 构造队伍 VO
|
|
|
+ IotRdDailyReportSummaryTeamRespVO teamVO = new IotRdDailyReportSummaryTeamRespVO();
|
|
|
+ DeptDO dept = tempDeptMap.get(deptId);
|
|
|
+ teamVO.setTeamName(dept != null ? dept.getName() : "未知队伍");
|
|
|
+ teamVO.setReportCount(reportsOfDept.size());
|
|
|
+ // 统计井数量(去重)
|
|
|
+ Set<Long> wellIds = reportsOfDept.stream()
|
|
|
+ .map(IotRdDailyReportDO::getTaskId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ teamVO.setWellCount(wellIds.size());
|
|
|
+ teamVO.setLevel(""); // 按需设置
|
|
|
+
|
|
|
+ // 2. 按井分组
|
|
|
+ Map<Long, List<IotRdDailyReportDO>> wellGroup = reportsOfDept.stream()
|
|
|
+ .filter(r -> r.getTaskId() != null)
|
|
|
+ .collect(Collectors.groupingBy(IotRdDailyReportDO::getTaskId));
|
|
|
+
|
|
|
+ List<IotRdDailyReportSummaryWellRespVO> wellVOs = new ArrayList<>();
|
|
|
+ wellGroup.forEach((taskId, reportsOfWell) -> {
|
|
|
+ IotRdDailyReportSummaryWellRespVO wellVO = new IotRdDailyReportSummaryWellRespVO();
|
|
|
+ wellVO.setTaskId(taskId);
|
|
|
+ wellVO.setWellName(taskPair.getOrDefault(taskId, "未知井"));
|
|
|
+ wellVO.setReportCount(reportsOfWell.size());
|
|
|
+ // 根据 status 统计(此处按需求:status=1 表示已填写,其他为未填写)
|
|
|
+ long filled = reportsOfWell.stream().filter(r -> r.getStatus() != null && r.getStatus() == 1).count();
|
|
|
+ long unfilled = reportsOfWell.size() - filled;
|
|
|
+ wellVO.setFilledCount(String.valueOf(filled));
|
|
|
+ wellVO.setUnfilledCount(String.valueOf(unfilled));
|
|
|
+ // 日报列表
|
|
|
+ List<IotRdDailyReportShortRespVO> shortReports = reportsOfWell.stream()
|
|
|
+ .map(r -> {
|
|
|
+ IotRdDailyReportShortRespVO shortVO = new IotRdDailyReportShortRespVO();
|
|
|
+ shortVO.setId(r.getId());
|
|
|
+ shortVO.setReportName(r.getReportName());
|
|
|
+ return shortVO;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ wellVO.setReports(shortReports);
|
|
|
+ wellVO.setLevel(""); // 按需设置
|
|
|
+ wellVOs.add(wellVO);
|
|
|
+ });
|
|
|
+
|
|
|
+ teamVO.setWells(wellVOs);
|
|
|
+ result.add(teamVO);
|
|
|
+ });
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按项目部维度 汇总 统计数据
|
|
|
* @param dailyReports 日报数据列表
|