From 79ca2cfcc2ab542f8baece5c27223a585e76c9e4 Mon Sep 17 00:00:00 2001 From: bayuzhen Date: Thu, 30 May 2024 16:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=A4=A7=E5=B1=8F=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E8=B5=84=E6=BA=90=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ResourceScreenServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bocloud.cos.service/src/main/java/com/bocloud/cos/service/ResourceScreenServiceImpl.java b/bocloud.cos.service/src/main/java/com/bocloud/cos/service/ResourceScreenServiceImpl.java index 106e64f..7db4155 100644 --- a/bocloud.cos.service/src/main/java/com/bocloud/cos/service/ResourceScreenServiceImpl.java +++ b/bocloud.cos.service/src/main/java/com/bocloud/cos/service/ResourceScreenServiceImpl.java @@ -87,12 +87,16 @@ public class ResourceScreenServiceImpl implements ResourceScreenService { List cloudServers = imsInternalService.listVmsByVendor(null, false, requestContext); //私有云平台 List cloudVendors = imsInternalService.listCloudVendor(null); - Set vendors = - cloudVendors.stream().filter(cloudVendor -> !cloudVendor.getIsPublic()) - .map(CloudVendor::getType).collect(Collectors.toSet()); - Set vendorIds = - cloudVendors.stream().filter(cloudVendor -> !cloudVendor.getIsPublic()) - .map(CloudVendor::getId).collect(Collectors.toSet()); + Set vendors = new HashSet<>(); + Set vendorIds = new HashSet<>(); + List noPublicVendors = new ArrayList<>(); + for (CloudVendor cloudVendor : cloudVendors) { + if (!cloudVendor.getIsPublic()) { + noPublicVendors.add(cloudVendor); + vendors.add(cloudVendor.getType()); + vendorIds.add(cloudVendor.getId()); + } + } List priServers = cloudServers.stream().filter( cloudServer -> null != cloudServer.getVendorType() && vendors.contains(cloudServer.getVendorType())) .collect(Collectors.toList()); @@ -116,8 +120,8 @@ public class ResourceScreenServiceImpl implements ResourceScreenService { hosts.removeIf(server -> null == server.getVendorId()); Map> hostMap = hosts.stream().filter(server -> null != server.getVendorId()) .collect(Collectors.groupingBy(com.bocloud.ims.entity.resource.Server::getVendorId)); - List vmVendors = imsInternalService.listCloudVendor(VendorType.VMWARE.name()); - for (CloudVendor vendor : vmVendors) { +// List vmVendors = imsInternalService.listCloudVendor(VendorType.VMWARE.name()); + for (CloudVendor vendor : noPublicVendors) { List servers = Optional.ofNullable(hostMap.get(vendor.getId())).orElse(new ArrayList<>()); for (com.bocloud.ims.entity.resource.Server server : servers) { com.bocloud.ims.entity.resource.ServerConfig config = server.getConfig();