Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

root 2 vuotta sitten
vanhempi
commit
8e994355e6

+ 2 - 0
api-common/src/main/java/api/common/pojo/vo/algorithm/RunningProjectVO.java

@@ -10,6 +10,8 @@ import lombok.Setter;
 @Setter
 public class RunningProjectVO {
 
+    private String id;
+
     //项目ID
     private String projectId;
 

+ 10 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/ctrl/AlgorithmCtrl.java

@@ -81,6 +81,16 @@ public class AlgorithmCtrl {
         return service.deleteByid(param);
     }
 
+    /**
+     * 删除算法前校验
+     * @return
+     */
+    @RequestMapping("deleteCheck")
+    @ResponseBody
+    public ResponseBodyVO deleteCheck(@RequestBody AlgorithmParameter param){
+        return service.deleteCheck(param);
+    }
+
 
     /**
      * 分享算法

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

@@ -30,6 +30,8 @@ public interface AlgorithmMapper {
 
     List<RunningProjectVO> selectRunningProject(@Param("id") String id);
 
+    List<RunningProjectVO> selectRunningProjectParent(@Param("id") String id);
+
     List<AlgorithmVO> selectSharedAlgorithmList(AlgorithmParameter param);
 
     int  selectDetailsBySy(AlgorithmParameter param);

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java

@@ -17,6 +17,8 @@ public interface AlgorithmService {
 
     ResponseBodyVO deleteByid(AlgorithmParameter param);
 
+    ResponseBodyVO deleteCheck(AlgorithmParameter param);
+
     ResponseBodyVO selectDetailsById(String algorithmId);
 
     ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param);

+ 47 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java

@@ -4,6 +4,7 @@ import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.algorithm.AlgorithmParameter;
+import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.param.system.DictParam;
 import api.common.pojo.po.algorithm.AlgorithmPO;
 import api.common.pojo.vo.algorithm.AlgorithmVO;
@@ -18,6 +19,7 @@ import com.css.simulation.resource.configuration.git.GitConfiguration;
 import com.css.simulation.resource.feign.AlgoPlatformService;
 import com.css.simulation.resource.feign.FileDownService;
 import com.css.simulation.resource.feign.SchedulerService;
+import com.css.simulation.resource.project.service.SimulationProjectService;
 import com.css.simulation.resource.system.service.DictService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,6 +41,9 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     DictService dictService;
     GitConfiguration gitConfiguration;
 
+    @Autowired
+    private SimulationProjectService simulationProjectService;
+
     @Autowired
     public AlgorithmServiceImpl(AlgoPlatformService algoPlatformService,
                                 SchedulerService schedulerService,
@@ -261,11 +266,29 @@ public class AlgorithmServiceImpl implements AlgorithmService {
             if (runningProjectVos != null && runningProjectVos.size() > 0) {
                 StringBuffer stringBuffer = new StringBuffer("");
                 for (RunningProjectVO vo : runningProjectVos) {
-                    String projectId = vo.getProjectId();
-                    stringBuffer.append(projectId + ",");
+                    //2022/10/08,删除算法将停止所有使用该算法的正在运行中的工作项目
+                    //子项目
+                    SimulationManualProjectParam voparam = new SimulationManualProjectParam();
+                    voparam.setId(vo.getId());
+                    voparam.setNowRunState(DictConstants.PROJECT_TERMINATED);
+                    simulationProjectService.updateProjectNowRunState(voparam);
+                }
+
+                //父项目
+                List<RunningProjectVO> runningParentProjectVos = algorithmMapper.selectRunningProjectParent(algorithmId);
+                if (runningParentProjectVos != null && runningParentProjectVos.size() > 0) {
+
+                    for (RunningProjectVO voParent : runningParentProjectVos) {
+                        SimulationManualProjectParam voparamParent = new SimulationManualProjectParam();
+                        stringBuffer.append(voParent.getProjectId() + ",");
+                        voparamParent.setId(voParent.getId());
+                        voparamParent.setAutomaticRunState("1");
+                        simulationProjectService.updateAutomaticRunState(voparamParent);
+                    }
+
                 }
                 String substring = stringBuffer.substring(0, stringBuffer.lastIndexOf(","));
-                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "已被工作ID:" + substring + " 应用,无法删除!");
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, "该算法已绑定ID:" + substring + " 自动运行项目,删除后该项目将停止自动运行");
             } else {
                 int i = algorithmMapper.deleteByid(param);
                 if (i > 0) {
@@ -278,6 +301,27 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
     }
 
+    @Override
+    public ResponseBodyVO deleteCheck(AlgorithmParameter param) {
+        if (isEmpty(param.getId())) {
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+        } else {
+            String algorithmId = param.getId();
+            List<RunningProjectVO> runningParentProjectVos = algorithmMapper.selectRunningProjectParent(algorithmId);
+            if (runningParentProjectVos != null && runningParentProjectVos.size() > 0) {
+                StringBuffer stringBuffer = new StringBuffer("");
+                for (RunningProjectVO voParent : runningParentProjectVos) {
+                    stringBuffer.append(voParent.getProjectId() + ",");
+                }
+
+                String substring = stringBuffer.substring(0, stringBuffer.lastIndexOf(","));
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, "该算法已绑定ID:" + substring + " 自动运行项目,删除后该项目将停止自动运行");
+            } else {
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"该算法未绑定自动运行项目");
+            }
+        }
+    }
+
     @Override
     public ResponseBodyVO selectDetailsById(String algorithmId) {
         if (isEmpty(algorithmId)) {

+ 10 - 1
simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml

@@ -83,7 +83,16 @@
 
     <!--查询绑定算法的正在运行的项目-->
     <select id="selectRunningProject"  parameterType="java.lang.String" resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
-        select project_id  from simulation_manual_project
+        select id,project_id  from simulation_automatic_subproject
+        where now_run_state = '20' and is_deleted = '0'
+        <if test="id != null and id != ''">
+            and  algorithm = #{id,jdbcType=VARCHAR}
+        </if>
+    </select>
+
+    <!--查询绑定算法的正在运行的项目的父项目-->
+    <select id="selectRunningProjectParent"  parameterType="java.lang.String" resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
+        select distinct parent_id as id,parent_project_id as projectId  from simulation_automatic_subproject
         where now_run_state = '20' and is_deleted = '0'
         <if test="id != null and id != ''">
             and  algorithm = #{id,jdbcType=VARCHAR}