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();