Procházet zdrojové kódy

feat: 目标检测任务调试

WANGKANG před 8 měsíci
rodič
revize
c7d71babd8

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

@@ -60,9 +60,6 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
 @Service
 public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection>
         implements ITargetDetectionService {
-    @Value("${server.port}")
-    public static String port;
-
     @Resource
     private TargetDetectionMapper targetDetectionMapper;
     @Autowired
@@ -481,37 +478,7 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         TargetDetection 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.getName().endsWith(BizConstant.TD_TRAIN_MODEL_SUFFIX)) {
-                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");
+        return getModelList_(modelPath, TaaisConfig.getProfile());
     }
 
     public static long getFileSize(File file) {

+ 14 - 12
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -65,12 +65,6 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
 @Service
 @Log4j2
 public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToInfrared> implements IToInfraredService {
-    @Value("${server.port}")
-    String port;
-
-    @Value("${taais.profile}")
-    String profile;
-
     @Autowired
     private ISysOssService ossService;
 
@@ -542,11 +536,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         return content;
     }
 
-    @Override
-    public CommonResult getModelList(Long id) {
-        ToInfrared entity = getById(id);
-        String outPutPath = entity.getOutputPath();
-        String modelPath = outPutPath + File.separator + "model";
+    public static CommonResult getModelList_(String modelPath, String profile) {
         File modelDir = new File(modelPath);
         if (!modelDir.exists()) {
             return CommonResult.fail("模型输出目录不存在!");
@@ -555,6 +545,9 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         Integer idx = 0;
         ArrayList<Map<String, String>> res = new ArrayList<>();
         for (File file : files) {
+            if (file.getName().endsWith(".log")) {
+                continue;
+            }
             idx += 1;
             Map<String, String> tmp = new HashMap<>();
             tmp.put("id", idx.toString());
@@ -563,7 +556,8 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             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(profile.length());
+            // /profile/upload/2024/10/27/1_1729404909511_20241027153840A001.zip
+            String url = "/api" + Constants.RESOURCE_PREFIX + filePath.substring(profile.length());
             url = url.replaceAll("\\\\", "/"); // windows
             tmp.put("url", url);
 
@@ -576,6 +570,14 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         return CommonResult.success(res, "success");
     }
 
+    @Override
+    public CommonResult getModelList(Long id) {
+        ToInfrared entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String modelPath = outPutPath + File.separator + "model";
+        return getModelList_(modelPath, TaaisConfig.getProfile());
+    }
+
     @Override
     public CommonResult previewPredictResult(Long id) {
         ToInfrared entity = getById(id);