Эх сурвалжийг харах

feat: CAT模型添加搞定

WANGKANG 8 сар өмнө
parent
commit
5149fdedfe

+ 5 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TrackSequenceController.java

@@ -142,4 +142,9 @@ public class TrackSequenceController extends BaseController {
     public CommonResult addEvaluate(@RequestBody AddEvaluate addEvaluate) {
     public CommonResult addEvaluate(@RequestBody AddEvaluate addEvaluate) {
         return trackSequenceService.addEvaluate(addEvaluate);
         return trackSequenceService.addEvaluate(addEvaluate);
     }
     }
+
+    @GetMapping("/model/{id}")
+    public CommonResult getModelList(@PathVariable("id") Long id) {
+        return trackSequenceService.getModelList(id);
+    }
 }
 }

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmConfigTrackMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmModelTrackMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/DataSeqMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/TargetDetectionMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/ToInfraredMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;
 import com.taais.biz.domain.ToInfrared;
 import com.taais.biz.domain.ToInfrared;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/TrackSequenceMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/Video2imageMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/VideoStableMapper.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.mapper;
 package com.taais.biz.mapper;
 
 
 import com.mybatisflex.core.BaseMapper;
 import com.mybatisflex.core.BaseMapper;

+ 2 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITrackSequenceService.java

@@ -85,4 +85,6 @@ public interface ITrackSequenceService extends IBaseService<TrackSequence> {
     CommonResult getDetail(Long id);
     CommonResult getDetail(Long id);
 
 
     CommonResult addEvaluate(AddEvaluate addEvaluate);
     CommonResult addEvaluate(AddEvaluate addEvaluate);
+
+    CommonResult getModelList(Long id);
 }
 }

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetDetectionServiceImpl.java

@@ -64,7 +64,7 @@ import com.alibaba.fastjson2.JSON;
 @Service
 @Service
 public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection> implements ITargetDetectionService {
 public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection> implements ITargetDetectionService {
     @Value("${server.port}")
     @Value("${server.port}")
-    String port;
+    public static String port;
 
 
     @Value("${server.task_stop_url}")
     @Value("${server.task_stop_url}")
     private String task_stop_url;
     private String task_stop_url;

+ 42 - 4
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -8,10 +8,8 @@ import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.text.DecimalFormat;
+import java.util.*;
 
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSON;
@@ -50,6 +48,8 @@ import com.taais.biz.service.ITrackSequenceService;
 
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
 import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
+import static com.taais.biz.service.impl.TargetDetectionServiceImpl.getFileSize;
+import static com.taais.biz.service.impl.TargetDetectionServiceImpl.port;
 import static com.taais.biz.service.impl.ToInfraredServiceImpl.readLogContent;
 import static com.taais.biz.service.impl.ToInfraredServiceImpl.readLogContent;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
@@ -551,4 +551,42 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             return CommonResult.success("新增评估任务失败!");
             return CommonResult.success("新增评估任务失败!");
         }
         }
     }
     }
+
+    @Override
+    public CommonResult getModelList(Long id) {
+        TrackSequence entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String modelPath = outPutPath;
+        File modelDir = new File(modelPath);
+        if (!modelDir.exists()) {
+            return CommonResult.fail("模型输出目录不存在!");
+        }
+        File[] files = modelDir.listFiles();
+        Integer idx = 0;
+        ArrayList<Map<String, String>> res = new ArrayList<>();
+        for (File file : files) {
+            if (!file.isDirectory()) {
+                continue;
+            }
+            idx += 1;
+            Map<String, String> tmp = new HashMap<>();
+            tmp.put("id", idx.toString());
+            tmp.put("name", file.getName());
+            String filePath = file.getPath();
+            tmp.put("path", filePath);
+            // todo 获取真正的url
+            // http://localhost:9090/profile/upload/2024/10/27/1_1729404909511_20241027153840A001.zip
+            String url = "http://localhost:" + port + Constants.RESOURCE_PREFIX + filePath.substring(TaaisConfig.getProfile().length());
+            url = url.replaceAll("\\\\", "/"); // windows
+            tmp.put("url", url);
+
+            double fileSize = (getFileSize(file) / (1024.0 * 1024.0));
+            DecimalFormat decimalFormat = new DecimalFormat("#.##");
+            String formatFileSize = decimalFormat.format(fileSize);
+            tmp.put("size", formatFileSize + "MB");
+            res.add(tmp);
+        }
+        return CommonResult.success(res, "success");
+    }
+
 }
 }