fix(任务中心): 任务详情列表获取项目下资源池
--bug=1048050 --user=王旭 【项目任务中心】任务详情列表-资源池搜索选项未展示k8s资源池 https://www.tapd.cn/55049933/s/1598006
This commit is contained in:
parent
9250df2205
commit
6c7b8fe614
|
@ -2,6 +2,7 @@ package io.metersphere.project.controller;
|
|||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import io.metersphere.project.service.ProjectService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.BatchExecTaskReportDTO;
|
||||
import io.metersphere.system.dto.request.BatchExecTaskPageRequest;
|
||||
|
@ -45,6 +46,8 @@ public class ProjectTaskHubController {
|
|||
private BaseTaskHubService baseTaskHubService;
|
||||
@Resource
|
||||
private BaseTaskHubLogService baseTaskHubLogService;
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
|
||||
@PostMapping("/exec-task/page")
|
||||
@Operation(summary = "项目-任务中心-执行任务列表")
|
||||
|
@ -82,7 +85,7 @@ public class ProjectTaskHubController {
|
|||
@Operation(summary = "项目-任务中心-获取资源池下拉选项")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ)
|
||||
public List<ResourcePoolOptionsDTO> getUserProject() {
|
||||
return baseTaskHubService.getProjectResourcePoolOptions(SessionUtils.getCurrentProjectId());
|
||||
return projectService.getProjectResourcePoolOptions(SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,16 +13,15 @@ import io.metersphere.sdk.exception.MSException;
|
|||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.domain.TestResourcePoolExample;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
import io.metersphere.system.dto.sdk.SessionUser;
|
||||
import io.metersphere.system.dto.taskhub.ResourcePoolOptionsDTO;
|
||||
import io.metersphere.system.dto.user.UserDTO;
|
||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||
import io.metersphere.system.mapper.*;
|
||||
import io.metersphere.system.service.BaseTaskHubService;
|
||||
import io.metersphere.system.service.CommonProjectService;
|
||||
import io.metersphere.system.service.UserLoginService;
|
||||
import io.metersphere.system.utils.ServiceUtils;
|
||||
|
@ -35,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -65,6 +65,8 @@ public class ProjectService {
|
|||
private BaseUserMapper baseUserMapper;
|
||||
|
||||
public static final Long ORDER_STEP = 5000L;
|
||||
@Resource
|
||||
private BaseTaskHubService baseTaskHubService;
|
||||
|
||||
|
||||
public List<Project> getUserProject(String organizationId, String userId) {
|
||||
|
@ -302,5 +304,31 @@ public class ProjectService {
|
|||
return extProjectMapper.getResourcePoolOption(projectId, "api_test");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目下的资源池及节点下拉选项
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
public List<ResourcePoolOptionsDTO> getProjectResourcePoolOptions(String projectId) {
|
||||
List<TestResourcePool> pools = getAllPoolOption(projectId);
|
||||
if (CollectionUtils.isNotEmpty(pools)) {
|
||||
Map<String, List<TestResourcePoolBlob>> poolMap = baseTaskHubService.getPoolMap(pools);
|
||||
return baseTaskHubService.handleOptions(pools, poolMap);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<TestResourcePool> getAllPoolOption(String projectId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
if (project.getAllResourcePool()) {
|
||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||
example.createCriteria().andDeletedEqualTo(false);
|
||||
return testResourcePoolMapper.selectByExample(example);
|
||||
} else {
|
||||
return extProjectMapper.getResourcePoolOption(projectId, "api_test");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
INSERT INTO `exec_task`(`id`, `num`, `task_name`, `status`, `case_count`, `result`, `task_type`, `trigger_mode`, `project_id`, `organization_id`, `create_time`, `create_user`, `start_time`, `end_time`)
|
||||
INSERT INTO `exec_task`(`id`, `num`, `task_name`, `status`, `case_count`, `result`, `task_type`, `trigger_mode`, `project_id`, `organization_id`, `create_time`, `create_user`, `start_time`, `end_time`, `integrated`)
|
||||
VALUES
|
||||
('pro_1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
||||
('pro_2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
||||
('pro_3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
||||
('pro_4', 4, '测试任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API_CASE_BATCH', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639);
|
||||
('pro_1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||
('pro_2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||
('pro_3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||
('pro_4', 4, '测试任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API_CASE_BATCH', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'1');
|
||||
|
||||
INSERT INTO `exec_task_item`(`id`, `task_id`, `resource_id`, `resource_name`, `task_origin`, `status`, `result`, `resource_pool_id`, `resource_pool_node`, `resource_type`, `project_id`, `organization_id`, `thread_id`, `start_time`, `end_time`, `executor`)
|
||||
VALUES
|
||||
|
|
|
@ -455,7 +455,7 @@ public class BaseTaskHubService {
|
|||
|
||||
}
|
||||
|
||||
private Map<String, List<TestResourcePoolBlob>> getPoolMap(List<TestResourcePool> allResourcePools) {
|
||||
public Map<String, List<TestResourcePoolBlob>> getPoolMap(List<TestResourcePool> allResourcePools) {
|
||||
List<String> ids = allResourcePools.stream().map(TestResourcePool::getId).toList();
|
||||
//获取全部资源池节点
|
||||
TestResourcePoolBlobExample blobExample = new TestResourcePoolBlobExample();
|
||||
|
@ -464,7 +464,7 @@ public class BaseTaskHubService {
|
|||
return testResourcePoolBlobs.stream().collect(Collectors.groupingBy(TestResourcePoolBlob::getId));
|
||||
}
|
||||
|
||||
private List<ResourcePoolOptionsDTO> handleOptions(List<TestResourcePool> allResourcePools, Map<String, List<TestResourcePoolBlob>> poolMap) {
|
||||
public List<ResourcePoolOptionsDTO> handleOptions(List<TestResourcePool> allResourcePools, Map<String, List<TestResourcePoolBlob>> poolMap) {
|
||||
List<ResourcePoolOptionsDTO> options = new ArrayList<>();
|
||||
allResourcePools.forEach(item -> {
|
||||
ResourcePoolOptionsDTO optionsDTO = new ResourcePoolOptionsDTO();
|
||||
|
@ -507,26 +507,6 @@ public class BaseTaskHubService {
|
|||
return handleOptions(allResourcePools, poolMap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取项目下的资源池及节点下拉选项
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
public List<ResourcePoolOptionsDTO> getProjectResourcePoolOptions(String projectId) {
|
||||
ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<ProjectTestResourcePool> projectPools = projectTestResourcePoolMapper.selectByExample(example);
|
||||
List<String> poolIds = projectPools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList();
|
||||
if (CollectionUtils.isNotEmpty(poolIds)) {
|
||||
List<TestResourcePool> allResourcePools = extResourcePoolMapper.selectProjectAllResourcePool(poolIds);
|
||||
Map<String, List<TestResourcePoolBlob>> poolMap = getPoolMap(allResourcePools);
|
||||
return handleOptions(allResourcePools, poolMap);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务详情列表资源节点状态
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue