martin vor 3 Jahren
Ursprung
Commit
d7364e53cc

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/MyOauthServerServiceFallback.java

@@ -4,7 +4,7 @@ import api.common.pojo.common.ResponseBodyVO;
 import com.css.simulation.resource.feign.MyOauthServerService;
 import org.springframework.stereotype.Service;
 
-@Service
+
 public class MyOauthServerServiceFallback implements MyOauthServerService {
 
 

+ 4 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/HomePageController.java

@@ -136,7 +136,7 @@ public class HomePageController {
     /**
      * 硬件监控
      */
-    @PostMapping("selectHardware")
+    @RequestMapping("selectHardware")
     @ResponseBody
     public ResponseBodyVO<HardwareVO> selectHardware() {
         return homePageService.selectHardware();
@@ -145,7 +145,7 @@ public class HomePageController {
     /**
      * 服务监控
      */
-    @PostMapping("selectService")
+    @RequestMapping("selectService")
     @ResponseBody
     public ResponseBodyVO<ServiceVO> selectService() {
         return homePageService.selectService();
@@ -154,7 +154,7 @@ public class HomePageController {
     /**
      * 日访问人数
      */
-    @PostMapping("selectAccess")
+    @RequestMapping("selectAccess")
     @ResponseBody
     public ResponseBodyVO<List<AccessVO>> selectAccess() {
         return homePageService.selectAccess();
@@ -164,7 +164,7 @@ public class HomePageController {
     /**
      * 服务器监控
      */
-    @PostMapping("selectServer")
+    @RequestMapping("selectServer")
     @ResponseBody
     public ResponseBodyVO<PageInfo<SystemServerVO>> selectServer(PageVO pageVO) {
         return homePageService.selectServer(pageVO);

+ 6 - 9
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/HomePageService.java

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