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

develop
bayuzhen 2024-05-30 16:47:28 +08:00
parent b24022e835
commit 1876740e27
1 changed files with 13 additions and 3 deletions

View File

@ -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<String> ipsToPreempt, List<String> ipsToFree) {
@ -79,8 +82,15 @@ public class ImsRpcServiceImpl implements ImsRpcService {
.col(CloudVendor::getId).in(vendorIds)
.list();
List<Server> servers = new ArrayList<>();
// 获取serverConfig
List<ServerConfig> serverConfigList = serverConfigRepository.queryProxy().list();
Map<Long, ServerConfig> serverConfigMap = serverConfigList.stream()
.collect(Collectors.toMap(ServerConfig::getServerId, serverConfig -> serverConfig));
for (CloudVendor cloudVendor : vendorList) {
List<Server> 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;