martin %!s(int64=3) %!d(string=hai) anos
pai
achega
bfb49aec33
Modificáronse 17 ficheiros con 436 adicións e 86 borrados
  1. 7 1
      api-common/pom.xml
  2. 73 0
      api-common/src/main/java/api/common/pojo/dto/Gpu.java
  3. 31 0
      api-common/src/main/java/api/common/pojo/dto/Process.java
  4. 5 4
      api-common/src/main/java/api/common/pojo/vo/home/ServiceVO.java
  5. 232 8
      api-common/src/main/java/api/common/util/SshUtil.java
  6. 11 0
      simulation-oauth-client/pom.xml
  7. 26 3
      simulation-oauth-client/src/main/java/com/css/simulation/oauth/client/controller/SignController.java
  8. 10 0
      simulation-oauth-client/src/main/resources/bootstrap-windowstest.yaml
  9. 0 39
      simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/controller/OauthServerController.java
  10. 4 6
      simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/scheduler/MyScheduler.java
  11. 15 4
      simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/controller/TaskController.java
  12. 1 2
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java
  13. 5 5
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/OauthClientService.java
  14. 2 2
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/OauthClientServiceFallback.java
  15. 6 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/ctrl/HomePageController.java
  16. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemAccessMapper.java
  17. 7 7
      simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/HomePageService.java

+ 7 - 1
api-common/pom.xml

@@ -16,11 +16,17 @@
         <maven.compiler.target>8</maven.compiler.target>
         <jackson-core.version>2.13.1</jackson-core.version>
         <sshd-netty.version>2.8.0</sshd-netty.version>
+        <dom4j.version>2.1.3</dom4j.version>
     </properties>
 
     <dependencies>
 
