feat(任务中心): 场景任务详情查看结果-场景步骤&场景步骤结果详情
This commit is contained in:
parent
fe96718b9b
commit
a695d84a62
|
@ -136,7 +136,7 @@ public class ApiReportController {
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/task-report/{id}")
|
@GetMapping("/task-report/{id}")
|
||||||
@Operation(summary = "系统-任务中心-场景用例执行任务详情-查看")
|
@Operation(summary = "系统-任务中心-接口用例执行任务详情-查看")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
|
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
|
||||||
public List<ApiReportDetailDTO> viewCaseItemReport(@PathVariable String id) {
|
public List<ApiReportDetailDTO> viewCaseItemReport(@PathVariable String id) {
|
||||||
return apiReportService.viewCaseTaskItemReport(id);
|
return apiReportService.viewCaseTaskItemReport(id);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.controller.scenario;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.api.dto.definition.ApiReportBatchRequest;
|
import io.metersphere.api.dto.definition.ApiReportBatchRequest;
|
||||||
|
import io.metersphere.api.dto.definition.ApiReportDetailDTO;
|
||||||
import io.metersphere.api.dto.definition.ApiReportPageRequest;
|
import io.metersphere.api.dto.definition.ApiReportPageRequest;
|
||||||
import io.metersphere.api.dto.report.ApiScenarioReportListDTO;
|
import io.metersphere.api.dto.report.ApiScenarioReportListDTO;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
||||||
|
@ -133,4 +134,20 @@ public class ApiScenarioReportController {
|
||||||
public void batchExportLog(@Validated @RequestBody ApiReportBatchRequest request) {
|
public void batchExportLog(@Validated @RequestBody ApiReportBatchRequest request) {
|
||||||
apiScenarioReportService.batchExportLog(request, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
apiScenarioReportService.batchExportLog(request, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/task-step/{id}")
|
||||||
|
@Operation(summary = "系统-任务中心-场景用例执行任务详情-查看(任务步骤)")
|
||||||
|
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
|
||||||
|
public ApiScenarioReportDTO viewScenarioItemReport(@PathVariable String id) {
|
||||||
|
return apiScenarioReportService.viewScenarioItemReport(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/task-report/{reportId}/{stepId}")
|
||||||
|
@Operation(summary = "系统-任务中心-场景用例执行任务详情-查看(步骤结果)")
|
||||||
|
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
|
||||||
|
public List<ApiScenarioReportDetailDTO> getScenarioReportDetail(@PathVariable String reportId,
|
||||||
|
@PathVariable String stepId) {
|
||||||
|
return apiScenarioReportService.getDetail(reportId, stepId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.service.scenario;
|
||||||
import io.metersphere.api.constants.ApiScenarioStepType;
|
import io.metersphere.api.constants.ApiScenarioStepType;
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.dto.definition.ApiReportBatchRequest;
|
import io.metersphere.api.dto.definition.ApiReportBatchRequest;
|
||||||
|
import io.metersphere.api.dto.definition.ApiReportDetailDTO;
|
||||||
import io.metersphere.api.dto.definition.ApiReportPageRequest;
|
import io.metersphere.api.dto.definition.ApiReportPageRequest;
|
||||||
import io.metersphere.api.dto.report.ApiScenarioReportListDTO;
|
import io.metersphere.api.dto.report.ApiScenarioReportListDTO;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
||||||
|
@ -18,8 +19,10 @@ import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.SubListUtils;
|
import io.metersphere.sdk.util.SubListUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
|
import io.metersphere.system.domain.ExecTask;
|
||||||
import io.metersphere.system.domain.TestResourcePool;
|
import io.metersphere.system.domain.TestResourcePool;
|
||||||
import io.metersphere.system.domain.User;
|
import io.metersphere.system.domain.User;
|
||||||
|
import io.metersphere.system.mapper.ExtExecTaskMapper;
|
||||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||||
import io.metersphere.system.mapper.UserMapper;
|
import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
|
@ -73,6 +76,8 @@ public class ApiScenarioReportService {
|
||||||
private static final String SPLITTER = "_";
|
private static final String SPLITTER = "_";
|
||||||
private static final int MAX = 50000;
|
private static final int MAX = 50000;
|
||||||
private static final int BATCH_SIZE = 1000;
|
private static final int BATCH_SIZE = 1000;
|
||||||
|
@Resource
|
||||||
|
private ExtExecTaskMapper extExecTaskMapper;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||||
public void insertApiScenarioReport(ApiScenarioReport report, ApiReportRelateTask taskRelation) {
|
public void insertApiScenarioReport(ApiScenarioReport report, ApiReportRelateTask taskRelation) {
|
||||||
|
@ -440,4 +445,31 @@ public class ApiScenarioReportService {
|
||||||
apiScenarioReportLogService.exportLog(reports, userId, projectId, "/api/report/scenario/batch-export");
|
apiScenarioReportLogService.exportLog(reports, userId, projectId, "/api/report/scenario/batch-export");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApiScenarioReportDTO viewScenarioItemReport(String id) {
|
||||||
|
List<ExecTask> taskList = extExecTaskMapper.selectTypeByItemId(id);
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||||
|
if (taskList.getFirst().getIntegrated()) {
|
||||||
|
//场景集合报告 TODO
|
||||||
|
return new ApiScenarioReportDTO();
|
||||||
|
} else {
|
||||||
|
//场景非集合报告
|
||||||
|
return scenarioReportDetail(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ApiScenarioReportDTO();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiScenarioReportDTO scenarioReportDetail(String id) {
|
||||||
|
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
|
||||||
|
example.createCriteria().andTaskResourceIdEqualTo(id);
|
||||||
|
List<ApiReportRelateTask> apiReportRelateTasks = apiReportRelateTaskMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isNotEmpty(apiReportRelateTasks)) {
|
||||||
|
//报告id
|
||||||
|
String reportId = apiReportRelateTasks.getFirst().getReportId();
|
||||||
|
return get(reportId);
|
||||||
|
}
|
||||||
|
return new ApiScenarioReportDTO();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ import org.junit.jupiter.api.*;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
|
import org.springframework.test.context.jdbc.SqlConfig;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
import org.springframework.test.web.servlet.ResultActions;
|
import org.springframework.test.web.servlet.ResultActions;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
@ -90,6 +92,8 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
private static final String DETAIL = BASIC + "/get/detail/";
|
private static final String DETAIL = BASIC + "/get/detail/";
|
||||||
private static final String EXPORT_REPORT = BASIC + "/export/{0}";
|
private static final String EXPORT_REPORT = BASIC + "/export/{0}";
|
||||||
private static final String BATCH_EXPORT_REPORT = BASIC + "/batch-export";
|
private static final String BATCH_EXPORT_REPORT = BASIC + "/batch-export";
|
||||||
|
private static final String TASK_STEP = BASIC + "/task-step/{0}";
|
||||||
|
private static final String TASK_REPORT = BASIC + "/task-report/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -551,4 +555,17 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
request.setSelectAll(true);
|
request.setSelectAll(true);
|
||||||
this.requestPost(BATCH_EXPORT_REPORT, request);
|
this.requestPost(BATCH_EXPORT_REPORT, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(11)
|
||||||
|
@Sql(scripts = {"/dml/init_scenario_task_item_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||||
|
public void getTaskStep() throws Exception {
|
||||||
|
this.requestGet(TASK_STEP, "scenario_1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(12)
|
||||||
|
public void getTaskReport() throws Exception {
|
||||||
|
this.requestGet(TASK_REPORT + "test-scenario-report-id" + "/" + "test-scenario-report-step-id1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
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
|
||||||
|
('scenario_1', 11, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||||
|
('scenario_2', 22, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
('scenario_1', 'scenario_1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
|
||||||
|
('scenario_2', 'scenario_2', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin');
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `api_report_relate_task`(`task_resource_id`, `report_id`)
|
||||||
|
VALUES
|
||||||
|
('scenario_1', 'test-scenario-report-id');
|
|
@ -183,7 +183,7 @@ public class ProjectTaskHubController {
|
||||||
@PostMapping("/schedule/update-cron")
|
@PostMapping("/schedule/update-cron")
|
||||||
@Operation(summary = "项目-任务中心-后台任务更新cron表达式")
|
@Operation(summary = "项目-任务中心-后台任务更新cron表达式")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
||||||
public void updateValue(@PathVariable ScheduleRequest request) {
|
public void updateValue(@Validated @RequestBody ScheduleRequest request) {
|
||||||
baseTaskHubService.updateCron(request);
|
baseTaskHubService.updateCron(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class OrganizationTaskHubController {
|
||||||
@PostMapping("/schedule/update-cron")
|
@PostMapping("/schedule/update-cron")
|
||||||
@Operation(summary = "组织-任务中心-后台任务更新cron表达式")
|
@Operation(summary = "组织-任务中心-后台任务更新cron表达式")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
||||||
public void updateValue(@PathVariable ScheduleRequest request) {
|
public void updateValue(@Validated @RequestBody ScheduleRequest request) {
|
||||||
baseTaskHubService.updateCron(request);
|
baseTaskHubService.updateCron(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ public class SystemTaskHubController {
|
||||||
@PostMapping("/schedule/update-cron")
|
@PostMapping("/schedule/update-cron")
|
||||||
@Operation(summary = "系统-任务中心-后台任务更新cron表达式")
|
@Operation(summary = "系统-任务中心-后台任务更新cron表达式")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
||||||
public void updateValue(@PathVariable ScheduleRequest request) {
|
public void updateValue(@Validated @RequestBody ScheduleRequest request) {
|
||||||
baseTaskHubService.updateCron(request);
|
baseTaskHubService.updateCron(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue