|
@@ -5,6 +5,7 @@ import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.mybatisflex.core.paginate.Page;
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
@@ -13,6 +14,8 @@ import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
|
|
|
import com.taais.biz.mapper.AlgorithmConfigTrackMapper;
|
|
|
import com.taais.common.core.config.TaaisConfig;
|
|
|
import com.taais.common.core.constant.Constants;
|
|
|
+import com.taais.common.core.core.domain.CommonResult;
|
|
|
+import com.taais.common.core.utils.DateUtils;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.core.utils.StringUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
@@ -32,6 +35,7 @@ import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
|
|
|
import com.taais.biz.service.IAlgorithmModelTrackService;
|
|
|
|
|
|
import static com.taais.biz.domain.table.AlgorithmModelTrackTableDef.ALGORITHM_MODEL_TRACK;
|
|
|
+import static com.taais.biz.constant.BizConstant.AlgorithmType;
|
|
|
|
|
|
/**
|
|
|
* 算法模型配置Service业务层处理
|
|
@@ -85,7 +89,7 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
|
|
|
*/
|
|
|
@Override
|
|
|
public AlgorithmModelTrackVo selectById(Long id) {
|
|
|
- AlgorithmModelTrackVo algorithmModelTrackVo = this.getOneAs(query().where(ALGORITHM_MODEL_TRACK.ID.eq(id)), AlgorithmModelTrackVo.class);
|
|
|
+ AlgorithmModelTrackVo algorithmModelTrackVo = this.getOneAs(query().where(ALGORITHM_MODEL_TRACK.ID.eq(id)), AlgorithmModelTrackVo.class);
|
|
|
|
|
|
Long algorithmId = algorithmModelTrackVo.getAlgorithmId();
|
|
|
|
|
@@ -129,23 +133,37 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
|
|
|
* @return 结果:true 操作成功,false 操作失败
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean insert(AlgorithmModelTrackBo algorithmModelTrackBo) {
|
|
|
- AlgorithmModelTrack algorithmModelTrack = MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack.class);
|
|
|
-
|
|
|
- SysOssVo inputOssEntity = ossService.getById(algorithmModelTrackBo.getModelInputOssId());
|
|
|
+ public CommonResult<String> insert(AlgorithmModelTrackBo algorithmModelTrackBo) {
|
|
|
+ AlgorithmConfigTrackVo algorithmConfigTrackVo = algorithmConfigTrackService.selectById(algorithmModelTrackBo.getAlgorithmId_());
|
|
|
+ if (algorithmConfigTrackVo.getType().equals(AlgorithmType.REASONING) && ObjectUtil.isEmpty(algorithmModelTrackBo.getModelInputOssId())) {
|
|
|
+ return CommonResult.fail("预测算法必须上传模型输入文件");
|
|
|
+ }
|
|
|
|
|
|
- String filePath = inputOssEntity.getFileName();
|
|
|
- String localPath = TaaisConfig.getProfile();
|
|
|
- String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+ AlgorithmModelTrack algorithmModelTrack = MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack.class);
|
|
|
|
|
|
+ String resourcePath = null;
|
|
|
+ if (algorithmModelTrackBo.getModelInputOssId() != null) {
|
|
|
+ SysOssVo inputOssEntity = ossService.getById(algorithmModelTrackBo.getModelInputOssId());
|
|
|
+
|
|
|
+ String filePath = inputOssEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+ } else {
|
|
|
+ String localPath = TaaisConfig.getUploadPath();
|
|
|
+ String path = DateUtils.datePath() + "/" + IdUtil.fastSimpleUUID();
|
|
|
+ ;
|
|
|
+ resourcePath = localPath + "/" + path + ".pt";
|
|
|
+ }
|
|
|
algorithmModelTrack.setModelAddress(resourcePath);
|
|
|
|
|
|
algorithmModelTrack.setAlgorithmId(algorithmModelTrackBo.getAlgorithmId_());
|
|
|
-
|
|
|
- AlgorithmConfigTrackVo algorithmConfigTrackVo = algorithmConfigTrackService.selectById(algorithmModelTrackBo.getAlgorithmId_());
|
|
|
algorithmModelTrack.setAlgorithmType(algorithmConfigTrackVo.getAlgorithmName());
|
|
|
|
|
|
- return this.save(algorithmModelTrack); // 使用全局配置的雪花算法主键生成器生成ID值
|
|
|
+ boolean inserted = this.save(algorithmModelTrack); // 使用全局配置的雪花算法主键生成器生成ID值
|
|
|
+ if (inserted) {
|
|
|
+ return CommonResult.success("新增算法模型配置成功");
|
|
|
+ }
|
|
|
+ return CommonResult.fail("新增算法模型配置失败");
|
|
|
}
|
|
|
|
|
|
/**
|