From fd83f2d36216fabb91ead27cf32f02a5de880def Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 25 Oct 2024 10:11:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=B5=84=E6=BA=90=E6=B1=A0):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=B5=84=E6=BA=90=E6=B1=A0=E5=AE=B9=E9=87=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048002 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001048002 --- .../system/mapper/ExtResourcePoolMapper.xml | 4 ++ .../service/TestResourcePoolService.java | 37 +++++++++++-------- 2 files changed, 26 insertions(+), 15 deletions(-) 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 ff5a7991b0..2a053cf66d 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,10 @@ and t.create_user in + + and t.type 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 42f4846791..de8cd3f5d5 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 @@ -300,26 +300,33 @@ public class TestResourcePoolService { ResourcePoolNodeMetric resourcePoolNodeMetric = new ResourcePoolNodeMetric(); TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(request.getPoolId()); if (testResourcePool == null || !testResourcePool.getEnable() || testResourcePool.getDeleted()) { - return null; + return new ResourcePoolNodeMetric(); + } + TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(request.getPoolId()); + byte[] configuration = testResourcePoolBlob.getConfiguration(); + String testResourceDTOStr = new String(configuration); + TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class); + if (CollectionUtils.isEmpty(testResourceDTO.getNodesList())) { + return new ResourcePoolNodeMetric(); } if (StringUtils.isBlank(request.getIp())) { - TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(request.getPoolId()); - byte[] configuration = testResourcePoolBlob.getConfiguration(); - String testResourceDTOStr = new String(configuration); - TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class); - if (CollectionUtils.isNotEmpty(testResourceDTO.getNodesList())) { - int concurrentNumber = 0; - int occupiedConcurrentNumber = 0; - for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) { - ResourcePoolNodeMetric nodeMetric = getNodeMetric(testResourceNodeDTO.getIp(), testResourceNodeDTO.getPort()); - concurrentNumber = concurrentNumber + testResourceNodeDTO.getConcurrentNumber(); - occupiedConcurrentNumber = occupiedConcurrentNumber + nodeMetric.getOccupiedConcurrentNumber(); - } - resourcePoolNodeMetric.setConcurrentNumber(concurrentNumber); - resourcePoolNodeMetric.setOccupiedConcurrentNumber(occupiedConcurrentNumber); + int concurrentNumber = 0; + int occupiedConcurrentNumber = 0; + for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) { + ResourcePoolNodeMetric nodeMetric = getNodeMetric(testResourceNodeDTO.getIp(), testResourceNodeDTO.getPort()); + concurrentNumber = concurrentNumber + testResourceNodeDTO.getConcurrentNumber(); + occupiedConcurrentNumber = occupiedConcurrentNumber + nodeMetric.getOccupiedConcurrentNumber(); } + resourcePoolNodeMetric.setConcurrentNumber(concurrentNumber); + resourcePoolNodeMetric.setOccupiedConcurrentNumber(occupiedConcurrentNumber); } else { resourcePoolNodeMetric = getNodeMetric(request.getIp(), request.getPort()); + for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) { + if (StringUtils.equals(testResourceNodeDTO.getIp(), request.getIp()) && StringUtils.equals(testResourceNodeDTO.getPort(), request.getPort())) { + resourcePoolNodeMetric.setConcurrentNumber(testResourceDTO.getConcurrentNumber()); + break; + } + } } return resourcePoolNodeMetric; }