Эх сурвалжийг харах

算法版本获取接口修改、项目自动运行获取仓库版本代码修改

zhaoyan 3 жил өмнө
parent
commit
c7f5023b09
14 өөрчлөгдсөн 127 нэмэгдсэн , 176 устгасан
  1. 4 0
      api-common/src/main/java/api/common/pojo/constants/DictConstants.java
  2. 3 0
      api-common/src/main/java/api/common/pojo/param/algorithm/AlgorithmParameter.java
  3. 5 1
      api-common/src/main/java/api/common/pojo/po/algorithm/AlgorithmPO.java
  4. 5 12
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/ctrl/AlgorithmCtrl.java
  5. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/mapper/AlgorithmMapper.java
  6. 2 4
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/service/AlgorithmService.java
  7. 72 72
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java
  8. 0 3
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/constants/ProjectConstants.java
  9. 28 65
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java
  10. 2 9
      simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationAutomaticProjectMapper.java
  11. 2 2
      simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml
  12. 1 6
      simulation-resource-server/src/main/resources/mapper/project/SimulationAutomaticProjectMapper.xml
  13. 1 1
      simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml
  14. 1 0
      simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml

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

@@ -78,6 +78,8 @@ public class DictConstants {
     //算法上传方式
     public static final String FILE = "1"; //文件上传
     public static final String GIT = "2"; //仓库地址
+    public static final String PLATFORM = "3"; //算法平台
+
 
     //报告评测等级
     public static final String REPORT_LEVEL_G = "G";
@@ -97,4 +99,6 @@ public class DictConstants {
     public static final String TASK_ERROR_REASON_3 = "容器终止!";
     public static final String TASK_ERROR_REASON_4 = "未知状态!";
     public static final String TASK_ERROR_REASON_5 = "打分出错!";
+
+
 }

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

@@ -34,6 +34,9 @@ public class AlgorithmParameter extends PageParameter {
     //代码仓库访问密码
     private String gitPassword;
 
+    //代码仓库版本号
+    private String gitVersion;
+
     //算法文件在 minio 上的位置
     private String minioPath;
 

+ 5 - 1
api-common/src/main/java/api/common/pojo/po/algorithm/AlgorithmPO.java

@@ -1,5 +1,6 @@
 package api.common.pojo.po.algorithm;
 
+import api.common.pojo.common.CommonPO;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -8,7 +9,10 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class AlgorithmPO extends BasePo {
+public class AlgorithmPO extends CommonPO {
+
+    //算法id
+    private String id;
 
     //算法名称
     private String algorithmName;

+ 5 - 12
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/ctrl/AlgorithmCtrl.java

@@ -70,16 +70,6 @@ public class AlgorithmCtrl {
         return service.selectSharedAlgorithmList(param);
     }
 
-    /**
-     * 判断算法绑定的项目是否正在运行
-     * @return
-     */
-    @RequestMapping("isAlgorithmRunning")
-    @ResponseBody
-    public ResponseBodyVO isAlgorithmRunning(@RequestBody AlgorithmParameter param){
-        return service.isAlgorithmRunning(param);
-    }
-
      /**
      * 删除算法
      * @return
@@ -110,7 +100,8 @@ public class AlgorithmCtrl {
     @RequestMapping("selectDetailsById")
     @ResponseBody
     public ResponseBodyVO selectDetailsById(@RequestBody AlgorithmParameter param){
-        return service.selectDetailsById(param);
+        String algorithmId = param.getId();
+        return service.selectDetailsById(algorithmId);
     }
 
     /**
@@ -132,7 +123,9 @@ public class AlgorithmCtrl {
     @RequestMapping("getGitVersion")
     @ResponseBody
     public ResponseBodyVO getGitVersion(@RequestBody AlgorithmParameter param) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
-        return service.getGitVersion(param);
+        String id = param.getId();
+        String gitVersion = service.getGitVersion(id);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"请求成功", gitVersion);
     }
 
 }

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

@@ -22,7 +22,7 @@ public interface AlgorithmMapper {
 
     int deleteByid(AlgorithmParameter param);
 
-    AlgorithmPO selectDetailsById(AlgorithmParameter param);
+    AlgorithmPO selectDetailsById(@Param("algorithmId") String algorithmId);
 
     List<AlgorithmPO> selectAlgorithmName(AlgorithmParameter param);
 

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

@@ -20,9 +20,7 @@ public interface AlgorithmService {
 
     ResponseBodyVO deleteByid(AlgorithmParameter param);
 
-    ResponseBodyVO selectDetailsById(AlgorithmParameter param);
-
-    ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param);
+    ResponseBodyVO selectDetailsById(String algorithmId);
 
     ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param);
 
@@ -30,7 +28,7 @@ public interface AlgorithmService {
 
     ResponseBodyVO testConnection(AlgorithmParameter param);
 
-    ResponseBodyVO getGitVersion(AlgorithmParameter param) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException;
+    String getGitVersion(String algorithmId);
 
     Map<String,Integer> selectDetailsBySy();
 }

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

@@ -12,10 +12,12 @@ 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.common.utils.PoUtil;
 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.system.service.DictService;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.pagehelper.PageInfo;
 import feign.Response;
 import org.eclipse.jgit.lib.Ref;
@@ -59,44 +61,53 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         if(algorithmPOS != null && algorithmPOS.size() > 0){
             return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在!");
         }else {
-            String minioPath = param.getMinioPath();
-            ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
-            if(checkRes.isStatus()){
-                if(isEmpty(param.getId())){
-                    //添加
-                    String algorithmId = StringUtil.getRandomUUID();
-                    param.setId(algorithmId);
-                    String algorithmCode = StringUtil.getRandomCode();
-                    param.setAlgorithmCode(algorithmCode);
-                    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,"添加失败");
-                    }
+            String uploadMode = param.getUploadMode();
+            if(DictConstants.FILE.equals(uploadMode)){
+                String minioPath = param.getMinioPath();
+                ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
+                if(checkRes.isStatus()){
+                    return doAddOrUpdate(param);
                 }else {
-                    //编辑
-                    AlgorithmPO po = setPo(param, true);
-                    int add = algorithmMapper.update(po);
-                    if (add > 0) {
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                    MinioParameter minioParameter = new MinioParameter();
+                    minioParameter.setObjectName(minioPath);
+                    Response remove =fileDownService.remove(minioParameter);
+                    if(remove.status() == 200){
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件已删除!");
                     }else {
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
                     }
                 }
             }else {
-                MinioParameter minioParameter = new MinioParameter();
-                minioParameter.setObjectName(minioPath);
-                Response remove =fileDownService.remove(minioParameter);
-                if(remove.status() == 200){
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件已删除!");
-                }else {
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
-                }
+                 return doAddOrUpdate(param);
             }
+        }
+    }
 
+    private ResponseBodyVO doAddOrUpdate(AlgorithmParameter param) {
+        if(isEmpty(param.getId())){
+            //添加
+            String algorithmId = StringUtil.getRandomUUID();
+            param.setId(algorithmId);
+            String algorithmCode = StringUtil.getRandomCode();
+            param.setAlgorithmCode(algorithmCode);
+            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 {
+            //编辑
+            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
@@ -179,7 +190,8 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         if(isEmpty(param.getId())){
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
         }else {
-            AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+            String algorithmId = param.getId();
+            AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
             List<AlgorithmPO> algorithmPOS = algorithmMapper.selectSharedAlgorithmName(po.getAlgorithmName());
             if(algorithmPOS != null && algorithmPOS.size() > 0){
                 return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在, 无法分享!");
@@ -208,31 +220,34 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     }
 
     @Override
-    public ResponseBodyVO getGitVersion(AlgorithmParameter param) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
-
-        AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+    public String getGitVersion(String algorithmId)  {
+        AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
         String gitUrl = po.getGitUrl();
         if(StringUtil.isEmpty(gitUrl)){
-            return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
+            return "";
         }
         //拼接get请求地址
         String prefix = "https://api.github.com/repos/";
         String suffix = "/commits?page=1&per_page=1";
         String gitInfo = gitUrl.substring(19, gitUrl.length()-4);
         String requestUrl = prefix + gitInfo + suffix;
-        String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), requestUrl);
-        List<HashMap> hashMaps = JsonUtil.jsonToList(result, HashMap.class);
-        String sha = "";
-        if(hashMaps.size() > 0){
-            HashMap hashMap = hashMaps.get(0);
-            sha = hashMap.get("sha").toString();
+        try {
+            String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), requestUrl);
+            List<HashMap> hashMaps = JsonUtil.jsonToList(result, HashMap.class);
+            if(hashMaps.size() > 0){
+                HashMap hashMap = hashMaps.get(0);
+                String version = hashMap.get("sha").toString();
+                return version;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
-        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"请求成功", sha);
+        return StringUtil.getRandomCode();
     }
 
+
     @Override
-    public ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param)
-    {
+    public ResponseBodyVO deleteByid(AlgorithmParameter param) {
         if(isEmpty(param.getId())){
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
         }else {
@@ -245,34 +260,24 @@ public class AlgorithmServiceImpl implements AlgorithmService {
                     stringBuffer.append(projectId+",");
                 }
                 String substring = stringBuffer.substring(0, stringBuffer.lastIndexOf(","));
-                return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"已被工作ID:"+ substring +" 应用,无法删除");
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"已被工作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);
+                int i = algorithmMapper.deleteByid(param);
+                if(i > 0){
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                }
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
             }
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
         }
 
     }
 
     @Override
-    public ResponseBodyVO selectDetailsById(AlgorithmParameter param) {
-        if(isEmpty(param.getId())){
+    public ResponseBodyVO selectDetailsById(String algorithmId) {
+        if(isEmpty(algorithmId)){
             return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
         }else {
-            AlgorithmPO po = algorithmMapper.selectDetailsById(param);
+            AlgorithmPO po = algorithmMapper.selectDetailsById(algorithmId);
             po.setValidationStatus(getDictName(DictConstants.VALIDATION_STATUS, po.getValidationStatus()));
             return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,po);
         }
@@ -296,7 +301,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
         AlgorithmPO po = new AlgorithmPO();
         //设置po信息
-        if("2".equals(param.getUploadMode())){ //使用仓库地址上传
+        if(DictConstants.GIT.equals(param.getUploadMode())){ //使用仓库地址上传
             String gitUrl = param.getGitUrl();
             String gitUserName = param.getGitUserName();
             String gitPassword = param.getGitPassword();
@@ -315,18 +320,13 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         po.setDescription(param.getDescription());
         po.setUploadMode(param.getUploadMode());
         po.setValidationStatus(DictConstants.SUCCESS);
-        po.setShare("0");
+        po.setShare(DictConstants.NO);
         po.setId(param.getId());
 
         if(isEdit){
-            po.setModifyTime(TimeUtil.getNowForMysql());
-            po.setModifyUserId(AuthUtil.getCurrentUserId());
+            PoUtil.initUpdatePo(po);
         }else {
-            po.setIsDeleted("0");
-            po.setCreateTime(TimeUtil.getNowForMysql());
-            po.setModifyTime(TimeUtil.getNowForMysql());
-            po.setCreateUserId(AuthUtil.getCurrentUserId());
-            po.setModifyUserId(AuthUtil.getCurrentUserId());
+            PoUtil.initAddPo(po);
         }
         return po;
 

+ 0 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/project/constants/ProjectConstants.java

@@ -17,9 +17,6 @@ public class ProjectConstants {
     //自动任务运行中止
     public static final String STOP_AUTO_PROJECT = "stopAutoProject";
 
-    //第三方算法类型(索为)
-    public static final String SY_ALGORITHM_TYPE="3";
-
     //任务运行状态字典
     public static final String TASK_RUN_STATE = "taskRunState";
 

+ 28 - 65
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -20,6 +20,7 @@ import api.common.pojo.po.scene.ScenePackagePO;
 import api.common.pojo.vo.project.*;
 import api.common.pojo.vo.scene.RunProjectVO;
 import api.common.util.*;
+import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
 import com.css.simulation.resource.algorithm.service.AlgorithmService;
 import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
@@ -45,20 +46,17 @@ import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.server.ServletServerHttpRequest;
 import org.springframework.scheduling.support.CronExpression;
 import org.springframework.stereotype.Service;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLEncoder;
-import java.nio.file.Files;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -88,6 +86,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     @Autowired
     private SimulationMptLastTargetScoreMapper simulationMptLastTargetScoreMapper;
 
+    @Autowired
+    private AlgorithmMapper algorithmMapper;
+
     @Resource
     private KafkaService kafkaService;
 
@@ -1280,7 +1281,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         List<DropDownVo> algorithmList = new ArrayList<>();
 
-        if(ProjectConstants.SY_ALGORITHM_TYPE.equals(algorithmType)){
+        if(DictConstants.PLATFORM.equals(algorithmType)){
             //第三方算法平台获取(索为)
             String sort = "algorithmId-desc";
             Integer page = 1;
@@ -3788,51 +3789,34 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         int i = simulationAutomaticProjectMapper.updateAutomaticRunState(param);
         if(i > 0){
             SimulationAutomaticProjectPo po = simulationAutomaticProjectMapper.selectById(id);
-            String algorithm = po.getAlgorithm();
+            String algorithmId = po.getAlgorithm();
             if("0".equals(param.getAutomaticRunState())){
                 //启动
                 //检查算法版本
-                AlgorithmPO algorithmParam = new AlgorithmPO();
-                algorithmParam.setId(algorithm);
-                AlgorithmPO aPo = simulationAutomaticProjectMapper.getAlgorithmGitVersion(algorithmParam);
+
+                //获取数据库中的算法版本
+                AlgorithmPO aPo = algorithmMapper.selectDetailsById(algorithmId);
                 String gitVersion = aPo.getGitVersion();
+                //获取当前算法版本
+                String currentGitVersion = algorithmService.getGitVersion(algorithmId);
 
-                AlgorithmParameter algorithmParameter = new AlgorithmParameter();
-                algorithmParameter.setId(algorithm);
+                boolean isRun = false; //判断是否启动运行
                 //首次获取版本
                 if(StringUtil.isEmpty(gitVersion)){
-
-                    //更新版本
-                    updateAlgorithm(algorithmParameter,algorithmParam);
-
-                    //添加一条子工作信息并推送消息到kafka ,执行项目
-                    createAutomaticSubProject(param);
-
-                    //推送定时请求,启动运行周期
-                    projectTaskStart(po);
-
+                    isRun = true;
                 }else{
                     //非首次,比对版本,校验是否执行任务
-                    String algorithmGitVersion = getAlgorithmGitVersion(algorithmParameter);
-                    if(algorithmGitVersion == null){
-                        throw new RuntimeException("------- 获取git算法版本信息失败");
+                    if(!gitVersion.equals(currentGitVersion)){
+                        isRun = true;
                     }
-
-                    if(!gitVersion.equals(algorithmGitVersion)){
-
-                        updateAlgorithmVersion(algorithmGitVersion, algorithmParam);
-
-                        //添加一条子工作信息并推送消息到kafka ,执行项目
-                        createAutomaticSubProject(param);
-
-                        //推送定时请求,启动运行周期
-                        projectTaskStart(po);
-
-                    }
-
                 }
+                if(isRun){ //启动运行
+                    AlgorithmParameter algorithmParam = new AlgorithmParameter();
+                    algorithmParam.setId(algorithmId);
+                    algorithmParam.setGitVersion(currentGitVersion);
 
-
+                    runProject(algorithmParam, param, po);
+                }
             }else if("1".equals(param.getAutomaticRunState())){
                 //停止
                 //推送定时请求
@@ -3857,41 +3841,20 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);*/
     }
 
-    private void updateAlgorithm(AlgorithmParameter algorithmParameter, AlgorithmPO algorithmParam){
-
-        String gitVersion = getAlgorithmGitVersion(algorithmParameter);
-        if(gitVersion == null){
-            throw new RuntimeException("------- 获取git算法版本信息失败");
-        }
 
-        updateAlgorithmVersion(gitVersion, algorithmParam);
-
-    }
-
-    private void updateAlgorithmVersion(String gitVersion, AlgorithmPO algorithmParam){
+    private void runProject(AlgorithmParameter algorithmParam, SimulationManualProjectParam simulationManualProjectParam, SimulationAutomaticProjectPo simulationAutomaticProjectPo){
 
         //更新算法版本
-        algorithmParam.setGitVersion(gitVersion);
         simulationAutomaticProjectMapper.updateAlgorithmGitVersion(algorithmParam);
 
-    }
+        //添加一条子工作信息并推送消息到kafka ,执行项目
+        createAutomaticSubProject(simulationManualProjectParam);
 
-    private String getAlgorithmGitVersion(AlgorithmParameter algorithmParameter){
-        try {
-            ResponseBodyVO gitVersion = algorithmService.getGitVersion(algorithmParameter);
-            if(200 == gitVersion.getCode()){
-                return gitVersion.getInfo().toString();
-            }else{
-                return null;
-            }
-        }catch (Exception e){
-            throw new RuntimeException("------- 请求错误:" + e.toString());
-        }
+        //推送定时请求,启动运行周期
+        projectTaskStart(simulationAutomaticProjectPo);
 
     }
 
-
-
     @Override
     public ResponseBodyVO selectAutomaticProject(SimulationManualProjectParam param) {
 
@@ -4221,11 +4184,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
 
     private void insertOtherAlgorithm(SimulationManualProjectParam param){
-        if(ProjectConstants.SY_ALGORITHM_TYPE.equals(param.getAlgorithmType())){
+        if(DictConstants.PLATFORM.equals(param.getAlgorithmType())){
             AlgorithmPO po = new AlgorithmPO();
             po.setId(param.getAlgorithm());
             po.setAlgorithmName(param.getAlgorithmName());
-            po.setUploadMode(ProjectConstants.SY_ALGORITHM_TYPE);
+            po.setUploadMode(DictConstants.PLATFORM);
             po.setIsDeleted("0");
             AlgorithmPO po1 = simulationProjectMapper.selectalgorithmByQuery(po);
             if(po1 == null){

+ 2 - 9
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationAutomaticProjectMapper.java

@@ -1,18 +1,13 @@
 package com.css.simulation.resource.project.mapper;
 
+import api.common.pojo.param.algorithm.AlgorithmParameter;
 import api.common.pojo.param.project.SimulationManualProjectParam;
-import api.common.pojo.po.algorithm.AlgorithmPO;
-import api.common.pojo.po.model.ConfigPO;
-import api.common.pojo.po.model.ConfigSensorPO;
-import api.common.pojo.po.model.VehiclePO;
 import api.common.pojo.po.project.*;
-import api.common.pojo.po.scene.ScenePackagePO;
 import api.common.pojo.vo.project.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
-import java.util.Map;
 
 @Mapper
 @Repository
@@ -39,9 +34,7 @@ public interface SimulationAutomaticProjectMapper {
 
      AutomaticProjectVo selectAutomaticProjectInfoById(String id);
 
-     AlgorithmPO getAlgorithmGitVersion(AlgorithmPO po);
-
-     int updateAlgorithmGitVersion(AlgorithmPO po);
+     int updateAlgorithmGitVersion(AlgorithmParameter algorithmParameter);
 
      int updateAutomaticRunTimes(SimulationAutomaticProjectPo po);
 

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

@@ -48,10 +48,10 @@
     </insert>
 
     <!--查询算法详情-->
-    <select id="selectDetailsById" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter" 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=#{id,jdbcType=VARCHAR}
+        where id=#{algorithmId,jdbcType=VARCHAR}
     </select>
 
     <!--查询算法列表—私有-->

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

@@ -172,13 +172,8 @@
         where p.id = #{id,jdbcType=VARCHAR} and p.is_deleted = '0'
     </select>
 
-    <!--根据算法id获取算法git版本号信息-->
-    <select id="getAlgorithmGitVersion" parameterType="api.common.pojo.po.algorithm.AlgorithmPO" resultType="api.common.pojo.po.algorithm.AlgorithmPO">
-        select id,git_version from algorithm where id=#{id}
-    </select>
-
     <!--更新算法版本号-->
-    <update id="updateAlgorithmGitVersion" parameterType="api.common.pojo.po.algorithm.AlgorithmPO">
+    <update id="updateAlgorithmGitVersion" parameterType="api.common.pojo.param.algorithm.AlgorithmParameter">
         update algorithm set git_version=#{gitVersion} where id=#{id}
     </update>
 

+ 1 - 1
simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml

@@ -18,7 +18,7 @@
         from system_user u
         left join system_cluster p on u.id = p.user_id
         <where>
-            u.is_deleted = '0' and u.visible = '1'
+            u.is_deleted = '0' and u.visible = '1' and p.is_deleted = '0'
             and u.role_code = #{roleCode,jdbcType=VARCHAR}
         </where>
         <if test="createUserId != null and createUserId != ''">

+ 1 - 0
simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml

@@ -17,6 +17,7 @@
         left join system_parameter p on u.id = p.user_id
         <where>
             u.is_deleted = '0' and u.visible = '1' and u.role_code = '2'
+            and p.is_deleted = '0'
         </where>
         <if test="userName != null and userName != ''">
             and u.username like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')