Explorar o código

删除算法提示关联自动项目

root %!s(int64=2) %!d(string=hai) anos
pai
achega
64b6b52219

+ 4 - 11
api-common/src/main/java/api/common/pojo/vo/algorithm/RunningProjectVO.java

@@ -1,19 +1,12 @@
 package api.common.pojo.vo.algorithm;
 
-import lombok.Getter;
-import lombok.Setter;
+import lombok.Data;
 
 /**
  * 算法绑定的正在运行的项目id的vo
  */
-@Getter
-@Setter
+@Data
 public class RunningProjectVO {
-
-    private String id;
-
-    //项目ID
-    private String projectId;
-
-
+    private String id;  // 数据库ID
+    private String projectId;   // 展示ID
 }

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/ctrl/AlgorithmCtrl.java

@@ -13,6 +13,7 @@ import java.io.IOException;
 import java.security.KeyManagementException;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
+import java.util.Map;
 
 /**
  * 算法库模块
@@ -87,7 +88,7 @@ public class AlgorithmCtrl {
      */
     @RequestMapping("deleteCheck")
     @ResponseBody
-    public ResponseBodyVO deleteCheck(@RequestBody AlgorithmParameter param){
+    public ResponseBodyVO<Map<String,String>> deleteCheck(@RequestBody AlgorithmParameter param){
         return service.deleteCheck(param);
     }
 

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

@@ -32,6 +32,10 @@ public interface AlgorithmMapper {
 
     List<RunningProjectVO> selectRunningProjectParent(@Param("id") String id);
 
+    List<RunningProjectVO> selectAutoProjectIdByAlgorithmId(@Param("algorithmId") String algorithmId);
+
+
+
     List<AlgorithmVO> selectSharedAlgorithmList(AlgorithmParameter param);
 
     int  selectDetailsBySy(AlgorithmParameter param);

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

@@ -17,7 +17,7 @@ public interface AlgorithmService {
 
     ResponseBodyVO deleteByid(AlgorithmParameter param);
 
-    ResponseBodyVO deleteCheck(AlgorithmParameter param);
+    ResponseBodyVO<Map<String,String>> deleteCheck(AlgorithmParameter param);
 
     ResponseBodyVO selectDetailsById(String algorithmId);
 

+ 8 - 9
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java

@@ -302,25 +302,24 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO deleteCheck(AlgorithmParameter param) {
+    public ResponseBodyVO<Map<String,String>> deleteCheck(AlgorithmParameter param) {
         if (isEmpty(param.getId())) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
         } else {
-            Map map =new HashMap();
+            Map<String,String> map =new HashMap<>();
             String algorithmId = param.getId();
             List<RunningProjectVO> runningParentProjectVos = algorithmMapper.selectRunningProjectParent(algorithmId);
             if (runningParentProjectVos != null && runningParentProjectVos.size() > 0) {
-                StringBuffer stringBuffer = new StringBuffer("");
+                StringBuilder stringBuilder = new StringBuilder();
                 for (RunningProjectVO voParent : runningParentProjectVos) {
-                    stringBuffer.append(voParent.getProjectId() + ",");
+                    stringBuilder.append(voParent.getProjectId()).append(",");
                 }
-
-                String substring = stringBuffer.substring(0, stringBuffer.lastIndexOf(","));
+                String substring = stringBuilder.substring(0, stringBuilder.lastIndexOf(","));
                 map.put("substring",substring);
-                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, "该算法已绑定ID:" + substring + " 自动运行项目,删除后该项目将停止自动运行",map);
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, "该算法已绑定ID为 " + substring + " 的自动运行项目,删除后该项目将停止自动运行",map);
             } else {
                 map.put("substring","");
-                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"该算法未绑定自动运行项目",map);
+                return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,"该算法未绑定自动运行项目",map);
             }
         }
     }

+ 85 - 71
simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml

@@ -1,61 +1,60 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.css.simulation.resource.algorithm.mapper.AlgorithmMapper" >
+<mapper namespace="com.css.simulation.resource.algorithm.mapper.AlgorithmMapper">
 
 
     <!--添加-->
     <insert id="add" parameterType="api.common.pojo.po.algorithm.AlgorithmPO">
         insert into algorithm
