From 29a054f0caab87e2c0e5042306881b79e1e32372 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 24 May 2023 14:22:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E7=8E=AF=E5=A2=83=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=B7=E8=BE=93=E5=85=A5=E5=90=8D=E7=A7=B0=E7=9A=84?= =?UTF-8?q?=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1026466 --user=王孝刚 【项目设置】编辑环境-提示请输入名称-实际已经有名称 https://www.tapd.cn/55049933/s/1375017 --- .../api/exec/ApiPoolDebugService.java | 29 ++++++++++++++----- .../service/SystemParameterService.java | 13 --------- .../project/menu/EnvironmentList.vue | 2 +- .../settings/system/BaseSetting.vue | 3 -- .../workspace/environment/EnvironmentList.vue | 2 +- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/exec/ApiPoolDebugService.java b/backend/src/main/java/io/metersphere/api/exec/ApiPoolDebugService.java index d1f7cf0040..4477932404 100644 --- a/backend/src/main/java/io/metersphere/api/exec/ApiPoolDebugService.java +++ b/backend/src/main/java/io/metersphere/api/exec/ApiPoolDebugService.java @@ -11,8 +11,10 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.dto.*; import io.metersphere.service.ProjectApplicationService; +import io.metersphere.service.QuotaService; import io.metersphere.service.SystemParameterService; import io.metersphere.utils.LoggerUtil; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.http.ResponseEntity; @@ -21,6 +23,7 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; @Service @@ -89,15 +92,27 @@ public class ApiPoolDebugService { LoggerUtil.info("校验项目为:【" + projectId + "】", runConfig.getReportId()); ProjectConfig config = projectApplicationService.getProjectConfig(projectId); List poolList = systemParameterService.getTestResourcePool(); - boolean contains = poolList.stream().map(TestResourcePoolDTO::getId) - .collect(Collectors.toList()).contains(config.getResourcePoolId()); - if (StringUtils.isEmpty(config.getResourcePoolId()) || !contains || BooleanUtils.isFalse(config.getPoolEnable())) { - String id = systemParameterService.filterQuota(poolList); - if (StringUtils.isBlank(id)) { - MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池"); + QuotaService baseQuotaService = CommonBeanFactory.getBean(QuotaService.class); + Set poolSets = baseQuotaService.getQuotaResourcePools(); + if (CollectionUtils.isNotEmpty(poolSets)) { + poolList = poolList.stream().filter(pool -> poolSets.contains(pool.getId())).collect(Collectors.toList()); + } + + if (CollectionUtils.isEmpty(poolList)) { + MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池"); + } + + boolean contains = poolList.stream().map(TestResourcePoolDTO::getId) + .collect(Collectors.toList()).contains(config.getResourcePoolId()) && BooleanUtils.isTrue(config.getPoolEnable()); + + if (!contains) { + List pools = poolList.stream().filter(pool -> + StringUtils.equals(pool.getName(), "LOCAL")).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(pools)) { + config.setResourcePoolId(pools.get(0).getId()); } else { - config.setResourcePoolId(id); + config.setResourcePoolId(poolList.get(0).getId()); } } runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig; diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 9c28248776..226e23f2bd 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -286,19 +286,6 @@ public class SystemParameterService { SystemParameterExample example = new SystemParameterExample(); parameters.forEach(param -> { - if (param.getParamKey().equals("base.concurrency")) { - if (StringUtils.isNotEmpty(param.getParamValue())) { - try { - int poolSize = Integer.parseInt(param.getParamValue()); - if (poolSize > 10000) { - MSException.throwException("并发数设置太大,请重新设置"); - } - CommonBeanFactory.getBean(ExecThreadPoolExecutor.class).setCorePoolSize(poolSize); - } catch (Exception e) { - MSException.throwException("并发数设置不规范,请重新设置"); - } - } - } // 去掉路径最后的 / param.setParamValue(StringUtils.removeEnd(param.getParamValue(), "/")); if (StringUtils.equals(param.getParamKey(), "base.url")) { diff --git a/frontend/src/business/components/project/menu/EnvironmentList.vue b/frontend/src/business/components/project/menu/EnvironmentList.vue index 6e9c0dbea8..b987157527 100644 --- a/frontend/src/business/components/project/menu/EnvironmentList.vue +++ b/frontend/src/business/components/project/menu/EnvironmentList.vue @@ -59,7 +59,7 @@ - +