|
@@ -9,7 +9,6 @@ import api.common.pojo.vo.home.ServiceVO;
|
|
|
import api.common.pojo.vo.home.SystemServerVO;
|
|
|
import api.common.util.TimeUtil;
|
|
|
import com.css.simulation.resource.feign.MyOauthServerService;
|
|
|
-import com.css.simulation.resource.project.mapper.SimulationProjectMapper;
|
|
|
import com.css.simulation.resource.scene.mapper.SystemAccessMapper;
|
|
|
import com.css.simulation.resource.scene.mapper.SystemServerMapper;
|
|
|
import com.css.simulation.resource.system.mapper.UserMapper;
|
|
@@ -38,23 +37,21 @@ public class HomePageService {
|
|
|
@Autowired
|
|
|
MyOauthServerService myOauthServerService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SimulationProjectMapper simulationProjectMapper;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
public ResponseBodyVO<HardwareVO> selectHardware() {
|
|
|
|
|
|
|
|
|
List<SystemServerPO> systemServerPOList = systemServerMapper.selectAll();
|
|
|
+
|
|
|
+
|
|
|
int weightSum = systemServerPOList.stream().mapToInt(SystemServerPO::getWeight).sum(); // 权重之和
|
|
|
+
|
|
|
HardwareVO build = HardwareVO.builder()
|
|
|
.serverNumber(systemServerPOList.size())
|
|
|
.memoryUsage(systemServerPOList.stream().mapToInt(po -> po.getMemoryUsage() * po.getWeight() / weightSum).sum() + "")
|
|
|
- .diskUsage(systemServerPOList.stream().mapToInt(po -> po.getDiskUsage() * po.getWeight() / weightSum) + "")
|
|
|
- .cpuUsage(systemServerPOList.stream().mapToInt(po -> po.getCpuUsage() * po.getWeight() / weightSum) + "")
|
|
|
- .gpuUsage(systemServerPOList.stream().mapToInt(po -> po.getGpuUsage() * po.getWeight() / weightSum) + "")
|
|
|
+ .diskUsage(systemServerPOList.stream().mapToInt(po -> po.getDiskUsage() * po.getWeight() / weightSum).sum() + "")
|
|
|
+ .cpuUsage(systemServerPOList.stream().mapToInt(po -> po.getCpuUsage() * po.getWeight() / weightSum).sum() + "")
|
|
|
+ .gpuUsage(systemServerPOList.stream().mapToInt(po -> po.getGpuUsage() * po.getWeight() / weightSum).sum() + "")
|
|
|
.build();
|
|
|
|
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, build);
|