Преглед на файлове

启动项目时检查算法是否删除

root преди 2 години
родител
ревизия
bfbe5410a6

+ 1 - 0
api-common/src/main/java/api/common/pojo/constants/DictConstants.java

@@ -44,6 +44,7 @@ public class DictConstants {
     public static final String NO = "0";//否
 
     public static final String IS_SHARED = "1";//是
+    public static final String IS_DELETED = "1";//是
     public static final String IS_NOT_SHARED = "0";//否
 
     public static final String SCENE_NATURAL = "1"; // 自然驾驶

+ 6 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/mapper/AlgorithmMapper.java

@@ -4,6 +4,7 @@ import api.common.pojo.po.algorithm.AlgorithmPO;
 import api.common.pojo.vo.algorithm.RunningProjectVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 import api.common.pojo.vo.algorithm.AlgorithmVO;
 import api.common.pojo.param.algorithm.AlgorithmParameter;
@@ -24,6 +25,11 @@ public interface AlgorithmMapper {
 
     AlgorithmPO selectDetailsById(@Param("algorithmId") String algorithmId);
 
+    @Select("        select a.is_deleted\n" +
+            "        from `algorithm` a \n" +
+            "        where a.id = #{id,jdbcType=VARCHAR}")
+    String selectIsDeletedById(@Param("algorithmId") String algorithmId);
+
     List<AlgorithmPO> selectAlgorithmName(AlgorithmParameter param);
 
     List<AlgorithmPO> selectSharedAlgorithmName(@Param("algorithmName") String algorithmName);

+ 7 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -3708,8 +3708,12 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         simulationAutomaticProjectMapper.updateAutomaticRunState(param);
         SimulationAutomaticProjectPo po = simulationAutomaticProjectMapper.selectById(id);  // 查询父项目信息
         String algorithmId = po.getAlgorithm();
-        if ("0".equals(param.getAutomaticRunState())) {
-            //启动
+        if ("0".equals(param.getAutomaticRunState())) { // 启动
+            //1 判断算法是否已经被删除
+            String isDeleted = algorithmMapper.selectIsDeletedById(algorithmId);
+            if (DictConstants.IS_DELETED.equals(isDeleted)) {
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "算法已被删除,无法启动项目。", null);
+            }
             //检查算法版本
             //获取数据库中的算法版本
             AlgorithmPO aPo = algorithmMapper.selectDetailsById(algorithmId);
@@ -3732,8 +3736,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 algorithmParam.setGitVersion(currentGitVersion);
                 runProject(algorithmParam, param, po);
             }
-        } else if ("1".equals(param.getAutomaticRunState())) {
-            //停止
+        } else if ("1".equals(param.getAutomaticRunState())) {  // 停止
             //推送定时请求
             projectTaskStop(po);
         }

+ 0 - 1
simulation-resource-server/src/main/resources/mapper/project/SimulationAutomaticProjectMapper.xml

@@ -8,7 +8,6 @@
         select *
         from simulation_automatic_project
         where id = #{id,jdbcType=VARCHAR}
-
     </select>
 
     <!--根据条件查询工作信息-->