Jelajahi Sumber

Merge branch 'dev_wk2' into develop

WANGKANG 8 bulan lalu
induk
melakukan
174ba62803
59 mengubah file dengan 1069 tambahan dan 309 penghapusan
  1. 1 0
      taais-admin/src/main/resources/application-dev.yml
  2. 1 0
      taais-admin/src/main/resources/application.yml
  3. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/constant/BizConstant.java
  4. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmConfigTrackController.java
  5. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmModelTrackController.java
  6. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataSeqController.java
  7. 13 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TargetDetectionController.java
  8. 20 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ToInfraredController.java
  9. 27 6
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TrackSequenceController.java
  10. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/Video2imageController.java
  11. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/VideoStableController.java
  12. 24 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AddEvaluate.java
  13. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmConfigTrack.java
  14. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmModelTrack.java
  15. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/DataSeq.java
  16. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TargetDetection.java
  17. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/ToInfrared.java
  18. 5 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TrackSequence.java
  19. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/Video2image.java
  20. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/VideoStable.java
  21. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmConfigTrackBo.java
  22. 8 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmModelTrackBo.java
  23. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/DataSeqBo.java
  24. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TargetDetectionBo.java
  25. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredBo.java
  26. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredStartResultBo.java
  27. 5 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TrackSequenceBo.java
  28. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/Video2imageBo.java
  29. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/VideoStableBo.java
  30. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/VideoStableStartResultBo.java
  31. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackVo.java
  32. 3 3
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/StartTaskConfig.java
  33. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceImportVo.java
  34. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceVo.java
  35. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmConfigTrackMapper.java
  36. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmModelTrackMapper.java
  37. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/DataSeqMapper.java
  38. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/TargetDetectionMapper.java
  39. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/ToInfraredMapper.java
  40. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/TrackSequenceMapper.java
  41. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/Video2imageMapper.java
  42. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/VideoStableMapper.java
  43. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmConfigTrackService.java
  44. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmModelTrackService.java
  45. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IDataSeqService.java
  46. 8 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITargetDetectionService.java
  47. 10 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IToInfraredService.java
  48. 14 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITrackSequenceService.java
  49. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IVideo2imageService.java
  50. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IVideoStableService.java
  51. 23 25
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmConfigTrackServiceImpl.java
  52. 22 24
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmModelTrackServiceImpl.java
  53. 57 37
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataSeqServiceImpl.java
  54. 130 55
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetDetectionServiceImpl.java
  55. 170 38
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java
  56. 359 93
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java
  57. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/Video2imageServiceImpl.java
  58. 15 19
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/VideoStableServiceImpl.java
  59. 14 8
      taais-modules/taais-biz/src/main/java/com/taais/biz/utils/ZipUtils.java

+ 1 - 0
taais-admin/src/main/resources/application-dev.yml

@@ -2,6 +2,7 @@ server:
   video_stable_start_url: http://localhost:11006/video_stable
   video_stable_stop_url: http://localhost:11006/video_stable_stop
   task_stop_url: http://localhost:11003/stop
+  task_stop_url_cat: http://localhost:11004/stop
 
 # 数据源配置
 spring:

+ 1 - 0
taais-admin/src/main/resources/application.yml

@@ -10,6 +10,7 @@ taais:
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/km/uploadPath,Linux配置 /home/km/uploadPath)
   # profile: D:/taais/uploadPath
+  # 后面不能有 /
   profile: D:/home/ObjectDetection_Web
   # 获取ip地址开关
   addressEnabled: false

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

@@ -9,6 +9,7 @@ public class BizConstant {
     public static final String MODEL_PATH = "model";
     public static final String MODEL_SUFFIX = ".pt";
     public static final String PREDICT_PATH = "predict";
+    public static final String TD_TRAIN_MODEL_SUFFIX = ".ckpt";
 
     public static final String UNZIP_SUFFIX = "_unzip";
     public static final String STABLE_SUFFIX = "_stable";

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmConfigTrackController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.util.List;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmModelTrackController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.util.List;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataSeqController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.util.List;

+ 13 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TargetDetectionController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.io.IOException;
@@ -126,4 +130,13 @@ public class TargetDetectionController extends BaseController {
          */
         return targetDetectionService.zipImages(id);
     }
+    @GetMapping("/log/{id}")
+    public CommonResult getLog(@PathVariable("id") Long id) {
+        return targetDetectionService.getLog(id);
+    }
+
+    @GetMapping("/model/{id}")
+    public CommonResult getModelList(@PathVariable("id") Long id) {
+        return targetDetectionService.getModelList(id);
+    }
 }

+ 20 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ToInfraredController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import com.taais.biz.domain.bo.ToInfraredBo;
@@ -34,6 +38,7 @@ import java.util.List;
 public class ToInfraredController extends BaseController {
     @Resource
     private IToInfraredService toInfraredService;
+    private Long ossId;
 
     /**
      * 查询可见光转红外列表
@@ -125,4 +130,19 @@ public class ToInfraredController extends BaseController {
          */
         return toInfraredService.zipImages(id);
     }
+
+    @GetMapping("/log/{id}")
+    public CommonResult getLog(@PathVariable("id") Long id) {
+        return toInfraredService.getLog(id);
+    }
+
+    @GetMapping("/model/{id}")
+    public CommonResult getModelList(@PathVariable("id") Long id) {
+        return toInfraredService.getModelList(id);
+    }
+
+    @GetMapping("/previewPredictResult/{id}")
+    public CommonResult previewPredictResult(@PathVariable("id") Long id) {
+        return toInfraredService.previewPredictResult(id);
+    }
 }

+ 27 - 6
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TrackSequenceController.java

@@ -1,8 +1,13 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.io.IOException;
 import java.util.List;
 
+import com.taais.biz.domain.AddEvaluate;
 import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import cn.dev33.satoken.annotation.SaCheckPermission;
