Przeglądaj źródła

feat: 算法模型添加成功

WANGKANG 9 miesięcy temu
rodzic
commit
0cd1816027

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmModelTrack.java

@@ -52,5 +52,5 @@ private static final long serialVersionUID = 1L;
     /** 系统 */
     private String system;
 
-
+    private String algorithmType;
 }

+ 7 - 8
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmModelTrackBo.java

@@ -16,17 +16,18 @@ import com.taais.common.orm.core.domain.BaseEntity;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @AutoMapper(target = AlgorithmModelTrack.class, reverseConvertGenerate = false)
-public class AlgorithmModelTrackBo extends BaseEntity{
+public class AlgorithmModelTrackBo extends BaseEntity {
     /**
      * 主键ID
      */
-    @NotNull(message = "主键ID不能为空")
     private Long id;
 
     /**
      * 算法
      */
     @NotNull(message = "算法不能为空")
+    private Long algorithmId_; // todo 因为前端bug被迫改名
+
     private Long algorithmId;
 
     /**
@@ -35,35 +36,33 @@ public class AlgorithmModelTrackBo extends BaseEntity{
     @NotBlank(message = "模型名称不能为空")
     private String modelName;
 
+    @NotNull(message = "模型文件不能为空")
+    private Long modelInputOssId;
+
     /**
      * 模型
      */
-    @NotBlank(message = "模型不能为空")
     private String modelAddress;
 
     /**
      * 训练样本数
      */
-    @NotNull(message = "训练样本数不能为空")
     private Long sampleNumber;
 
     /**
      * 训练循环次数
      */
-    @NotNull(message = "训练循环次数不能为空")
     private Long cycleEpoch;
 
     /**
      * 备注
      */
-    @NotBlank(message = "备注不能为空")
     private String remarks;
 
     /**
      * 系统
      */
-    @NotBlank(message = "系统不能为空")
     private String system;
 
-
+    private String algorithmType;
 }

+ 1 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackVo.java

@@ -63,6 +63,5 @@ private static final long serialVersionUID = 1L;
     @ExcelProperty(value = "系统")
     private String system;
 
-
-
+    private String algorithmType;
 }

+ 46 - 15
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmModelTrackServiceImpl.java

@@ -6,12 +6,21 @@ import java.util.List;
 import cn.hutool.core.util.ObjectUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
+import com.taais.biz.domain.AlgorithmConfigTrack;
+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.utils.MapstructUtils;
 import com.taais.common.core.utils.StringUtils;
 import com.taais.common.orm.core.page.PageQuery;
 import com.taais.common.core.core.page.PageResult;
 import com.taais.common.orm.core.service.impl.BaseServiceImpl;
+import com.taais.system.domain.SysOss;
+import com.taais.system.domain.vo.SysOssVo;
+import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import com.taais.biz.mapper.AlgorithmModelTrackMapper;
@@ -19,6 +28,7 @@ import com.taais.biz.domain.AlgorithmModelTrack;
 import com.taais.biz.domain.bo.AlgorithmModelTrackBo;
 import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
 import com.taais.biz.service.IAlgorithmModelTrackService;
+
 import static com.taais.biz.domain.table.AlgorithmModelTrackTableDef.ALGORITHM_MODEL_TRACK;
 
 /**
@@ -29,6 +39,12 @@ import static com.taais.biz.domain.table.AlgorithmModelTrackTableDef.ALGORITHM_M
  */
 @Service
 public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmModelTrackMapper, AlgorithmModelTrack> implements IAlgorithmModelTrackService {
+    @Autowired
+    private ISysOssService ossService;
+
+    @Autowired
+    private AlgorithmConfigTrackServiceImpl algorithmConfigTrackService;
+
     @Resource
     private AlgorithmModelTrackMapper algorithmModelTrackMapper;
 
@@ -40,19 +56,21 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
     private QueryWrapper buildQueryWrapper(AlgorithmModelTrackBo algorithmModelTrackBo) {
         QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
         queryWrapper.and(ALGORITHM_MODEL_TRACK.ALGORITHM_ID.eq
-        (algorithmModelTrackBo.getAlgorithmId()));
+            (algorithmModelTrackBo.getAlgorithmId()));
         queryWrapper.and(ALGORITHM_MODEL_TRACK.MODEL_NAME.like
-        (algorithmModelTrackBo.getModelName()));
+            (algorithmModelTrackBo.getModelName()));
         queryWrapper.and(ALGORITHM_MODEL_TRACK.MODEL_ADDRESS.eq
-        (algorithmModelTrackBo.getModelAddress()));
+            (algorithmModelTrackBo.getModelAddress()));
         queryWrapper.and(ALGORITHM_MODEL_TRACK.SAMPLE_NUMBER.eq
-        (algorithmModelTrackBo.getSampleNumber()));
+            (algorithmModelTrackBo.getSampleNumber()));
         queryWrapper.and(ALGORITHM_MODEL_TRACK.CYCLE_EPOCH.eq
-        (algorithmModelTrackBo.getCycleEpoch()));
+            (algorithmModelTrackBo.getCycleEpoch()));
         queryWrapper.and(ALGORITHM_MODEL_TRACK.REMARKS.eq
-        (algorithmModelTrackBo.getRemarks()));
+            (algorithmModelTrackBo.getRemarks()));
         queryWrapper.and(ALGORITHM_MODEL_TRACK.SYSTEM.eq
-        (algorithmModelTrackBo.getSystem()));
+            (algorithmModelTrackBo.getSystem()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.ALGORITHM_TYPE.eq
+            (algorithmModelTrackBo.getAlgorithmType()));
 
         return queryWrapper;
     }
