소스 검색

Merge remote-tracking branch 'origin/master'

martin 3 년 전
부모
커밋
4a73b14d36

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

@@ -3,7 +3,7 @@ package api.common.pojo.constants;
 public class DictConstants {
 
     //字典缓存目录key
-    public static final String BASE_KEY = "DICT:";
+    public static final String BASE_KEY = "GQ-DICT:";
     public static final String LIST_KEY = "LIST:";
     public static final String MAP_KEY = "MAP:";
 
@@ -46,4 +46,15 @@ public class DictConstants {
     public static final String TASK_TERMINATED = "Terminated"; // 任务执行状态,已终止
 
 
+
+    //算法校验状态
+    public static final String WAITING = "1"; //等待校验
+    public static final String RUNNING = "2"; //校验中
+    public static final String SUCCESS = "3"; //校验成功
+    public static final String FAIL = "4"; //校验失败
+
+    //算法上传方式
+    public static final String FILE = "1"; //文件上传
+    public static final String GIT = "2"; //仓库地址
+
 }

+ 43 - 0
api-common/src/main/java/api/common/pojo/param/algorithm/AlgorithmParameter.java

@@ -0,0 +1,43 @@
+package api.common.pojo.param.algorithm;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.web.multipart.MultipartFile;
+
+@Getter
+@Setter
+public class AlgorithmParameter extends PageParameter {
+    //id
+    private String id;
+
+    //算法名称
+    private String algorithmName;
+
+    //算法描述
+    private String description;
+
+    //校验状态
+    private String validationStatus;
+
+    //上传方式
+    private String uploadMode;
+
+    //仓库地址
+    private String gitUrl;
+
+    //代码仓库访问令牌
+    private String gitToken;
+
+    //算法文件
+    private MultipartFile file;
+
+    //是否删除
+    private String isDeleted;
+
+    //是否公有
+    private String share;
+
+    //创建用户ID
+    private String createUserId;
+
+}

+ 17 - 0
api-common/src/main/java/api/common/pojo/param/algorithm/PageParameter.java

@@ -0,0 +1,17 @@
+package api.common.pojo.param.algorithm;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class PageParameter {
+
+    private Integer pageNum;
+
+    private Integer PageSize;
+
+    private boolean isLimit;
+
+}
+

+ 44 - 0
api-common/src/main/java/api/common/pojo/po/algorithm/AlgorithmPO.java

@@ -0,0 +1,44 @@
+package api.common.pojo.po.algorithm;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 算法数据
+ */
+@Getter
+@Setter
+public class AlgorithmPO extends BasePo {
+
+    //算法名称
+    private String algorithmName;
+
+    //算法描述
+    private String description;
+
+    //校验状态
+    private String validationStatus;
+
+    //上传方式
+    private String uploadMode;
+
+    //仓库地址
+    private String gitUrl;
+
+    //代码仓库访问令牌
+    private String gitToken;
+
+    //算法文件名称
+    private String fileName;
+
+    //算法文件在 minio 上的位置
+    private String minioPath;
+
+    //算法文件的 linux 备份路径
+    private String linuxPath;
+
+    //是否公有
+    private String share;
+
+
+}

+ 51 - 0
api-common/src/main/java/api/common/pojo/po/algorithm/BasePo.java

@@ -0,0 +1,51 @@
+package api.common.pojo.po.algorithm;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * 数据表公共字段
+ */
+@Getter
+@Setter
+public class BasePo {
+
+    //id
+    private String id;
+
+    //创建时间
+    private Date createTime;
+
+    //创建人
+    private String createUserId;
+
+    //修改时间
+    private Date modifyTime;
+
+    //修改人
+    private String modifyUserId;
+
+    //是否删除
+    private String isDeleted;
+
+    public void createPo(){
+        id = createId();
+        Date date = new Date();
+        createTime = date;
+        modifyTime = date;
+        isDeleted = "0";
+        /// TODO 创建人
+    }
+
+    public void updatePo(){
+        modifyTime = new Date();
+        /// TODO 修改人
+    }
+
+    private String createId(){
+        return UUID.randomUUID().toString().replace("-","");
+    }
+}

+ 28 - 0
api-common/src/main/java/api/common/pojo/vo/algorithm/AlgorithmVO.java

@@ -0,0 +1,28 @@
+package api.common.pojo.vo.algorithm;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 算法列表vo
+ */
+@Getter
+@Setter
+public class AlgorithmVO {
+
+    //算法ID
+    private String id;
+
+    //算法名称
+    private String algorithmName;
+
+    //算法描述
+    private String description;
+
+    //校验状态
+    private String validationStatus;
+
+    //上传方式
+    private String uploadMode;
+
+}

+ 15 - 0
api-common/src/main/java/api/common/pojo/vo/algorithm/PageInfoVo.java

@@ -0,0 +1,15 @@
+package api.common.pojo.vo.algorithm;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class PageInfoVo<T> {
+
+    private List<T> info;
+
+    private Long total;
+}

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

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

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

@@ -0,0 +1,112 @@
+package com.css.simulation.resource.algorithm.ctrl;
+
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.algorithm.AlgorithmParameter;
+import com.css.simulation.resource.algorithm.service.AlgorithmService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.io.IOException;
+
+/**
+ * 算法库模块
+ */
+@Controller
+@RequestMapping("/algorithm")
+public class AlgorithmCtrl {
+
+    @Autowired
+    private AlgorithmService service;
+
+
+    /**
+     * 新增/修改算法
+     * @param param
+     * @return
+     */
+    @RequestMapping("addOrUpdate")
+    @ResponseBody
+    public ResponseBodyVO addOrUpdate(AlgorithmParameter param) throws IOException {
+        return service.addOrUpdate(param);
+    }
+
+    /**
+     * 查询算法列表-私有导入和私有仓库页面
+     * @param param
+     * @return
+     */
+    @RequestMapping("selectAlgorithmList")
+    @ResponseBody
+    public ResponseBodyVO selectAlgorithmList(@RequestBody AlgorithmParameter param){
+        return service.selectAlgorithmList(param);
+    }
+
+    /**
+     * 查询算法列表-公有页面
+     * @param param
+     * @return
+     */
+    @RequestMapping("selectSharedAlgorithmList")
+    @ResponseBody
+    public ResponseBodyVO selectSharedAlgorithmList(@RequestBody AlgorithmParameter param){
+        return service.selectSharedAlgorithmList(param);
+    }
+
+    /**
+     * 判断算法绑定的项目是否正在运行
+     * @return
+     */
+    @RequestMapping("isAlgorithmRunning")
+    @ResponseBody
+    public ResponseBodyVO isAlgorithmRunning(@RequestBody AlgorithmParameter param){
+        return service.isAlgorithmRunning(param);
+    }
+
+     /**
+     * 删除算法
+     * @return
+     */
+    @RequestMapping("deleteByid")
+    @ResponseBody
+    public ResponseBodyVO deleteByid(@RequestBody AlgorithmParameter param){
+        return service.deleteByid(param);
+    }
+
+
+    /**
+     * 分享算法
+     * @return
+     */
+    @RequestMapping("shareAlgorithm")
+    @ResponseBody
+    public ResponseBodyVO shareAlgorithm(@RequestBody AlgorithmParameter param){
+        return service.shareAlgorithm(param);
+    }
+
+
+    /**
+     * 查看算法详情
+     * @param param
+     * @return
+     */
+    @RequestMapping("selectDetailsById")
+    @ResponseBody
+    public ResponseBodyVO selectDetailsById(@RequestBody AlgorithmParameter param){
+        return service.selectDetailsById(param);
+    }
+
+    /**
+     * git测试连接
+     * @param param
+     * @return
+     */
+    @RequestMapping("testConnection")
+    @ResponseBody
+    public ResponseBodyVO testConnection(@RequestBody AlgorithmParameter param){
+        return service.testConnection(param);
+    }
+}

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

@@ -0,0 +1,30 @@
+package com.css.simulation.resource.algorithm.mapper;
+
+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.springframework.stereotype.Repository;
+import api.common.pojo.vo.algorithm.AlgorithmVO;
+import api.common.pojo.param.algorithm.AlgorithmParameter;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface AlgorithmMapper {
+
+    List<AlgorithmVO> selectAlgorithmList(AlgorithmParameter param);
+
+    int add(AlgorithmPO po);
+
+    int update(AlgorithmPO po);
+
+    int deleteByid(AlgorithmParameter param);
+
+    AlgorithmPO selectDetailsById(AlgorithmParameter param);
+
+    List<RunningProjectVO> selectRunningProject(@Param("id") String id);
+
+    List<AlgorithmVO> selectSharedAlgorithmList(AlgorithmParameter param);
+}

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

@@ -0,0 +1,26 @@
+package com.css.simulation.resource.algorithm.service;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.algorithm.AlgorithmParameter;
+
+import java.io.IOException;
+
+
+public interface AlgorithmService {
+
+    ResponseBodyVO addOrUpdate(AlgorithmParameter param) throws IOException;
+
+    ResponseBodyVO selectAlgorithmList(AlgorithmParameter param);
+
+    ResponseBodyVO deleteByid(AlgorithmParameter param);
+
+    ResponseBodyVO selectDetailsById(AlgorithmParameter param);
+
+    ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param);
+
+    ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param);
+
+    ResponseBodyVO shareAlgorithm(AlgorithmParameter param);
+
+    ResponseBodyVO testConnection(AlgorithmParameter param);
+}