-
+        <!-- xml 处理库 -->
+        <dependency>
+            <groupId>org.dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>${dom4j.version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.sshd</groupId>

+ 73 - 0
api-common/src/main/java/api/common/pojo/dto/Gpu.java

@@ -0,0 +1,73 @@
+package api.common.pojo.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+public class Gpu {
+    //名称
+    private String name;
+    //总内存
+    private String totalMemory;
+    //已用内存
+    private String usedMemory;
+    //空闲内存
+    private String freeMemory;
+ 
+    /**
+     * 使用率 整形,最大为100
+     */
+    private int usageRate;
+    //进程信息
+    private List<Process> processes;
+ 
+    public String getName() {
+        return name;
+    }
+ 
+    public void setName(String name) {
+        this.name = name;
+    }
+ 
+    public String getTotalMemory() {
+        return totalMemory;
+    }
+ 
+    public void setTotalMemory(String totalMemory) {
+        this.totalMemory = totalMemory;
+    }
+ 
+    public String getUsedMemory() {
+        return usedMemory;
+    }
+ 
+    public void setUsedMemory(String usedMemory) {
+        this.usedMemory = usedMemory;
+    }
+ 
+    public String getFreeMemory() {
+        return freeMemory;
+    }
+ 
+    public void setFreeMemory(String freeMemory) {
+        this.freeMemory = freeMemory;
+    }
+ 
+    public int getUsageRate() {
+        return usageRate;
+    }
+ 
+    public void setUsageRate(int usageRate) {
+        this.usageRate = usageRate;
+    }
+ 
+    public List<Process> getProcesses() {
+        return processes;
+    }
+ 
+    public void setProcesses(List<Process> processes) {
+        this.processes = processes;
+    }
+}

+ 31 - 0
api-common/src/main/java/api/common/pojo/dto/Process.java

@@ -0,0 +1,31 @@
+package api.common.pojo.dto;
+
+public class Process {
+    private String pid;
+    private String name;
+    private String usedMemory;
+ 
+    public String getPid() {
+        return pid;
+    }
+ 
+    public void setPid(String pid) {
+        this.pid = pid;
+    }
+ 
+    public String getName() {
+        return name;
+    }
+ 
+    public void setName(String name) {
+        this.name = name;
+    }
+ 
+    public String getUsedMemory() {
+        return usedMemory;
+    }
+ 
+    public void setUsedMemory(String usedMemory) {
+        this.usedMemory = usedMemory;
+    }
+}

+ 5 - 4
api-common/src/main/java/api/common/pojo/vo/home/ServiceVO.java

@@ -1,15 +1,16 @@
 package api.common.pojo.vo.home;
 
 
-import api.common.pojo.common.CommonPO;
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
 
-@EqualsAndHashCode(callSuper = true)
 @Data
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
-public class ServiceVO extends CommonPO {
+public class ServiceVO {
 
     Integer userNumber;
     Integer onlineNumber;

+ 232 - 8
api-common/src/main/java/api/common/util/SshUtil.java

@@ -1,15 +1,21 @@
 package api.common.util;
 
 
+import api.common.pojo.dto.Gpu;
 import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.channel.ChannelExec;
 import org.apache.sshd.client.channel.ClientChannelEvent;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.session.ClientSession;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.Collections;
+import java.util.*;
+
 
 /**
  * https://github.com/apache/mina-sshd
@@ -26,13 +32,12 @@ public class SshUtil {
     private static final int port = 22;
 
     /**
-     *
-     * @param hostname  主机名或 IP
-     * @param username  用户名
-     * @param password  密码
-     * @param command   命令
-     * @return  执行结果
-     * @throws IOException  异常
+     * @param hostname 主机名或 IP
+     * @param username 用户名
+     * @param password 密码
+     * @param command  命令
+     * @return 执行结果
+     * @throws IOException 异常
      */
     public static String execute(String hostname, String username, String password, String command) throws IOException {
         String result;
@@ -62,4 +67,223 @@ public class SshUtil {
     }
 
 
+    /**
+     * 获取 cpu 使用率
+     */
+    public static double cpu(String hostname, String username, String password) throws IOException, InterruptedException {
+
+        Map<?, ?> map1 = cpuInfo(hostname, username, password);
+        Thread.sleep(5 * 1000);
+        Map<?, ?> map2 = cpuInfo(hostname, username, password);
+
+        long user1 = Long.parseLong(map1.get("user").toString());
+        long nice1 = Long.parseLong(map1.get("nice").toString());
+        long system1 = Long.parseLong(map1.get("system").toString());
+        long idle1 = Long.parseLong(map1.get("idle").toString());
+
+        long user2 = Long.parseLong(map2.get("user").toString());
+        long nice2 = Long.parseLong(map2.get("nice").toString());
+        long system2 = Long.parseLong(map2.get("system").toString());
+        long idle2 = Long.parseLong(map2.get("idle").toString());
+
+        long total1 = user1 + system1 + nice1;
+        long total2 = user2 + system2 + nice2;
+        double total = total2 - total1;
+
+        long totalIdle1 = user1 + nice1 + system1 + idle1;
+        long totalIdle2 = user2 + nice2 + system2 + idle2;
+        double totalIdle = totalIdle2 - totalIdle1;
+
+        return total / totalIdle;
+
+    }
+
+
+    /**
+     * 功能:CPU使用信息
+     */
+    private static Map<?, ?> cpuInfo(String hostname, String username, String password) throws IOException {
+
+        String execute = SshUtil.execute(hostname, username, password, "cat /proc/stat");
+        String[] split = execute.split("\n");
+        Map<String, Object> map = new HashMap<>();
+        for (String line : split) {
+            if (line.startsWith("cpu")) {
+                StringTokenizer tokenizer = new StringTokenizer(line);
+                List<String> temp = new ArrayList<>();
+                while (tokenizer.hasMoreElements()) {
+                    String value = tokenizer.nextToken();
+                    temp.add(value);
+                }
+                map.put("user", temp.get(1));
+                map.put("nice", temp.get(2));
+                map.put("system", temp.get(3));
+                map.put("idle", temp.get(4));
+                map.put("iowait", temp.get(5));
+                map.put("irq", temp.get(6));
+                map.put("softirq", temp.get(7));
+                map.put("stealstolen", temp.get(8));
+                break;
+            }
+        }
+
+        return map;
+    }
+
+
+    /**
+     * 功能:CPU使用信息
+     */
+    public static List<Gpu> gpu(String hostname, String username, String password) throws IOException, DocumentException {
+        String execute = SshUtil.execute(hostname, username, password, "nvidia-smi -q -x");
+        String REG = "<!DOCTYPE.*.dtd\">";
+        execute = execute.replaceAll(REG, "");
+        Document document = DocumentHelper.parseText(execute);
+        List<Element> gpu = document.getRootElement().elements("gpu");
+        List<Gpu> gpuList = new ArrayList<>();
+        gpu.forEach(element -> {
+            Gpu gpuInfo = new Gpu();
+            String uuid = element.element("uuid").getText();
+            Element fbMemoryUsage = element.element("fb_memory_usage");
+            String total = fbMemoryUsage.element("total").getText();
+            String used = fbMemoryUsage.element("used").getText();
+            String free = fbMemoryUsage.element("free").getText();
+            gpuInfo.setTotalMemory(total);
+            gpuInfo.setUsedMemory(used);
+            gpuInfo.setFreeMemory(free);
+            gpuInfo.setName(uuid);
+            Element processes = element.element("processes");
+            List<Element> infos = processes.elements("process_info");
+            List<api.common.pojo.dto.Process> processInfos = new ArrayList<>();
+            infos.forEach(info -> {
+                api.common.pojo.dto.Process process = new api.common.pojo.dto.Process();
+                String pid = info.element("pid").getText();
+                String name = info.element("process_name").getText();
+                String usedMemory = info.element("used_memory").getText();
+                process.setPid(pid);
+                process.setName(name);
+                process.setUsedMemory(usedMemory);
+                processInfos.add(process);
+            });
+            gpuInfo.setProcesses(processInfos);
+            int intTotal = Integer.parseInt(total.split(" ")[0]);
+            int intUsed = Integer.parseInt(used.split(" ")[0]);
+            gpuInfo.setUsageRate((int) ((float) intUsed / intTotal * 100));
+            gpuList.add(gpuInfo);
+        });
+        return gpuList;
+    }
+
+
+    /**
+     * 内存使用率
+     *
+     * @param hostname 主机名
+     * @param username 用户名
+     * @param password 密码
+     * @return 剩余可用内存
+     */
+    public static double memory0(String hostname, String username, String password) throws IOException {
+        String execute = SshUtil.execute(hostname, username, password, "cat /proc/meminfo");
+        String[] split = execute.split("\n");
+        Map<String, Object> map = new HashMap<>();
+        for (String line : split) {
+            if (line == null)
+                break;
+            int beginIndex = 0;
+            int endIndex = line.indexOf(":");
+            if (endIndex != -1) {
+                String key = line.substring(beginIndex, endIndex);
+                beginIndex = endIndex + 1;
+                endIndex = line.length();
+                String memory = line.substring(beginIndex, endIndex);
+                String value = memory.replace("kB", "").trim();
+                map.put(key, value);
+            }
+        }
+
+        long memTotal = Long.parseLong(map.get("MemTotal").toString());
+        long memFree = Long.parseLong(map.get("MemFree").toString());
+        long memused = memTotal - memFree;
+        long buffers = Long.parseLong(map.get("Buffers").toString());
+        long cached = Long.parseLong(map.get("Cached").toString());
+
+        return (double) (memused - buffers - cached) / memTotal;
+    }
+
+    /**
+     * 剩余可用内存
+     *
+     * @param hostname 主机名
+     * @param username 用户名
+     * @param password 密码
+     * @return 剩余可用内存
+     */
+    public static double memory1(String hostname, String username, String password) throws IOException {
+        String execute = SshUtil.execute(hostname, username, password, "cat /proc/meminfo");
+        String[] split = execute.split("\n");
+        Map<String, Object> map = new HashMap<>();
+        for (String line : split) {
+            if (line == null)
+                break;
+            int beginIndex = 0;
+            int endIndex = line.indexOf(":");
+            if (endIndex != -1) {
+                String key = line.substring(beginIndex, endIndex);
+                beginIndex = endIndex + 1;
+                endIndex = line.length();
+                String memory = line.substring(beginIndex, endIndex);
+                String value = memory.replace("kB", "").trim();
+                map.put(key, value);
+            }
+        }
+
+        long memTotal = Long.parseLong(map.get("MemTotal").toString());
+        long memFree = Long.parseLong(map.get("MemFree").toString());
+        long memused = memTotal - memFree;
+        long buffers = Long.parseLong(map.get("Buffers").toString());
+        long cached = Long.parseLong(map.get("Cached").toString());
+
+        return memTotal - (memused - buffers - cached);
+    }
+
+
+    /**
+     * 磁盘使用率
+     *
+     * @param hostname 主机名
+     * @param username 用户名
+     * @param password 密码
+     * @return 磁盘使用率
+     */
+    public static double disk0(String hostname, String username, String password) throws IOException {
+        String execute = execute(hostname, username, password, "df --total");
+        String[] split = execute.split("\n");
+        String[] split1 = split[split.length - 1].split("\\s+");
+        long totalSize = Long.parseLong(split1[1]);
+        long totalUsed = Long.parseLong(split1[2]);
+        long totalAvailable = Long.parseLong(split1[3]);
+        String totalUsedPercent = split1[4];
+        return totalUsed * 1.0 / totalSize;
+    }
+
+    /**
+     * 剩余可用磁盘
+     *
+     * @param hostname 主机名
+     * @param username 用户名
+     * @param password 密码
+     * @return 剩余可用磁盘
+     */
+    public static double disk1(String hostname, String username, String password) throws IOException {
+        String execute = execute(hostname, username, password, "df --total");
+        String[] split = execute.split("\n");
+        String[] split1 = split[split.length - 1].split("\\s+");
+        long totalSize = Long.parseLong(split1[1]);
+        long totalUsed = Long.parseLong(split1[2]);
+        long totalAvailable = Long.parseLong(split1[3]);
+        String totalUsedPercent = split1[4];
+        return totalAvailable;
+    }
+
 }

+ 11 - 0
simulation-oauth-client/pom.xml

@@ -37,6 +37,17 @@
         </dependency>
         <!-- 数据库 - 结束 -->
 
+        <!-- 缓存 - 开始-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+        <!-- 缓存 - 结束-->
+
         <!-- http 客户端 -->
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>

+ 26 - 3
simulation-oauth-client/src/main/java/com/css/simulation/oauth/client/controller/SignController.java

@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Controller;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.annotation.Resource;
+import java.util.Set;
 
 @Controller
 @RequestMapping("/sign")
@@ -36,11 +38,14 @@ public class SignController {
     UserMapper userMapper;
     @Autowired
     CloseableHttpClient closeableHttpClient;
-    @Resource
+    @Autowired
     RequestConfig requestConfig;
-    @Resource
+    @Autowired
     OauthParameter oauthParameter;
 
+    @Autowired
+    StringRedisTemplate redisTemplate;
+
     @RequestMapping("/hello")
     @ResponseBody
     public String hello() {
@@ -91,8 +96,9 @@ public class SignController {
                 "&secret=" + oauthParameter.getZoogooyAppSecret() +
                 "&code=" + encodeCode +
                 "&grant_type=authorization_code";
-        log.info("------- /single 根据编码之后的 code 获取众工业平台 access_token:" + zoogooyTokenUrl);
+        log.info("------- /single 根据编码之后的 code 获取众工业平台 access_token 的地址为:" + zoogooyTokenUrl);
         String zoogooyTokenJson = HttpUtil.get(closeableHttpClient, requestConfig, zoogooyTokenUrl);
+        log.info("------- /single 根据编码之后的 code 获取众工业平台 access_token 的结果为:" + zoogooyTokenJson);
         ObjectMapper objectMapper1 = new ObjectMapper();
         JsonNode tokenRoot = objectMapper1.readTree(zoogooyTokenJson);
         if (!tokenRoot.path("success").asBoolean()) {
@@ -235,4 +241,21 @@ public class SignController {
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, simulationTokenVO);
     }
 
+    /**
+     * 服务监控
+     */
+    @RequestMapping ("online")
+    @ResponseBody
+    public ResponseBodyVO<Integer> online() {
+        int online;
+
+        Set<String> keys = redisTemplate.keys("access:*");
+        if (CollectionUtil.isEmpty(keys)) {
+            online = 0;
+        } else {
+            online = keys.size();
+        }
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, online);
+    }
+
 }

+ 10 - 0
simulation-oauth-client/src/main/resources/bootstrap-windowstest.yaml

@@ -0,0 +1,10 @@
+spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 10.15.12.70:8848
+        namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
+      config:
+        server-addr: 10.15.12.70:8848
+        namespace: 3698bfc2-a612-487a-b2a2-aaad16cd9d9d
+        file-extension: yaml

+ 0 - 39
simulation-oauth-server/src/main/java/com/css/simulation/oauth/server/controller/OauthServerController.java

@@ -1,39 +0,0 @@
-package com.css.simulation.oauth.server.controller;
-
-
-import api.common.pojo.common.ResponseBodyVO;
-import api.common.util.CollectionUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.Set;
-
-@RestController
-public class OauthServerController {
-
-
-    @Autowired
-    RedisTemplate<String, String> redisTemplate;
-
-    /**
-     * 服务监控
-     */
-    @PostMapping("online")
-    @ResponseBody
-    public ResponseBodyVO<Integer> online() {
-        int online;
-
-        Set<String> keys = redisTemplate.keys("access:*");
-        if (CollectionUtil.isEmpty(keys)) {
-            online = 0;
-        } else {
-            online = keys.size();
-        }
-        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, online);
-    }
-
-
-}

+ 4 - 6
simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/scheduler/Statistic.java → simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/scheduler/MyScheduler.java

@@ -3,14 +3,12 @@ package com.css.simulation.resource.monitor.scheduler;
 import org.springframework.stereotype.Component;
 
 @Component
-public class Statistic {
+public class MyScheduler {
+
 
-//    /**
-//     * 内存使用率统计。
-//     */
 //    @Scheduled(fixedDelay = 60 * 60 * 1000)
-//    public void df() {
-//        diskFreeService.getDiskFree();
+//    public void server() {
+//        SshUtil
 //    }
 
 

+ 15 - 4
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/controller/TaskController.java

@@ -1,14 +1,16 @@
 package com.css.simulation.resource.scheduler.controller;
 
 
+import api.common.util.IoUtil;
 import com.css.simulation.resource.scheduler.service.TaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.io.IOException;
 
 @RefreshScope
 @RestController
@@ -25,6 +27,15 @@ public class TaskController {
         return hello;
     }
 
+    @PostMapping("/download")
+    public void download(
+            @RequestParam("filePath") String filePath,
+            HttpServletResponse response
+    ) throws IOException {
+        FileInputStream inputStream = new FileInputStream(filePath);
+        IoUtil.copyBytes(inputStream, response.getOutputStream(), 4096);
+    }
+
     /**
      * Pod 的心跳接口
      */

+ 1 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java

@@ -2,7 +2,6 @@ package com.css.simulation.resource.algorithm.service;
 
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.algorithm.AlgorithmParameter;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.Map;
@@ -28,5 +27,5 @@ public interface AlgorithmService {
 
     ResponseBodyVO testConnection(AlgorithmParameter param);
 
-    Map selectDetailsBySy();
+    Map<String,Integer> selectDetailsBySy();
 }

+ 5 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/MyOauthServerService.java → simulation-resource-server/src/main/java/com/css/simulation/resource/feign/OauthClientService.java

@@ -7,14 +7,14 @@ import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 
 //@FeignClient(name = "test", url = "http://10.15.12.72:8001", fallback = RedisServiceFallback.class, configuration = FeignConfiguration.class)
-@FeignClient(value = "simulation-oauth-server",
-        contextId = "oauthServer",
-        path = "/simulation/oauth/server",
+@FeignClient(value = "simulation-oauth-client",
+        contextId = "oauthClient",
+        path = "/simulation/oauth/client",
         fallback = RedisServiceFallback.class,
         configuration = FeignConfiguration.class)
-public interface MyOauthServerService {
+public interface OauthClientService {
 
-    @PostMapping("/online")
+    @PostMapping("/sign/online")
     ResponseBodyVO<Integer> online();
 
 

+ 2 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/MyOauthServerServiceFallback.java → simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/OauthClientServiceFallback.java

@@ -1,10 +1,10 @@
 package com.css.simulation.resource.feign.fallback;
 
 import api.common.pojo.common.ResponseBodyVO;
-import com.css.simulation.resource.feign.MyOauthServerService;
+import com.css.simulation.resource.feign.OauthClientService;
 
 
-public class MyOauthServerServiceFallback implements MyOauthServerService {
+public class OauthClientServiceFallback implements OauthClientService {
 
 
     @Override

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

@@ -40,12 +40,14 @@ public class HomePageController {
     //首页概况汇总方法
     @PostMapping("/queryAllNum")
     @ResponseBody
-    public ResponseBodyVO<Integer> queryAllNum() {
+    public ResponseBodyVO<Map<String,Integer>> queryAllNum() {
 
-        Map map = algorithmService.selectDetailsBySy();
+        Map<String,Integer> map = algorithmService.selectDetailsBySy();
         map.put("ConfigTotal", ConfigService.getConfigTotal());
         map.put("SceneNum", sceneNaturalService.querySceneNumBySy());
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, map);
+        map.put("maxConcurrency", sceneNaturalService.querySceneNumBySy());
+        map.put("currentConcurrency", sceneNaturalService.querySceneNumBySy());
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, map);
     }
 
 
@@ -54,7 +56,7 @@ public class HomePageController {
     @ResponseBody
     public ResponseBodyVO<Integer> querySceneNumBySy() {
         Integer SceneNum = sceneNaturalService.querySceneNumBySy();
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, SceneNum);
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, SceneNum);
     }
 
     //首页车辆配置数量

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemAccessMapper.java

@@ -12,7 +12,7 @@ public interface SystemAccessMapper {
 
     @Select("<script>" +
             "        select count(id) from system_access\n" +
-            "        where is_deleted = '0'\n" +
+            "        where 1=1\n" +
             "        <if test=\"startDate != null\">\n" +
             "            and access_time &gt;= #{startDate}\n" +
             "        </if>\n" +

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

@@ -8,7 +8,7 @@ import api.common.pojo.vo.home.HardwareVO;
 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.feign.OauthClientService;
 import com.css.simulation.resource.scene.mapper.SystemAccessMapper;
 import com.css.simulation.resource.scene.mapper.SystemServerMapper;
 import com.css.simulation.resource.system.mapper.UserMapper;
@@ -35,7 +35,7 @@ public class HomePageService {
     UserMapper userMapper;
 
     @Autowired
-    MyOauthServerService myOauthServerService;
+    OauthClientService oauthClientService;
 
 
     public ResponseBodyVO<HardwareVO> selectHardware() {
@@ -48,10 +48,10 @@ public class HomePageService {
 
         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).sum() + "")
-                .cpuUsage(systemServerPOList.stream().mapToInt(po -> po.getCpuUsage() * po.getWeight() / weightSum).sum() + "")
-                .gpuUsage(systemServerPOList.stream().mapToInt(po -> po.getGpuUsage() * po.getWeight() / weightSum).sum() + "")
+                .memoryUsage(systemServerPOList.stream().mapToInt(po -> po.getMemoryUsage() * po.getWeight() / weightSum).sum() + "%")
+                .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);
@@ -63,7 +63,7 @@ public class HomePageService {
 
         ServiceVO build = ServiceVO.builder()
                 .userNumber(userMapper.selectCount())
-                .onlineNumber(myOauthServerService.online().getInfo())
+                .onlineNumber(oauthClientService.online().getInfo())
                 .simulationNodeNumber(1)
                 .simulationLicenseNumber(1)
                 .dynamicsLicenseNumber(1)