From 2e44835dcbbfc157660e26a60347accc101a4fb0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 17 Feb 2022 19:43:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E5=BC=95=E7=94=A8=E8=AE=BE=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/exec/api/ApiCaseExecuteService.java | 4 +- .../api/service/ApiAutomationService.java | 16 ++-- .../mapper/ext/ExtApiScenarioReportMapper.xml | 4 +- .../base/mapper/ext/ExtTaskMapper.xml | 4 +- .../scenario/common/ApiBaseComponent.vue | 73 +++++++++++-------- .../component/ApiScenarioComponent.vue | 23 +----- .../scenario/component/StepExtendBtns.vue | 60 ++++++++++++++- 7 files changed, 120 insertions(+), 64 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java index ee63f2cd31..b34f1c4929 100644 --- a/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java @@ -201,7 +201,9 @@ public class ApiCaseExecuteService { report.setName(caseWithBLOBs.getName()); report.setProjectId(caseWithBLOBs.getProjectId()); report.setVersionId(caseWithBLOBs.getVersionId()); - report.setIntegratedReportId(finalSerialReportId); + if (StringUtils.isNotEmpty(finalSerialReportId)) { + report.setIntegratedReportId(finalSerialReportId); + } executeQueue.put(caseWithBLOBs.getId(), report); responseDTOS.add(new MsExecResponseDTO(caseWithBLOBs.getId(), report.getId(), request.getTriggerMode())); }); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index dd7300e09f..08dc943a5c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -701,13 +701,15 @@ public class ApiAutomationService { } else { String scenarioId = request.getId(); ApiScenarioWithBLOBs apiScenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(scenarioId); - String environmentType = apiScenarioWithBLOBs.getEnvironmentType(); - String environmentGroupId = apiScenarioWithBLOBs.getEnvironmentGroupId(); - String environmentJson = apiScenarioWithBLOBs.getEnvironmentJson(); - if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) { - environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId); - } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) { - environmentMap = JSON.parseObject(environmentJson, Map.class); + if (apiScenarioWithBLOBs != null) { + String environmentType = apiScenarioWithBLOBs.getEnvironmentType(); + String environmentGroupId = apiScenarioWithBLOBs.getEnvironmentGroupId(); + String environmentJson = apiScenarioWithBLOBs.getEnvironmentJson(); + if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) { + environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId); + } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) { + environmentMap = JSON.parseObject(environmentJson, Map.class); + } } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index cb166de194..b60fad0767 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -127,7 +127,7 @@ 'Saved' as execute_type, 'API_INDEPENDENT' as report_type from api_definition_exec_result a_r - where a_r.integrated_report_id is null + where a_r.integrated_report_id is null or a_r.integrated_report_id = 'null' ) r @@ -211,7 +211,7 @@ 'Saved' as execute_type, 'API_INDEPENDENT' as report_type from api_definition_exec_result a_r - where a_r.integrated_report_id is null + where a_r.integrated_report_id is null or a_r.integrated_report_id = 'null' ) r diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml index 5544a2e27f..f75dc5edf2 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml @@ -33,7 +33,7 @@ and t.user_id = #{request.executor} - and t.integrated_report_id is null + and (t.integrated_report_id is null or t.integrated_report_id = 'null') ) UNION ALL (select t.id,t.name,'PERFORMANCE' as executionModule, ifnull(t2.name,'LOCAL') as actuator, t1.`name` as executor,t.create_time as executionTime, t.trigger_mode as triggerMode ,t.`status` as executionStatus @@ -80,7 +80,7 @@ from api_definition_exec_result t left join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on t.actuator = t2.id left join api_definition t3 on t.resource_id = t3.id left join api_test_case t4 on t4.id = t.resource_id left join test_plan_api_case t5 on t.resource_id = t5.id left join test_plan t6 on t5.test_plan_id = t6.id - where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.integrated_report_id is null and (t3.project_id =#{request.projectId} OR t4.project_id =#{request.projectId} OR t6.project_id = #{request.projectId}) and t.status not in ("saved","completed","success","error","STOP") + where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and (t.integrated_report_id is null t.integrated_report_id='null') and (t3.project_id =#{request.projectId} OR t4.project_id =#{request.projectId} OR t6.project_id = #{request.projectId}) and t.status not in ("saved","completed","success","error","STOP") ) UNION ALL (select t.id,t.create_time as executionTime diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue index df46160d3a..4b2d7ca846 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue @@ -10,23 +10,22 @@ - + - + {{ data.name }} {{ getMethod() }} - + -
@@ -39,7 +38,15 @@ - +
@@ -66,6 +73,7 @@