处理大屏展示资源使用情况问题

develop
bayuzhen 2024-05-30 16:23:12 +08:00
parent 07329a2e0c
commit 79ca2cfcc2
1 changed files with 12 additions and 8 deletions

View File

@ -87,12 +87,16 @@ public class ResourceScreenServiceImpl implements ResourceScreenService {
List<CloudServer> cloudServers = imsInternalService.listVmsByVendor(null, false, requestContext); List<CloudServer> cloudServers = imsInternalService.listVmsByVendor(null, false, requestContext);
//私有云平台 //私有云平台
List<CloudVendor> cloudVendors = imsInternalService.listCloudVendor(null); List<CloudVendor> cloudVendors = imsInternalService.listCloudVendor(null);
Set<String> vendors = Set<String> vendors = new HashSet<>();
cloudVendors.stream().filter(cloudVendor -> !cloudVendor.getIsPublic()) Set<Long> vendorIds = new HashSet<>();
.map(CloudVendor::getType).collect(Collectors.toSet()); List<CloudVendor> noPublicVendors = new ArrayList<>();
Set<Long> vendorIds = for (CloudVendor cloudVendor : cloudVendors) {
cloudVendors.stream().filter(cloudVendor -> !cloudVendor.getIsPublic()) if (!cloudVendor.getIsPublic()) {
.map(CloudVendor::getId).collect(Collectors.toSet()); noPublicVendors.add(cloudVendor);
vendors.add(cloudVendor.getType());
vendorIds.add(cloudVendor.getId());
}
}
List<CloudServer> priServers = cloudServers.stream().filter( List<CloudServer> priServers = cloudServers.stream().filter(
cloudServer -> null != cloudServer.getVendorType() && vendors.contains(cloudServer.getVendorType())) cloudServer -> null != cloudServer.getVendorType() && vendors.contains(cloudServer.getVendorType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -116,8 +120,8 @@ public class ResourceScreenServiceImpl implements ResourceScreenService {
hosts.removeIf(server -> null == server.getVendorId()); hosts.removeIf(server -> null == server.getVendorId());
Map<Long, List<com.bocloud.ims.entity.resource.Server>> hostMap = hosts.stream().filter(server -> null != server.getVendorId()) Map<Long, List<com.bocloud.ims.entity.resource.Server>> hostMap = hosts.stream().filter(server -> null != server.getVendorId())
.collect(Collectors.groupingBy(com.bocloud.ims.entity.resource.Server::getVendorId)); .collect(Collectors.groupingBy(com.bocloud.ims.entity.resource.Server::getVendorId));
List<CloudVendor> vmVendors = imsInternalService.listCloudVendor(VendorType.VMWARE.name()); // List<CloudVendor> vmVendors = imsInternalService.listCloudVendor(VendorType.VMWARE.name());
for (CloudVendor vendor : vmVendors) { for (CloudVendor vendor : noPublicVendors) {
List<com.bocloud.ims.entity.resource.Server> servers = Optional.ofNullable(hostMap.get(vendor.getId())).orElse(new ArrayList<>()); List<com.bocloud.ims.entity.resource.Server> servers = Optional.ofNullable(hostMap.get(vendor.getId())).orElse(new ArrayList<>());
for (com.bocloud.ims.entity.resource.Server server : servers) { for (com.bocloud.ims.entity.resource.Server server : servers) {
com.bocloud.ims.entity.resource.ServerConfig config = server.getConfig(); com.bocloud.ims.entity.resource.ServerConfig config = server.getConfig();