瀏覽代碼

feat: 后端细节微调

WANGKANG 8 月之前
父節點
當前提交
93ade702f2

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

@@ -7,6 +7,9 @@ public class BizConstant {
     // 视频文件存储目录
     public static final String UPLOAD_DIR = "uploads/";
 
+    public static final String UNZIP_SUFFIX = "_unzip";
+    public static final String TO_INFRARED_SUFFIX = "_to_infrared";
+
     public static class ModelStatus {
         public static final String NOT_START = "0";
         public static final String RUNNING = "1";

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/ToInfraredVo.java

@@ -116,4 +116,8 @@ public class ToInfraredVo extends BaseEntity implements Serializable {
     private String outputPath;
 
     private Long algorithmModelId;
+    private String type;
+    private String subsystem;
+    private String algorithmName;
+    private String modelName;
 }

+ 4 - 3
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataSeqServiceImpl.java

@@ -7,6 +7,7 @@ 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.constant.BizConstant;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
 import com.taais.common.core.utils.MapstructUtils;
@@ -142,7 +143,7 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
         String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
         dataSeq.setFilePath(resourcePath);
 
-        String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + "_unzip";
+        String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
         unzip(dataSeq.getFilePath(), unzipPath);
         dataSeq.setUnzipPath(unzipPath);
 
@@ -192,9 +193,9 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
         String filePath = ossEntity.getFileName();
         String localPath = TaaisConfig.getProfile();
         String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
-        String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + "_unzip";
+        String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
 
-        String urlPrefix = ossEntity.getUrl().substring(0,  ossEntity.getUrl().lastIndexOf(".")) + "_unzip";
+        String urlPrefix = ossEntity.getUrl().substring(0,  ossEntity.getUrl().lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
 
         // 列出unzipPath下所有图片文件
         File directory = new File(unzipPath);

+ 18 - 7
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -14,6 +14,8 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.ToInfrared;
 import com.taais.biz.domain.bo.ToInfraredBo;
+import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
+import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
 import com.taais.biz.domain.vo.StartToInfraredTask;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.biz.mapper.ToInfraredMapper;
@@ -133,6 +135,15 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     public PageResult<ToInfraredVo> selectPage(ToInfraredBo toInfraredBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(toInfraredBo);
         Page<ToInfraredVo> page = this.pageAs(PageQuery.build(), queryWrapper, ToInfraredVo.class);
+        page.getRecords().forEach(entity -> {
+            Long modelId = entity.getAlgorithmModelId();
+            AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
+            AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(model.getAlgorithmId());
+            entity.setType(config.getType());
+            entity.setSubsystem(config.getSubsystem());
+            entity.setAlgorithmName(config.getAlgorithmName());
+            entity.setModelName(model.getModelName());
+        });
         return PageResult.build(page);
     }
 
@@ -224,8 +235,8 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         String fileName_without_suffix = removeFileExtension(fileName);
 
         Path path = Paths.get(resourcePath);
-        Path inputPath = path.resolveSibling(fileName_without_suffix + "_images");
-        Path outputPath = path.resolveSibling(fileName_without_suffix + "_to_infrared");
+        Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
+        Path outputPath = path.resolveSibling(fileName_without_suffix + BizConstant.TO_INFRARED_SUFFIX);
 
         makeDir(inputPath.toString());
         makeDir(outputPath.toString());
@@ -241,17 +252,17 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
 
         StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
+        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
         startToInfraredTask.setBizId(toInfrared.getId());
 
-        // if (algorithmConfigTrack.getType() == AlgorithmType.TRAIN) {
-        startToInfraredTask.setModel_path(algorithmModelTrack.getModelAddress());
-        // }
-
         startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
         startToInfraredTask.setSource_dir(toInfrared.getInputPath());
         startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
 
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
+        if (algorithmConfigTrack.getType() == BizConstant.AlgorithmType.REASONING) {
+            startToInfraredTask.setModel_path(algorithmModelTrack.getModelAddress());
+        }
+
 
         HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {