mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 12:39:12 +08:00
feat(任务中心): 任务详情查看结果-用例
This commit is contained in:
parent
18f09585d5
commit
cd8962225a
@ -133,4 +133,12 @@ public class ApiReportController {
|
||||
public void batchExportLog(@Validated @RequestBody ApiReportBatchRequest request) {
|
||||
apiReportService.batchExportLog(request, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/task-report/{id}")
|
||||
@Operation(summary = "系统-任务中心-场景用例执行任务详情-查看")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
|
||||
public List<ApiReportDetailDTO> viewCaseItemReport(@PathVariable String id) {
|
||||
return apiReportService.viewCaseTaskItemReport(id);
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,10 @@ import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.SubListUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.ExecTask;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.mapper.ExtExecTaskMapper;
|
||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||
@ -67,6 +69,10 @@ public class ApiReportService {
|
||||
private ApiReportNoticeService apiReportNoticeService;
|
||||
@Resource
|
||||
private ApiReportRelateTaskMapper apiReportRelateTaskMapper;
|
||||
@Resource
|
||||
private ApiReportStepMapper apiReportStepMapper;
|
||||
@Resource
|
||||
private ExtExecTaskMapper extExecTaskMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||
public void insertApiReport(ApiReport report) {
|
||||
@ -312,4 +318,45 @@ public class ApiReportService {
|
||||
apiReportLogService.exportLog(reports, userId, projectId, "/api/report/case/batch-export");
|
||||
}
|
||||
}
|
||||
|
||||
public List<ApiReportDetailDTO> viewCaseTaskItemReport(String id) {
|
||||
List<ExecTask> taskList = extExecTaskMapper.selectTypeByItemId(id);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||
if (taskList.getFirst().getIntegrated()) {
|
||||
//集合报告 TODO
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
//非集合报告
|
||||
return reportDetail(id);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private List<ApiReportDetailDTO> reportDetail(String id) {
|
||||
List<ApiReportDetailDTO> list = new ArrayList<>();
|
||||
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
|
||||
example.createCriteria().andTaskResourceIdEqualTo(id);
|
||||
List<ApiReportRelateTask> apiReportRelateTasks = apiReportRelateTaskMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(apiReportRelateTasks)) {
|
||||
//报告id
|
||||
String reportId = apiReportRelateTasks.getFirst().getReportId();
|
||||
//获取步骤id
|
||||
String stepId = getStepId(reportId);
|
||||
|
||||
list = getDetail(reportId, stepId);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String getStepId(String reportId) {
|
||||
ApiReportStepExample example = new ApiReportStepExample();
|
||||
example.createCriteria().andReportIdEqualTo(reportId);
|
||||
List<ApiReportStep> apiReportSteps = apiReportStepMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(apiReportSteps)) {
|
||||
return apiReportSteps.getFirst().getStepId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import io.metersphere.sdk.mapper.ShareInfoMapper;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.domain.ExecTask;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.domain.TestResourcePoolExample;
|
||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||
@ -37,6 +38,8 @@ import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
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.ResultActions;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
@ -83,6 +86,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||
private static final String DETAIL = BASIC + "/get/detail/";
|
||||
private static final String EXPORT_REPORT = BASIC + "/export/{0}";
|
||||
private static final String BATCH_EXPORT_REPORT = BASIC + "/batch-export";
|
||||
private static final String TASK_REPORT = BASIC + "/task-report/{0}";
|
||||
|
||||
|
||||
@Test
|
||||
@ -506,4 +510,11 @@ public class ApiReportControllerTests extends BaseTest {
|
||||
request.setSelectAll(true);
|
||||
this.requestPost(BATCH_EXPORT_REPORT, request);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
@Sql(scripts = {"/dml/init_task_item_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||
public void getTaskReport() throws Exception {
|
||||
this.requestGet(TASK_REPORT, "1");
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
('1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||
('2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||
('3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
||||
('4', 4, '删除任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '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
|
||||
('1', '1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
|
||||
('2', '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 ('1', 'test-report-id');
|
@ -114,7 +114,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void getProStatistics() throws Exception {
|
||||
List<String> ids = List.of("pro_1", "pro_2");
|
||||
MvcResult mvcResult = this.requestPostWithOkAndReturn(PROJECT_STATISTICS, ids);
|
||||
@ -219,7 +219,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void projectTaskItemBatchStop() throws Exception {
|
||||
mockPost("/api/task/item/stop", "");
|
||||
TaskHubItemBatchRequest request = new TaskHubItemBatchRequest();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.system.domain.ExecTask;
|
||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
||||
@ -26,4 +27,6 @@ public interface ExtExecTaskMapper {
|
||||
* @return 任务ID列表
|
||||
*/
|
||||
List<String> getTaskIdsByTime(@Param("timeMills") long timeMills, @Param("projectId") String projectId);
|
||||
|
||||
List<ExecTask> selectTypeByItemId(@Param("itemId") String itemId);
|
||||
}
|
||||
|
@ -118,4 +118,9 @@
|
||||
<select id="getTaskIdsByTime" resultType="java.lang.String">
|
||||
select id from exec_task where project_id = #{projectId} and start_time <= #{timeMills}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectTypeByItemId" resultType="io.metersphere.system.domain.ExecTask">
|
||||
select integrated from exec_task inner join exec_task_item on exec_task.id = exec_task_item.task_id where exec_task_item.id = #{itemId}
|
||||
</select>
|
||||
</mapper>
|
@ -191,7 +191,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||
* 系统任务项停止
|
||||
*/
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void systemTaskItemStop() throws Exception {
|
||||
mockPost("/api/task/item/stop", "");
|
||||
this.requestGet(SYSTEM_TASK_ITEM_STOP + "1");
|
||||
@ -200,7 +200,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void systemGetTaskItemOrder() throws Exception {
|
||||
MvcResult mvcResult = this.requestPostWithOkAndReturn(SYSTEM_TASK_ITEM_ORDER, List.of("1"));
|
||||
HashMap resultData = getResultData(mvcResult, HashMap.class);
|
||||
@ -392,7 +392,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void getOrgStatistics() throws Exception {
|
||||
List<String> ids = List.of("1", "2");
|
||||
MvcResult mvcResult = this.requestPostWithOkAndReturn(ORG_STATISTICS, ids);
|
||||
|
Loading…
Reference in New Issue
Block a user