WXF преди 3 години
родител
ревизия
e6f4e08acd

+ 5 - 44
simulation-resource-server/src/main/java/com/css/simulation/resource/home/ctrl/HomePageCtrl.java

@@ -43,49 +43,16 @@ public class HomePageCtrl {
     @ResponseBody
     public ResponseBodyVO<Map<String,Integer>> queryAllNum() {
 
-        Map<String,Integer> map = algorithmService.selectDetailsBySy();
-        map.put("ConfigTotal", configService.getConfigTotal());
-        map.put("SceneNum", sceneNaturalService.querySceneNumBySy());
-        map.put("maxConcurrency", clusterService.getLicenseNum());
-        map.put("currentConcurrency", 1);
+        Map<String,Integer> map = algorithmService.selectDetailsBySy();//算法文件数量
+        map.put("ConfigTotal", configService.getConfigTotal());//车辆配置数量
+        map.put("SceneNum", sceneNaturalService.querySceneNumBySy());//场景数量
+        map.put("maxConcurrency", clusterService.getLicenseNum());//最大并发数量
+        map.put("currentConcurrency", homePageService.getRuningTask());//当前并发数量
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, map);
     }
 
-
-    /*//首页查询场景数量
-    @PostMapping("/querySceneNumBySy")
-    @ResponseBody
-    public ResponseBodyVO<Integer> querySceneNumBySy() {
-        Integer SceneNum = sceneNaturalService.querySceneNumBySy();
-        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, SceneNum);
-    }
-
-    //首页车辆配置数量
-    @PostMapping("/queryCarDisposeNumBySy")
-    @ResponseBody
-    public ResponseBodyVO<Integer> queryCarDisposeNumBySy() {
-        Integer ConfigTotal = configService.getConfigTotal();
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, ConfigTotal);
-    }
-
-    *//**
-     * 首页算法文件数量
-     *
-     * @param
-     * @return
-     *//*
-    @RequestMapping("selectDetailsBySy")
-    @ResponseBody
-    public ResponseBodyVO selectDetailsBySy() {
-
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, algorithmService.selectDetailsBySy());
-    }*/
-
     /**
      * 近一周运行运行项目数量
-     *
-     * @param
-     * @return
      */
     @RequestMapping("selectRunProjectBySy")
     @ResponseBody
@@ -96,9 +63,6 @@ public class HomePageCtrl {
 
     /**
      * 近一周运行任务数量
-     *
-     * @param
-     * @return
      */
     @RequestMapping("selectRunTaskBySy")
     @ResponseBody
@@ -109,9 +73,6 @@ public class HomePageCtrl {
 
     /**
      * 任务运行状态统计-饼图
-     *
-     * @param
-     * @return
      */
     @RequestMapping("selectRunTaskByState")
     @ResponseBody

+ 3 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/home/mapper/HomePageMapper.java

@@ -2,10 +2,7 @@ package com.css.simulation.resource.home.mapper;
 
 import api.common.pojo.po.home.SystemServerPO;
 import api.common.pojo.vo.home.LineChartVO;
-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.annotations.*;
 import org.apache.ibatis.type.JdbcType;
 
 import java.util.List;
@@ -75,4 +72,6 @@ public interface HomePageMapper {
     List<LineChartVO> selectRunTaskChart(Map<String, String> param);
 
     List<LineChartVO> selectRunProjectChart(Map<String, String> param);
+
+    Integer getRuningTask(@Param("currentUserId")String currentUserId);
 }

+ 6 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/home/service/HomePageService.java

@@ -43,8 +43,8 @@ public class HomePageService {
         List<SystemServerPO> systemServerPOList = homePageMapper.selectAll();
         long memorySum = systemServerPOList.stream().mapToLong(SystemServerPO::getMemoryTotal).sum();  // 内存之和
         long diskSum = systemServerPOList.stream().mapToLong(SystemServerPO::getDiskTotal).sum();  // 磁盘之和
-        long cpuSum = systemServerPOList.stream().mapToLong(SystemServerPO::getDiskTotal).sum();  // cpu线程数 之和
-        long gpuSum = systemServerPOList.stream().mapToLong(SystemServerPO::getDiskTotal).sum();  // 显存之和
+        long cpuSum = systemServerPOList.stream().mapToLong(SystemServerPO::getCpuTotal).sum();  // cpu线程数 之和
+        long gpuSum = systemServerPOList.stream().mapToLong(SystemServerPO::getGpuTotal).sum();  // 显存之和
         HardwareVO build = HardwareVO.builder()
                 .serverNumber(systemServerPOList.size())
                 .memoryUsage((int) systemServerPOList.stream().mapToDouble(po -> po.getMemoryUsage() * po.getMemoryTotal() / memorySum).sum() + "%")
@@ -140,4 +140,8 @@ public class HomePageService {
         }
         return list;
     }
+
+    public Integer getRuningTask() {
+        return homePageMapper.getRuningTask(AuthUtil.getCurrentUserId());
+    }
 }

+ 10 - 0
simulation-resource-server/src/main/resources/mapper/home/HomePageMapper.xml

@@ -27,4 +27,14 @@
         ORDER BY toDate ASC
     </select>
 
+    <select id="getRuningTask" parameterType="java.lang.String" resultType="java.lang.Integer">
+        select
+          COUNT(id) as num
+        FROM simulation_manual_project_task
+        WHERE (run_state = 'Pending'
+          OR run_state = 'Running'
+          OR run_state = 'PendingAnalysis'
+          OR run_state = 'Analysing')
+          and create_user_id = #{currentUserId,jdbcType=VARCHAR}
+    </select>
 </mapper>