Browse Source

是否生成 gpu 视频

root 2 years ago
parent
commit
174b63d52b

+ 12 - 4
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/TaskManager.java

@@ -92,7 +92,6 @@ public class TaskManager {
     ProjectUtil projectUtil;
     ProjectUtil projectUtil;
     @Resource
     @Resource
     VideoService videoService;
     VideoService videoService;
-
     @Resource
     @Resource
     private SqlSessionFactory sqlSessionFactory;
     private SqlSessionFactory sqlSessionFactory;
 
 
@@ -150,9 +149,18 @@ public class TaskManager {
                     taskMapper.updateFailStateWithStopTime(taskId, state, TimeUtil.getNowForMysql(), DictConstants.TASK_ERROR_REASON_3);
                     taskMapper.updateFailStateWithStopTime(taskId, state, TimeUtil.getNowForMysql(), DictConstants.TASK_ERROR_REASON_3);
                 } else if ("PendingAnalysis".equals(state)) {
                 } else if ("PendingAnalysis".equals(state)) {
                     taskMapper.updateSuccessStateWithStopTime(taskId, state, TimeUtil.getNowForMysql());
                     taskMapper.updateSuccessStateWithStopTime(taskId, state, TimeUtil.getNowForMysql());
-                    // 多线程创建视频和生成
-                    FutureTask<ResponseBodyVO<String>> videoTask = new FutureTask<>(() -> videoService.generateVideo(projectId, projectType, maxSimulationTime, taskId));
-                    new Thread(videoTask, "video-" + StringUtil.getRandomEightBitUUID()).start();
+                    // 查询项目是否使用 cpu 生成视频
+                    String isChoiceGpu = "1";
+                    if (DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)) {
+                        isChoiceGpu = manualProjectMapper.selectIsChoiceGpuById(projectId);
+                    }
+                    if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)) {
+                        isChoiceGpu = autoSubProjectMapper.selectIsChoiceGpuById(projectId);
+                    }
+                    if (DictConstants.NO.equals(isChoiceGpu)) {
+                        FutureTask<ResponseBodyVO<String>> videoTask = new FutureTask<>(() -> videoService.generateVideo(projectId, projectType, maxSimulationTime, taskId));
+                        new Thread(videoTask, "video-" + StringUtil.getRandomEightBitUUID()).start();
+                    }
                 }
                 }
                 // -------------------------------- 判断项目是否结束 --------------------------------
                 // -------------------------------- 判断项目是否结束 --------------------------------
                 ProjectMessageDTO projectMessageDTO = JsonUtil.jsonToBean(stringRedisTemplate.opsForValue().get(redisPrefix.getProjectRunningKey()), ProjectMessageDTO.class);
                 ProjectMessageDTO projectMessageDTO = JsonUtil.jsonToBean(stringRedisTemplate.opsForValue().get(redisPrefix.getProjectRunningKey()), ProjectMessageDTO.class);

+ 5 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/AutoSubProjectMapper.java

@@ -49,4 +49,9 @@ public interface AutoSubProjectMapper {
             "where id = #{id}")
             "where id = #{id}")
     void updateProjectState(@Param("id") String id, @Param("state") String state, @Param("finishTime") Timestamp finishTime);
     void updateProjectState(@Param("id") String id, @Param("state") String state, @Param("finishTime") Timestamp finishTime);
 
 
+    @Select("select is_choice_gpu\n" +
+            "from simulation_automatic_subproject\n" +
+            "where id = #{projectId}")
+    String selectIsChoiceGpuById(@Param("projectId") String projectId);
+
 }
 }

+ 6 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/ManualProjectMapper.java

@@ -29,6 +29,12 @@ public interface ManualProjectMapper {
             "where id = #{projectId}")
             "where id = #{projectId}")
     ProjectPO selectById(@Param("projectId") String projectId);
     ProjectPO selectById(@Param("projectId") String projectId);
 
 
+
+    @Select("select is_choice_gpu\n" +
+            "from simulation_manual_project\n" +
+            "where id = #{projectId}")
+    String selectIsChoiceGpuById(@Param("projectId") String projectId);
+
     @ResultMap("project")
     @ResultMap("project")
     @Select("select id, scene, create_user_id, parallelism, '1' project_type\n" +
     @Select("select id, scene, create_user_id, parallelism, '1' project_type\n" +
             "from simulation_manual_project\n" +
             "from simulation_manual_project\n" +