Selaa lähdekoodia

feat: 添加一个insert2函数,返回值改为entity

WANGKANG 5 kuukautta sitten
vanhempi
sitoutus
11b1ac376b

+ 39 - 4
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -197,6 +197,43 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         return this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
     }
 
+    @Transactional
+    public ToInfrared insert2(ToInfraredBo entityBo) {
+        // 检查input_oss_id是否存在
+        if (ObjectUtil.isNull(entityBo.getInputOssId())) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        SysOssVo ossEntity = ossService.getById(entityBo.getInputOssId());
+        if (ObjectUtil.isNull(ossEntity)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        ToInfrared entity = new ToInfrared();
+        entity.setInputOssId(entityBo.getInputOssId());
+        entity.setUrl(ossEntity.getUrl());
+        entity.setZipFilePath(ossEntity.getFileName());
+        entity.setName(entityBo.getName());
+        entity.setStatus(NOT_START);
+        entity.setRemarks(entityBo.getRemarks());
+        entity.setAlgorithmModelId(entityBo.getAlgorithmModelId());
+        entity.setAlgorithmId(entityBo.getAlgorithmId());
+        boolean flag = this.save(entity);
+
+        if (!flag) {
+            throw new RuntimeException("新增失败");
+        }
+
+        entity = updateEntity(entity, entityBo, ossEntity);
+
+        // 步骤 6. 保存算法参数到数据库
+        boolean flag_ = this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+        if (!flag_) {
+            throw new RuntimeException("新增失败");
+        }
+        return entity;
+    }
+
     public static Map<String, Object> getAlgorithmParameters(String algorithmConfigStr, Map<String, Object> otherParams) {
         Map<String, Object> algorithmParameters = new HashMap<>();
         List<Dict> config_list = JsonUtils.parseArrayMap(algorithmConfigStr);
@@ -244,8 +281,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             result.put("source_dir", source_dir);
             result.put("result_dir", result_dir);
             result.put("log_path", log_path);
-        }
-        else if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.REASONING)) {
+        } else if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.REASONING)) {
             String source_dir = getPredictInputPath(ossEntity);
             String result_dir = getPredictOutputPath(entity, ossEntity);
             String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TO_INFRARED_SUFFIX);
@@ -254,8 +290,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             result.put("result_dir", result_dir);
             result.put("log_path", log_path);
             result.put("model_path", model_path);
-        }
-        else {
+        } else {
             throw new RuntimeException("算法类型错误");
         }
 

+ 41 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -212,6 +212,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
      * @return 结果:true 操作成功,false 操作失败
      */
     @Override
+    @Transactional
     public CommonResult insert(TrackSequenceBo entityBo) {
         // 检查input_oss_id是否存在
         if (ObjectUtil.isNull(entityBo.getInputOssId())) {
@@ -249,6 +250,44 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         }
     }
 
+    @Transactional
+    public TrackSequence insert2(TrackSequenceBo entityBo) {
+        // 检查input_oss_id是否存在
+        if (ObjectUtil.isNull(entityBo.getInputOssId())) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        SysOssVo ossEntity = ossService.getById(entityBo.getInputOssId());
+        if (ObjectUtil.isNull(ossEntity)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        TrackSequence entity = new TrackSequence();
+        entity.setInputOssId(entityBo.getInputOssId());
+        entity.setUrl(ossEntity.getUrl());
+        entity.setZipFilePath(ossEntity.getFileName());
+        entity.setName(entityBo.getName());
+        entity.setStatus(NOT_START);
+        entity.setRemarks(entityBo.getRemarks());
+        entity.setAlgorithmModelId(entityBo.getAlgorithmModelId());
+        entity.setAlgorithmId(entityBo.getAlgorithmId());
+        boolean flag = this.save(entity);
+
+        if (!flag) {
+            throw new RuntimeException("新增注释轨迹序列任务失败");
+        }
+
+        entity = updateEntity(entity, entityBo, ossEntity);
+
+        // 步骤 6. 保存算法参数到数据库
+        boolean __ = this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+        if (!__) {
+            throw new RuntimeException("新增注释轨迹序列任务失败");
+        }
+
+        return entity;
+    }
+
     private TrackSequence updateEntity(TrackSequence entity, TrackSequenceBo entityBo, SysOssVo ossEntity) {
         // 从这里开始,配置任务的algorithm_parameters参数
         // 步骤 1. 首先根据算法id获取算法配置
@@ -294,8 +333,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TO_INFRARED_SUFFIX);
             Long inputLabelOssId = entityBo.getOtherParams().get("inputLabelOssId") == null ? null : Long.parseLong((String) entityBo.getOtherParams().get("inputLabelOssId"));
             String label_dir = getLabelDirPath(inputLabelOssId);
-            Long predictAlgorithmId = (Long) entityBo.getOtherParams().get("predictAlgorithmId");
-            String txt_dir = getTxtDirPath(predictAlgorithmId);
+            Long trackSequencePredictTaskId = (Long) entityBo.getOtherParams().get("trackSequencePredictTaskId");
+            String txt_dir = getTxtDirPath(trackSequencePredictTaskId);
             result.put("source_dir", source_dir);
             result.put("result_dir", result_dir);
             result.put("log_path", log_path);