Przeglądaj źródła

feat: 模型添加状态信息

WANGKANG 8 miesięcy temu
rodzic
commit
72fe950e8a

+ 8 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/constant/BizConstant.java

@@ -7,6 +7,14 @@ public class BizConstant {
     // 视频文件存储目录
     public static final String UPLOAD_DIR = "uploads/";
 
+    public static class ModelStatus {
+        public static final String NOT_START = "0";
+        public static final String RUNNING = "1";
+        public static final String END = "2";
+        public static final String FAILED = "3";
+        public static final String INTERRUPTED = "4";
+    }
+
     public static class BizType {
         public static final String VIDEO_STABLE = "video_stable";
         public static final String TO_INFRARED = "to_infrared";

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

@@ -53,4 +53,13 @@ private static final long serialVersionUID = 1L;
     private String system;
 
     private String algorithmType;
+
+    /*
+    *  NOT_START = "0";
+       RUNNING = "1";
+       END = "2";
+       FAILED = "3";
+       INTERRUPTED = "4";
+    */
+    private String modelStatus;
 }

+ 2 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmModelTrackBo.java

@@ -63,4 +63,6 @@ public class AlgorithmModelTrackBo extends BaseEntity {
     private String system;
 
     private String algorithmType;
+
+    private String modelStatus;
 }

+ 35 - 11
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackVo.java

@@ -8,8 +8,10 @@ import com.taais.common.excel.convert.ExcelDictConvert;
 import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+
 import java.io.Serial;
 import java.io.Serializable;
+
 import com.taais.common.orm.core.domain.BaseEntity;
 
 /**
@@ -24,45 +26,67 @@ import com.taais.common.orm.core.domain.BaseEntity;
 @AutoMapper(target = AlgorithmModelTrack.class)
 public class AlgorithmModelTrackVo extends BaseEntity implements Serializable {
 
-@Serial
-private static final long serialVersionUID = 1L;
+    @Serial
+    private static final long serialVersionUID = 1L;
 
-    /** 主键ID */
+    /**
+     * 主键ID
+     */
     @ExcelProperty(value = "主键ID")
     private Long id;
 
-    /** 算法 */
+    /**
+     * 算法
+     */
     @ExcelProperty(value = "算法")
     private Long algorithmId;
 
-    /** 模型名称 */
+    /**
+     * 模型名称
+     */
     @ExcelProperty(value = "模型名称")
     private String modelName;
 
-    /** 模型 */
+    /**
+     * 模型
+     */
     @ExcelProperty(value = "模型")
     private String modelAddress;
 
-    /** 训练样本数 */
+    /**
+     * 训练样本数
+     */
     @ExcelProperty(value = "训练样本数")
     private Long sampleNumber;
 
-    /** 训练循环次数 */
+    /**
+     * 训练循环次数
+     */
     @ExcelProperty(value = "训练循环次数")
     private Long cycleEpoch;
 
-    /** 备注 */
+    /**
+     * 备注
+     */
     @ExcelProperty(value = "备注")
     private String remarks;
 
-    /** 逻辑删除标志(0代表存在 1代表删除) */
+    /**
+     * 逻辑删除标志(0代表存在 1代表删除)
+     */
     @ExcelProperty(value = "逻辑删除标志(0代表存在 1代表删除)")
     private Integer delFlag;
 
-    /** 系统 */
+    /**
+     * 系统
+     */
     @ExcelProperty(value = "系统")
     private String system;
 
     private String algorithmType;
     private String parameterConfig;
+
+    private String modelStatus;
+    private String type;
+    private String subsystem;
 }

+ 22 - 5
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmModelTrackServiceImpl.java

@@ -9,6 +9,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
+import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.AlgorithmConfigTrack;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
 import com.taais.biz.mapper.AlgorithmConfigTrackMapper;
@@ -127,6 +128,14 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
     public PageResult<AlgorithmModelTrackVo> selectPage(AlgorithmModelTrackBo algorithmModelTrackBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(algorithmModelTrackBo);
         Page<AlgorithmModelTrackVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmModelTrackVo.class);
+        page.getRecords().forEach(model -> {
+            Long algorithmId = model.getAlgorithmId();
+
+            AlgorithmConfigTrackVo algorithmConfig = algorithmConfigTrackService.selectById(algorithmId);
+            model.setType(algorithmConfig.getType());
+            model.setSubsystem(algorithmConfig.getSubsystem());
+        });
+
         return PageResult.build(page);
     }
 
@@ -152,13 +161,21 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
             String filePath = inputOssEntity.getFileName();
             String localPath = TaaisConfig.getProfile();
             resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
+            algorithmModelTrack.setModelAddress(resourcePath);
         } else {
-            String localPath = TaaisConfig.getUploadPath();
-            String path = DateUtils.datePath() + "/" + IdUtil.fastSimpleUUID();
-            ;
-            resourcePath = localPath + "/" + path + ".pt";
+            // String localPath = TaaisConfig.getUploadPath();
+            // String path = DateUtils.datePath() + "/" + IdUtil.fastSimpleUUID();
+            // resourcePath = localPath + "/" + path + ".pt";
+            // 本来这里是默认整一个虚拟模型地址,后面发现不合适便去掉了
         }
-        algorithmModelTrack.setModelAddress(resourcePath);
+        if (AlgorithmType.REASONING.equals(algorithmConfigTrackVo.getType()) || AlgorithmType.TEST.equals(algorithmConfigTrackVo.getType())) {
+            algorithmModelTrack.setModelStatus(BizConstant.ModelStatus.END);
+        } else if (AlgorithmType.TRAIN.equals(algorithmConfigTrackVo.getType())) {
+            algorithmModelTrack.setModelStatus(BizConstant.ModelStatus.NOT_START);
+        } else {
+            return CommonResult.fail("算法类型不正确");
+        }
+
 
         algorithmModelTrack.setAlgorithmId(algorithmModelTrackBo.getAlgorithmId());
         algorithmModelTrack.setAlgorithmType(algorithmConfigTrackVo.getAlgorithmName());