fix[project]: getTaskTree的任务关联需求类型

This commit is contained in:
2026-04-15 09:25:04 +08:00
parent ce0bb7929d
commit 107382136a

View File

@@ -522,6 +522,54 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
}
}
/**
* 关联任务与需求的需求类型demandType
* @param newTaskList 任务列表
*/
private void relateDemandType(List<TaskNodePo> newTaskList) {
// 1. 任务列表为空直接返回
if (CollectionUtils.isEmpty(newTaskList)) {
return;
}
// 2. 提取有效demandId
List<String> demandIdList = newTaskList.stream()
.map(TaskNodePo::getDemandId)
.filter(StringUtils::isNotBlank)
.distinct()
.toList();
log.info("relateDemandType 查询需求ID列表{}", demandIdList);
if (CollectionUtils.isEmpty(demandIdList)) {
return;
}
// 3. 查询需求信息
List<SpdmDemandVo> demandList = demandMapper.getDemandListById(demandIdList);
if (CollectionUtils.isEmpty(demandList)) {
log.info("relateDemandType 根据ID未查询到对应需求信息");
return;
}
// 4. 转成 Mapuuid -> demandType
Map<String, String> demandDemandTypeMap = demandList.stream()
.filter(demand -> StringUtils.isNotBlank(demand.getDemandType()))
.collect(Collectors.toMap(
SpdmDemandVo::getUuid,
SpdmDemandVo::getDemandType,
(oldVal, newVal) -> oldVal
));
// 5. 批量设置 demandType
for (TaskNodePo taskNodePo : newTaskList) {
String demandId = taskNodePo.getDemandId();
if (StringUtils.isNotBlank(demandId)) {
taskNodePo.setDemandType(demandDemandTypeMap.get(demandId));
}
}
}
@Override
public SdmResponse getTaskTree(ProjectTreeTagReq req) {
List<TaskNodeTag> idMapList = req.getIdMap();
@@ -560,6 +608,7 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
if (CollectionUtils.isNotEmpty(taskTreeTaskList)) {
log.info("查询到的任务为:{}", taskTreeTaskList.stream().map(TaskNodePo::getId).toList());
taskTreeTaskList.forEach(task -> task.setNodeType("task"));
relateDemandType(taskTreeTaskList);
taskTreePerformanceList = mapper.getPerformanceListByNodeIdList(taskTreeTaskList.stream().map(TaskNodePo::getUuid).toList());
if (CollectionUtils.isNotEmpty(taskTreePerformanceList)) {
log.info("查询到的指标为:{}", taskTreePerformanceList.stream().map(PerformanceNodePo::getId).toList());