From f5706f2a44388abf73d94a98b15fe6afb0318feb Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 20 Sep 2024 12:52:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=B1=A0=E5=88=97=E8=A1=A8=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/i18n/commons.properties | 1 + .../resources/i18n/commons_en_US.properties | 1 + .../resources/i18n/commons_zh_CN.properties | 1 + .../resources/i18n/commons_zh_TW.properties | 1 + .../system/dto/pool/TestResourcePoolDTO.java | 11 ++++++++++ .../system/mapper/ExtResourcePoolMapper.xml | 6 +++++ .../service/TestResourcePoolService.java | 22 +++++++++++++++++++ 7 files changed, 43 insertions(+) diff --git a/backend/framework/sdk/src/main/resources/i18n/commons.properties b/backend/framework/sdk/src/main/resources/i18n/commons.properties index bb93cd98d9..ce343c0a83 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons.properties @@ -435,6 +435,7 @@ http_result_not_found=%s不存在 enum_value_valid_message=枚举值不合法,必须为 #system organization +all_organization=全部组织 organization_member_log=组织成员 #system project project_admin=项目管理员 diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties index afcda0260d..91d039593e 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties @@ -70,6 +70,7 @@ start_time_is_null=Start time cannot be null end_time_is_null=End time cannot be null #organization +all_organization=All Organization organization_not_exists=Organization is not exists #test resource pool test_resource_pool_id_is_null=Test Resource Pool ID cannot be null diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties index d7b2e6d252..994f04cde5 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties @@ -70,6 +70,7 @@ startTime_must_be_less_than_endTime=开始日期必须小于结束日期 start_time_is_null=开始日期不能为空 end_time_is_null=结束日期不能为空 +all_organization=全部组织 organization_not_exists=组织不存在 #test resource pool test_resource_pool_id_is_null=资源池ID不能为空 diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties index acb6d472c7..ec1f993361 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties @@ -70,6 +70,7 @@ end_time_is_null=結束日期不能為空 resource.name=資源 #organization +all_organization=全部組織 organization_not_exists=組織不存在 #test resource pool test_resource_pool_id_is_null=資源池ID不能為空 diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/pool/TestResourcePoolDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/pool/TestResourcePoolDTO.java index 965afb21a8..51f29bf840 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/pool/TestResourcePoolDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/pool/TestResourcePoolDTO.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @Data @EqualsAndHashCode(callSuper = false) public class TestResourcePoolDTO extends TestResourcePool { @@ -13,4 +15,13 @@ public class TestResourcePoolDTO extends TestResourcePool { @Schema(description = "资源池是否在使用中") private Boolean inUsed; + @Schema(description = "最大并发数") + private int maxConcurrentNumber; + + @Schema(description = "剩余并发数") + private Boolean lastConcurrentNumber;; + + @Schema(description = "组织名称集合") + private List orgNames; + } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtResourcePoolMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtResourcePoolMapper.xml index 46b8cbad48..c7e49a5931 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtResourcePoolMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtResourcePoolMapper.xml @@ -36,6 +36,12 @@ and t.create_user in + + and t.id in ( + select tpo.test_resource_pool_id from test_resource_pool_organization tpo where tpo.org_id in + + ) + diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TestResourcePoolService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TestResourcePoolService.java index 5d7baef4e0..169a31719f 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TestResourcePoolService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TestResourcePoolService.java @@ -141,6 +141,28 @@ public class TestResourcePoolService { if (pool.getAllOrg() || CollectionUtils.isNotEmpty(testResourcePoolOrganizations)) { testResourcePoolDTO.setInUsed(true); } + //增加组织名称 + if (pool.getAllOrg()) { + testResourcePoolDTO.setOrgNames(List.of(Translator.get("all_organization"))); + } else if (CollectionUtils.isNotEmpty(testResourcePoolOrganizations)) { + List orgIds = testResourcePoolOrganizations.stream().map(TestResourcePoolOrganization::getOrgId).distinct().toList(); + OrganizationExample organizationExample = new OrganizationExample(); + organizationExample.createCriteria().andIdIn(orgIds); + List organizations = organizationMapper.selectByExample(organizationExample); + List orgNameList = organizations.stream().map(Organization::getName).distinct().toList(); + testResourcePoolDTO.setOrgNames(orgNameList); + } + //获取最大并发 + if (StringUtils.equalsIgnoreCase(pool.getType(),ResourcePoolTypeEnum.NODE.toString())) { + int concurrentNumber = 0; + for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) { + concurrentNumber = concurrentNumber+testResourceNodeDTO.getConcurrentNumber(); + } + testResourcePoolDTO.setMaxConcurrentNumber(concurrentNumber); + } else { + testResourcePoolDTO.setMaxConcurrentNumber(testResourceDTO.getConcurrentNumber()); + } + //TODO: 调接口获取剩余并发 testResourcePoolDTOS.add(testResourcePoolDTO); }); return testResourcePoolDTOS;