@@ -72,12 +77,8 @@ public class TrackSequenceController extends BaseController {
     @Log(title = "注视轨迹序列", businessType = BusinessType.INSERT)
     @RepeatSubmit()
     @PostMapping
-    public CommonResult<Void> add(@Validated @RequestBody TrackSequenceBo trackSequenceBo) {
-        boolean inserted = trackSequenceService.insert(trackSequenceBo);
-        if (!inserted) {
-            return CommonResult.fail("新增注视轨迹序列记录失败!");
-        }
-        return CommonResult.success();
+    public CommonResult add(@Validated @RequestBody TrackSequenceBo trackSequenceBo) {
+        return trackSequenceService.insert(trackSequenceBo);
     }
 
     /**
@@ -126,4 +127,24 @@ public class TrackSequenceController extends BaseController {
          */
         return trackSequenceService.zipImages(id);
     }
+
+    @GetMapping("/log/{id}")
+    public CommonResult getLog(@PathVariable("id") Long id) {
+        return trackSequenceService.getLog(id);
+    }
+
+    @GetMapping("/detail/{id}")
+    public CommonResult getDetail(@PathVariable("id") Long id) {
+        return trackSequenceService.getDetail(id);
+    }
+
+    @PostMapping("/add_evaluate")
+    public CommonResult addEvaluate(@RequestBody 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/controller/Video2imageController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.io.File;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/VideoStableController.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.controller;
 
 import java.io.File;

+ 24 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AddEvaluate.java

@@ -0,0 +1,24 @@
+/**
+ * @Date: 20241029
+ * @Author: WANGKANG
+ * @Blog: https://wangkang1717/github.io
+ * @Email: 1686617586@qq.com
+ * @Description: None
+ * Copyright 2024 WANGKANG, All Rights Reserved.
+ */
+
+package com.taais.biz.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class AddEvaluate {
+    private Long id;
+    private String name;
+    private Long algorithmId;
+    private String remarks;
+}

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import com.mybatisflex.annotation.Column;

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import com.mybatisflex.annotation.Column;

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import java.util.Date;

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import java.util.Date;

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import java.util.Date;

+ 5 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TrackSequence.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import java.util.Date;
@@ -75,4 +79,5 @@ private static final long serialVersionUID = 1L;
     private String zipFilePath;
 
     private Long algorithmModelId;
+    private Long algorithmId;
 }

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import java.util.Date;

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain;
 
 import java.util.Date;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmConfigTrackBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.taais.biz.domain.AlgorithmConfigTrack;

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.taais.biz.domain.AlgorithmModelTrack;
@@ -36,6 +40,8 @@ public class AlgorithmModelTrackBo extends BaseEntity {
 
     // @NotNull(message = "模型文件不能为空")
     private Long modelInputOssId;
+    // 模型的路径
+    private String modelPath;
 
     /**
      * 模型
@@ -62,6 +68,8 @@ public class AlgorithmModelTrackBo extends BaseEntity {
      */
     private String system;
 
+    private String subSystem;
+
     private String algorithmType;
 
     private String modelStatus;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/DataSeqBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.taais.biz.domain.DataSeq;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TargetDetectionBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.taais.biz.domain.TargetDetection;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredStartResultBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import jakarta.validation.constraints.NotNull;

+ 5 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TrackSequenceBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -95,4 +99,5 @@ public class TrackSequenceBo extends BaseEntity{
     private String zipFilePath;
 
     private Long algorithmModelId;
+    private Long algorithmId;
 }

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/Video2imageBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/VideoStableBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import com.alibaba.excel.annotation.ExcelProperty;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/VideoStableStartResultBo.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.domain.bo;
 
 import jakarta.validation.constraints.NotNull;

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

@@ -84,6 +84,7 @@ public class AlgorithmModelTrackVo extends BaseEntity implements Serializable {
     private String system;
 
     private String algorithmType;
+    private String algorithmName;
     private String parameterConfig;
 
     private String modelStatus;

+ 3 - 3
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/StartToInfraredTask.java → taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/StartTaskConfig.java

@@ -1,6 +1,5 @@
 package com.taais.biz.domain.vo;
 
-import jakarta.validation.constraints.NotNull;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -9,18 +8,19 @@ import lombok.NoArgsConstructor;
  * @Datetime : 2023/12/5 12:13
  * @Author : WANGKANG
  * @Email : 1686617586@qq.com
- * @File : StartToInfraredTask.java
+ * @File : StartTaskConfig.java
  * @Brief :
  * Copyright 2023 WANGKANG, All Rights Reserved.
  */
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-public class StartToInfraredTask {
+public class StartTaskConfig {
     private String bizType;
     private Long bizId;
     private String otherParams;
     private String model_path;
     private String result_dir;
     private String source_dir;
+    private String log_path;
 }

+ 1 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceImportVo.java

@@ -86,4 +86,5 @@ public class TrackSequenceImportVo implements Serializable
     private String zipFilePath;
 
     private Long algorithmModelId;
+    private Long algorithmId;
 }

+ 1 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceVo.java

@@ -128,4 +128,5 @@ public class TrackSequenceVo extends BaseEntity implements Serializable {
     private String subsystem;
     private String algorithmName;
     private String modelName;
+    private Long algorithmId;
 }

+ 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;
 
 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;
 
 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;
 
 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;
 
 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;
 import com.mybatisflex.core.BaseMapper;
 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;
 
 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;
 
 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;
 
 import com.mybatisflex.core.BaseMapper;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmConfigTrackService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import java.util.List;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmModelTrackService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import java.util.List;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IDataSeqService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import java.util.List;

+ 8 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITargetDetectionService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import java.util.List;
@@ -74,4 +78,8 @@ public interface ITargetDetectionService extends IBaseService<TargetDetection> {
     CommonResult getResult(TaskTrackResultBo taskTrackResultBo);
 
     ResponseEntity<Resource> zipImages(Long id);
+
+    CommonResult getLog(Long id);
+
+    CommonResult getModelList(Long id);
 }

+ 10 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IToInfraredService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 
@@ -75,4 +79,10 @@ public interface IToInfraredService extends IBaseService<ToInfrared> {
     CommonResult getResult(TaskTrackResultBo toInfraredStartResultBo);
 
     ResponseEntity<Resource> zipImages(Long id);
+
+    CommonResult getLog(Long id);
+
+    CommonResult getModelList(Long id);
+
+    CommonResult previewPredictResult(Long id);
 }

+ 14 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITrackSequenceService.java

@@ -1,7 +1,12 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import java.util.List;
 
+import com.taais.biz.domain.AddEvaluate;
 import com.taais.biz.domain.TaskTrackResultBo;
 import com.taais.biz.domain.TrackSequence;
 import com.taais.biz.domain.vo.TrackSequenceVo;
@@ -49,7 +54,7 @@ public interface ITrackSequenceService extends IBaseService<TrackSequence> {
      * @param trackSequenceBo 注视轨迹序列Bo
      * @return 结果:true 操作成功,false 操作失败
      */
-    boolean insert(TrackSequenceBo trackSequenceBo);
+    CommonResult insert(TrackSequenceBo trackSequenceBo);
 
     /**
      * 修改注视轨迹序列
@@ -74,4 +79,12 @@ public interface ITrackSequenceService extends IBaseService<TrackSequence> {
     ResponseEntity<Resource> zipImages(Long id);
 
     CommonResult getResult(TaskTrackResultBo taskTrackResultBo);
+
+    CommonResult getLog(Long id);
+
+    CommonResult getDetail(Long id);
+
+    CommonResult addEvaluate(AddEvaluate addEvaluate);
+
+    CommonResult getModelList(Long id);
 }

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IVideo2imageService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import com.taais.biz.domain.Video2image;

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IVideoStableService.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service;
 
 import java.util.List;

+ 23 - 25
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmConfigTrackServiceImpl.java

@@ -1,3 +1,8 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
+
 package com.taais.biz.service.impl;
 
 import java.util.ArrayList;
@@ -21,6 +26,7 @@ import com.taais.biz.domain.AlgorithmConfigTrack;
 import com.taais.biz.domain.bo.AlgorithmConfigTrackBo;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
 import com.taais.biz.service.IAlgorithmConfigTrackService;
+
 import static com.taais.biz.domain.table.AlgorithmConfigTrackTableDef.ALGORITHM_CONFIG_TRACK;
 
 /**
@@ -41,22 +47,14 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
 
     private QueryWrapper buildQueryWrapper(AlgorithmConfigTrackBo algorithmConfigTrackBo) {
         QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.TYPE.eq
-        (algorithmConfigTrackBo.getType()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.PARENT_ID.eq
-        (algorithmConfigTrackBo.getParentId()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.SUBSYSTEM.eq
-        (algorithmConfigTrackBo.getSubsystem()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.ALGORITHM_NAME.like
-        (algorithmConfigTrackBo.getAlgorithmName()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.ALGORITHM_ADDRESS.eq
-        (algorithmConfigTrackBo.getAlgorithmAddress()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.PARAMETER_CONFIG.eq
-        (algorithmConfigTrackBo.getParameterConfig()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.REMARKS.eq
-        (algorithmConfigTrackBo.getRemarks()));
-        queryWrapper.and(ALGORITHM_CONFIG_TRACK.SYSTEM.eq
-        (algorithmConfigTrackBo.getSystem()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.TYPE.eq(algorithmConfigTrackBo.getType()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.PARENT_ID.eq(algorithmConfigTrackBo.getParentId()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.SUBSYSTEM.eq(algorithmConfigTrackBo.getSubsystem()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.ALGORITHM_NAME.like(algorithmConfigTrackBo.getAlgorithmName()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.ALGORITHM_ADDRESS.eq(algorithmConfigTrackBo.getAlgorithmAddress()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.PARAMETER_CONFIG.eq(algorithmConfigTrackBo.getParameterConfig()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.REMARKS.eq(algorithmConfigTrackBo.getRemarks()));
+        queryWrapper.and(ALGORITHM_CONFIG_TRACK.SYSTEM.eq(algorithmConfigTrackBo.getSystem()));
 
         return queryWrapper;
     }
@@ -69,7 +67,7 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
      */
     @Override
     public AlgorithmConfigTrackVo selectById(Long id) {
-            return this.getOneAs(query().where(ALGORITHM_CONFIG_TRACK.ID.eq(id)), AlgorithmConfigTrackVo.class);
+        return this.getOneAs(query().where(ALGORITHM_CONFIG_TRACK.ID.eq(id)), AlgorithmConfigTrackVo.class);
 
     }
 
@@ -82,7 +80,7 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
     @Override
     public List<AlgorithmConfigTrackVo> selectList(AlgorithmConfigTrackBo algorithmConfigTrackBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(algorithmConfigTrackBo);
-            return this.listAs(queryWrapper, AlgorithmConfigTrackVo.class);
+        return this.listAs(queryWrapper, AlgorithmConfigTrackVo.class);
     }
 
     /**
@@ -94,7 +92,7 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
     @Override
     public PageResult<AlgorithmConfigTrackVo> selectPage(AlgorithmConfigTrackBo algorithmConfigTrackBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(algorithmConfigTrackBo);
-            Page<AlgorithmConfigTrackVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmConfigTrackVo.class);
+        Page<AlgorithmConfigTrackVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmConfigTrackVo.class);
         return PageResult.build(page);
     }
 
@@ -106,7 +104,7 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
      */
     @Override
     public boolean insert(AlgorithmConfigTrackBo algorithmConfigTrackBo) {
-    AlgorithmConfigTrack algorithmConfigTrack =MapstructUtils.convert(algorithmConfigTrackBo, AlgorithmConfigTrack. class);
+        AlgorithmConfigTrack algorithmConfigTrack = MapstructUtils.convert(algorithmConfigTrackBo, AlgorithmConfigTrack.class);
 
         return this.save(algorithmConfigTrack);//使用全局配置的雪花算法主键生成器生成ID值
     }
@@ -119,10 +117,10 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
      */
     @Override
     public boolean update(AlgorithmConfigTrackBo algorithmConfigTrackBo) {
-        AlgorithmConfigTrack algorithmConfigTrack =MapstructUtils.convert(algorithmConfigTrackBo, AlgorithmConfigTrack. class);
-        if (ObjectUtil.isNotNull(algorithmConfigTrack) && ObjectUtil.isNotNull(algorithmConfigTrack.getId())){
+        AlgorithmConfigTrack algorithmConfigTrack = MapstructUtils.convert(algorithmConfigTrackBo, AlgorithmConfigTrack.class);
+        if (ObjectUtil.isNotNull(algorithmConfigTrack) && ObjectUtil.isNotNull(algorithmConfigTrack.getId())) {
             boolean updated = this.updateById(algorithmConfigTrack);
-                return updated;
+            return updated;
         }
         return false;
     }
@@ -147,8 +145,8 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
 
         for (AlgorithmConfigTrack algorithmConfigTrack : algorithmConfigTrackMapper.selectAll()) {
             HashMap<String, Object> map = new HashMap<>();
-            map.put("label",algorithmConfigTrack.getAlgorithmName());
-            map.put("value",algorithmConfigTrack.getId());
+            map.put("label", algorithmConfigTrack.getAlgorithmName());
+            map.put("value", algorithmConfigTrack.getId());
             map.put("type", algorithmConfigTrack.getType());
             map.put("subsystem", algorithmConfigTrack.getSubsystem());
 

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

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
 import java.io.File;
@@ -64,22 +68,14 @@ 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()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.MODEL_NAME.like
-            (algorithmModelTrackBo.getModelName()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.MODEL_ADDRESS.eq
-            (algorithmModelTrackBo.getModelAddress()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.SAMPLE_NUMBER.eq
-            (algorithmModelTrackBo.getSampleNumber()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.CYCLE_EPOCH.eq
-            (algorithmModelTrackBo.getCycleEpoch()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.REMARKS.eq
-            (algorithmModelTrackBo.getRemarks()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.SYSTEM.eq
-            (algorithmModelTrackBo.getSystem()));
-        queryWrapper.and(ALGORITHM_MODEL_TRACK.ALGORITHM_TYPE.eq
-            (algorithmModelTrackBo.getAlgorithmType()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.ALGORITHM_ID.eq(algorithmModelTrackBo.getAlgorithmId()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.MODEL_NAME.like(algorithmModelTrackBo.getModelName()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.MODEL_ADDRESS.eq(algorithmModelTrackBo.getModelAddress()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.SAMPLE_NUMBER.eq(algorithmModelTrackBo.getSampleNumber()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.CYCLE_EPOCH.eq(algorithmModelTrackBo.getCycleEpoch()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.REMARKS.eq(algorithmModelTrackBo.getRemarks()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.SYSTEM.eq(algorithmModelTrackBo.getSystem()));
+        queryWrapper.and(ALGORITHM_MODEL_TRACK.ALGORITHM_TYPE.eq(algorithmModelTrackBo.getAlgorithmType()));
 
         return queryWrapper;
     }
@@ -150,14 +146,14 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
     @Override
     public CommonResult<String> insert(AlgorithmModelTrackBo algorithmModelTrackBo) {
         AlgorithmConfigTrackVo algorithmConfigTrackVo = algorithmConfigTrackService.selectById(algorithmModelTrackBo.getAlgorithmId());
-        if (algorithmConfigTrackVo.getType().equals(AlgorithmType.REASONING) && ObjectUtil.isEmpty(algorithmModelTrackBo.getModelInputOssId())) {
-            return CommonResult.fail("预测算法必须上传模型文件");
+        if (algorithmConfigTrackVo.getType().equals(AlgorithmType.REASONING) && ObjectUtil.isEmpty(algorithmModelTrackBo.getModelInputOssId()) && ObjectUtil.isEmpty(algorithmModelTrackBo.getModelPath())) {
+            return CommonResult.fail("预测算法必须上传模型文件或指定模型路径!");
         }
 
         AlgorithmModelTrack algorithmModelTrack = MapstructUtils.convert(algorithmModelTrackBo, AlgorithmModelTrack.class);
 
         String resourcePath = null;
-        if (algorithmModelTrackBo.getModelInputOssId() != null) {
+        if (ObjectUtil.isNotEmpty(algorithmModelTrackBo.getModelInputOssId())) {
             SysOssVo inputOssEntity = ossService.getById(algorithmModelTrackBo.getModelInputOssId());
 
             String filePath = inputOssEntity.getFileName();
@@ -177,11 +173,13 @@ public class AlgorithmModelTrackServiceImpl extends BaseServiceImpl<AlgorithmMod
             } else {
                 return CommonResult.fail("模型格式不正确,请上传.zip或.pt文件");
             }
-        } else {
-            // String localPath = TaaisConfig.getUploadPath();
-            // String path = DateUtils.datePath() + "/" + IdUtil.fastSimpleUUID();
-            // resourcePath = localPath + "/" + path + ".pt";
-            // 本来这里是默认整一个虚拟模型地址,后面发现不合适便去掉了
+        } // 这是使用ossid上传
+        else if (ObjectUtil.isNotEmpty(algorithmModelTrackBo.getModelPath())) { // 这是使用路径上传
+            File modelFile = new File(algorithmModelTrackBo.getModelPath());
+            if (!modelFile.exists()) {
+                return CommonResult.fail("模型路径不存在!");
+            }
+            algorithmModelTrack.setModelAddress(algorithmModelTrackBo.getModelPath());
         }
 
         if (AlgorithmType.REASONING.equals(algorithmConfigTrackVo.getType()) || AlgorithmType.TEST.equals(algorithmConfigTrackVo.getType())) {

+ 57 - 37
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataSeqServiceImpl.java

@@ -1,8 +1,10 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
 import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -31,7 +33,6 @@ import com.taais.biz.domain.vo.DataSeqVo;
 import com.taais.biz.service.IDataSeqService;
 
 import static com.taais.biz.domain.table.DataSeqTableDef.DATA_SEQ;
-import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
 import static com.taais.biz.utils.ZipUtils.unzip;
 
 /**
@@ -54,34 +55,20 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
 
     private QueryWrapper buildQueryWrapper(DataSeqBo dataSeqBo) {
         QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
-        queryWrapper.and(DATA_SEQ.NAME.like
-            (dataSeqBo.getName()));
-        queryWrapper.and(DATA_SEQ.DATA_TYPE.eq
-            (dataSeqBo.getDataType()));
-        queryWrapper.and(DATA_SEQ.FILE_TYPE.eq
-            (dataSeqBo.getFileType()));
-        queryWrapper.and(DATA_SEQ.OBJECT_TYPE.eq
-            (dataSeqBo.getObjectType()));
-        queryWrapper.and(DATA_SEQ.OBJECT_SUBTYPE.eq
-            (dataSeqBo.getObjectSubtype()));
-        queryWrapper.and(DATA_SEQ.BATCH_NUM.eq
-            (dataSeqBo.getBatchNum()));
-        queryWrapper.and(DATA_SEQ.SCENE.eq
-            (dataSeqBo.getScene()));
-        queryWrapper.and(DATA_SEQ.DATA_SOURCE.eq
-            (dataSeqBo.getDataSource()));
-        queryWrapper.and(DATA_SEQ.GATHER_TIME.eq
-            (dataSeqBo.getGatherTime()));
-        queryWrapper.and(DATA_SEQ.GATHER_SPOT.eq
-            (dataSeqBo.getGatherSpot()));
-        queryWrapper.and(DATA_SEQ.URL.eq
-            (dataSeqBo.getUrl()));
-        queryWrapper.and(DATA_SEQ.LOG.eq
-            (dataSeqBo.getLog()));
-        queryWrapper.and(DATA_SEQ.REMARKS.eq
-            (dataSeqBo.getRemarks()));
-        queryWrapper.and(DATA_SEQ.SUBSYSTEM.eq
-            (dataSeqBo.getSubsystem()));
+        queryWrapper.and(DATA_SEQ.NAME.like(dataSeqBo.getName()));
+        queryWrapper.and(DATA_SEQ.DATA_TYPE.eq(dataSeqBo.getDataType()));
+        queryWrapper.and(DATA_SEQ.FILE_TYPE.eq(dataSeqBo.getFileType()));
+        queryWrapper.and(DATA_SEQ.OBJECT_TYPE.eq(dataSeqBo.getObjectType()));
+        queryWrapper.and(DATA_SEQ.OBJECT_SUBTYPE.eq(dataSeqBo.getObjectSubtype()));
+        queryWrapper.and(DATA_SEQ.BATCH_NUM.eq(dataSeqBo.getBatchNum()));
+        queryWrapper.and(DATA_SEQ.SCENE.eq(dataSeqBo.getScene()));
+        queryWrapper.and(DATA_SEQ.DATA_SOURCE.eq(dataSeqBo.getDataSource()));
+        queryWrapper.and(DATA_SEQ.GATHER_TIME.eq(dataSeqBo.getGatherTime()));
+        queryWrapper.and(DATA_SEQ.GATHER_SPOT.eq(dataSeqBo.getGatherSpot()));
+        queryWrapper.and(DATA_SEQ.URL.eq(dataSeqBo.getUrl()));
+        queryWrapper.and(DATA_SEQ.LOG.eq(dataSeqBo.getLog()));
+        queryWrapper.and(DATA_SEQ.REMARKS.eq(dataSeqBo.getRemarks()));
+        queryWrapper.and(DATA_SEQ.SUBSYSTEM.eq(dataSeqBo.getSubsystem()));
 
         return queryWrapper;
     }
@@ -199,15 +186,50 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
         String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
         String unzipPath = resourcePath.substring(0, resourcePath.lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
 
-        String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + BizConstant.UNZIP_SUFFIX;
+        String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().indexOf(Constants.RESOURCE_PREFIX) + Constants.RESOURCE_PREFIX.length());
 
         // 列出unzipPath下所有图片文件
         File directory = new File(unzipPath);
-        File[] files = directory.listFiles();
-        List<String> imageList = Arrays.asList(files).stream().filter(file -> file.isFile() && isImageFile(file)).map(file -> urlPrefix + "/" + file.getName()).toList();
+
+        List<String> imageList = new ArrayList<>();
+        filterImages(imageList, directory, urlPrefix);
         return imageList;
     }
 
+    public void filterImages(List<String> imageList, File path, String urlPrefix) {
+        File[] files = path.listFiles();
+        if (files == null || files.length == 0) {
+            return;
+        }
+        List<String> tmpList = Arrays.asList(files).stream().filter(file -> file.isFile() && isImageFile(file)).map(file -> urlPrefix + file.getPath().substring(TaaisConfig.getProfile().length()).replaceAll("\\\\", "/")).toList();
+        imageList.addAll(tmpList);
+
+        for (File file : files) {
+            if (file.isDirectory()) {
+                filterImages(imageList, file, urlPrefix);
+            }
+        }
+    }
+
+    public static List<String> calculateImagePath(String urlPrefix, File path) {
+        List<String> imageList = new ArrayList<>();
+        File[] files = path.listFiles();
+        if (files == null || files.length == 0) {
+            return null;
+        }
+        List<String> tmpList = Arrays.asList(files).stream().filter(file -> file.isFile() && isImageFile(file)).map(file -> urlPrefix + file.getPath().substring(TaaisConfig.getProfile().length()).replaceAll("\\\\", "/")).toList();
+        imageList.addAll(tmpList);
+        return imageList;
+    }
+
+    public static List<String> calculateImagePath(String urlPrefix, String path) {
+        File dir = new File(path);
+        if (!dir.exists() || !dir.isDirectory()) {
+            return null;
+        }
+        return calculateImagePath(urlPrefix, dir);
+    }
+
     @Override
     public List<String> getImages(Long inputOdssId, String subsystem, Boolean isInput, String dir) {
         // 检查input_oss_id是否存在
@@ -248,9 +270,7 @@ public class DataSeqServiceImpl extends BaseServiceImpl<DataSeqMapper, DataSeq>
     }
 
     // 常见图片格式的后缀
-    private static final String[] IMAGE_EXTENSIONS = {
-        ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".webp"
-    };
+    private static final String[] IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".webp"};
 
     // 判断文件是否为常见图片格式
     public static boolean isImageFile(File file) {

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

@@ -1,13 +1,18 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Path;
 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 com.mybatisflex.core.paginate.Page;
@@ -16,8 +21,7 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 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.mapper.ToInfraredMapper;
+import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
@@ -45,6 +49,7 @@ import com.taais.biz.service.ITargetDetectionService;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.TargetDetectionTableDef.TARGET_DETECTION;
+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.sendPostMsg;
 
@@ -58,6 +63,9 @@ import com.alibaba.fastjson2.JSON;
  */
 @Service
 public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection> implements ITargetDetectionService {
+    @Value("${server.port}")
+    public static String port;
+
     @Value("${server.task_stop_url}")
     private String task_stop_url;
 
@@ -78,32 +86,19 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
 
     private QueryWrapper buildQueryWrapper(TargetDetectionBo targetDetectionBo) {
         QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
-        queryWrapper.and(TARGET_DETECTION.NAME.like
-            (targetDetectionBo.getName()));
-        queryWrapper.and(TARGET_DETECTION.STATUS.eq
-            (targetDetectionBo.getStatus()));
-        queryWrapper.and(TARGET_DETECTION.START_TIME.eq
-            (targetDetectionBo.getStartTime()));
-        queryWrapper.and(TARGET_DETECTION.END_TIME.eq
-            (targetDetectionBo.getEndTime()));
-        queryWrapper.and(TARGET_DETECTION.COST_SECOND.eq
-            (targetDetectionBo.getCostSecond()));
-        queryWrapper.and(TARGET_DETECTION.LOG.eq
-            (targetDetectionBo.getLog()));
-        queryWrapper.and(TARGET_DETECTION.REMARKS.eq
-            (targetDetectionBo.getRemarks()));
-        queryWrapper.and(TARGET_DETECTION.URL.eq
-            (targetDetectionBo.getUrl()));
-        queryWrapper.and(TARGET_DETECTION.INPUT_OSS_ID.eq
-            (targetDetectionBo.getInputOssId()));
-        queryWrapper.and(TARGET_DETECTION.INPUT_PATH.eq
-            (targetDetectionBo.getInputPath()));
-        queryWrapper.and(TARGET_DETECTION.OUTPUT_PATH.eq
-            (targetDetectionBo.getOutputPath()));
-        queryWrapper.and(TARGET_DETECTION.ZIP_FILE_PATH.eq
-            (targetDetectionBo.getZipFilePath()));
-        queryWrapper.and(TARGET_DETECTION.ALGORITHM_MODEL_ID.eq
-            (targetDetectionBo.getAlgorithmModelId()));
+        queryWrapper.and(TARGET_DETECTION.NAME.like(targetDetectionBo.getName()));
+        queryWrapper.and(TARGET_DETECTION.STATUS.eq(targetDetectionBo.getStatus()));
+        queryWrapper.and(TARGET_DETECTION.START_TIME.eq(targetDetectionBo.getStartTime()));
+        queryWrapper.and(TARGET_DETECTION.END_TIME.eq(targetDetectionBo.getEndTime()));
+        queryWrapper.and(TARGET_DETECTION.COST_SECOND.eq(targetDetectionBo.getCostSecond()));
+        queryWrapper.and(TARGET_DETECTION.LOG.eq(targetDetectionBo.getLog()));
+        queryWrapper.and(TARGET_DETECTION.REMARKS.eq(targetDetectionBo.getRemarks()));
+        queryWrapper.and(TARGET_DETECTION.URL.eq(targetDetectionBo.getUrl()));
+        queryWrapper.and(TARGET_DETECTION.INPUT_OSS_ID.eq(targetDetectionBo.getInputOssId()));
+        queryWrapper.and(TARGET_DETECTION.INPUT_PATH.eq(targetDetectionBo.getInputPath()));
+        queryWrapper.and(TARGET_DETECTION.OUTPUT_PATH.eq(targetDetectionBo.getOutputPath()));
+        queryWrapper.and(TARGET_DETECTION.ZIP_FILE_PATH.eq(targetDetectionBo.getZipFilePath()));
+        queryWrapper.and(TARGET_DETECTION.ALGORITHM_MODEL_ID.eq(targetDetectionBo.getAlgorithmModelId()));
 
         return queryWrapper;
     }
@@ -245,12 +240,12 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
 
         Path path = Paths.get(resourcePath);
         Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
-        Path outputPath = path.resolveSibling(fileName_without_suffix + BizConstant.TARGET_DETECTION_SUFFIX);
+        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TARGET_DETECTION_SUFFIX);
 
-        makeDir(inputPath.toString());
+//        makeDir(inputPath.toString());
         makeDir(outputPath.toString());
 
-        File file = new File(resourcePath);
+        File file = new File(inputPath.toString());
         if (!file.exists()) {
             ZipUtils.unzip(resourcePath, inputPath.toString());
         }
@@ -263,22 +258,36 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TARGET_DETECTION);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TARGET_DETECTION);
+        startTaskConfig.setBizId(entity.getId());
 
-        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
+        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        startToInfraredTask.setSource_dir(entity.getInputPath());
-        startToInfraredTask.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setSource_dir(entity.getInputPath());
+        startTaskConfig.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
             String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName();
-            startToInfraredTask.setModel_path(modelPath);
+            startTaskConfig.setModel_path(modelPath);
+        } else if (BizConstant.AlgorithmType.TRAIN.equals(algorithmConfigTrack.getType())) {
+            // 这时候需要在之前的基础上,添加类别的路径
+            File dir = new File(startTaskConfig.getSource_dir());
+            File[] files = dir.listFiles();
+            // 暂时只传第一个文件夹用作训练
+            if (files == null || files.length == 0) {
+                return CommonResult.fail("输入数据集为空!");
+            }
+            for (File file__ : files) {
+                if (file__.isDirectory()) {
+                    startTaskConfig.setSource_dir(file__.getAbsolutePath()); // 设置路径
+                    break;
+                }
+            }
         }
 
-
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -294,11 +303,11 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
     public CommonResult stop(Long id) {
         TargetDetection entity = getById(id);
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
+        startTaskConfig.setBizId(entity.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(entity);
@@ -328,11 +337,11 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         algorithmModelTrack.setModelStatus("200".equals(status) ? BizConstant.ModelStatus.END : BizConstant.ModelStatus.FAILED);
 
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
-        String params =  algorithmConfigTrack.getParameterConfig();
+        String params = algorithmConfigTrack.getParameterConfig();
         HashMap<String, Object> parse = (HashMap<String, Object>) JSON.parse((params));
 
-        if("200".equals(status) && ObjectUtil.isNull(algorithmModelTrack.getModelAddress())) {
-            algorithmModelTrack.setModelAddress(entity.getOutputPath() + File.separator + ((HashMap<String, String>)parse.get("dataset")).get("classes"));
+        if ("200".equals(status) && ObjectUtil.isNull(algorithmModelTrack.getModelAddress())) {
+            algorithmModelTrack.setModelAddress(entity.getOutputPath() + File.separator + ((HashMap<String, String>) parse.get("dataset")).get("classes"));
 
             System.out.println(parse.get("dataset"));
             algorithmModelTrackService.updateById(algorithmModelTrack);
@@ -387,9 +396,75 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         }
 
         org.springframework.core.io.Resource resource = new FileSystemResource(file);
-        return ResponseEntity.ok()
-            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
-            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
-            .body(resource);
+        return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"").header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
+    }
+
+    private String getLogFileName(TargetDetection entity) {
+        return entity.getId() + BizConstant.TARGET_DETECTION_SUFFIX + ".log";
+    }
+
+    @Override
+    public CommonResult getLog(Long id) {
+        TargetDetection entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String logPath = outPutPath + File.separator + getLogFileName(entity);
+        System.out.println(logPath);
+        File file = new File(logPath);
+        if (!file.exists()) {
+            return CommonResult.fail("日志文件不存在!");
+        }
+        return CommonResult.success(readLogContent(logPath), "success");
+    }
+
+    @Override
+    public CommonResult getModelList(Long id) {
+        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");
+    }
+
+    public static long getFileSize(File file) {
+        // 返回单位B
+        if (file.isFile()) {
+            return file.length();
+        } else {
+            long totalSize = 0;
+            if (file.listFiles() != null && file.listFiles().length > 0) {
+                for (File file__ : Objects.requireNonNull(file.listFiles())) {
+                    totalSize += getFileSize(file__);
+                }
+            }
+            return totalSize;
+        }
     }
 }

+ 170 - 38
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -1,12 +1,18 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.text.DecimalFormat;
+import java.util.*;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.mybatisflex.core.paginate.Page;
@@ -17,7 +23,7 @@ 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.StartTaskConfig;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.biz.mapper.ToInfraredMapper;
 import com.taais.biz.service.IToInfraredService;
@@ -45,6 +51,8 @@ import org.springframework.transaction.annotation.Transactional;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
+import static com.taais.biz.service.impl.DataSeqServiceImpl.calculateImagePath;
+import static com.taais.biz.service.impl.DataSeqServiceImpl.isImageFile;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
 
 /**
@@ -56,6 +64,12 @@ 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;
+
     @Value("${server.task_stop_url}")
     private String task_stop_url;
 
@@ -226,9 +240,9 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
     @Override
     public CommonResult start(Long id) {
-        ToInfrared toInfrared = getById(id);
+        ToInfrared entity = getById(id);
 
-        SysOssVo inputOssEntity = ossService.getById(toInfrared.getInputOssId());
+        SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
 
         String filePath = inputOssEntity.getFileName();
         String localPath = TaaisConfig.getProfile();
@@ -239,55 +253,49 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         Path path = Paths.get(resourcePath);
         Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
-        Path outputPath = path.resolveSibling(fileName_without_suffix + BizConstant.TO_INFRARED_SUFFIX);
+        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TO_INFRARED_SUFFIX);
 
-        makeDir(inputPath.toString());
+//        makeDir(inputPath.toString());
         makeDir(outputPath.toString());
 
-        File file = new File(resourcePath);
+        File file = new File(inputPath.toString());
         if (!file.exists()) {
             ZipUtils.unzip(resourcePath, inputPath.toString());
         }
 
-        toInfrared.setInputPath(inputPath.toString());
-        toInfrared.setOutputPath(outputPath.toString());
+        entity.setInputPath(inputPath.toString());
+        entity.setOutputPath(outputPath.toString());
 
-        toInfrared.setStartTime(new Date());
+        entity.setStartTime(new Date());
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(toInfrared.getAlgorithmModelId());
+        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
-        startToInfraredTask.setBizId(toInfrared.getId());
-
-        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
+        startTaskConfig.setBizId(entity.getId());
 
-//        String osName = System.getProperty("os.name");
-//        if (osName.toLowerCase().contains("windows")) {
-//            startToInfraredTask.setSource_dir("C:" + toInfrared.getInputPath());
-//            startToInfraredTask.setResult_dir("C:" + toInfrared.getOutputPath());
-//        } else {
-        startToInfraredTask.setSource_dir(toInfrared.getInputPath());
-        startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
-//        }
+        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        // startToInfraredTask.setSource_dir(toInfrared.getInputPath());
-        // startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
+        startTaskConfig.setSource_dir(entity.getInputPath());
+        startTaskConfig.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
-            startToInfraredTask.setModel_path(algorithmModelTrack.getModelAddress());
+            startTaskConfig.setModel_path(algorithmModelTrack.getModelAddress());
+            startTaskConfig.setSource_dir(entity.getInputPath() + File.separator + BizConstant.PREDICT_PATH);
+            startTaskConfig.setResult_dir(entity.getOutputPath() + File.separator + BizConstant.PREDICT_PATH);
         }
 
 
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
-            toInfrared.setStatus(BizConstant.VideoStatus.RUNNING);
-            updateById(toInfrared);
+            entity.setStatus(BizConstant.VideoStatus.RUNNING);
+            updateById(entity);
             return CommonResult.success("任务开始成功,请等待完成");
         } else {
-            toInfrared.setStatus(BizConstant.VideoStatus.FAILED);
-            updateById(toInfrared);
+            entity.setStatus(BizConstant.VideoStatus.FAILED);
+            updateById(entity);
             return CommonResult.fail("任务开始失败,请检查!");
         }
     }
@@ -296,11 +304,11 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     public CommonResult stop(Long id) {
         ToInfrared toInfrared = getById(id);
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
-        startToInfraredTask.setBizId(toInfrared.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
+        startTaskConfig.setBizId(toInfrared.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             toInfrared.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(toInfrared);
@@ -376,6 +384,130 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         }
     }
 
+    private String getLogFileName(ToInfrared entity) {
+        return entity.getId() + BizConstant.TO_INFRARED_SUFFIX + ".log";
+    }
+
+    @Override
+    public CommonResult getLog(Long id) {
+        ToInfrared entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String logPath = outPutPath + File.separator + getLogFileName(entity);
+        System.out.println(logPath);
+        File file = new File(logPath);
+        if (!file.exists()) {
+            return CommonResult.fail("日志文件不存在!");
+        }
+        return CommonResult.success(readLogContent(logPath), "success");
+    }
+
+    public static String readLogContent(String path) {
+        String content = "";
+        try (BufferedReader br = new BufferedReader(new FileReader(path))) {
+            String line;
+            while ((line = br.readLine()) != null) {
+                content += (line + "<br />\n");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.out.println("读取文件失败!" + e.getMessage());
+            content = "读取文件失败!" + e.getMessage();
+        }
+
+        return content;
+    }
+
+    @Override
+    public CommonResult getModelList(Long id) {
+        ToInfrared entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String modelPath = outPutPath + File.separator + "model";
+        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) {
+            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(profile.length());
+            url = url.replaceAll("\\\\", "/"); // windows
+            tmp.put("url", url);
+
+            double fileSize = (file.length() / (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");
+    }
+
+    @Override
+    public CommonResult previewPredictResult(Long id) {
+        ToInfrared entity = getById(id);
+
+        SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
+
+        String filePath = inputOssEntity.getFileName();
+        String localPath = TaaisConfig.getProfile();
+        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
+
+        String fileName = StringUtils.substringAfterLast(filePath, "/");
+        String fileName_without_suffix = removeFileExtension(fileName);
+
+        Path path = Paths.get(resourcePath);
+        Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX + File.separator + BizConstant.PREDICT_PATH);
+        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TO_INFRARED_SUFFIX + File.separator + BizConstant.PREDICT_PATH);
+
+        String urlPrefix = inputOssEntity.getUrl().substring(0, inputOssEntity.getUrl().indexOf(Constants.RESOURCE_PREFIX) + Constants.RESOURCE_PREFIX.length());
+
+        return getCompareImage(urlPrefix, inputPath.toString(), outputPath.toString());
+    }
+
+    public static CommonResult getCompareImage(String urlPrefix, String inputPath, String outputPath) {
+        try {
+             List<String> inputImageList = calculateImagePath(urlPrefix, inputPath);
+            List<String> outputImageList = calculateImagePath(urlPrefix, outputPath);
+
+            HashMap<String,String> nameToUrl1 = new HashMap<>();
+
+            for (String imageUrl : inputImageList) {
+                String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
+                nameToUrl1.put(name, imageUrl);
+            }
+            HashMap<String,String> nameToUrl2 = new HashMap<>();
+            for (String imageUrl : outputImageList) {
+                String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
+                nameToUrl2.put(name, imageUrl);
+            }
+            List<String> inputImageNames = new ArrayList<>(nameToUrl1.keySet());
+
+            inputImageNames.sort(Comparator.naturalOrder());
+
+            List<Map<String, String>> resultList = new ArrayList<>();
+            for (String inputImageName : inputImageNames) {
+                Map<String, String> map = new HashMap<>();
+                map.put("inputUrl", nameToUrl1.get(inputImageName));
+                map.put("outputUrl", nameToUrl2.get(inputImageName));
+                resultList.add(map);
+            }
+
+            return CommonResult.success(resultList, "success");
+        } catch (Exception e) {
+            System.out.println("getImages error: " + e.getMessage());
+            return CommonResult.fail("getImages error: " + e.getMessage());
+        }
+    }
+
     private ResponseEntity<org.springframework.core.io.Resource> getPredictImages(ToInfrared toInfrared) {
         String outputPath = toInfrared.getOutputPath();
         String predictDir = outputPath + File.separator + BizConstant.PREDICT_PATH;

+ 359 - 93
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -1,13 +1,15 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
 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 com.alibaba.fastjson2.JSON;
@@ -17,7 +19,7 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 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.StartTaskConfig;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
@@ -30,6 +32,7 @@ import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
@@ -45,6 +48,9 @@ import com.taais.biz.service.ITrackSequenceService;
 
 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.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.VideoStableServiceImpl.*;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
 
@@ -56,7 +62,11 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
  */
 @Service
 public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence> implements ITrackSequenceService {
-    @Value("${server.task_stop_url}")
+
+    private static final String MASC = "MASC";
+    private static final String CAT = "CAT";
+
+    @Value("${server.task_stop_url_cat}")
     private String task_stop_url;
 
     @Autowired
@@ -77,30 +87,18 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
 
     private QueryWrapper buildQueryWrapper(TrackSequenceBo trackSequenceBo) {
         QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
-        queryWrapper.and(TRACK_SEQUENCE.NAME.like
-            (trackSequenceBo.getName()));
-        queryWrapper.and(TRACK_SEQUENCE.STATUS.eq
-            (trackSequenceBo.getStatus()));
-        queryWrapper.and(TRACK_SEQUENCE.START_TIME.eq
-            (trackSequenceBo.getStartTime()));
-        queryWrapper.and(TRACK_SEQUENCE.END_TIME.eq
-            (trackSequenceBo.getEndTime()));
-        queryWrapper.and(TRACK_SEQUENCE.COST_SECOND.eq
-            (trackSequenceBo.getCostSecond()));
-        queryWrapper.and(TRACK_SEQUENCE.LOG.eq
-            (trackSequenceBo.getLog()));
-        queryWrapper.and(TRACK_SEQUENCE.REMARKS.eq
-            (trackSequenceBo.getRemarks()));
-        queryWrapper.and(TRACK_SEQUENCE.URL.eq
-            (trackSequenceBo.getUrl()));
-        queryWrapper.and(TRACK_SEQUENCE.INPUT_OSS_ID.eq
-            (trackSequenceBo.getInputOssId()));
-        queryWrapper.and(TRACK_SEQUENCE.INPUT_PATH.eq
-            (trackSequenceBo.getInputPath()));
-        queryWrapper.and(TRACK_SEQUENCE.OUTPUT_PATH.eq
-            (trackSequenceBo.getOutputPath()));
-        queryWrapper.and(TRACK_SEQUENCE.ZIP_FILE_PATH.eq
-            (trackSequenceBo.getZipFilePath()));
+        queryWrapper.and(TRACK_SEQUENCE.NAME.like(trackSequenceBo.getName()));
+        queryWrapper.and(TRACK_SEQUENCE.STATUS.eq(trackSequenceBo.getStatus()));
+        queryWrapper.and(TRACK_SEQUENCE.START_TIME.eq(trackSequenceBo.getStartTime()));
+        queryWrapper.and(TRACK_SEQUENCE.END_TIME.eq(trackSequenceBo.getEndTime()));
+        queryWrapper.and(TRACK_SEQUENCE.COST_SECOND.eq(trackSequenceBo.getCostSecond()));
+        queryWrapper.and(TRACK_SEQUENCE.LOG.eq(trackSequenceBo.getLog()));
+        queryWrapper.and(TRACK_SEQUENCE.REMARKS.eq(trackSequenceBo.getRemarks()));
+        queryWrapper.and(TRACK_SEQUENCE.URL.eq(trackSequenceBo.getUrl()));
+        queryWrapper.and(TRACK_SEQUENCE.INPUT_OSS_ID.eq(trackSequenceBo.getInputOssId()));
+        queryWrapper.and(TRACK_SEQUENCE.INPUT_PATH.eq(trackSequenceBo.getInputPath()));
+        queryWrapper.and(TRACK_SEQUENCE.OUTPUT_PATH.eq(trackSequenceBo.getOutputPath()));
+        queryWrapper.and(TRACK_SEQUENCE.ZIP_FILE_PATH.eq(trackSequenceBo.getZipFilePath()));
 
         return queryWrapper;
     }
@@ -141,13 +139,30 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         Page<TrackSequenceVo> page = this.pageAs(PageQuery.build(), queryWrapper, TrackSequenceVo.class);
         page.getRecords().forEach(entity -> {
             Long modelId = entity.getAlgorithmModelId();
-            AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
-            if (ObjectUtil.isNotNull(model)) {
-                AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(model.getAlgorithmId());
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
-                entity.setModelName(model.getModelName());
+            Long algorithmId = entity.getAlgorithmId();
+            if (modelId != null) {
+                AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
+            }
+            if (algorithmId != null) {
+                AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
+            } else {
+                AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
+                if (ObjectUtil.isNotNull(model)) {
+                    AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(model.getAlgorithmId());
+                    if (ObjectUtil.isNotNull(config)) {
+                        entity.setType(config.getType());
+                        entity.setSubsystem(config.getSubsystem());
+                        entity.setAlgorithmName(config.getAlgorithmName());
+                    }
+                }
             }
         });
         return PageResult.build(page);
@@ -160,20 +175,37 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
      * @return 结果:true 操作成功,false 操作失败
      */
     @Override
-    public boolean insert(TrackSequenceBo trackSequenceBo) {
+    public CommonResult insert(TrackSequenceBo trackSequenceBo) {
+        // 检查任务名称
+        if (ObjectUtil.isEmpty(trackSequenceBo.getName()) || (!trackSequenceBo.getName().startsWith(MASC) && !trackSequenceBo.getName().startsWith(CAT))) {
+            return CommonResult.fail("任务命名错误,需以MASC或CAT开头!");
+        }
+
         // 检查input_oss_id是否存在
         if (ObjectUtil.isNull(trackSequenceBo.getInputOssId())) {
-            return false;
+            return CommonResult.fail("请上传模型");
         }
 
         SysOssVo ossEntity = ossService.getById(trackSequenceBo.getInputOssId());
         if (ObjectUtil.isNull(ossEntity)) {
-            return false;
+            return CommonResult.fail("找不到指定模型!");
+        }
+
+        if (trackSequenceBo.getName().startsWith(MASC)) {
+            if (ObjectUtil.isEmpty(trackSequenceBo.getAlgorithmId())) {
+                return CommonResult.fail("请指定算法!");
+            }
+
+            AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(trackSequenceBo.getAlgorithmId());
+            if (ObjectUtil.isNull(config)) {
+                return CommonResult.fail("找不到指定的算法!");
+            }
         }
 
         TrackSequence trackSequence = new TrackSequence();
 
-        trackSequence.setInputOssId(trackSequenceBo.getInputOssId());
+        BeanUtils.copyProperties(trackSequenceBo, trackSequence);
+
         trackSequence.setUrl(ossEntity.getUrl());
 
         String filePath = ossEntity.getFileName();
@@ -189,14 +221,15 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         trackSequence.setOutputPath(outPath.toString());
 
         trackSequence.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
-
-        trackSequence.setName(trackSequenceBo.getName());
         trackSequence.setStatus(NOT_START);
-        trackSequence.setRemarks(trackSequenceBo.getRemarks());
 
-        trackSequence.setAlgorithmModelId(trackSequenceBo.getAlgorithmModelId());
 
-        return this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
+        boolean __ = this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
+        if (__) {
+            return CommonResult.success();
+        } else {
+            return CommonResult.fail();
+        }
     }
 
     /**
@@ -229,62 +262,138 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
 
     @Override
     public CommonResult start(Long id) {
+        /*
+         * WANGKANG 望维护此代码的后来者安息。
+         *
+         * 不是我想写这么恶心,只是没办法,算法端的逻辑写的跟屎一样。。。。
+         */
         TrackSequence entity = getById(id);
+        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
+        AlgorithmConfigTrack algorithmConfigTrack = null;
+        try {
+            algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        } catch (Exception e) {
+            algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
+        }
 
-        SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
 
-        String filePath = inputOssEntity.getFileName();
-        String localPath = TaaisConfig.getProfile();
-        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
+        if (algorithmConfigTrack.getType().equals(BizConstant.AlgorithmType.TEST) && (entity.getName().startsWith(MASC) || entity.getName().startsWith(CAT))) {
+            startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
+            startTaskConfig.setBizId(entity.getId());
 
-        String fileName = StringUtils.substringAfterLast(filePath, "/");
-        String fileName_without_suffix = removeFileExtension(fileName);
+            startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        Path path = Paths.get(resourcePath);
-        Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
-        Path outputPath = path.resolveSibling(fileName_without_suffix + BizConstant.TRACK_SEQUENCE_SUFFIX);
+            startTaskConfig.setSource_dir(entity.getInputPath());
+            startTaskConfig.setResult_dir(entity.getOutputPath());
+            startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
+        } else {
+            SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
 
-        makeDir(inputPath.toString());
-        makeDir(outputPath.toString());
+            String filePath = inputOssEntity.getFileName();
+            String localPath = TaaisConfig.getProfile();
+            String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
 
-        File file = new File(resourcePath);
-        if (!file.exists()) {
-            ZipUtils.unzip(resourcePath, inputPath.toString());
-        }
+            String fileName = StringUtils.substringAfterLast(filePath, "/");
+            String fileName_without_suffix = removeFileExtension(fileName);
 
-        entity.setInputPath(inputPath.toString());
-        entity.setOutputPath(outputPath.toString());
+            Path path = Paths.get(resourcePath);
+            Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
+            Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX);
 
-        entity.setStartTime(new Date());
+//        makeDir(inputPath.toString());
+            makeDir(outputPath.toString());
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
+            File file = new File(inputPath.toString());
+            if (!file.exists()) {
+                ZipUtils.unzip(resourcePath, inputPath.toString());
+            }
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
-        startToInfraredTask.setBizId(entity.getId());
+            entity.setInputPath(inputPath.toString());
+            entity.setOutputPath(outputPath.toString());
 
-        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
+            entity.setStartTime(new Date());
 
-        startToInfraredTask.setSource_dir(entity.getInputPath());
-        startToInfraredTask.setResult_dir(entity.getOutputPath());
+            startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
+            startTaskConfig.setBizId(entity.getId());
 
-        if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
-            if(algorithmModelTrack.getModelName().startsWith("masc") || algorithmModelTrack.getModelName().startsWith("MASC")) {
-                String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName().substring(5);
-                startToInfraredTask.setModel_path(modelPath);
-            }
-            else if(algorithmModelTrack.getModelName().startsWith("cat") || algorithmModelTrack.getModelName().startsWith("CAT")) {
+            startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
+
+            startTaskConfig.setSource_dir(entity.getInputPath());
+            startTaskConfig.setResult_dir(entity.getOutputPath());
+            startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + getLogFileName(entity));
+
+            if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
                 String modelPath = algorithmModelTrack.getModelAddress();
-                startToInfraredTask.setModel_path(modelPath);
-            }
-            else {
-                return CommonResult.fail("模型命名失败,请以MASC或CAT开头命名模型");
+                startTaskConfig.setModel_path(modelPath);
+                if (entity.getName().startsWith(CAT)) {
+                    startTaskConfig.setSource_dir(startTaskConfig.getSource_dir());
+//                    File file________ = new File(startTaskConfig.getSource_dir());
+//                    if (!file________.exists()) {
+//                        return CommonResult.fail("数据集为空!");
+//                    }
+//                    if (file________.listFiles() != null && file________.listFiles().length > 0) {
+//                        for (File file___________________tmp : file________.listFiles()) {
+//                            if (file___________________tmp.isDirectory()) {
+//                                startTaskConfig.setSource_dir(file___________________tmp.getPath());
+//                                break;
+//                            }
+//                        }
+//                    }
+
+                    File file___________________________ = new File(startTaskConfig.getModel_path());
+                    if (!file___________________________.exists()) {
+                        return CommonResult.fail("模型不存在!");
+                    }
+                    if (file___________________________.listFiles() != null && file___________________________.listFiles().length > 0) {
+                        for (File file___________________tmp : file___________________________.listFiles()) {
+                            if (file___________________tmp.isDirectory()) {
+                                startTaskConfig.setModel_path(file___________________tmp.getPath());
+                                break;
+                            }
+                        }
+                    }
+                }
+//            if (algorithmModelTrack.getModelName().startsWith("masc") || algorithmModelTrack.getModelName().startsWith("MASC")) {
+//                String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName().substring(5);
+//                startTaskConfig.setModel_path(modelPath);
+//            } else if (algorithmModelTrack.getModelName().startsWith("cat") || algorithmModelTrack.getModelName().startsWith("CAT")) {
+//                String modelPath = algorithmModelTrack.getModelAddress();
+//                startTaskConfig.setModel_path(modelPath);
+//            } else {
+//                return CommonResult.fail("模型命名失败,请以MASC或CAT开头命名模型");
+//            }
+            } else if (BizConstant.AlgorithmType.TRAIN.equals(algorithmConfigTrack.getType()) && entity.getName().startsWith(CAT)) {
+                File file________ = new File(startTaskConfig.getSource_dir());
+                if (!file________.exists()) {
+                    return CommonResult.fail("数据集为空!");
+                }
+                boolean flag = false;
+                if (file________.listFiles() != null && file________.listFiles().length > 0) {
+                    for (File file___________________tmp : file________.listFiles()) {
+                        if (file___________________tmp.isDirectory()) {
+                            startTaskConfig.setSource_dir(file___________________tmp.getPath());
+                            flag = true;
+//                            if (file___________________tmp.listFiles() != null && file___________________tmp.listFiles().length > 0) {
+//                                for (File file________________________________________________________________________________________ : file___________________tmp.listFiles()) {
+//                                    if (file________________________________________________________________________________________.isDirectory() &&
+//                                        file________________________________________________________________________________________.getName().equals("images")) {
+//                                        startTaskConfig.setSource_dir(file________________________________________________________________________________________.getPath());
+//                                        flag = true;
+//                                        break;
+//                                    }
+//                                }
+//                            }
+//                            break;
+                        }
+                    }
+                }
+                if (!(flag && !false && (1!=2) && (1 == 1))) {
+                    return CommonResult.fail("数据集错误!!!!!!");
+                }
             }
         }
-
-
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -300,11 +409,11 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
     public CommonResult stop(Long id) {
         TrackSequence entity = getById(id);
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
+        startTaskConfig.setBizId(entity.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(entity);
@@ -329,9 +438,17 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
             outputPath = entity.getOutputPath() + File.separator + "predict";
+            File file__ = new File(outputPath);
+            if (!file__.exists()) {
+                outputPath = entity.getOutputPath();
+            }
             zipFilePath = outputPath + ".zip";
         } else if (BizConstant.AlgorithmType.TEST.equals(algorithmConfigTrack.getType())) {
             outputPath = entity.getOutputPath() + File.separator + "evaluate";
+            File file__ = new File(outputPath);
+            if (!file__.exists()) {
+                outputPath = entity.getOutputPath();
+            }
             zipFilePath = outputPath + ".zip";
         } else if (BizConstant.AlgorithmType.TRAIN.equals(algorithmConfigTrack.getType())) {
             outputPath = entity.getOutputPath();
@@ -355,10 +472,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         }
 
         org.springframework.core.io.Resource resource = new FileSystemResource(file);
-        return ResponseEntity.ok()
-            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
-            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
-            .body(resource);
+        return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"").header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     @Override
@@ -392,4 +506,156 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         }
         return CommonResult.success();
     }
+
+    private String getLogFileName(TrackSequence entity) {
+        return entity.getId() + BizConstant.TRACK_SEQUENCE_SUFFIX + ".log";
+    }
+
+    @Override
+    public CommonResult getLog(Long id) {
+        TrackSequence entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String logPath = outPutPath + File.separator + getLogFileName(entity);
+        System.out.println(logPath);
+        File file = new File(logPath);
+        if (!file.exists()) {
+            return CommonResult.fail("日志文件不存在!");
+        }
+        return CommonResult.success(readLogContent(logPath), "success");
+    }
+
+    @Override
+    public CommonResult getDetail(Long id) {
+        TrackSequenceVo entity = selectById(id);
+        if (entity.getName().startsWith(MASC)) {
+            AlgorithmModelTrack modelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
+            AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+
+            AlgorithmModelTrackVo res = new AlgorithmModelTrackVo();
+
+            BeanUtils.copyProperties(modelTrack, res);
+            BeanUtils.copyProperties(algorithmConfigTrack, res);
+
+            res.setAlgorithmId(algorithmConfigTrack.getId());
+            res.setId(modelTrack.getId());
+
+            return CommonResult.success(res, "success");
+        } else if (entity.getName().startsWith(CAT)) {
+            AlgorithmModelTrack modelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
+            AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(modelTrack.getAlgorithmId());
+
+            AlgorithmModelTrackVo res = new AlgorithmModelTrackVo();
+
+            BeanUtils.copyProperties(modelTrack, res);
+            BeanUtils.copyProperties(algorithmConfigTrack, res);
+
+            res.setAlgorithmId(algorithmConfigTrack.getId());
+            res.setId(modelTrack.getId());
+
+            return CommonResult.success(res, "success");
+        } else {
+            return CommonResult.fail("命名错误!");
+        }
+    }
+
+    @Override
+    public CommonResult addEvaluate(AddEvaluate addEvaluate) {
+        // 检查任务名称
+        if (ObjectUtil.isEmpty(addEvaluate.getName()) || (!addEvaluate.getName().startsWith(MASC) && !addEvaluate.getName().startsWith(CAT))) {
+            return CommonResult.fail("任务命名错误,需以MASC或CAT开头!");
+        }
+
+        if (ObjectUtil.isEmpty(addEvaluate.getAlgorithmId())) {
+            return CommonResult.fail("请指定算法!");
+        }
+
+        AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(addEvaluate.getAlgorithmId());
+        if (ObjectUtil.isNull(config)) {
+            return CommonResult.fail("找不到指定的算法!");
+        }
+
+        TrackSequence entity = this.getById(addEvaluate.getId());
+        TrackSequence evaluate_entity = new TrackSequence();
+        evaluate_entity.setStatus(NOT_START);
+        evaluate_entity.setUrl(entity.getUrl());
+        if (addEvaluate.getName().startsWith(MASC)) {
+            evaluate_entity.setInputPath(entity.getInputPath() + ";" + entity.getOutputPath() + File.separator + "gaze" + File.separator + "txt");
+        } else if (addEvaluate.getName().startsWith(CAT)) {
+            File file________ = new File(entity.getInputPath());
+            if (!file________.exists()) {
+                return CommonResult.fail("数据集为空!");
+            }
+            evaluate_entity.setInputPath(entity.getInputPath() + ";" + entity.getOutputPath() + File.separator + "txt");
+//            if (file________.listFiles() != null && file________.listFiles().length > 0) {
+//                for (File file___________________tmp : file________.listFiles()) {
+//                    if (file___________________tmp.isDirectory()) {
+//                        evaluate_entity.setInputPath(file___________________tmp.getPath() + ";" + entity.getOutputPath() + File.separator + "txt");
+//                        break;
+//                    }
+//                }
+//            }
+        } else {
+            return CommonResult.fail("命名错误!");
+        }
+        evaluate_entity.setZipFilePath(entity.getZipFilePath());
+        evaluate_entity.setAlgorithmModelId(entity.getAlgorithmModelId());
+        evaluate_entity.setInputOssId(entity.getInputOssId());
+
+        evaluate_entity.setName(addEvaluate.getName());
+        evaluate_entity.setAlgorithmId(addEvaluate.getAlgorithmId());
+        evaluate_entity.setRemarks(addEvaluate.getRemarks());
+
+        boolean flag__ = save(evaluate_entity);
+
+        if (flag__) {
+            Path path = Paths.get(entity.getOutputPath());
+            evaluate_entity.setOutputPath(path.resolveSibling(evaluate_entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX).toString());
+            boolean flag___ = updateById(evaluate_entity);
+            if (flag___) {
+                return CommonResult.success("新增评估任务成功!");
+            } else {
+                return CommonResult.success("新增评估任务成功! 更新输出路径失败");
+            }
+        } else {
+            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");
+    }
+
 }

+ 4 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/Video2imageServiceImpl.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
 import java.io.File;

+ 15 - 19
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/VideoStableServiceImpl.java

@@ -1,3 +1,7 @@
+/**
+ * 20241029 ©WANGKANG 1686617586@qq.com
+ */
+
 package com.taais.biz.service.impl;
 
 import java.io.File;
@@ -72,22 +76,14 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
 
     private QueryWrapper buildQueryWrapper(VideoStableBo videoStableBo) {
         QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
-        queryWrapper.and(VIDEO_STABLE.NAME.like
-            (videoStableBo.getName()));
-        queryWrapper.and(VIDEO_STABLE.STATUS.like
-            (videoStableBo.getStatus()));
-        queryWrapper.and(VIDEO_STABLE.INPUT_OSS_ID.eq
-            (videoStableBo.getInputOssId()));
-        queryWrapper.and(VIDEO_STABLE.START_TIME.eq
-            (videoStableBo.getStartTime()));
-        queryWrapper.and(VIDEO_STABLE.END_TIME.eq
-            (videoStableBo.getEndTime()));
-        queryWrapper.and(VIDEO_STABLE.COST_SECOND.eq
-            (videoStableBo.getCostSecond()));
-        queryWrapper.and(VIDEO_STABLE.LOG.like
-            (videoStableBo.getLog()));
-        queryWrapper.and(VIDEO_STABLE.REMARKS.like
-            (videoStableBo.getRemarks()));
+        queryWrapper.and(VIDEO_STABLE.NAME.like(videoStableBo.getName()));
+        queryWrapper.and(VIDEO_STABLE.STATUS.like(videoStableBo.getStatus()));
+        queryWrapper.and(VIDEO_STABLE.INPUT_OSS_ID.eq(videoStableBo.getInputOssId()));
+        queryWrapper.and(VIDEO_STABLE.START_TIME.eq(videoStableBo.getStartTime()));
+        queryWrapper.and(VIDEO_STABLE.END_TIME.eq(videoStableBo.getEndTime()));
+        queryWrapper.and(VIDEO_STABLE.COST_SECOND.eq(videoStableBo.getCostSecond()));
+        queryWrapper.and(VIDEO_STABLE.LOG.like(videoStableBo.getLog()));
+        queryWrapper.and(VIDEO_STABLE.REMARKS.like(videoStableBo.getRemarks()));
 
         return queryWrapper;
     }
@@ -356,12 +352,12 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
             List<String> inputImageList = getImageUrls(ossEntity, unzipPath, BizConstant.UNZIP_SUFFIX);
             List<String> outputImageList = getImageUrls(ossEntity, resultPath, BizConstant.STABLE_SUFFIX);
 
-            HashMap<String,String> nameToUrl1 = new HashMap<>();
+            HashMap<String, String> nameToUrl1 = new HashMap<>();
             for (String imageUrl : inputImageList) {
                 String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
                 nameToUrl1.put(name, imageUrl);
             }
-            HashMap<String,String> nameToUrl2 = new HashMap<>();
+            HashMap<String, String> nameToUrl2 = new HashMap<>();
             for (String imageUrl : outputImageList) {
                 String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
                 nameToUrl2.put(name, imageUrl);
@@ -385,7 +381,7 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         }
     }
 
-    public List<String> getImageUrls(SysOssVo ossEntity, String path,  String suffix) {
+    public List<String> getImageUrls(SysOssVo ossEntity, String path, String suffix) {
         String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + suffix;
         // 列出unzipPath下所有图片文件
         File directory = new File(path);

+ 14 - 8
taais-modules/taais-biz/src/main/java/com/taais/biz/utils/ZipUtils.java

@@ -1,3 +1,13 @@
+/**
+ * @Date: 20241029
+ * @Author: WANGKANG
+ * @Blog: https://wangkang1717/github.io
+ * @Email: 1686617586@qq.com
+ * @Description: None
+ * Copyright 2024 WANGKANG, All Rights Reserved.
+ */
+
+
 package com.taais.biz.utils;
 
 import java.io.*;
@@ -18,12 +28,10 @@ public class ZipUtils {
     public static void zipFolderFiles(String sourceFolderPath, String zipFilePath) throws IOException {
         File sourceFolder = new File(sourceFolderPath);
         if (!sourceFolder.exists() || !sourceFolder.isDirectory()) {
-            throw new IllegalArgumentException(
-                "Source folder does not exist or is not a directory: " + sourceFolderPath);
+            throw new IllegalArgumentException("Source folder does not exist or is not a directory: " + sourceFolderPath);
         }
 
-        try (FileOutputStream fos = new FileOutputStream(zipFilePath);
-             ZipOutputStream zos = new ZipOutputStream(fos)) {
+        try (FileOutputStream fos = new FileOutputStream(zipFilePath); ZipOutputStream zos = new ZipOutputStream(fos)) {
             zipDirectory(sourceFolder, "", zos);
         }
     }
@@ -87,8 +95,7 @@ public class ZipUtils {
                             parentDir.mkdirs();
                         }
                         // 解压文件
-                        try (InputStream inputStream = zipFile.getInputStream(entry);
-                             FileOutputStream outputStream = new FileOutputStream(entryFile)) {
+                        try (InputStream inputStream = zipFile.getInputStream(entry); FileOutputStream outputStream = new FileOutputStream(entryFile)) {
                             byte[] buffer = new byte[1024];
                             int len;
                             while ((len = inputStream.read(buffer)) > 0) {
@@ -112,8 +119,7 @@ public class ZipUtils {
 
     public static void main(String[] args) {
         try {
-            zipFolderFiles("C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\dataset_20241012115340A001_to_infrared",
-                "C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\dataset_20241012115340A001_to_infrared.zip");
+            zipFolderFiles("C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\dataset_20241012115340A001_to_infrared", "C:\\home\\ObjectDetection_Web\\upload\\2024\\10\\12\\dataset_20241012115340A001_to_infrared.zip");
         } catch (IOException e) {
             e.printStackTrace();
         }