-        (
-        id,
-        algorithm_name,
-        algorithm_code,
-        description,
-        validation_status,
-        upload_mode,
-        git_url,
-        git_user_name,
-        git_password,
-        file_name,
-        minio_path,
-        share,
-        create_time,
-        create_user_id,
-        modify_time,
-        modify_user_id,
-        is_deleted
-        )
-        value
-        (
-        #{id,jdbcType=VARCHAR},
-        #{algorithmName,jdbcType=VARCHAR},
-        #{algorithmCode,jdbcType=VARCHAR},
-        #{description,jdbcType=LONGNVARCHAR},
-        #{validationStatus,jdbcType=VARCHAR},
-        #{uploadMode,jdbcType=VARCHAR},
-        #{gitUrl,jdbcType=VARCHAR},
-        #{gitUserName,jdbcType=VARCHAR},
-        #{gitPassword,jdbcType=VARCHAR},
-        #{fileName,jdbcType=VARCHAR},
-        #{minioPath,jdbcType=VARCHAR},
-        #{share,jdbcType=VARCHAR},
-        #{createTime,jdbcType=TIMESTAMP},
-        #{createUserId,jdbcType=VARCHAR},
-        #{modifyTime,jdbcType=TIMESTAMP},
-        #{modifyUserId,jdbcType=VARCHAR},
-        #{isDeleted,jdbcType=VARCHAR}
-        )
+        (id,
+         algorithm_name,
+         algorithm_code,
+         description,
+         validation_status,
+         upload_mode,
+         git_url,
+         git_user_name,
+         git_password,
+         file_name,
+         minio_path,
+         share,
+         create_time,
+         create_user_id,
+         modify_time,
+         modify_user_id,
+         is_deleted)
+            value
+            ( #{id,jdbcType=VARCHAR},
+            #{algorithmName,jdbcType=VARCHAR},
+            #{algorithmCode,jdbcType=VARCHAR},
+            #{description,jdbcType=LONGNVARCHAR},
+            #{validationStatus,jdbcType=VARCHAR},
+            #{uploadMode,jdbcType=VARCHAR},
+            #{gitUrl,jdbcType=VARCHAR},
+            #{gitUserName,jdbcType=VARCHAR},
+            #{gitPassword,jdbcType=VARCHAR},
+            #{fileName,jdbcType=VARCHAR},
+            #{minioPath,jdbcType=VARCHAR},
+            #{share,jdbcType=VARCHAR},
+            #{createTime,jdbcType=TIMESTAMP},
+            #{createUserId,jdbcType=VARCHAR},
+            #{modifyTime,jdbcType=TIMESTAMP},
+            #{modifyUserId,jdbcType=VARCHAR},
+            #{isDeleted,jdbcType=VARCHAR}
+            )
     </insert>
 
     <!--查询算法详情-->
-    <select id="selectDetailsById" parameterType="java.lang.String" resultType="api.common.pojo.po.algorithm.AlgorithmPO">
+    <select id="selectDetailsById" parameterType="java.lang.String"
+            resultType="api.common.pojo.po.algorithm.AlgorithmPO">
         select *
         from algorithm
-        where id=#{algorithmId,jdbcType=VARCHAR}
+        where id = #{algorithmId,jdbcType=VARCHAR}
     </select>
 
     <!--查询算法列表—私有-->
-    <select id="selectAlgorithmList" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
+    <select id="selectAlgorithmList" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter"
+            resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
         select id, algorithm_code, algorithm_name, description, validation_status, upload_mode from algorithm
         <where>
             is_deleted = '0' and share = '0'
@@ -82,31 +81,44 @@
     </select>
 
     <!--查询绑定算法的正在运行的项目-->
-    <select id="selectRunningProject"  parameterType="java.lang.String" resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
-        select a.id,a.project_id  from simulation_automatic_subproject a left join simulation_automatic_project b
+    <select id="selectRunningProject" parameterType="java.lang.String"
+            resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
+        select a.id,a.project_id from simulation_automatic_subproject a left join simulation_automatic_project b
         on a.parent_id=b.id
-        where a.now_run_state = '20' and a.is_deleted = '0' and  b.is_deleted = '0'
+        where a.now_run_state = '20' and a.is_deleted = '0' and b.is_deleted = '0'
         <if test="id != null and id != ''">
-            and  b.algorithm = #{id,jdbcType=VARCHAR}
+            and b.algorithm = #{id,jdbcType=VARCHAR}
         </if>
     </select>
 
     <!--查询绑定算法的正在运行的项目的父项目-->
-    <select id="selectRunningProjectParent"  parameterType="java.lang.String" resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
-        select distinct a.parent_id as id,a.parent_project_id as projectId  from simulation_automatic_subproject a left join simulation_automatic_project b
+    <select id="selectRunningProjectParent" parameterType="java.lang.String"
+            resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
+        select distinct a.parent_id as id,a.parent_project_id as projectId from simulation_automatic_subproject a left
+        join simulation_automatic_project b
         on a.parent_id=b.id
