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,26 +300,33 @@ 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();
}
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())) { if (StringUtils.isBlank(request.getIp())) {
TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(request.getPoolId()); int concurrentNumber = 0;
byte[] configuration = testResourcePoolBlob.getConfiguration(); int occupiedConcurrentNumber = 0;
String testResourceDTOStr = new String(configuration); for (TestResourceNodeDTO testResourceNodeDTO : testResourceDTO.getNodesList()) {
TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class); ResourcePoolNodeMetric nodeMetric = getNodeMetric(testResourceNodeDTO.getIp(), testResourceNodeDTO.getPort());
if (CollectionUtils.isNotEmpty(testResourceDTO.getNodesList())) { concurrentNumber = concurrentNumber + testResourceNodeDTO.getConcurrentNumber();
int concurrentNumber = 0; occupiedConcurrentNumber = occupiedConcurrentNumber + nodeMetric.getOccupiedConcurrentNumber();
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);
} }
resourcePoolNodeMetric.setConcurrentNumber(concurrentNumber);
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;
} }