+ 281 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java

@@ -0,0 +1,281 @@
+package com.css.simulation.resource.algorithm.serviceImpl;
+import api.common.pojo.common.PageVO;
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.algorithm.AlgorithmParameter;
+import api.common.pojo.po.algorithm.AlgorithmPO;
+import api.common.pojo.vo.algorithm.PageInfoVo;
+import api.common.pojo.constants.DictConstants;
+import api.common.util.StringUtil;
+import api.common.util.FileUtil;
+import api.common.pojo.vo.algorithm.AlgorithmVO;
+import api.common.pojo.vo.algorithm.RunningProjectVO;
+import com.css.simulation.resource.common.utils.AuthUtil;
+import com.css.simulation.resource.common.utils.PageUtil;
+import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
+import com.css.simulation.resource.algorithm.service.AlgorithmService;
+import com.css.simulation.resource.feign.FileDownService;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class AlgorithmServiceImpl implements AlgorithmService {
+
+    @Autowired
+    private AlgorithmMapper algorithmMapper;
+    
+    @Autowired
+    FileDownService fileDownService;
+    
+    @Override
+    public ResponseBodyVO addOrUpdate(AlgorithmParameter param) throws IOException {
+        if(isEmpty(param.getId())){
+            //添加
+            String algorithmId = StringUtil.getRandomUUID();
+            String uploadMode = param.getUploadMode();
+            if("1".equals(uploadMode)){
+                MultipartFile file = param.getFile();
+                String fileName = file.getOriginalFilename();
+                String linuxPath = "/opt/simulation-cloud/algorithm/" + algorithmId + "/" + fileName;
+                String minioPath = "algorithm/" + algorithmId + "/" + fileName;
+                boolean uploadSuccess = uploadFile(file, linuxPath, minioPath);
+                if(uploadSuccess) {
+                    param.setId(algorithmId);
+                    AlgorithmPO po = setPo(param, fileName, linuxPath, minioPath, false);
+                    int add = algorithmMapper.add(po);
+                    if(add > 0){
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                    }else {
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
+                    }
+                }else {
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
+                }
+            }else {
+                param.setId(algorithmId);
+                AlgorithmPO po = setPo(param, "", "", "", false);
+                int add = algorithmMapper.add(po);
+                if(add > 0){
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                }else {
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
+                }
+            }
+        }else {
+            //编辑
+            String uploadMode = param.getUploadMode();
+            String algorithmId = param.getId();
+            if("1".equals(uploadMode)) {
+                MultipartFile file = param.getFile();
+                String fileName = file.getOriginalFilename();
+                String linuxPath = "/opt/simulation-cloud/algorithm/" + algorithmId + "/" + fileName;
+                String minioPath = "algorithm/" + algorithmId + "/" + fileName;
+
+                boolean uploadSuccess = uploadFile(file, linuxPath, minioPath);
+                if (uploadSuccess) {
+                    AlgorithmPO po = setPo(param, fileName, linuxPath, minioPath, true);
+                    int add = algorithmMapper.update(po);
+                    if (add > 0) {
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                    }else {
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+                    }
+                } else {
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+                }
+            }else {
+                AlgorithmPO po = setPo(param, "", "", "", true);
+                int add = algorithmMapper.update(po);
+                if (add > 0) {
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                }else {
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+                }
+            }
+        }
+
+    }
+
+    @Override
+    public ResponseBodyVO selectAlgorithmList(AlgorithmParameter param) {
+        param.setIsDeleted("0");
+        param.setCreateUserId(AuthUtil.getCurrentUserId());
+        setPage(param.getPageNum()==null?1:param.getPageNum(), param.getPageSize()==null?10:param.getPageSize());
+        List<AlgorithmVO> vos = algorithmMapper.selectAlgorithmList(param);
+        PageInfo<AlgorithmVO> pageInfo = new PageInfo<>(vos);
+        PageInfoVo<AlgorithmVO> result = new PageInfoVo<>();
+
+        result.setInfo(vos);
+        result.setTotal(pageInfo.getTotal());
+
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,result);
+    }
+
+    @Override
+    public ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param) {
+        param.setIsDeleted("0");
+        param.setShare("1");
+        setPage(param.getPageNum()==null?1:param.getPageNum(), param.getPageSize()==null?10:param.getPageSize());
+        List<AlgorithmVO> vos = algorithmMapper.selectSharedAlgorithmList(param);
+        PageInfo<AlgorithmVO> pageInfo = new PageInfo<>(vos);
+        PageInfoVo<AlgorithmVO> result = new PageInfoVo<>();
+
+        result.setInfo(vos);
+        result.setTotal(pageInfo.getTotal());
+
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,result);
+    }
+
+    @Override
+    public ResponseBodyVO shareAlgorithm(AlgorithmParameter param) {
+        if(isEmpty(param.getId())){
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+        }else {
+            AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+            po.setShare("1");
+            po.setId(StringUtil.getRandomUUID());
+            int add = algorithmMapper.add(po);
+            if(add > 0){
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+            }
+            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"分享失败");
+        }
+    }
+
+    @Override
+    public ResponseBodyVO testConnection(AlgorithmParameter param) {
+        return null;
+    }
+
+    @Override
+    public ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param)
+    {
+        if(isEmpty(param.getId())){
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+        }else {
+            String algorithmId = param.getId();
+            List<RunningProjectVO> runningProjectVos = algorithmMapper.selectRunningProject(algorithmId);
+            if(runningProjectVos != null && runningProjectVos.size() > 0){
+                StringBuffer stringBuffer = new StringBuffer("");
+                for (RunningProjectVO vo:runningProjectVos){
+                    String projectId = vo.getProjectId();
+                    stringBuffer.append(projectId+",");
+                }
+                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 deleteByid(AlgorithmParameter param) {
+        if(isEmpty(param.getId())){
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+        }else {
+            int i = algorithmMapper.deleteByid(param);
+            if(i > 0){
+                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+            }
+            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
+        }
+
+    }
+
+    @Override
+    public ResponseBodyVO selectDetailsById(AlgorithmParameter param) {
+        if(isEmpty(param.getId())){
+            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+        }else {
+            AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,po);
+        }
+
+    }
+
+
+    private boolean isEmpty(String value){
+        if(value == null){
+            return true;
+        }
+        value = value.trim();
+        if(value.length() == 0){
+            return true;
+        }
+        return false;
+    }
+
+    private void setPage(Integer pageNum, Integer pageSize){
+        PageVO pageVO = new PageVO();
+        pageVO.setCurrentPage(pageNum);
+        pageVO.setPageSize(pageSize);
+        PageUtil.setPageInfo(pageVO);
+    }
+
+
+    public boolean uploadFile(MultipartFile file, String linuxPath, String minioPath){
+
+        boolean uploadSuccess = false;
+        try {
+            //linux备份
+            InputStream inputStream = file.getInputStream();
+            FileUtil.writeInputStreamToLocalFile(inputStream, linuxPath);
+            uploadSuccess = true;
+            //minio保存
+            ResponseBodyVO<String> upload = fileDownService.upload(file, minioPath);
+            if(upload.getCode() != 200){
+                uploadSuccess = false;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return uploadSuccess;
+
+    }
+
+
+    private AlgorithmPO setPo(AlgorithmParameter param, String fileName, String linuxPath, String minioPath, Boolean isEdit) throws IOException {
+
+        String algorithmId = param.getId();
+        AlgorithmPO po = new AlgorithmPO();
+        //设置po信息
+        String gitUrl = "";
+        String gitToken = "";
+        if("2".equals(param.getUploadMode())){ //使用仓库地址上传
+            gitUrl = param.getGitUrl();
+            gitToken = param.getGitToken();
+        }
+        po.setAlgorithmName(param.getAlgorithmName());
+        po.setDescription(param.getDescription());
+        po.setUploadMode(param.getUploadMode());
+        po.setGitUrl(gitUrl);
+        po.setGitToken(gitToken);
+        po.setFileName(fileName);
+        po.setValidationStatus(DictConstants.SUCCESS);
+        po.setShare("0");
+        po.setLinuxPath(linuxPath);
+        po.setMinioPath(minioPath);
+        po.setId(algorithmId);
+
+        Date date = new Date();
+        if(isEdit){
+            po.setModifyTime(date);
+            po.setCreateUserId(AuthUtil.getCurrentUserId());
+        }else {
+            po.setIsDeleted("0");
+            po.setCreateTime(date);
+            po.setCreateUserId(AuthUtil.getCurrentUserId());
+        }
+        return po;
+
+    }
+
+}

+ 138 - 0
simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml

@@ -0,0 +1,138 @@
+<?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" >
+
+
+    <!--添加-->
+    <insert id="add" parameterType="api.common.pojo.po.algorithm.AlgorithmPO">
+        insert into algorithm
+        (
+        id,
+        algorithm_name,
+        description,
+        validation_status,
+        upload_mode,
+        git_url,
+        git_token,
+        file_name,
+        minio_path,
+        linux_path,
+        share,
+        create_time,
+        create_user_id,
+        modify_time,
+        modify_user_id,
+        is_deleted
+        )
+        value
+        (
+        #{id,jdbcType=VARCHAR},
+        #{algorithmName,jdbcType=VARCHAR},
+        #{description,jdbcType=LONGNVARCHAR},
+        #{validationStatus,jdbcType=VARCHAR},
+        #{uploadMode,jdbcType=VARCHAR},
+        #{gitUrl,jdbcType=VARCHAR},
+        #{gitToken,jdbcType=VARCHAR},
+        #{fileName,jdbcType=VARCHAR},
+        #{minioPath,jdbcType=VARCHAR},
+        #{linuxPath,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="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="api.common.pojo.po.algorithm.AlgorithmPO">
+        select *
+        from algorithm
+        where id=#{id,jdbcType=VARCHAR}
+    </select>
+
+    <!--查询算法列表—私有-->
+    <select id="selectAlgorithmList" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
+        select id, algorithm_name, description, validation_status, upload_mode from algorithm
+        <where>
+            is_deleted = '0'
+        </where>
+        <if test="id != null and id != ''">
+            and id like CONCAT('%',#{id,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="algorithmName != null and algorithmName != ''">
+            and algorithm_name like CONCAT('%',#{algorithmName,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="description != null and description != ''">
+            and description like CONCAT('%',#{description,jdbcType=LONGNVARCHAR},'%')
+        </if>
+        <if test="validationStatus != null and validationStatus != ''">
+            and validation_status = #{validationStatus,jdbcType=VARCHAR}
+        </if>
+        <if test="uploadMode != null and uploadMode != ''">
+            and upload_mode = #{uploadMode,jdbcType=VARCHAR}
+        </if>
+        <if test="createUserId != null and createUserId != ''">
+            and create_user_id = #{createUserId,jdbcType=VARCHAR}
+        </if>
+        order by modify_time desc, create_time desc
+    </select>
+
+    <!--查询绑定算法的正在运行的项目-->
+    <select id="selectRunningProject"  parameterType="java.lang.String" resultType="api.common.pojo.vo.algorithm.RunningProjectVO">
+        select project_id  from simulation_manual_project
+        where now_run_state = '20' and is_deleted = '0'
+        <if test="id != null and id != ''">
+            and  algorithm = #{id,jdbcType=VARCHAR}
+        </if>
+    </select>
+
+    <!--查询算法列表—公有-->
+    <select id="selectSharedAlgorithmList" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
+        select id, algorithm_name, description, validation_status, upload_mode from algorithm
+        <where>
+            is_deleted = '0'
+        </where>
+        <if test="id != null and id != ''">
+            and id like CONCAT('%',#{id,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="algorithmName != null and algorithmName != ''">
+            and algorithm_name like CONCAT('%',#{algorithmName,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="description != null and description != ''">
+            and description like CONCAT('%',#{description,jdbcType=LONGNVARCHAR},'%')
+        </if>
+        <if test="validationStatus != null and validationStatus != ''">
+            and validation_status = #{validationStatus,jdbcType=VARCHAR}
+        </if>
+        <if test="share != null and share != ''">
+            and share = #{share,jdbcType=VARCHAR}
+        </if>
+        order by modify_time desc, create_time desc
+    </select>
+
+    <!--删除-->
+    <update id="deleteByid">
+        update algorithm
+        set is_deleted='1'
+        where id = #{id,jdbcType=VARCHAR}
+    </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_token=#{gitToken,jdbcType=VARCHAR},
+        file_name=#{fileName,jdbcType=VARCHAR},
+        minio_path=#{minioPath,jdbcType=VARCHAR},
+        linux_path=#{linuxPath,jdbcType=VARCHAR},
+        modify_time=#{modifyTime,jdbcType=VARCHAR},
+        modify_user_id=#{modifyUserId,jdbcType=VARCHAR},
+        where id=#{id,jdbcType=VARCHAR}
+    </update>
+
+</mapper>