diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ReportDetailCasePageDTO.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ReportDetailCasePageDTO.java index d68cb706ae..5179046e57 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ReportDetailCasePageDTO.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ReportDetailCasePageDTO.java @@ -37,4 +37,8 @@ public class ReportDetailCasePageDTO { private String collectionId; @Schema(description = "测试点名称") private String collectionName; + @Schema(description = "耗时ms") + private Long requestDuration; + @Schema(description = "耗时s") + private Double requestTime; } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiCaseMapper.xml index 9b408c340d..f633fcd859 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiCaseMapper.xml @@ -38,9 +38,10 @@ select tprac.api_case_id as id, tprac.api_case_num as num, tprac.api_case_name as name, tprac.test_plan_name as planName, tprac.test_plan_collection_id collectionId, tpc.name collectionName, tprac.api_case_module as moduleName, tprac.api_case_priority as priority, tprac.api_case_execute_report_id reportId, ifnull(tprac.api_case_bug_count, 0) as bugCount, - ifnull(tprac.api_case_execute_result, 'PENDING') as executeResult, tprac.api_case_execute_user as executeUser, atc.project_id projectId + ifnull(tprac.api_case_execute_result, 'PENDING') as executeResult, tprac.api_case_execute_user as executeUser, atc.project_id projectId, ar.request_duration as requestDuration from test_plan_report_api_case tprac left join api_test_case atc on tprac.api_case_id = atc.id left join test_plan_collection tpc on tprac.test_plan_collection_id = tpc.id + left join api_report ar on tprac.api_case_execute_report_id = ar.id where tprac.test_plan_report_id in #{id} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiScenarioMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiScenarioMapper.xml index 51bfe79194..00444f09cc 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiScenarioMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportApiScenarioMapper.xml @@ -37,9 +37,10 @@ select distinct tpras.api_scenario_id as id, tpras.api_scenario_num as num, tpras.api_scenario_name as name, tpras.test_plan_name as planName, tpras.test_plan_collection_id collectionId, tpc.name collectionName, tpras.api_scenario_module as moduleName, tpras.api_scenario_priority as priority, tpras.api_scenario_execute_report_id reportId, ifnull(tpras.api_scenario_bug_count, 0) as bugCount, - ifnull(tpras.api_scenario_execute_result, 'PENDING') as executeResult, tpras.api_scenario_execute_user as executeUser, aso.project_id projectId + ifnull(tpras.api_scenario_execute_result, 'PENDING') as executeResult, tpras.api_scenario_execute_user as executeUser, aso.project_id projectId, asr.request_duration as requestDuration from test_plan_report_api_scenario tpras left join api_scenario aso on tpras.api_scenario_id = aso.id left join test_plan_collection tpc on tpras.test_plan_collection_id = tpc.id + left join api_scenario_report asr on tpras.api_scenario_execute_report_id = asr.id where tpras.test_plan_report_id in #{id} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index d80dde3016..e929366bf3 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -941,7 +941,10 @@ public class TestPlanReportService { List distinctUserIds = detailCases.stream().map(ReportDetailCasePageDTO::getExecuteUser).distinct().collect(Collectors.toList()); distinctUserIds.removeIf(StringUtils::isEmpty); Map userMap = getUserMap(distinctUserIds); - detailCases.forEach(detailCase -> detailCase.setExecuteUser(userMap.getOrDefault(detailCase.getExecuteUser(), detailCase.getExecuteUser()))); + detailCases.forEach(detailCase -> { + detailCase.setExecuteUser(userMap.getOrDefault(detailCase.getExecuteUser(), detailCase.getExecuteUser())); + detailCase.setRequestTime(detailCase.getRequestDuration() == null ? 0 : detailCase.getRequestDuration() / 1000.0); + }); return detailCases; }