From 4f24e2c79572fb64a23835cc146c8279d20ff8ef Mon Sep 17 00:00:00 2001 From: Joshi <3040996759@qq.com> Date: Sat, 25 Oct 2025 09:52:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(oa):=E4=B8=BA=E9=A1=B9=E7=9B=AE=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=AD=A5=E9=AA=A4=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?ID=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 OaProjectScheduleStep 实体中新增 projectId 字段- 查询用户负责的进度步骤时,构建 scheduleId 到 projectId 的映射关系-为每个进度步骤设置对应的项目ID,便于后续数据追踪与筛选 -保留原有统计逻辑,确保功能兼容性 --- .../oa/domain/OaProjectScheduleStep.java | 2 ++ .../OaProjectScheduleStepServiceImpl.java | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/OaProjectScheduleStep.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/OaProjectScheduleStep.java index b53afa0..8d71cbf 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/OaProjectScheduleStep.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/OaProjectScheduleStep.java @@ -139,4 +139,6 @@ public class OaProjectScheduleStep extends BaseEntity { //排序字段 private Integer sortNum; + private Long projectId; + } diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaProjectScheduleStepServiceImpl.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaProjectScheduleStepServiceImpl.java index 4a53d87..1aaf661 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaProjectScheduleStepServiceImpl.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaProjectScheduleStepServiceImpl.java @@ -369,21 +369,30 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS .eq(SysOaProject::getFunctionary, nickName) ); - // 4. 查询用户负责的进度步骤(核心数据) + // 4. 查询用户负责的进度步骤(核心数据),并关联项目ID List userSteps = new ArrayList<>(); + // 存储 scheduleId 与 projectId 的映射关系(关键:通过进度主表关联项目ID) + Map scheduleProjectMap = new HashMap<>(); + if (CollUtil.isNotEmpty(projectIds)) { - // 查询关联项目的进度主表 + // 查询关联项目的进度主表,并构建 scheduleId -> projectId 映射 List schedules = projectScheduleMapper.selectList( Wrappers.lambdaQuery() .in(OaProjectSchedule::getProjectId, projectIds) .eq(OaProjectSchedule::getDelFlag, "0") ); if (CollUtil.isNotEmpty(schedules)) { - List scheduleIds = schedules.stream() + // 构建映射:进度ID -> 项目ID + scheduleProjectMap = schedules.stream() .filter(Objects::nonNull) - .map(OaProjectSchedule::getScheduleId) - .filter(Objects::nonNull) - .collect(Collectors.toList()); + .filter(s -> s.getScheduleId() != null && s.getProjectId() != null) + .collect(Collectors.toMap( + OaProjectSchedule::getScheduleId, + OaProjectSchedule::getProjectId, + (existing, replacement) -> existing // 若有重复ID,保留第一个 + )); + + List scheduleIds = new ArrayList<>(scheduleProjectMap.keySet()); // 查询用户负责的进度步骤 userSteps = projectScheduleStepMapper.selectList( @@ -393,10 +402,19 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS .eq(OaProjectScheduleStep::getDelFlag, "0") .eq(OaProjectScheduleStep::getUseFlag, 1) ); + + // 为每个步骤设置对应的项目ID + for (OaProjectScheduleStep step : userSteps) { + if (step != null && step.getScheduleId() != null) { + // 从映射中获取当前步骤所属的项目ID + Long projectId = scheduleProjectMap.get(step.getScheduleId()); + step.setProjectId(projectId); + } + } } } - // 5. 统计进度数据 + // 5. 统计进度数据(逻辑不变) PersonalReportDTO.ProgressStats progressStats = new PersonalReportDTO.ProgressStats(); progressStats.setTotal((long) userSteps.size()); progressStats.setCompleted(userSteps.stream() @@ -415,7 +433,7 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS result.setUserInfo(user); result.setResponsibleProjects(responsibleProjects); result.setProgressStats(progressStats); - result.setUserSteps(userSteps); + result.setUserSteps(userSteps); // 此时userSteps已包含每个步骤对应的projectId return result; }