refactor(测试计划): 优化任务中心层级数据返回

This commit is contained in:
song-cc-rock 2024-07-04 14:41:52 +08:00 committed by Craftsman
parent 39bf127a3f
commit e1c38e87d4
3 changed files with 8 additions and 13 deletions

View File

@ -5,7 +5,6 @@ import lombok.Data;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -69,8 +68,8 @@ public class TaskCenterDTO implements Serializable {
private boolean historyDeleted = false; private boolean historyDeleted = false;
@Schema(description = "计划组ID") @Schema(description = "计划组ID")
private String parentId; private String parent;
@Schema(description = "计划组子任务") @Schema(description = "计划组子任务")
private List<TaskCenterDTO> children = new ArrayList<>(); private List<TaskCenterDTO> children;
} }

View File

@ -61,7 +61,7 @@
</select> </select>
<select id="taskCenterlist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO"> <select id="taskCenterlist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO">
select select
distinct tpr.id, tpr.id,
tpr.project_id, tpr.project_id,
tpr.integrated, tpr.integrated,
tpr.result_status as status, tpr.result_status as status,
@ -70,7 +70,7 @@
tpr.create_user AS operationName, tpr.create_user AS operationName,
tpr.trigger_mode, tpr.trigger_mode,
tpr.start_time, tpr.start_time,
'' as parentId, '' as parent,
project.organization_id, project.organization_id,
tp.num AS resourceNum, tp.num AS resourceNum,
tp.name AS resourceName, tp.name AS resourceName,
@ -101,7 +101,7 @@
<select id="getChildTaskCenter" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO"> <select id="getChildTaskCenter" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO">
select select
distinct tpr.id, tpr.id,
tpr.project_id, tpr.project_id,
tpr.integrated, tpr.integrated,
tpr.result_status as status, tpr.result_status as status,
@ -110,7 +110,7 @@
tpr.create_user as operationName, tpr.create_user as operationName,
tpr.trigger_mode, tpr.trigger_mode,
tpr.start_time, tpr.start_time,
tpr.parent_id as parentId, tpr.parent_id as parent,
project.organization_id, project.organization_id,
tp.num as resourceNum, tp.num as resourceNum,
tp.name as resourceName, tp.name as resourceName,

View File

@ -133,12 +133,8 @@ public class TestPlanTaskCenterService {
List<String> groupReportIds = list.stream().filter(TaskCenterDTO::isIntegrated).map(TaskCenterDTO::getId).toList(); List<String> groupReportIds = list.stream().filter(TaskCenterDTO::isIntegrated).map(TaskCenterDTO::getId).toList();
if (CollectionUtils.isNotEmpty(groupReportIds)) { if (CollectionUtils.isNotEmpty(groupReportIds)) {
List<TaskCenterDTO> childTaskCenterList = extTestPlanReportMapper.getChildTaskCenter(groupReportIds); List<TaskCenterDTO> childTaskCenterList = extTestPlanReportMapper.getChildTaskCenter(groupReportIds);
Map<String, List<TaskCenterDTO>> childTaskMap = childTaskCenterList.stream().collect(Collectors.groupingBy(TaskCenterDTO::getParentId)); Map<String, List<TaskCenterDTO>> childTaskMap = childTaskCenterList.stream().collect(Collectors.groupingBy(TaskCenterDTO::getParent));
list.forEach(item -> { list.forEach(item -> item.setChildren(childTaskMap.get(item.getId())));
if (CollectionUtils.isNotEmpty(childTaskMap.get(item.getId()))) {
item.setChildren(childTaskMap.get(item.getId()));
}
});
} }
// 执行历史列表 // 执行历史列表