fix(资源池): 修复资源池容量显示不正确问题

--bug=1048002 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001048002
This commit is contained in:
guoyuqi 2024-10-25 10:11:46 +08:00 committed by Craftsman
parent 53982f7bee
commit fd83f2d362
2 changed files with 26 additions and 15 deletions

View File

@ -36,6 +36,10 @@
and t.create_user in and t.create_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/> <include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when> </when>
<when test="key=='type'">
and t.type in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<when test="key=='orgId'"> <when test="key=='orgId'">
and t.id in ( and t.id in (
select tpo.test_resource_pool_id from test_resource_pool_organization tpo where tpo.org_id in select tpo.test_resource_pool_id from test_resource_pool_organization tpo where tpo.org_id in

View File

@ -300,14 +300,16 @@ public class TestResourcePoolService {
ResourcePoolNodeMetric resourcePoolNodeMetric = new ResourcePoolNodeMetric(); ResourcePoolNodeMetric resourcePoolNodeMetric = new ResourcePoolNodeMetric();
TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(request.getPoolId()); TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(request.getPoolId());
if (testResourcePool == null || !testResourcePool.getEnable() || testResourcePool.getDeleted()) { if (testResourcePool == null || !testResourcePool.getEnable() || testResourcePool.getDeleted()) {
return null; return new ResourcePoolNodeMetric();
} }
if (StringUtils.isBlank(request.getIp())) {
TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(request.getPoolId()); TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(request.getPoolId());
byte[] configuration = testResourcePoolBlob.getConfiguration(); byte[] configuration = testResourcePoolBlob.getConfiguration();
String testResourceDTOStr = new String(configuration); String testResourceDTOStr = new String(configuration);
TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class); TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class);
if (CollectionUtils.isNotEmpty(testResourceDTO.getNodesList())) { if (CollectionUtils.isEmpty(testResourceDTO.getNodesList())) {
return new ResourcePoolNodeMetric();
}
if (StringUtils.isBlank(request.getIp())) {
int concurrentNumber = 0; int concurrentNumber = 0;
int occupiedConcurrentNumber = 0; int occupiedConcurrentNumber = 0;
for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) { for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) {
@ -317,9 +319,14 @@ public class TestResourcePoolService {
} }
resourcePoolNodeMetric.setConcurrentNumber(concurrentNumber); resourcePoolNodeMetric.setConcurrentNumber(concurrentNumber);
resourcePoolNodeMetric.setOccupiedConcurrentNumber(occupiedConcurrentNumber); resourcePoolNodeMetric.setOccupiedConcurrentNumber(occupiedConcurrentNumber);
}
} else { } else {
resourcePoolNodeMetric = getNodeMetric(request.getIp(), request.getPort()); 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; return resourcePoolNodeMetric;
} }