From 1876740e27a6c59e7967b0eefe4bc8410991c980 Mon Sep 17 00:00:00 2001 From: bayuzhen Date: Thu, 30 May 2024 16:47:28 +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 --- .../ims/service/rpc/ImsRpcServiceImpl.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java index 1ded508..6e335e0 100644 --- a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java +++ b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java @@ -5,8 +5,10 @@ import com.bocloud.entity.bean.GenericEntity; import com.bocloud.ims.entity.resource.CloudVendor; import com.bocloud.ims.entity.resource.Ip; import com.bocloud.ims.entity.resource.Server; +import com.bocloud.ims.entity.resource.ServerConfig; import com.bocloud.ims.repository.resource.CloudVendorRepository; import com.bocloud.ims.repository.resource.IpRepository; +import com.bocloud.ims.repository.resource.ServerConfigRepository; import com.bocloud.ims.repository.resource.ServerRepository; import com.bocloud.rpc.interfaces.ims.ImsRpcService; import com.bocloud.service.lock.BocloudACLock; @@ -16,10 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Slf4j @Service @@ -33,6 +34,8 @@ public class ImsRpcServiceImpl implements ImsRpcService { private ServerRepository serverRepository; @Autowired private CloudVendorRepository cloudVendorRepositoryl; + @Autowired + private ServerConfigRepository serverConfigRepository; @Override public void preemptOrFreeIp(List ipsToPreempt, List ipsToFree) { @@ -79,8 +82,15 @@ public class ImsRpcServiceImpl implements ImsRpcService { .col(CloudVendor::getId).in(vendorIds) .list(); List servers = new ArrayList<>(); + // 获取serverConfig + List serverConfigList = serverConfigRepository.queryProxy().list(); + Map serverConfigMap = serverConfigList.stream() + .collect(Collectors.toMap(ServerConfig::getServerId, serverConfig -> serverConfig)); for (CloudVendor cloudVendor : vendorList) { List list = this.serverRepository.list(1, 100000, null, null, null, cloudVendor.getType(), null, null); + for (Server server : list) { + server.setConfig(serverConfigMap.get(server.getId())); + } servers.addAll(list); } return servers;