feat(oa):为项目进度步骤添加项目ID关联
- 在 OaProjectScheduleStep 实体中新增 projectId 字段- 查询用户负责的进度步骤时,构建 scheduleId 到 projectId 的映射关系-为每个进度步骤设置对应的项目ID,便于后续数据追踪与筛选 -保留原有统计逻辑,确保功能兼容性
This commit is contained in:
@@ -139,4 +139,6 @@ public class OaProjectScheduleStep extends BaseEntity {
|
||||
//排序字段
|
||||
private Integer sortNum;
|
||||
|
||||
private Long projectId;
|
||||
|
||||
}
|
||||
|
||||
@@ -369,21 +369,30 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
|
||||
.eq(SysOaProject::getFunctionary, nickName)
|
||||
);
|
||||
|
||||
// 4. 查询用户负责的进度步骤(核心数据)
|
||||
// 4. 查询用户负责的进度步骤(核心数据),并关联项目ID
|
||||
List<OaProjectScheduleStep> userSteps = new ArrayList<>();
|
||||
// 存储 scheduleId 与 projectId 的映射关系(关键:通过进度主表关联项目ID)
|
||||
Map<Long, Long> scheduleProjectMap = new HashMap<>();
|
||||
|
||||
if (CollUtil.isNotEmpty(projectIds)) {
|
||||
// 查询关联项目的进度主表
|
||||
// 查询关联项目的进度主表,并构建 scheduleId -> projectId 映射
|
||||
List<OaProjectSchedule> schedules = projectScheduleMapper.selectList(
|
||||
Wrappers.<OaProjectSchedule>lambdaQuery()
|
||||
.in(OaProjectSchedule::getProjectId, projectIds)
|
||||
.eq(OaProjectSchedule::getDelFlag, "0")
|
||||
);
|
||||
if (CollUtil.isNotEmpty(schedules)) {
|
||||
List<Long> 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<Long> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user