@@ -65,7 +83,7 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
      */
     @Override
     public AlgorithmModelTrackVo selectById(Long id) {
-            return this.getOneAs(query().where(ALGORITHM_MODEL_TRACK.ID.eq(id)), AlgorithmModelTrackVo.class);
+        return this.getOneAs(query().where(ALGORITHM_MODEL_TRACK.ID.eq(id)), AlgorithmModelTrackVo.class);
 
     }
 
@@ -78,7 +96,7 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
     @Override
     public List<AlgorithmModelTrackVo> selectList(AlgorithmModelTrackBo algorithmModelTrackBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(algorithmModelTrackBo);
-            return this.listAs(queryWrapper, AlgorithmModelTrackVo.class);
+        return this.listAs(queryWrapper, AlgorithmModelTrackVo.class);
     }
 
     /**
@@ -90,7 +108,7 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
     @Override
     public PageResult<AlgorithmModelTrackVo> selectPage(AlgorithmModelTrackBo algorithmModelTrackBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(algorithmModelTrackBo);
-            Page<AlgorithmModelTrackVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmModelTrackVo.class);
+        Page<AlgorithmModelTrackVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmModelTrackVo.class);
         return PageResult.build(page);
     }
 
@@ -102,9 +120,22 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
      */
     @Override
     public boolean insert(AlgorithmModelTrackBo algorithmModelTrackBo) {
-    AlgorithmModelTrack algorithmModelTrack =MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack. class);
+        AlgorithmModelTrack algorithmModelTrack = MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack.class);
+
+        SysOssVo inputOssEntity = ossService.getById(algorithmModelTrackBo.getModelInputOssId());
+
+        String filePath = inputOssEntity.getFileName();
+        String localPath = TaaisConfig.getProfile();
+        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
+
+        algorithmModelTrack.setModelAddress(resourcePath);
+
+        algorithmModelTrack.setAlgorithmId(algorithmModelTrackBo.getAlgorithmId_());
+
+        AlgorithmConfigTrackVo algorithmConfigTrackVo = algorithmConfigTrackService.selectById(algorithmModelTrackBo.getAlgorithmId_());
+        algorithmModelTrack.setAlgorithmType(algorithmConfigTrackVo.getAlgorithmName());
 
-        return this.save(algorithmModelTrack);//使用全局配置的雪花算法主键生成器生成ID值
+        return this.save(algorithmModelTrack); // 使用全局配置的雪花算法主键生成器生成ID值
     }
 
     /**
@@ -115,10 +146,10 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
      */
     @Override
     public boolean update(AlgorithmModelTrackBo algorithmModelTrackBo) {
-        AlgorithmModelTrack algorithmModelTrack =MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack. class);
-        if (ObjectUtil.isNotNull(algorithmModelTrack) && ObjectUtil.isNotNull(algorithmModelTrack.getId())){
+        AlgorithmModelTrack algorithmModelTrack = MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack.class);
+        if (ObjectUtil.isNotNull(algorithmModelTrack) && ObjectUtil.isNotNull(algorithmModelTrack.getId())) {
             boolean updated = this.updateById(algorithmModelTrack);
-                return updated;
+            return updated;
         }
         return false;
     }

+ 0 - 1
taais-modules/taais-biz/src/main/resources/mapper/demo/AlgorithmConfigTrackMapper.xml

@@ -3,5 +3,4 @@
     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.taais.biz.mapper.AlgorithmConfigTrackMapper">
-
 </mapper>