diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index ab64c2e6f8..9d58630422 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -49,8 +49,10 @@ import io.metersphere.request.ScheduleRequest; import io.metersphere.service.*; import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.LoggerUtil; -import io.metersphere.service.ApiPoolDebugService; import io.metersphere.xpack.track.dto.IssuesDao; +import jakarta.annotation.Resource; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.BooleanUtils; @@ -67,9 +69,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; @@ -1584,6 +1583,7 @@ public class TestPlanService { /** * 合并ui场景的环境信息 + * * @param planId * @param scenarioEnv * @return diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java index b6186e7aca..520b6441a3 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java @@ -6,18 +6,22 @@ import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.*; -import io.metersphere.plan.dto.*; +import io.metersphere.plan.dto.ApiModuleDTO; +import io.metersphere.plan.dto.BatchRunDefinitionRequest; +import io.metersphere.plan.dto.TestCaseReportStatusResultDTO; +import io.metersphere.plan.dto.TestPlanSimpleReportDTO; import io.metersphere.plan.request.api.ApiTestCaseRequest; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.utils.DiscoveryUtil; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -47,7 +51,11 @@ public class PlanTestPlanApiCaseService extends ApiTestService { //记录接口用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); try { - report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + if (MapUtils.isEmpty(report.getProjectEnvMap())) { + report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + } else { + report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList)); + } } catch (Exception e) { LogUtil.error(e); } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java index bc9b09949f..6cc47e4039 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java @@ -12,12 +12,13 @@ import io.metersphere.plan.request.api.ApiScenarioRequest; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.utils.DiscoveryUtil; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -40,7 +41,11 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService { //记录接口用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); try { - report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + if (MapUtils.isEmpty(report.getProjectEnvMap())) { + report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + } else { + report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList)); + } } catch (Exception e) { LogUtil.error(e); } @@ -115,7 +120,7 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService { } public RunModeConfigDTO setScenarioEnv(String planId, RunModeConfigDTO runModeConfig) { - return microService.postForData(serviceName, BASE_UEL + "/set/env/" + planId, runModeConfig, RunModeConfigDTO.class); + return microService.postForData(serviceName, BASE_UEL + "/set/env/" + planId, runModeConfig, RunModeConfigDTO.class); } public void relevanceByTestIds(List scenarioIds, String planId) { diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java index 2fe8160493..9834d53751 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java @@ -17,12 +17,13 @@ import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.request.ResetOrderRequest; import io.metersphere.utils.DiscoveryUtil; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -70,7 +71,11 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService { //记录UI用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); try { - report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + if (MapUtils.isEmpty(report.getProjectEnvMap())) { + report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + } else { + report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList)); + } } catch (Exception e) { LogUtil.error(e); }