diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java index d5b60fcec1..148f25c219 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java @@ -129,16 +129,21 @@ public class TestPlanTaskCenterService { if (CollectionUtils.isNotEmpty(projectIds)) { Map historyDeletedMap = new HashMap<>(); list = extTestPlanReportMapper.taskCenterlist(request, isSystem ? new ArrayList<>() : projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); + // 执行历史ID集合 + List reportIds = list.stream().map(TaskCenterDTO::getId).collect(Collectors.toList()); // 查询计划组的任务的子计划任务 List groupReportIds = list.stream().filter(TaskCenterDTO::isIntegrated).map(TaskCenterDTO::getId).toList(); if (CollectionUtils.isNotEmpty(groupReportIds)) { List childTaskCenterList = extTestPlanReportMapper.getChildTaskCenter(groupReportIds); Map> childTaskMap = childTaskCenterList.stream().collect(Collectors.groupingBy(TaskCenterDTO::getParent)); - list.forEach(item -> item.setChildren(childTaskMap.get(item.getId()))); + list.forEach(item -> { + item.setChildren(childTaskMap.get(item.getId())); + if (CollectionUtils.isNotEmpty(item.getChildren())) { + reportIds.addAll(item.getChildren().stream().map(TaskCenterDTO::getId).toList()); + } + }); } - // 执行历史列表 - List reportIds = list.stream().map(TaskCenterDTO::getId).toList(); if (CollectionUtils.isNotEmpty(reportIds)) { List historyDeletedList = extTestPlanReportMapper.getHistoryDeleted(reportIds); historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity()));