处理大屏展示资源使用情况问题
parent
b24022e835
commit
1876740e27
|
@ -5,8 +5,10 @@ import com.bocloud.entity.bean.GenericEntity;
|
||||||
import com.bocloud.ims.entity.resource.CloudVendor;
|
import com.bocloud.ims.entity.resource.CloudVendor;
|
||||||
import com.bocloud.ims.entity.resource.Ip;
|
import com.bocloud.ims.entity.resource.Ip;
|
||||||
import com.bocloud.ims.entity.resource.Server;
|
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.CloudVendorRepository;
|
||||||
import com.bocloud.ims.repository.resource.IpRepository;
|
import com.bocloud.ims.repository.resource.IpRepository;
|
||||||
|
import com.bocloud.ims.repository.resource.ServerConfigRepository;
|
||||||
import com.bocloud.ims.repository.resource.ServerRepository;
|
import com.bocloud.ims.repository.resource.ServerRepository;
|
||||||
import com.bocloud.rpc.interfaces.ims.ImsRpcService;
|
import com.bocloud.rpc.interfaces.ims.ImsRpcService;
|
||||||
import com.bocloud.service.lock.BocloudACLock;
|
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.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@ -33,6 +34,8 @@ public class ImsRpcServiceImpl implements ImsRpcService {
|
||||||
private ServerRepository serverRepository;
|
private ServerRepository serverRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CloudVendorRepository cloudVendorRepositoryl;
|
private CloudVendorRepository cloudVendorRepositoryl;
|
||||||
|
@Autowired
|
||||||
|
private ServerConfigRepository serverConfigRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preemptOrFreeIp(List<String> ipsToPreempt, List<String> ipsToFree) {
|
public void preemptOrFreeIp(List<String> ipsToPreempt, List<String> ipsToFree) {
|
||||||
|
@ -79,8 +82,15 @@ public class ImsRpcServiceImpl implements ImsRpcService {
|
||||||
.col(CloudVendor::getId).in(vendorIds)
|
.col(CloudVendor::getId).in(vendorIds)
|
||||||
.list();
|
.list();
|
||||||
List<Server> servers = new ArrayList<>();
|
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) {
|
for (CloudVendor cloudVendor : vendorList) {
|
||||||
List<Server> list = this.serverRepository.list(1, 100000, null, null, null, cloudVendor.getType(), null, null);
|
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);
|
servers.addAll(list);
|
||||||
}
|
}
|
||||||
return servers;
|
return servers;
|
||||||
|
|
Loading…
Reference in New Issue