martin преди 3 години
родител
ревизия
ee57e39648

+ 14 - 0
api-common/src/main/java/api/common/pojo/common/ResponseBodyVO.java

@@ -19,18 +19,32 @@ public class ResponseBodyVO<T> {
 
     // -------------------------------- Comment --------------------------------
 
+    /**
+     *
+     * @param response response 对象
+     */
     public ResponseBodyVO(Response response) {
         this.status = response.isStatus();
         this.code = response.getCode();
         this.message = response.getMessage();
     }
 
+    /**
+     *
+     * @param response response 对象
+     * @param message message 信息
+     */
     public ResponseBodyVO(Response response, String message) {
         this.status = response.isStatus();
         this.code = response.getCode();
         this.message = message;
     }
 
+    /**
+     *
+     * @param response response 对象
+     * @param info info 结果数据
+     */
     public ResponseBodyVO(Response response, T info) {
         this.status = response.isStatus();
         this.code = response.getCode();

+ 26 - 0
api-common/src/main/java/api/common/pojo/po/SystemServerPO.java

@@ -0,0 +1,26 @@
+package api.common.pojo.po;
+
+
+import api.common.pojo.common.CommonPO;
+import lombok.*;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemServerPO extends CommonPO {
+
+    String id;
+    String serverId;
+    String serverAddress;
+    String serverType;
+    String cpuUsage;
+    String memoryUsage;
+    String memoryAvailable;
+    String diskUsage;
+    String diskAvailable;
+    String taskNumber;
+
+
+}

+ 3 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/configuration/kubernetes/KubernetesConfiguration.java

@@ -5,6 +5,7 @@ import io.kubernetes.client.util.ClientBuilder;
 import io.kubernetes.client.util.KubeConfig;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.util.ResourceUtils;
 
 import java.io.File;
 import java.io.FileReader;
@@ -15,9 +16,9 @@ public class KubernetesConfiguration {
 
     @Bean
     public ApiClient apiClient() throws IOException {
-//        File config = ResourceUtils.getFile("classpath:kubernetes/config");  // 开发环境可用,生产环境不行,无法从jar 包读取
+        File config = ResourceUtils.getFile("classpath:kubernetes/config");  // 开发环境可用,生产环境不行,无法从jar 包读取
 //        File config = new File("D:\\idea-project\\simulation-cloud\\simulation-resource-scheduler\\src\\main\\resources\\kubernetes\\config");  //windows
-        File config = new File("/root/.kube/config");   //linux
+//        File config = new File("/root/.kube/config");   //linux
 //
 //        ClassPathResource classPathResource = new ClassPathResource("kubernetes/config");
 //        InputStream inputStream =classPathResource.getInputStream();

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

@@ -7,6 +7,7 @@ import com.css.simulation.resource.algorithm.service.AlgorithmService;
 import com.css.simulation.resource.project.service.SimulationProjectService;
 import com.css.simulation.resource.scene.service.HomePageService;
 import com.css.simulation.resource.scene.service.SceneNaturalService;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -14,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.annotation.Resource;
 import java.util.Map;
 
 //首页系统概览
@@ -22,22 +22,24 @@ import java.util.Map;
 @RestController
 @RequestMapping("/homePage")
 public class HomePageController {
-    @Resource
+    @Autowired
     SceneNaturalService sceneNaturalService;
-    @Resource
-    private AlgorithmService algorithmService;
     @Autowired
-    private SimulationProjectService simulationProjectService;
+    AlgorithmService algorithmService;
+    @Autowired
+    SimulationProjectService simulationProjectService;
+    @Autowired
+    com.css.simulation.resource.model.service.ConfigService ConfigService;
     @Autowired
-    private com.css.simulation.resource.model.service.ConfigService ConfigService;
+    HomePageService homePageService;
 
     //首页概况汇总方法
     @PostMapping("/queryAllNum")
     @ResponseBody
     public ResponseBodyVO<Integer> queryAllNum() {
 
-        Map map=algorithmService.selectDetailsBySy();
-        map.put("ConfigTotal",ConfigService.getConfigTotal());
+        Map map = algorithmService.selectDetailsBySy();
+        map.put("ConfigTotal", ConfigService.getConfigTotal());
         map.put("SceneNum", sceneNaturalService.querySceneNumBySy());
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, map);
     }
@@ -132,7 +134,7 @@ public class HomePageController {
      */
     @PostMapping("selectServerList")
     @ResponseBody
-    public ResponseBodyVO<SystemServerVO> selectServerList(PageVO pageVO) {
-        return HomePageService.selectServerList(pageVO);
+    public ResponseBodyVO<PageInfo<SystemServerVO>> selectServerList(PageVO pageVO) {
+        return homePageService.selectServerList(pageVO);
     }
 }

+ 58 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/mapper/SystemServerMapper.java

@@ -0,0 +1,58 @@
+package com.css.simulation.resource.scene.mapper;
+
+import api.common.pojo.vo.system.SystemServerVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Result;
+import org.apache.ibatis.annotations.Results;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.type.JdbcType;
+
+import java.util.List;
+
+
+/**
+ * create table if not exists simulation.system_server
+ * (
+ * 	id varchar(32) null,
+ * 	server_id varchar(64) null,
+ * 	server_address varchar(32) null,
+ * 	server_type varchar(32) null,
+ * 	cpu_useage varchar(32) null,
+ * 	memory_useage varchar(32) null,
+ * 	memory_available varchar(32) null comment '剩余内存,单位GB',
+ * 	disk_usage varchar(32) null,
+ * 	disk_abailable varchar(32) null comment '剩余磁盘,单位GB',
+ * 	task_number varchar(32) null comment '执行任务数量'
+ * )
+ * comment '服务器表';
+ */
+@Mapper
+public interface SystemServerMapper {
+    @Results(id = "server", value = {
+            @Result(column = "id", property = "id", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "server_id", property = "serverId", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "server_address", property = "serverAddress", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "server_type", property = "serverType", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "cpu_usage", property = "cpuUsage", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "memory_usage", property = "memoryUsage", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "memory_available", property = "memoryAvailable", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "disk_usage", property = "diskUsage", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "disk_available", property = "diskAvailable", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "task_number", property = "taskNumber", jdbcType = JdbcType.VARCHAR)
+    })
+
+    @Select("select id,\n" +
+            "       server_id,\n" +
+            "       server_address,\n" +
+            "       server_type,\n" +
+            "       cpu_usage,\n" +
+            "       memory_usage,\n" +
+            "       memory_available,\n" +
+            "       disk_usage,\n" +
+            "       disk_available,\n" +
+            "       task_number\n" +
+            "from system_server\n" +
+            "where is_deleted = '0'")
+    List<SystemServerVO> selectAll();
+
+}

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

@@ -3,15 +3,26 @@ package com.css.simulation.resource.scene.service;
 import api.common.pojo.common.PageVO;
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.vo.system.SystemServerVO;
-import com.github.pagehelper.Page;
+import com.css.simulation.resource.scene.mapper.SystemServerMapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
 
 @Service
 public class HomePageService {
-    public static ResponseBodyVO<SystemServerVO> selectServerList(PageVO pageVO) {
-        Page<List<SystemServerVO>> page = new Page<>();
-        return null;
+
+    @Autowired
+    SystemServerMapper systemServerMapper;
+
+
+    public ResponseBodyVO<PageInfo<SystemServerVO>> selectServerList(PageVO pageVO) {
+
+        PageHelper.startPage(pageVO.getCurrentPage(), pageVO.getPageSize());
+        List<SystemServerVO> systemServerPOList = systemServerMapper.selectAll();
+
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, new PageInfo<>(systemServerPOList));
     }
 }