martin 2 роки тому
батько
коміт
8e969f7204

+ 6 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/TaskManager.java

@@ -419,14 +419,18 @@ public class TaskManager {
 
 
     @SneakyThrows
-    public void done(PrefixTO redisPrefix, SshClient sshClient, ClientSession clientSession, String projectId) {
+    public void done(PrefixTO redisPrefix, SshClient sshClient, ClientSession clientSession, String projectId,String projectType) {
 
         // 关闭 ssh 连接
         clientSession.close();
         sshClient.stop();
 
         // 更新项目状态为已完成
-        manualProjectMapper.updateProjectState(projectId, DictConstants.PROJECT_COMPLETED, TimeUtil.getNowForMysql());   // 修改该 project 的状态为已完成
+        if (DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)){
+            manualProjectMapper.updateProjectState(projectId, DictConstants.PROJECT_COMPLETED, TimeUtil.getNowForMysql());
+        }else if(DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)){
+            autoSubProjectMapper.updateProjectState(projectId, DictConstants.PROJECT_COMPLETED, TimeUtil.getNowForMysql());
+        }
 
 
         // 删除 kafka topic

+ 4 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/AutoSubProjectMapper.java

@@ -5,6 +5,7 @@ import com.css.simulation.resource.scheduler.pojo.po.ProjectPO;
 import org.apache.ibatis.annotations.*;
 import org.apache.ibatis.type.JdbcType;
 
+import java.sql.Timestamp;
 import java.util.List;
 
 @Mapper
@@ -38,8 +39,9 @@ public interface AutoSubProjectMapper {
 
 
     @Update("update simulation_automatic_subproject\n" +
-            "set now_run_state = #{nowRunState}\n" +
+            "set now_run_state  = #{state},\n" +
+            "    finish_time = #{finishTime}\n" +
             "where id = #{id}")
-    void updateNowRunStateById(@Param("nowRunState") String nowRunState, @Param("id") String id);
+    void updateProjectState(@Param("id") String id, @Param("state") String state, @Param("finishTime") Timestamp finishTime);
 
 }

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

@@ -32,22 +32,12 @@ public interface ManualProjectMapper {
     List<ProjectPO> selectByNowRunState(@Param("nowRunState") String nowRunState);
 
 
-    @Update("update simulation_manual_project\n" +
-            "set now_run_state = #{nowRunState}\n" +
-            "where id = #{id}")
-    void updateNowRunStateById(@Param("nowRunState") String nowRunState, @Param("id") String id);
-
     @Update("update simulation_manual_project\n" +
             "set now_run_state  = #{state},\n" +
             "    finish_time = #{finishTime}\n" +
             "where id = #{id}")
     void updateProjectState(@Param("id") String id, @Param("state") String state, @Param("finishTime") Timestamp finishTime);
 
-    @Update("update simulation_manual_project\n" +
-            "set task_completed = #{taskCompleted}\n" +
-            "where id = #{id}")
-    void updateTaskCompleted(@Param("id") String id, @Param("taskCompleted") int taskCompleted);
-
 
     @Select("select create_user_id\n" +
             "from simulation_manual_project\n" +

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/TaskService.java

@@ -60,7 +60,7 @@ public class TaskService {
         //3 打分
         taskManager.score(redisPrefix, userId, projectId, projectType, clientSession);
         //4 结束
-        taskManager.done(redisPrefix, sshClient, clientSession, projectId);
+        taskManager.done(redisPrefix, sshClient, clientSession, projectId, projectType);
         log.info("TaskService--taskState 项目 " + projectId + " 执行完成!");
     }