From a37d09f3ed7c717fc83da88e0b07931c45ca0a70 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 19 Jun 2024 16:28:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E5=88=86=E4=BA=AB=E9=A1=B5=E9=9D=A2=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8A=A5=E5=91=8A=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/mapper/ExtTestPlanReportMapper.java | 4 +- .../plan/mapper/ExtTestPlanReportMapper.xml | 12 ++ .../service/TestPlanTaskCenterService.java | 12 +- frontend/src/api/modules/test-plan/report.ts | 34 ++++++ frontend/src/api/requrls/test-plan/report.ts | 17 +++ .../pure/ms-time-selector/MsTimeSelector.vue | 1 + frontend/src/config/pathMap.ts | 24 ++++ .../detail/component/apiAndScenarioTable.vue | 5 +- .../component/caseAndScenarioReportDrawer.vue | 115 ++++++++++++++++++ 9 files changed, 211 insertions(+), 13 deletions(-) create mode 100644 frontend/src/views/test-plan/report/detail/component/caseAndScenarioReportDrawer.vue diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.java index 6a6198d884..0da2d3a182 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.java @@ -60,5 +60,7 @@ public interface ExtTestPlanReportMapper { List getScenarioReports(@Param("ids") List ids); - void batchUpdateExecuteTimeAndStatus(@Param("startTime") long startTime,@Param("ids")List ids); + void batchUpdateExecuteTimeAndStatus(@Param("startTime") long startTime, @Param("ids") List ids); + + List getReportsByIds(@Param("ids") List ids); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.xml index 533b4917cc..70db8909be 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportMapper.xml @@ -217,6 +217,18 @@ + + update test_plan_report set start_time = #{startTime}, exec_status = 'RUNNING' diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java index 1d9e0dd583..e670086c54 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java @@ -291,6 +291,7 @@ public class TestPlanTaskCenterService { detailReport(request, apiReports, userId, module, ApiExecuteResourceType.TEST_PLAN_API_CASE.name()); List scenarioReports = extTestPlanReportMapper.getScenarioReports(subList); detailReport(request, scenarioReports, userId, module, ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name()); + saveLog(subList, userId, StringUtils.join(module, "_REAL_TIME_TEST_PLAN")); }); } @@ -331,20 +332,13 @@ public class TestPlanTaskCenterService { MsHttpClient.stopApi(endpoint, subList); } catch (Exception e) { LogUtils.error(e); - } finally { - saveLog(subList, userId, StringUtils.join(module, "_REAL_TIME_TEST_PLAN"), resourceType); } }); }); } - private void saveLog(List ids, String userId, String module, String type) { - List reports = new ArrayList<>(); - if (StringUtils.equals(type, ApiExecuteResourceType.TEST_PLAN_API_CASE.name())) { - reports = extApiReportMapper.selectByIds(ids); - } else if (StringUtils.equals(type, ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name())) { - reports = extApiScenarioReportMapper.selectByIds(ids); - } + private void saveLog(List ids, String userId, String module) { + List reports = extTestPlanReportMapper.getReportsByIds(ids); //取出所有的项目id List projectIds = reports.stream().map(ReportDTO::getProjectId).distinct().toList(); //根据项目id取出组织id diff --git a/frontend/src/api/modules/test-plan/report.ts b/frontend/src/api/modules/test-plan/report.ts index 00c8b749ed..9b42a4dfc7 100644 --- a/frontend/src/api/modules/test-plan/report.ts +++ b/frontend/src/api/modules/test-plan/report.ts @@ -2,6 +2,7 @@ import MSR from '@/api/http'; import * as reportUrl from '@/api/requrls/test-plan/report'; import type { GetShareId } from '@/models/apiTest/report'; +import { ReportDetail, ReportStepDetail } from "@/models/apiTest/report"; import { CommonList, TableQueryParams } from '@/models/common'; import { ApiOrScenarioCaseItem, @@ -116,4 +117,37 @@ export function getReportDetailSharePage(data: TableQueryParams) { return MSR.post>({ url: reportUrl.ReportDetailSharePageUrl, data }); } +export function reportScenarioDetail(reportId: string, shareId?: string | undefined) { + if (shareId) { + return MSR.get({ url: `${reportUrl.ReportShareScenarioUrlGet}/${shareId}/${reportId}` }); + } + return MSR.get({ url: `${reportUrl.ReportScenarioUrl}/${reportId}` }); +} +// 报告步骤详情 +export function reportStepDetail(reportId?: string, stepId?: string, shareId?: string | undefined) { + if (shareId) { + return MSR.get({ + url: `${reportUrl.ReportShareScenarioUrlGetDetail}/${shareId}/${reportId}/${stepId}`, + }); + } + return MSR.get({ url: `${reportUrl.ReportDetailScenarioUrl}/${reportId}/${stepId}` }); +} +// 用例报告详情 +export function reportCaseDetail(reportId: string, shareId?: string | undefined) { + if (shareId) { + return MSR.get({ url: `${reportUrl.ReportShareApiUrlGet}/${shareId}/${reportId}` }); + } + return MSR.get({ url: `${reportUrl.ReportApiUrl}/${reportId}` }); +} + +// 报告步骤详情 +export function reportCaseStepDetail(reportId: string, stepId: string, shareId?: string | undefined) { + if (shareId) { + return MSR.get({ + url: `${reportUrl.ReportShareApiUrlGetDetail}/${shareId}/${reportId}/${stepId}`, + }); + } + return MSR.get({ url: `${reportUrl.ReportDetailApiUrl}/${reportId}/${stepId}` }); +} + export default {}; diff --git a/frontend/src/api/requrls/test-plan/report.ts b/frontend/src/api/requrls/test-plan/report.ts index 64fefbdf91..e8e60ac637 100644 --- a/frontend/src/api/requrls/test-plan/report.ts +++ b/frontend/src/api/requrls/test-plan/report.ts @@ -40,3 +40,20 @@ export const ReportShareScenarioUrl = '/test-plan/report/share/detail/scenario/c export const ReportDetailPageUrl = '/test-plan/report/detail/plan/report/page'; // 测试计划-聚合报告-报告明细-分享 export const ReportDetailSharePageUrl = '/test-plan/report/share/detail/plan/report/page'; + +// 测试计划-报告明细-接口报告-分享 +export const ReportShareApiUrlGet = '/test-plan/report/share/detail/api-report'; +export const ReportShareApiUrlGetDetail = '/test-plan/report/share/detail/api-report/get'; + +// 测试计划-报告明细-接口报告 +export const ReportApiUrl = '/test-plan/api/case/report/get'; +export const ReportDetailApiUrl = '/test-plan/api/case/report/get/detail'; + +// 测试计划-报告明细-场景报告-分享 +export const ReportShareScenarioUrlGet = '/test-plan/report/share/detail/scenario-report'; +export const ReportShareScenarioUrlGetDetail = '/test-plan/report/share/detail/scenario-report/get'; + +// 测试计划-报告明细-场景报告 +export const ReportScenarioUrl = '/test-plan/api/scenario/report/get'; +export const ReportDetailScenarioUrl = '/test-plan/api/scenario/report/get/detail'; + diff --git a/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue b/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue index 0f64f9e270..d365ac9be8 100644 --- a/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue +++ b/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue @@ -4,6 +4,7 @@ v-model:model-value="numberValue" class="w-[120px]" :min="1" + :max="1000" hide-button size="small" :disabled="props.disabled" diff --git a/frontend/src/config/pathMap.ts b/frontend/src/config/pathMap.ts index 1b52c8ace1..6dd771149a 100644 --- a/frontend/src/config/pathMap.ts +++ b/frontend/src/config/pathMap.ts @@ -904,6 +904,18 @@ export const pathMap: PathMapItem[] = [ type: TaskCenterEnum.API_SCENARIO, }, }, + { + key: 'PROJECT_MANAGEMENT_TASK_CENTER_REAL_TIME_TEST_PLAN', // 项目管理-任务中心-实时任务-接口场景 + locale: 'project.taskCenter.testPlan', + route: '', + permission: [], + level: MENU_LEVEL[2], + routeQuery: { + task: true, + tab: 'real', + type: TaskCenterEnum.TEST_PLAN, + }, + }, ], }, { @@ -937,6 +949,18 @@ export const pathMap: PathMapItem[] = [ type: TaskCenterEnum.API_IMPORT, }, }, + { + key: 'PROJECT_MANAGEMENT_TASK_CENTER_TIME_TEST_PLAN', // 项目管理-任务中心-定时任务-测试计划 + locale: 'project.taskCenter.testPlan', + route: '', + permission: [], + level: MENU_LEVEL[2], + routeQuery: { + task: true, + tab: 'timing', + type: TaskCenterEnum.TEST_PLAN, + }, + }, ], }, ], diff --git a/frontend/src/views/test-plan/report/detail/component/apiAndScenarioTable.vue b/frontend/src/views/test-plan/report/detail/component/apiAndScenarioTable.vue index 6f4fad081f..5ed8cc88d7 100644 --- a/frontend/src/views/test-plan/report/detail/component/apiAndScenarioTable.vue +++ b/frontend/src/views/test-plan/report/detail/component/apiAndScenarioTable.vue @@ -21,7 +21,7 @@ v-model:visible="reportVisible" :is-scenario="props.activeTab === 'scenarioCase'" :report-id="apiReportId" - do-not-show-share + :share-id="props.shareId" /> @@ -31,8 +31,8 @@ import type { MsTableColumn } from '@/components/pure/ms-table/type'; import useTable from '@/components/pure/ms-table/useTable'; import caseLevel from '@/components/business/ms-case-associate/caseLevel.vue'; - import CaseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue'; import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue'; + import CaseAndScenarioReportDrawer from '@/views/test-plan/report/detail/component/caseAndScenarioReportDrawer.vue'; import { getApiPage, getScenarioPage } from '@/api/modules/test-plan/report'; @@ -41,7 +41,6 @@ import { FilterSlotNameEnum } from '@/enums/tableFilterEnum'; import { casePriorityOptions, lastReportStatusListOptions } from '@/views/api-test/components/config'; - import { executionResultMap } from '@/views/case-management/caseManagementFeature/components/utils'; const props = defineProps<{ reportId: string; diff --git a/frontend/src/views/test-plan/report/detail/component/caseAndScenarioReportDrawer.vue b/frontend/src/views/test-plan/report/detail/component/caseAndScenarioReportDrawer.vue new file mode 100644 index 0000000000..48633dbced --- /dev/null +++ b/frontend/src/views/test-plan/report/detail/component/caseAndScenarioReportDrawer.vue @@ -0,0 +1,115 @@ + + +