|
@@ -1,5 +1,6 @@
|
|
package com.css.simulation.resource.algorithm.serviceImpl;
|
|
package com.css.simulation.resource.algorithm.serviceImpl;
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
|
+import api.common.pojo.param.MinioParameter;
|
|
import api.common.pojo.param.algorithm.AlgorithmParameter;
|
|
import api.common.pojo.param.algorithm.AlgorithmParameter;
|
|
import api.common.pojo.param.system.DictParam;
|
|
import api.common.pojo.param.system.DictParam;
|
|
import api.common.pojo.po.algorithm.AlgorithmPO;
|
|
import api.common.pojo.po.algorithm.AlgorithmPO;
|
|
@@ -12,12 +13,11 @@ import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
|
|
import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
|
|
import com.css.simulation.resource.algorithm.service.AlgorithmService;
|
|
import com.css.simulation.resource.algorithm.service.AlgorithmService;
|
|
import com.css.simulation.resource.feign.AlgoPlatformService;
|
|
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.css.simulation.resource.system.service.DictService;
|
|
-import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
-import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
-import org.apache.http.client.methods.HttpGet;
|
|
|
|
-import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
|
|
+import feign.Response;
|
|
import org.eclipse.jgit.lib.Ref;
|
|
import org.eclipse.jgit.lib.Ref;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -38,6 +38,12 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
@Resource
|
|
@Resource
|
|
AlgoPlatformService algoPlatformService;
|
|
AlgoPlatformService algoPlatformService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ SchedulerService schedulerService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ FileDownService fileDownService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private AlgorithmMapper algorithmMapper;
|
|
private AlgorithmMapper algorithmMapper;
|
|
|
|
|
|
@@ -53,29 +59,43 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
if(algorithmPOS != null && algorithmPOS.size() > 0){
|
|
if(algorithmPOS != null && algorithmPOS.size() > 0){
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在!");
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在!");
|
|
}else {
|
|
}else {
|
|
- 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);
|
|
|
|
|
|
+ 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,"添加失败");
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
|
|
|
+ //编辑
|
|
|
|
+ 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, "编辑失败");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}else {
|
|
}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 {
|
|
}else {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -300,13 +320,13 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
|
|
|
if(isEdit){
|
|
if(isEdit){
|
|
po.setModifyTime(TimeUtil.getNowForMysql());
|
|
po.setModifyTime(TimeUtil.getNowForMysql());
|
|
- po.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
|
|
|
|
+ po.setModifyUserId(AuthUtil.getCurrentUserId());
|
|
}else {
|
|
}else {
|
|
po.setIsDeleted("0");
|
|
po.setIsDeleted("0");
|
|
po.setCreateTime(TimeUtil.getNowForMysql());
|
|
po.setCreateTime(TimeUtil.getNowForMysql());
|
|
po.setModifyTime(TimeUtil.getNowForMysql());
|
|
po.setModifyTime(TimeUtil.getNowForMysql());
|
|
po.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
po.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
- po.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
|
|
|
+ po.setModifyUserId(AuthUtil.getCurrentUserId());
|
|
}
|
|
}
|
|
return po;
|
|
return po;
|
|
|
|
|