-        where a.now_run_state = '20' and a.is_deleted = '0' and  b.is_deleted = '0'
+        where a.now_run_state = '20' and a.is_deleted = '0' and b.is_deleted = '0'
         <if test="id != null and id != ''">
-            and  b.algorithm = #{id,jdbcType=VARCHAR}
+            and b.algorithm = #{id,jdbcType=VARCHAR}
         </if>
     </select>
 
+    <!--查询算法绑定的自动运行父项目-->
+    <select id="selectAutoProjectIdByAlgorithmId" parameterType="java.lang.String"
+            resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
+        select id, project_id
+        from simulation_automatic_project
+        where is_deleted = '0'
+          and algorithm = #{id,jdbcType=VARCHAR}
+    </select>
+
     <!--查询算法名称是否已存在-当前用户-->
-    <select id="selectAlgorithmName"  parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="api.common.pojo.po.algorithm.AlgorithmPO">
-        select id  from algorithm
+    <select id="selectAlgorithmName" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter"
+            resultType="api.common.pojo.po.algorithm.AlgorithmPO">
+        select id from algorithm
         where is_deleted = '0'
         <if test="algorithmName != null and algorithmName != ''">
-            and  algorithm_name = #{algorithmName,jdbcType=VARCHAR}
+            and algorithm_name = #{algorithmName,jdbcType=VARCHAR}
         </if>
         <if test="createUserId != null and createUserId != ''">
             and create_user_id = #{createUserId,jdbcType=VARCHAR}
@@ -121,7 +133,8 @@
 
 
     <!--查询算法列表—公有-->
-    <select id="selectSharedAlgorithmList" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
+    <select id="selectSharedAlgorithmList" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter"
+            resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
         select id, algorithm_code, algorithm_name, description, validation_status, upload_mode from algorithm
         <where>
             is_deleted = '0'
@@ -146,10 +159,10 @@
 
     <!--查询算法名称是否已存在-公有-->
     <select id="selectSharedAlgorithmName" resultType="api.common.pojo.po.algorithm.AlgorithmPO">
-        select id  from algorithm
+        select id from algorithm
         where is_deleted = '0' and share = '1'
         <if test="algorithmName != null and algorithmName != ''">
-            and  algorithm_name = #{algorithmName,jdbcType=VARCHAR}
+            and algorithm_name = #{algorithmName,jdbcType=VARCHAR}
         </if>
     </select>
 
@@ -161,23 +174,24 @@
     </update>
 
     <update id="update" parameterType="api.common.pojo.po.algorithm.AlgorithmPO">
-        update algorithm set
-        algorithm_name=#{algorithmName,jdbcType=VARCHAR},
-        description=#{description,jdbcType=VARCHAR},
-        validation_status=#{validationStatus,jdbcType=VARCHAR},
-        upload_mode=#{uploadMode,jdbcType=VARCHAR},
-        git_url=#{gitUrl,jdbcType=VARCHAR},
-        git_user_name=#{gitUserName,jdbcType=VARCHAR},
-        git_password=#{gitPassword,jdbcType=VARCHAR},
-        file_name=#{fileName,jdbcType=VARCHAR},
-        minio_path=#{minioPath,jdbcType=VARCHAR},
-        modify_time=#{modifyTime,jdbcType=VARCHAR},
-        modify_user_id=#{modifyUserId,jdbcType=VARCHAR}
-        where id=#{id,jdbcType=VARCHAR}
+        update algorithm
+        set algorithm_name=#{algorithmName,jdbcType=VARCHAR},
+            description=#{description,jdbcType=VARCHAR},
+            validation_status=#{validationStatus,jdbcType=VARCHAR},
+            upload_mode=#{uploadMode,jdbcType=VARCHAR},
+            git_url=#{gitUrl,jdbcType=VARCHAR},
+            git_user_name=#{gitUserName,jdbcType=VARCHAR},
+            git_password=#{gitPassword,jdbcType=VARCHAR},
+            file_name=#{fileName,jdbcType=VARCHAR},
+            minio_path=#{minioPath,jdbcType=VARCHAR},
+            modify_time=#{modifyTime,jdbcType=VARCHAR},
+            modify_user_id=#{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
     </update>
 
     <!--查询算法数量首页-->
-    <select id="selectDetailsBySy" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="java.lang.Integer">
+    <select id="selectDetailsBySy" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter"
+            resultType="java.lang.Integer">
         select count(id)
         from algorithm
         where