Преглед на файлове

Merge remote-tracking branch 'origin/develop' into develop

allen преди 1 месец
родител
ревизия
4a4c9a61e4
променени са 37 файла, в които са добавени 1850 реда и са изтрити 731 реда
  1. 114 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmTaskTrackController.java
  2. 0 5
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TrackSequenceController.java
  3. 11 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmConfigTrack.java
  4. 2 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmModelTrack.java
  5. 61 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmTaskTrack.java
  6. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TargetDetection.java
  7. 5 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/ToInfrared.java
  8. 11 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TrackSequence.java
  9. 27 4
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmConfigTrackBo.java
  10. 3 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmModelTrackBo.java
  11. 81 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmTaskTrackBo.java
  12. 29 11
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TargetDetectionBo.java
  13. 22 2
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredBo.java
  14. 0 29
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredStartResultBo.java
  15. 33 9
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TrackSequenceBo.java
  16. 14 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmConfigTrackImportVo.java
  17. 13 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmConfigTrackVo.java
  18. 2 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackImportVo.java
  19. 6 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackVo.java
  20. 109 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmSubTaskTrackVo.java
  21. 66 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmTaskTrackImportVo.java
  22. 74 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmTaskTrackVo.java
  23. 10 5
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetDetectionImportVo.java
  24. 13 6
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetDetectionVo.java
  25. 9 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/ToInfraredImportVo.java
  26. 9 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/ToInfraredVo.java
  27. 18 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceImportVo.java
  28. 20 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceVo.java
  29. 16 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmTaskTrackMapper.java
  30. 68 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmTaskTrackService.java
  31. 0 2
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITrackSequenceService.java
  32. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmConfigTrackServiceImpl.java
  33. 342 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmTaskTrackServiceImpl.java
  34. 159 170
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetDetectionServiceImpl.java
  35. 248 85
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java
  36. 243 399
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java
  37. 7 0
      taais-modules/taais-biz/src/main/resources/mapper/demo/AlgorithmTaskTrackMapper.xml

+ 114 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmTaskTrackController.java

@@ -0,0 +1,114 @@
+package com.taais.biz.controller;
+
+import java.util.List;
+
+import lombok.RequiredArgsConstructor;
+import jakarta.servlet.http.HttpServletResponse;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import com.taais.common.core.core.domain.CommonResult;
+import com.taais.common.excel.utils.ExcelUtil;
+import com.taais.common.log.annotation.Log;
+import com.taais.common.log.enums.BusinessType;
+import com.taais.common.web.annotation.RepeatSubmit;
+import com.taais.common.web.core.BaseController;
+import jakarta.annotation.Resource;
+import com.taais.biz.domain.vo.AlgorithmTaskTrackVo;
+import com.taais.biz.domain.bo.AlgorithmTaskTrackBo;
+import com.taais.biz.service.IAlgorithmTaskTrackService;
+
+import com.taais.common.core.core.page.PageResult;
+
+/**
+ * 可辨识性分析总任务Controller
+ *
+ * @author wangkang
+ * 2025-01-06
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/demo/algorithmTaskTrack")
+public class AlgorithmTaskTrackController extends BaseController {
+    @Resource
+    private IAlgorithmTaskTrackService algorithmTaskTrackService;
+
+    /**
+     * 查询可辨识性分析总任务列表
+     */
+    @SaCheckPermission("demo:algorithmTaskTrack:list")
+    @GetMapping("/list")
+    public CommonResult<PageResult<AlgorithmTaskTrackVo>> list(AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        return CommonResult.success(algorithmTaskTrackService.selectPage(algorithmTaskTrackBo));
+    }
+
+    /**
+     * 导出可辨识性分析总任务列表
+     */
+    @SaCheckPermission("demo:algorithmTaskTrack:export")
+    @Log(title = "可辨识性分析总任务", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        List<AlgorithmTaskTrackVo> list = algorithmTaskTrackService.selectList(algorithmTaskTrackBo);
+        ExcelUtil.exportExcel(list, "可辨识性分析总任务", AlgorithmTaskTrackVo.class, response);
+    }
+
+    /**
+     * 获取可辨识性分析总任务详细信息
+     */
+    @SaCheckPermission("demo:algorithmTaskTrack:query")
+    @GetMapping(value = "/{id}")
+    public CommonResult<AlgorithmTaskTrackVo> getInfo(@PathVariable Long id) {
+        return CommonResult.success(algorithmTaskTrackService.selectById(id));
+    }
+
+    /**
+     * 新增可辨识性分析总任务
+     */
+    @SaCheckPermission("demo:algorithmTaskTrack:add")
+    @Log(title = "可辨识性分析总任务", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping
+    public CommonResult<Void> add(@Validated @RequestBody AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        boolean inserted = algorithmTaskTrackService.insert(algorithmTaskTrackBo);
+        if (!inserted) {
+            return CommonResult.fail("新增可辨识性分析总任务记录失败!");
+        }
+        return CommonResult.success();
+    }
+
+    /**
+     * 修改可辨识性分析总任务
+     */
+    @SaCheckPermission("demo:algorithmTaskTrack:edit")
+    @Log(title = "可辨识性分析总任务", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping
+    public CommonResult<Void> edit(@Validated @RequestBody AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        Boolean updated = algorithmTaskTrackService.update(algorithmTaskTrackBo);
+        if (!updated) {
+            return CommonResult.fail("修改可辨识性分析总任务记录失败!");
+        }
+        return CommonResult.success();
+    }
+
+    /**
+     * 删除可辨识性分析总任务
+     */
+    @SaCheckPermission("demo:algorithmTaskTrack:remove")
+    @Log(title = "可辨识性分析总任务", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public CommonResult<Void> remove(@PathVariable Long[] ids) {
+        boolean deleted = algorithmTaskTrackService.deleteByIds(ids);
+        if (!deleted) {
+            return CommonResult.fail("删除可辨识性分析总任务记录失败!");
+        }
+        return CommonResult.success();
+    }
+
+    @GetMapping("/listSubTask/{id}")
+    public CommonResult listSubTask(@PathVariable Long id) {
+        return algorithmTaskTrackService.listSubTask(id);
+    }
+}

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

@@ -138,11 +138,6 @@ public class TrackSequenceController extends BaseController {
         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);

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

@@ -59,5 +59,16 @@ private static final long serialVersionUID = 1L;
     /** 系统 */
     private String system;
 
+    /// 20241230 新增
+    /** 开始api */
+    private String startApi;
 
+    /** 暂停api */
+    private String pauseApi;
+
+    /** 结束api */
+    private String terminateApi;
+
+    /** 算法参数 */
+    private String parameters;
 }

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

@@ -66,4 +66,6 @@ private static final long serialVersionUID = 1L;
        INTERRUPTED = "4";
     */
     private String modelStatus;
+
+    private String algorithmParameters;
 }

+ 61 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmTaskTrack.java

@@ -0,0 +1,61 @@
+package com.taais.biz.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.mybatisflex.annotation.Column;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import com.taais.common.orm.core.domain.BaseEntity;
+
+/**
+ * 可辨识性分析总任务对象 algorithm_task_track
+ *
+ * @author wangkang
+ * 2025-01-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Table(value = "algorithm_task_track")
+public class AlgorithmTaskTrack extends BaseEntity
+    {
+@Serial
+private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    @Id
+    private Long id;
+
+    /** 任务名称 */
+    private String name;
+
+    /** 任务状态 */
+    private String status;
+
+    /** 开始时间 */
+    private Date startTime;
+
+    /** 结束时间 */
+    private Date endTime;
+
+    /** 耗时 */
+    private Long costSecond;
+
+    /** 日志 */
+    private String log;
+
+    /** 备注 */
+    private String remarks;
+
+    /** 逻辑删除标志(0代表存在 1代表删除) */
+    @Column(isLogicDelete = true)
+    private Integer delFlag;
+
+    /** 系统 */
+    private String system;
+
+
+}

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

@@ -81,5 +81,9 @@ private static final long serialVersionUID = 1L;
     /** 模型的id */
     private Long algorithmModelId;
 
+    private String algorithmParameters;
+    private Long algorithmId;
+    private String logPath;
 
+    private Long parentTaskId;
 }

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

@@ -104,4 +104,9 @@ public class ToInfrared extends BaseEntity {
 
     private Long algorithmModelId;
 
+    private String algorithmParameters;
+    private Long algorithmId;
+    private String logPath;
+
+    private Long parentTaskId;
 }

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

@@ -5,6 +5,8 @@
 package com.taais.biz.domain;
 
 import java.util.Date;
+
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.mybatisflex.annotation.Column;
 import com.mybatisflex.annotation.Id;
@@ -80,4 +82,13 @@ private static final long serialVersionUID = 1L;
 
     private Long algorithmModelId;
     private Long algorithmId;
+    private String algorithmParameters;
+    private String logPath;
+
+    private Long parentTaskId;
+    private Long predictTaskId;
+    private Long inputLabelOssId;
+
+    /* 目标检测模型id */
+    private Long algorithmModelTargetDetectionId;
 }

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

@@ -5,11 +5,11 @@
 package com.taais.biz.domain.bo;
 
 import com.taais.biz.domain.AlgorithmConfigTrack;
+import com.taais.common.orm.core.domain.BaseEntity;
 import io.github.linpeilie.annotations.AutoMapper;
+import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import jakarta.validation.constraints.*;
-import com.taais.common.orm.core.domain.BaseEntity;
 
 /**
  * 算法配置业务对象 algorithm_config_track
@@ -20,7 +20,7 @@ import com.taais.common.orm.core.domain.BaseEntity;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @AutoMapper(target = AlgorithmConfigTrack.class, reverseConvertGenerate = false)
-public class AlgorithmConfigTrackBo extends BaseEntity{
+public class AlgorithmConfigTrackBo extends BaseEntity {
     /**
      * 主键ID
      */
@@ -56,7 +56,7 @@ public class AlgorithmConfigTrackBo extends BaseEntity{
     /**
      * 参数配置
      */
-    @NotBlank(message = "参数配置不能为空")
+//    @NotBlank(message = "参数配置不能为空")
     private String parameterConfig;
 
     /**
@@ -68,4 +68,27 @@ public class AlgorithmConfigTrackBo extends BaseEntity{
      * 系统
      */
     private String system;
+
+    /**
+     * 开始api
+     */
+    @NotBlank(message = "开始api不能为空")
+    private String startApi;
+
+    /**
+     * 暂停api
+     */
+    private String pauseApi;
+
+    /**
+     * 结束api
+     */
+    @NotBlank(message = "结束api不能为空")
+    private String terminateApi;
+
+    /**
+     * 算法参数
+     */
+    @NotBlank(message = "算法参数不能为空")
+    private String parameters;
 }

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

@@ -4,6 +4,7 @@
 
 package com.taais.biz.domain.bo;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.taais.biz.domain.AlgorithmModelTrack;
 import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
@@ -73,4 +74,6 @@ public class AlgorithmModelTrackBo extends BaseEntity {
     private String algorithmType;
 
     private String modelStatus;
+
+    private String algorithmParameters;
 }

+ 81 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmTaskTrackBo.java

@@ -0,0 +1,81 @@
+package com.taais.biz.domain.bo;
+
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.taais.biz.domain.AlgorithmTaskTrack;
+import com.taais.common.orm.core.domain.BaseEntity;
+import io.github.linpeilie.annotations.AutoMapper;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 可辨识性分析总任务业务对象 algorithm_task_track
+ *
+ * @author wangkang
+ * @date 2025-01-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = AlgorithmTaskTrack.class, reverseConvertGenerate = false)
+public class AlgorithmTaskTrackBo extends BaseEntity {
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 任务名称
+     */
+    @NotBlank(message = "任务名称不能为空")
+    private String name;
+
+    /**
+     * 任务状态
+     */
+    private String status;
+
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date endTime;
+
+    /**
+     * 耗时
+     */
+    private Long costSecond;
+
+    /**
+     * 日志
+     */
+    private String log;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * 系统
+     */
+    private String system;
+
+    // 将其他参数存入Map
+    private Map<String, Object> otherParams = new HashMap<>();
+
+    @JsonAnySetter
+    public void addOtherParam(String name, Object value) {
+        this.otherParams.put(name, value);
+    }
+}

+ 29 - 11
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TargetDetectionBo.java

@@ -4,14 +4,19 @@
 
 package com.taais.biz.domain.bo;
 
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.taais.biz.domain.TargetDetection;
+import com.taais.common.orm.core.domain.BaseEntity;
 import io.github.linpeilie.annotations.AutoMapper;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import jakarta.validation.constraints.*;
+
 import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.taais.common.orm.core.domain.BaseEntity;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 目标检测业务对象 target_detection
@@ -22,7 +27,7 @@ import com.taais.common.orm.core.domain.BaseEntity;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @AutoMapper(target = TargetDetection.class, reverseConvertGenerate = false)
-public class TargetDetectionBo extends BaseEntity{
+public class TargetDetectionBo extends BaseEntity {
     /**
      * ID
      */
@@ -36,12 +41,12 @@ public class TargetDetectionBo extends BaseEntity{
 
     /**
      * 状态
-        0:未开始
-        1:进行中
-        2:完成
-        3:失败
-        4:中断
-             */
+     * 0:未开始
+     * 1:进行中
+     * 2:完成
+     * 3:失败
+     * 4:中断
+     */
     private String status;
 
     /**
@@ -100,6 +105,19 @@ public class TargetDetectionBo extends BaseEntity{
     /**
      * 模型的id
      */
-    @NotNull(message = "模型的id不能为空")
     private Long algorithmModelId;
+
+    private String algorithmParameters;
+    @NotNull(message = "算法不能为空")
+    private Long algorithmId;
+    private String logPath;
+    private Long parentTaskId;
+
+    // 将其他参数存入Map
+    private Map<String, Object> otherParams = new HashMap<>();
+
+    @JsonAnySetter
+    public void addOtherParam(String name, Object value) {
+        this.otherParams.put(name, value);
+    }
 }

+ 22 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredBo.java

@@ -4,15 +4,20 @@
 
 package com.taais.biz.domain.bo;
 
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.taais.biz.domain.ToInfrared;
+import com.taais.common.orm.core.domain.BaseEntity;
 import io.github.linpeilie.annotations.AutoMapper;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import jakarta.validation.constraints.*;
-import com.taais.common.orm.core.domain.BaseEntity;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 可见光转红外业务对象 to_infrared
@@ -94,4 +99,19 @@ public class ToInfraredBo extends BaseEntity {
     private String outputPath;
 
     private Long algorithmModelId;
+
+
+    private String algorithmParameters;
+    @NotNull(message = "算法不能为空")
+    private Long algorithmId;
+    private String logPath;
+    private Long parentTaskId;
+
+    // 将其他参数存入Map
+    private Map<String, Object> otherParams = new HashMap<>();
+
+    @JsonAnySetter
+    public void addOtherParam(String name, Object value) {
+        this.otherParams.put(name, value);
+    }
 }

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

@@ -1,29 +0,0 @@
-/**
- * 20241029 ©WANGKANG 1686617586@qq.com
- */
-
-package com.taais.biz.domain.bo;
-
-import jakarta.validation.constraints.NotNull;
-import lombok.*;
-
-/**
- * @Datetime : 2023/12/5 12:13
- * @Author : WANGKANG
- * @Email : 1686617586@qq.com
- * @File : ToInfraredStartResultBo.java
- * @Brief :
- * Copyright 2023 WANGKANG, All Rights Reserved.
- */
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@EqualsAndHashCode()
-public class ToInfraredStartResultBo {
-    @NotNull(message = "status不能为空")
-    private String status;
-    private String msg;
-    @NotNull(message = "id不能为空")
-    private Long id;
-}

+ 33 - 9
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TrackSequenceBo.java

@@ -4,15 +4,22 @@
 
 package com.taais.biz.domain.bo;
 
+import com.fasterxml.jackson.annotation.JsonAnySetter;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.taais.biz.domain.TrackSequence;
+import com.taais.common.orm.core.domain.BaseEntity;
 import io.github.linpeilie.annotations.AutoMapper;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import jakarta.validation.constraints.*;
-import com.taais.common.orm.core.domain.BaseEntity;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Value;
 
 /**
  * 注视轨迹序列业务对象 track_sequence
@@ -23,7 +30,7 @@ import java.util.Date;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @AutoMapper(target = TrackSequence.class, reverseConvertGenerate = false)
-public class TrackSequenceBo extends BaseEntity{
+public class TrackSequenceBo extends BaseEntity {
     /**
      * ID
      */
@@ -37,11 +44,11 @@ public class TrackSequenceBo extends BaseEntity{
 
     /**
      * 状态
-0:未开始
-1:进行中
-2:完成
-3:失败
-4:中断
+     * 0:未开始
+     * 1:进行中
+     * 2:完成
+     * 3:失败
+     * 4:中断
      */
     private String status;
 
@@ -80,7 +87,7 @@ public class TrackSequenceBo extends BaseEntity{
     /**
      * $column.columnComment
      */
-    @NotNull(message = "上传文件不能为空")
+    // @NotNull(message = "上传文件不能为空")
     private Long inputOssId;
 
     /**
@@ -99,5 +106,22 @@ public class TrackSequenceBo extends BaseEntity{
     private String zipFilePath;
 
     private Long algorithmModelId;
+
     private Long algorithmId;
+    private String algorithmParameters;
+    private String logPath;
+    private Long parentTaskId;
+    // @NotNull(message = "目标检测模型ID不能为空")
+    private Long algorithmModelTargetDetectionId;
+
+    private Long predictTaskId; // 预测任务ID
+    private Long inputLabelOssId; // 输入标签文件OSS ID
+
+    // 将其他参数存入Map
+    private Map<String, Object> otherParams = new HashMap<>();
+
+    @JsonAnySetter
+    public void addOtherParam(String name, Object value) {
+        this.otherParams.put(name, value);
+    }
 }

+ 14 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmConfigTrackImportVo.java

@@ -60,5 +60,19 @@ public class AlgorithmConfigTrackImportVo implements Serializable
     @ExcelProperty(value = "系统")
     private String system;
 
+    /** 开始api */
+    @ExcelProperty(value = "开始api")
+    private String startApi;
 
+    /** 暂停api */
+    @ExcelProperty(value = "暂停api")
+    private String pauseApi;
+
+    /** 结束api */
+    @ExcelProperty(value = "结束api")
+    private String terminateApi;
+
+    /** 算法参数配置 */
+    @ExcelProperty(value = "算法参数配置")
+    private String parameters;
 }

+ 13 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmConfigTrackVo.java

@@ -67,6 +67,19 @@ private static final long serialVersionUID = 1L;
     @ExcelProperty(value = "系统")
     private String system;
 
+    /** 开始api */
+    @ExcelProperty(value = "开始api")
+    private String startApi;
 
+    /** 暂停api */
+    @ExcelProperty(value = "暂停api")
+    private String pauseApi;
 
+    /** 结束api */
+    @ExcelProperty(value = "结束api")
+    private String terminateApi;
+
+    /** 算法参数配置 */
+    @ExcelProperty(value = "算法参数配置")
+    private String parameters;
 }

+ 2 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackImportVo.java

@@ -56,5 +56,6 @@ public class AlgorithmModelTrackImportVo implements Serializable
     @ExcelProperty(value = "系统")
     private String system;
 
-
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
 }

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

@@ -87,7 +87,12 @@ public class AlgorithmModelTrackVo extends BaseEntity implements Serializable {
     private String algorithmName;
     private String parameterConfig;
 
-    private String modelStatus;
     private String type;
     private String subsystem;
+
+    @ExcelProperty(value = "模型状态")
+    private String modelStatus;
+
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
 }

+ 109 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmSubTaskTrackVo.java

@@ -0,0 +1,109 @@
+package com.taais.biz.domain.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.taais.common.excel.annotation.ExcelDictFormat;
+import com.taais.common.excel.convert.ExcelDictConvert;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serial;
+import java.util.Date;
+
+/**
+ * @Datetime : 2023/12/5 12:13
+ * @Author : WANGKANG
+ * @Email : 1686617586@qq.com
+ * @File : AlgorithmSubTaskTrackVo.java
+ * @Brief :
+ * Copyright 2023 WANGKANG, All Rights Reserved.
+ */
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class AlgorithmSubTaskTrackVo {
+    /**
+     * ID
+     */
+    private Long id;
+
+    /**
+     * 任务名称
+     */
+    private String name;
+
+    /**
+     * 状态
+     * 0:未开始
+     * 1:进行中
+     * 2:完成
+     * 3:失败
+     * 4:中断
+     */
+    private String status;
+
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 耗时
+     */
+    private Long costSecond;
+
+    /**
+     * 日志
+     */
+    private String log;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * $column.columnComment
+     */
+    private Integer delFlag;
+
+    /**
+     * $column.columnComment
+     */
+    private String url;
+
+    /**
+     * $column.columnComment
+     */
+    private Long inputOssId;
+
+    /**
+     * 输入路径
+     */
+    private String inputPath;
+
+    /**
+     * 输出路径
+     */
+    private String outputPath;
+    private String zipFilePath;
+
+    private Long algorithmModelId;
+
+    private String algorithmParameters;
+    private Long algorithmId;
+    private String logPath;
+
+    private Long parentTaskId;
+
+    private String type;
+    private String subsystem;
+    private String algorithmName;
+    private String modelName;
+}

+ 66 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmTaskTrackImportVo.java

@@ -0,0 +1,66 @@
+package com.taais.biz.domain.vo;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.taais.common.excel.annotation.ExcelDictFormat;
+import com.taais.common.excel.convert.ExcelDictConvert;
+import lombok.Data;
+import java.io.Serial;
+import java.io.Serializable;
+import lombok.NoArgsConstructor;
+
+/**
+ * 可辨识性分析总任务导入视图对象 algorithm_task_track
+ *
+ * @author wangkang
+ * @date 2025-01-06
+ */
+
+@Data
+@NoArgsConstructor
+public class AlgorithmTaskTrackImportVo implements Serializable
+{
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+
+     /** 任务名称 */
+    @ExcelProperty(value = "任务名称")
+    private String name;
+
+     /** 任务状态 */
+    @ExcelProperty(value = "任务状态")
+    private String status;
+
+     /** 开始时间 */
+    @ExcelProperty(value = "开始时间")
+    private Date startTime;
+
+     /** 结束时间 */
+    @ExcelProperty(value = "结束时间")
+    private Date endTime;
+
+     /** 耗时 */
+    @ExcelProperty(value = "耗时")
+    private Long costSecond;
+
+     /** 日志 */
+    @ExcelProperty(value = "日志")
+    private String log;
+
+     /** 备注 */
+    @ExcelProperty(value = "备注")
+    private String remarks;
+
+     /** 逻辑删除标志(0代表存在 1代表删除) */
+    @ExcelProperty(value = "逻辑删除标志(0代表存在 1代表删除)")
+    private Integer delFlag;
+
+     /** 系统 */
+    @ExcelProperty(value = "系统")
+    private String system;
+
+
+}

+ 74 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmTaskTrackVo.java

@@ -0,0 +1,74 @@
+package com.taais.biz.domain.vo;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.taais.biz.domain.AlgorithmTaskTrack;
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.taais.common.excel.annotation.ExcelDictFormat;
+import com.taais.common.excel.convert.ExcelDictConvert;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.io.Serial;
+import java.io.Serializable;
+import com.taais.common.orm.core.domain.BaseEntity;
+
+/**
+ * 可辨识性分析总任务视图对象 algorithm_task_track
+ *
+ * @author wangkang
+ * @date 2025-01-06
+ */
+@Data
+@ExcelIgnoreUnannotated
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = AlgorithmTaskTrack.class)
+public class AlgorithmTaskTrackVo extends BaseEntity implements Serializable {
+
+@Serial
+private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    @ExcelProperty(value = "主键ID")
+    private Long id;
+
+    /** 任务名称 */
+    @ExcelProperty(value = "任务名称")
+    private String name;
+
+    /** 任务状态 */
+    @ExcelProperty(value = "任务状态")
+    private String status;
+
+    /** 开始时间 */
+    @ExcelProperty(value = "开始时间")
+    private Date startTime;
+
+    /** 结束时间 */
+    @ExcelProperty(value = "结束时间")
+    private Date endTime;
+
+    /** 耗时 */
+    @ExcelProperty(value = "耗时")
+    private Long costSecond;
+
+    /** 日志 */
+    @ExcelProperty(value = "日志")
+    private String log;
+
+    /** 备注 */
+    @ExcelProperty(value = "备注")
+    private String remarks;
+
+    /** 逻辑删除标志(0代表存在 1代表删除) */
+    @ExcelProperty(value = "逻辑删除标志(0代表存在 1代表删除)")
+    private Integer delFlag;
+
+    /** 系统 */
+    @ExcelProperty(value = "系统")
+    private String system;
+
+
+
+}

+ 10 - 5
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetDetectionImportVo.java

@@ -1,17 +1,14 @@
 package com.taais.biz.domain.vo;
 
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.taais.common.excel.annotation.ExcelDictFormat;
 import com.taais.common.excel.convert.ExcelDictConvert;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serial;
 import java.io.Serializable;
-
-import lombok.NoArgsConstructor;
+import java.util.Date;
 
 /**
  * 目标检测导入视图对象 target_detection
@@ -119,5 +116,13 @@ public class TargetDetectionImportVo implements Serializable {
     @ExcelProperty(value = "模型的id")
     private Long algorithmModelId;
 
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
+    @ExcelProperty(value = "算法id")
+    private Long algorithmId;
+    @ExcelProperty(value = "日志路径")
+    private String logPath;
 
+    @ExcelProperty(value = "父任务ID")
+    private Long parentTaskId;
 }

+ 13 - 6
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetDetectionVo.java

@@ -1,21 +1,18 @@
 package com.taais.biz.domain.vo;
 
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.taais.biz.domain.TargetDetection;
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.taais.biz.domain.TargetDetection;
 import com.taais.common.excel.annotation.ExcelDictFormat;
 import com.taais.common.excel.convert.ExcelDictConvert;
+import com.taais.common.orm.core.domain.BaseEntity;
 import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
 import java.io.Serializable;
-
-import com.taais.common.orm.core.domain.BaseEntity;
+import java.util.Date;
 
 /**
  * 目标检测视图对象 target_detection
@@ -133,4 +130,14 @@ public class TargetDetectionVo extends BaseEntity implements Serializable {
     private String subsystem;
     private String algorithmName;
     private String modelName;
+
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
+    @ExcelProperty(value = "算法id")
+    private Long algorithmId;
+    @ExcelProperty(value = "日志路径")
+    private String logPath;
+
+    @ExcelProperty(value = "父任务ID")
+    private Long parentTaskId;
 }

+ 9 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/ToInfraredImportVo.java

@@ -81,5 +81,13 @@ public class ToInfraredImportVo implements Serializable
     @ExcelProperty(value = "输出路径")
     private String outputPath;
 
-
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
+    @ExcelProperty(value = "算法ID")
+    private Long algorithmId;
+    @ExcelProperty(value = "日志路径")
+    private String logPath;
+
+    @ExcelProperty(value = "父任务ID")
+    private Long parentTaskId;
 }

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

@@ -120,4 +120,13 @@ public class ToInfraredVo extends BaseEntity implements Serializable {
     private String subsystem;
     private String algorithmName;
     private String modelName;
+
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
+    @ExcelProperty(value = "算法ID")
+    private Long algorithmId;
+    @ExcelProperty(value = "日志路径")
+    private String logPath;
+    @ExcelProperty(value = "父任务ID")
+    private Long parentTaskId;
 }

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

@@ -85,6 +85,24 @@ public class TrackSequenceImportVo implements Serializable
     @ExcelProperty(value = "zip文件输出路径")
     private String zipFilePath;
 
+    @ExcelProperty(value = "算法模型ID")
     private Long algorithmModelId;
+    @ExcelProperty(value = "算法ID")
     private Long algorithmId;
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
+    @ExcelProperty(value = "日志路径")
+    private String logPath;
+
+    @ExcelProperty(value = "父任务ID")
+    private Long parentTaskId;
+
+    @ExcelProperty(value = "预测任务ID")
+    private Long predictTaskId;
+
+    @ExcelProperty(value = "输入标签文件OSS ID")
+    private Long inputLabelOssId;
+
+    @ExcelProperty(value = "目标检测模型id")
+    private Long algorithmModelTargetDetectionId;
 }

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

@@ -122,11 +122,30 @@ public class TrackSequenceVo extends BaseEntity implements Serializable {
     @ExcelProperty(value = "zip文件输出路径")
     private String zipFilePath;
 
-    private Long algorithmModelId;
 
     private String type;
     private String subsystem;
     private String algorithmName;
     private String modelName;
+
+    @ExcelProperty(value = "算法模型ID")
+    private Long algorithmModelId;
+    @ExcelProperty(value = "算法ID")
     private Long algorithmId;
+    @ExcelProperty(value = "算法参数")
+    private String algorithmParameters;
+    @ExcelProperty(value = "日志路径")
+    private String logPath;
+
+    @ExcelProperty(value = "父任务ID")
+    private Long parentTaskId;
+
+    @ExcelProperty(value = "预测任务ID")
+    private Long predictTaskId;
+
+    @ExcelProperty(value = "输入标签文件OSS ID")
+    private Long inputLabelOssId;
+
+    @ExcelProperty(value = "目标检测模型id")
+    private Long algorithmModelTargetDetectionId;
 }

+ 16 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmTaskTrackMapper.java

@@ -0,0 +1,16 @@
+package com.taais.biz.mapper;
+
+import com.mybatisflex.core.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import com.taais.biz.domain.AlgorithmTaskTrack;
+
+/**
+ * 可辨识性分析总任务Mapper接口
+ *
+ * @author wangkang
+ * 2025-01-06
+ */
+@Mapper
+public interface AlgorithmTaskTrackMapper extends BaseMapper<AlgorithmTaskTrack> {
+
+}

+ 68 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmTaskTrackService.java

@@ -0,0 +1,68 @@
+package com.taais.biz.service;
+
+import java.util.List;
+
+import com.taais.biz.domain.AlgorithmTaskTrack;
+import com.taais.biz.domain.vo.AlgorithmTaskTrackVo;
+import com.taais.biz.domain.bo.AlgorithmTaskTrackBo;
+import com.taais.common.core.core.domain.CommonResult;
+import com.taais.common.orm.core.service.IBaseService;
+import com.taais.common.core.core.page.PageResult;
+
+/**
+ * 可辨识性分析总任务Service接口
+ *
+ * @author wangkang
+ * 2025-01-06
+ */
+public interface IAlgorithmTaskTrackService extends IBaseService<AlgorithmTaskTrack> {
+    /**
+     * 查询可辨识性分析总任务
+     *
+     * @param id 可辨识性分析总任务主键
+     * @return 可辨识性分析总任务
+     */
+        AlgorithmTaskTrackVo selectById(Long id);
+
+    /**
+     * 查询可辨识性分析总任务列表
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 可辨识性分析总任务集合
+     */
+    List<AlgorithmTaskTrackVo> selectList(AlgorithmTaskTrackBo algorithmTaskTrackBo);
+
+    /**
+     * 分页查询可辨识性分析总任务列表
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 分页可辨识性分析总任务集合
+     */
+    PageResult<AlgorithmTaskTrackVo> selectPage(AlgorithmTaskTrackBo algorithmTaskTrackBo);
+
+    /**
+     * 新增可辨识性分析总任务
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 结果:true 操作成功,false 操作失败
+     */
+    boolean insert(AlgorithmTaskTrackBo algorithmTaskTrackBo);
+
+    /**
+     * 修改可辨识性分析总任务
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 结果:true 更新成功,false 更新失败
+     */
+    boolean update(AlgorithmTaskTrackBo algorithmTaskTrackBo);
+
+    /**
+     * 批量删除可辨识性分析总任务
+     *
+     * @param ids 需要删除的可辨识性分析总任务主键集合
+     * @return 结果:true 删除成功,false 删除失败
+     */
+    boolean deleteByIds(Long[] ids);
+
+    CommonResult listSubTask(Long id);
+}

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

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

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

@@ -55,6 +55,7 @@ public class AlgorithmConfigTrackServiceImpl extends BaseServiceImpl<AlgorithmCo
         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.orderBy(ALGORITHM_CONFIG_TRACK.ID.asc());
 
         return queryWrapper;
     }

+ 342 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmTaskTrackServiceImpl.java

@@ -0,0 +1,342 @@
+package com.taais.biz.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.mybatisflex.core.paginate.Page;
+import com.mybatisflex.core.query.QueryWrapper;
+import com.taais.biz.domain.AlgorithmModelTrack;
+import com.taais.biz.domain.AlgorithmTaskTrack;
+import com.taais.biz.domain.ToInfrared;
+import com.taais.biz.domain.TrackSequence;
+import com.taais.biz.domain.bo.AlgorithmTaskTrackBo;
+import com.taais.biz.domain.bo.ToInfraredBo;
+import com.taais.biz.domain.bo.TrackSequenceBo;
+import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
+import com.taais.biz.domain.vo.AlgorithmSubTaskTrackVo;
+import com.taais.biz.domain.vo.AlgorithmTaskTrackVo;
+import com.taais.biz.mapper.AlgorithmTaskTrackMapper;
+import com.taais.biz.service.IAlgorithmTaskTrackService;
+import com.taais.common.core.config.TaaisConfig;
+import com.taais.common.core.constant.Constants;
+import com.taais.common.core.core.domain.CommonResult;
+import com.taais.common.core.core.page.PageResult;
+import com.taais.common.core.utils.MapstructUtils;
+import com.taais.common.orm.core.page.PageQuery;
+import com.taais.common.orm.core.service.impl.BaseServiceImpl;
+import com.taais.system.domain.SysOss;
+import com.taais.system.service.impl.SysOssServiceImpl;
+import jakarta.annotation.Resource;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+
+import static com.taais.biz.domain.table.AlgorithmTaskTrackTableDef.ALGORITHM_TASK_TRACK;
+
+/**
+ * 可辨识性分析总任务Service业务层处理
+ *
+ * @author wangkang
+ *         2025-01-06
+ */
+@Service
+public class AlgorithmTaskTrackServiceImpl extends BaseServiceImpl<AlgorithmTaskTrackMapper, AlgorithmTaskTrack>
+        implements IAlgorithmTaskTrackService {
+    @Autowired
+    private AlgorithmConfigTrackServiceImpl algorithmConfigTrackService;
+    @Autowired
+    private AlgorithmModelTrackServiceImpl algorithmModelTrackService;
+    @Autowired
+    private SysOssServiceImpl ossService;
+    @Autowired
+    private ToInfraredServiceImpl toInfraredService;
+    @Autowired
+    private TargetDetectionServiceImpl targetDetectionService;
+    @Autowired
+    private TrackSequenceServiceImpl trackSequenceService;
+
+    @Resource
+    private AlgorithmTaskTrackMapper algorithmTaskTrackMapper;
+
+    @Override
+    public QueryWrapper query() {
+        return super.query().from(ALGORITHM_TASK_TRACK);
+    }
+
+    private QueryWrapper buildQueryWrapper(AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
+        queryWrapper.and(ALGORITHM_TASK_TRACK.NAME.like(algorithmTaskTrackBo.getName()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.STATUS.eq(algorithmTaskTrackBo.getStatus()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.START_TIME.eq(algorithmTaskTrackBo.getStartTime()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.END_TIME.eq(algorithmTaskTrackBo.getEndTime()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.COST_SECOND.eq(algorithmTaskTrackBo.getCostSecond()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.LOG.eq(algorithmTaskTrackBo.getLog()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.REMARKS.eq(algorithmTaskTrackBo.getRemarks()));
+        queryWrapper.and(ALGORITHM_TASK_TRACK.SYSTEM.eq(algorithmTaskTrackBo.getSystem()));
+
+        queryWrapper.orderBy(ALGORITHM_TASK_TRACK.CREATE_TIME.desc());
+
+        return queryWrapper;
+    }
+
+    /**
+     * 查询可辨识性分析总任务
+     *
+     * @param id 可辨识性分析总任务主键
+     * @return 可辨识性分析总任务
+     */
+    @Override
+    public AlgorithmTaskTrackVo selectById(Long id) {
+        return this.getOneAs(query().where(ALGORITHM_TASK_TRACK.ID.eq(id)), AlgorithmTaskTrackVo.class);
+
+    }
+
+    /**
+     * 查询可辨识性分析总任务列表
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 可辨识性分析总任务集合
+     */
+    @Override
+    public List<AlgorithmTaskTrackVo> selectList(AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        QueryWrapper queryWrapper = buildQueryWrapper(algorithmTaskTrackBo);
+        return this.listAs(queryWrapper, AlgorithmTaskTrackVo.class);
+    }
+
+    /**
+     * 分页查询可辨识性分析总任务列表
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 分页可辨识性分析总任务集合
+     */
+    @Override
+    public PageResult<AlgorithmTaskTrackVo> selectPage(AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        QueryWrapper queryWrapper = buildQueryWrapper(algorithmTaskTrackBo);
+        Page<AlgorithmTaskTrackVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmTaskTrackVo.class);
+        return PageResult.build(page);
+    }
+
+    public Long parseLong(Object obj) {
+        if (obj == null) {
+            return null;
+        }
+        if (obj instanceof Long) {
+            return (Long) obj;
+        } else {
+            try {
+                return Long.parseLong(obj.toString());
+            } catch (NumberFormatException e) {
+                // 处理解析失败的情况
+                throw new IllegalArgumentException("参数不是一个有效的Long值: " + obj);
+            }
+        }
+    }
+
+    public ToInfraredBo cteateToInfraredTaskBo(Map<String, Object> params) {
+        ToInfraredBo toInfraredBo = new ToInfraredBo();
+        toInfraredBo.setName("ToInfrared_" + params.get("name"));
+        toInfraredBo.setInputOssId(parseLong(params.get("inputDatasetOssId")));
+        toInfraredBo.setRemarks((String) params.get("remarks"));
+        toInfraredBo.setParentTaskId(parseLong(params.get("parentTaskId")));
+
+        toInfraredBo.setAlgorithmModelId(parseLong(params.get("toInfraredModelId")));
+        toInfraredBo.setAlgorithmId(parseLong(params.get("toInfraredAlgorithmId")));
+
+        toInfraredBo.setOtherParams((Map<String, Object>) params.get("toInfraredAlgorithmParams"));
+
+        return toInfraredBo;
+    }
+
+    public TrackSequenceBo createTrackSequencePredictBo(Map<String, Object> params) {
+        TrackSequenceBo trackSequenceBo = new TrackSequenceBo();
+        trackSequenceBo.setName("TrackSequence_predict_" + params.get("name"));
+        trackSequenceBo.setInputOssId(parseLong(params.get("inputDatasetOssId")));
+        trackSequenceBo.setRemarks((String) params.get("remarks"));
+        trackSequenceBo.setParentTaskId(parseLong(params.get("parentTaskId")));
+
+        trackSequenceBo.setAlgorithmModelId(parseLong(params.get("trackSequenceModelId")));
+        trackSequenceBo.setAlgorithmId(parseLong(params.get("trackSequenceAlgorithmId")));
+        trackSequenceBo.setAlgorithmModelTargetDetectionId(parseLong(params.get("TD_modelId")));
+
+        Map<String, Object> otherParams = (Map<String, Object>) params.get("trackSequenceAlgorithmParams");
+        if (ObjectUtil.isNull(otherParams)) {
+            otherParams = new HashMap<>();
+        }
+        trackSequenceBo.setOtherParams(otherParams);
+
+        return trackSequenceBo;
+    }
+
+    public TrackSequenceBo createTrackSequenceEvaluateBo(Map<String, Object> params) {
+        TrackSequenceBo trackSequenceBo = new TrackSequenceBo();
+        trackSequenceBo.setName("TrackSequence_evaluate_" + params.get("name"));
+        trackSequenceBo.setInputOssId(parseLong(params.get("inputDatasetOssId")));
+        trackSequenceBo.setRemarks((String) params.get("remarks"));
+        trackSequenceBo.setParentTaskId(parseLong(params.get("parentTaskId")));
+
+        if (ObjectUtil.isNull(params.get("trackSequenceEvaluateAlgorithmId"))) {
+            throw new IllegalArgumentException("评估算法为空!");
+        }
+
+        trackSequenceBo.setAlgorithmId(parseLong(params.get("trackSequenceEvaluateAlgorithmId")));
+        trackSequenceBo.setAlgorithmModelTargetDetectionId(parseLong(params.get("TD_modelId")));
+        trackSequenceBo.setPredictTaskId(parseLong(params.get("trackSequencePredictTaskId")));
+        trackSequenceBo.setInputLabelOssId(parseLong(params.get("inputEvaluateLabelOssId")));
+
+        Map<String, Object> otherParams = (Map<String, Object>) params.get("trackSequenceEvaluateAlgorithmParams");
+        if (ObjectUtil.isNull(otherParams)) {
+            otherParams = new HashMap<>();
+        }
+        trackSequenceBo.setOtherParams(otherParams);
+
+        return trackSequenceBo;
+    }
+
+    /**
+     * 新增可辨识性分析总任务
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 结果:true 操作成功,false 操作失败
+     */
+    @Override
+    @Transactional
+    public boolean insert(AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        // 这里估计还是得用save手动构造entity了,如果用entityBo太麻烦了
+        AlgorithmTaskTrack algorithmTaskTrack = MapstructUtils.convert(algorithmTaskTrackBo, AlgorithmTaskTrack.class);
+        boolean flag = this.save(algorithmTaskTrack);
+        if (!flag) {
+            return false;
+        }
+        // 步骤
+        // 创建可见光转红外预测任务
+        Map<String, Object> params = algorithmTaskTrackBo.getOtherParams();
+        params.put("name", algorithmTaskTrackBo.getName());
+        params.put("remarks", algorithmTaskTrackBo.getRemarks());
+        params.put("parentTaskId", algorithmTaskTrack.getId());
+
+        if (params.containsKey("ifToInfrared") && params.get("ifToInfrared").equals(true)) {
+            ToInfraredBo toInfraredBo = cteateToInfraredTaskBo(params);
+            toInfraredBo.setParentTaskId(algorithmTaskTrack.getId());
+            ToInfrared toInfraredTask = toInfraredService.insert2(toInfraredBo);
+
+            // 需要更新一下inputDatasetOssId,以便于创建trackSequencePredictTask任务
+            // todo 这里有一个很恶心的地方,就是可见光转红外预测任务的输出是输出目录的/images文件夹,乌鱼子,,,
+            String outPath = toInfraredTask.getOutputPath();
+            if (outPath.endsWith("/images")) {
+                outPath = outPath.substring(0, outPath.length() - 7);
+            }
+            Long inputDatasetOssId_new = getNewOssId(outPath);
+            params.put("inputDatasetOssId", inputDatasetOssId_new);
+        }
+
+        // 创建可辨识性预测任务
+        TrackSequenceBo trackSequencePredictBo = createTrackSequencePredictBo(params);
+        trackSequencePredictBo.setParentTaskId(algorithmTaskTrack.getId());
+        CommonResult result__ = trackSequenceService.insert(trackSequencePredictBo);
+        TrackSequence trackSequencePredictTask = (TrackSequence) result__.getData();
+        // 创建可辨识性分析评估任务
+        if (params.containsKey("ifEvaluate") && params.get("ifEvaluate").equals(true)) {
+            params.put("trackSequencePredictTaskId", trackSequencePredictTask.getId());
+            TrackSequenceBo trackSequenceEvaluateBo = createTrackSequenceEvaluateBo(params);
+            trackSequenceEvaluateBo.setParentTaskId(algorithmTaskTrack.getId());
+            CommonResult result____ = trackSequenceService.insert(trackSequenceEvaluateBo);
+            TrackSequence trackSequenceEvaluateTask = (TrackSequence) result____.getData();
+        }
+
+        return true;
+    }
+
+    public Long getNewOssId(String outputPath) {
+        Path path = Paths.get(outputPath);
+        String dirName = path.getFileName().toString();
+        String fileName = Constants.RESOURCE_PREFIX + outputPath.substring(TaaisConfig.getProfile().length());
+
+        SysOss oss = new SysOss();
+        oss.setUrl("no url");
+        oss.setFileSuffix("no suffix");
+        oss.setFileName(fileName);
+        oss.setOriginalName(dirName);
+        oss.setService("Local");
+        boolean flag = ossService.save(oss);
+
+        if (flag) {
+            return oss.getOssId();
+        } else {
+            throw new RuntimeException("save oss failed");
+        }
+    }
+
+    /**
+     * 修改可辨识性分析总任务
+     *
+     * @param algorithmTaskTrackBo 可辨识性分析总任务Bo
+     * @return 结果:true 更新成功,false 更新失败
+     */
+    @Override
+    public boolean update(AlgorithmTaskTrackBo algorithmTaskTrackBo) {
+        AlgorithmTaskTrack algorithmTaskTrack = MapstructUtils.convert(algorithmTaskTrackBo, AlgorithmTaskTrack.class);
+        if (ObjectUtil.isNotNull(algorithmTaskTrack) && ObjectUtil.isNotNull(algorithmTaskTrack.getId())) {
+            boolean updated = this.updateById(algorithmTaskTrack);
+            return updated;
+        }
+        return false;
+    }
+
+    /**
+     * 批量删除可辨识性分析总任务
+     *
+     * @param ids 需要删除的可辨识性分析总任务主键集合
+     * @return 结果:true 删除成功,false 删除失败
+     */
+    @Transactional
+    @Override
+    public boolean deleteByIds(Long[] ids) {
+        return this.removeByIds(Arrays.asList(ids));
+    }
+
+    public AlgorithmSubTaskTrackVo setSubTaskVo(Long modelId, Long algorithmId, AlgorithmSubTaskTrackVo subTaskVo) {
+        if (ObjectUtil.isNotNull(modelId)) {
+            AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
+            subTaskVo.setModelName(model.getModelName());
+        }
+
+        if (ObjectUtil.isNotNull(algorithmId)) {
+            AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
+            subTaskVo.setType(config.getType());
+            subTaskVo.setSubsystem(config.getSubsystem());
+            subTaskVo.setAlgorithmName(config.getAlgorithmName());
+        }
+
+        return subTaskVo;
+    }
+
+    @Override
+    public CommonResult listSubTask(Long id) {
+        List<ToInfrared> toInfraredList = toInfraredService.getByParentTaskId(id);
+        List<TrackSequence> trackSequenceList = trackSequenceService.getByParentTaskId(id);
+
+        List<AlgorithmSubTaskTrackVo> subTaskVoList = new ArrayList<>();
+        if (ObjectUtil.isNotEmpty(toInfraredList)) {
+            for (ToInfrared toInfrared : toInfraredList) {
+                AlgorithmSubTaskTrackVo subTaskVo = new AlgorithmSubTaskTrackVo();
+                BeanUtils.copyProperties(toInfrared, subTaskVo);
+                subTaskVo = setSubTaskVo(toInfrared.getAlgorithmModelId(), toInfrared.getAlgorithmId(), subTaskVo);
+                subTaskVoList.add(subTaskVo);
+            }
+        }
+
+        if (ObjectUtil.isNotEmpty(trackSequenceList)) {
+            for (TrackSequence trackSequence : trackSequenceList) {
+                AlgorithmSubTaskTrackVo subTaskVo = new AlgorithmSubTaskTrackVo();
+                BeanUtils.copyProperties(trackSequence, subTaskVo);
+                subTaskVo = setSubTaskVo(trackSequence.getAlgorithmModelId(), trackSequence.getAlgorithmId(),
+                        subTaskVo);
+                subTaskVoList.add(subTaskVo);
+            }
+        }
+        return CommonResult.success(subTaskVoList);
+    }
+}

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

@@ -12,7 +12,6 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.bo.TargetDetectionBo;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
-import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
 import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.domain.vo.TargetDetectionVo;
 import com.taais.biz.mapper.TargetDetectionMapper;
@@ -23,7 +22,7 @@ import com.taais.common.core.constant.Constants;
 import com.taais.common.core.core.domain.CommonResult;
 import com.taais.common.core.core.page.PageResult;
 import com.taais.common.core.utils.MapstructUtils;
-import com.taais.common.core.utils.StringUtils;
+import com.taais.common.json.utils.JsonUtils;
 import com.taais.common.orm.core.page.PageQuery;
 import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import com.taais.common.websocket.utils.WebSocketUtils;
@@ -48,23 +47,19 @@ import java.util.*;
 
 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.ToInfraredServiceImpl.*;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
 
 /**
  * 目标检测Service业务层处理
  *
  * @author wangkang
- * 2024-09-29
+ *         2024-09-29
  */
 @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;
-
+public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection>
+        implements ITargetDetectionService {
     @Resource
     private TargetDetectionMapper targetDetectionMapper;
     @Autowired
@@ -75,6 +70,12 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
     @Autowired
     private AlgorithmModelTrackServiceImpl algorithmModelTrackService;
 
+    public List<TargetDetection> getByParentTaskId(Long parentTaskId) {
+        QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
+        queryWrapper.and(TARGET_DETECTION.PARENT_TASK_ID.eq(parentTaskId));
+        return this.list(queryWrapper);
+    }
+
     @Override
     public QueryWrapper query() {
         return super.query().from(TARGET_DETECTION);
@@ -120,7 +121,7 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
     @Override
     public List<TargetDetectionVo> selectList(TargetDetectionBo targetDetectionBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(targetDetectionBo);
-        queryWrapper.orderBy(TARGET_DETECTION.CREATE_TIME,Boolean.FALSE);
+        queryWrapper.orderBy(TARGET_DETECTION.CREATE_TIME, Boolean.FALSE);
         return this.listAs(queryWrapper, TargetDetectionVo.class);
     }
 
@@ -133,17 +134,22 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
     @Override
     public PageResult<TargetDetectionVo> selectPage(TargetDetectionBo targetDetectionBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(targetDetectionBo);
-        queryWrapper.orderBy(TARGET_DETECTION.CREATE_TIME,Boolean.FALSE);
+        queryWrapper.orderBy(TARGET_DETECTION.CREATE_TIME, Boolean.FALSE);
         Page<TargetDetectionVo> page = this.pageAs(PageQuery.build(), queryWrapper, TargetDetectionVo.class);
         page.getRecords().forEach(entity -> {
             Long modelId = entity.getAlgorithmModelId();
-            AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
-            if (ObjectUtil.isNotNull(model)) {
-                AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(model.getAlgorithmId());
+            if (ObjectUtil.isNotNull(modelId)) {
+                AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
+                entity.setModelName(model.getModelName());
+
+            }
+
+            Long algorithmId = entity.getAlgorithmId();
+            if (ObjectUtil.isNotNull(algorithmId)) {
+                AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
                 entity.setType(config.getType());
                 entity.setSubsystem(config.getSubsystem());
                 entity.setAlgorithmName(config.getAlgorithmName());
-                entity.setModelName(model.getModelName());
             }
         });
         page.getRecords().sort(Comparator.comparing(TargetDetectionVo::getCreateTime).reversed());
@@ -153,47 +159,99 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
     /**
      * 新增目标检测
      *
-     * @param targetDetectionBo 目标检测Bo
+     * @param entityBo 目标检测Bo
      * @return 结果:true 操作成功,false 操作失败
      */
     @Override
-    public boolean insert(TargetDetectionBo targetDetectionBo) {
+    @Transactional
+    public boolean insert(TargetDetectionBo entityBo) {
         // 检查input_oss_id是否存在
-        if (ObjectUtil.isNull(targetDetectionBo.getInputOssId())) {
+        if (ObjectUtil.isNull(entityBo.getInputOssId())) {
             return false;
         }
 
-        SysOssVo ossEntity = ossService.getById(targetDetectionBo.getInputOssId());
+        SysOssVo ossEntity = ossService.getById(entityBo.getInputOssId());
         if (ObjectUtil.isNull(ossEntity)) {
             return false;
         }
 
-        TargetDetection targetDetection = new TargetDetection();
+        TargetDetection entity = new TargetDetection();
+        entity.setInputOssId(entityBo.getInputOssId());
+        entity.setUrl(ossEntity.getUrl());
+        entity.setZipFilePath(ossEntity.getFileName());
+        entity.setName(entityBo.getName());
+        entity.setStatus(NOT_START);
+        entity.setRemarks(entityBo.getRemarks());
+        entity.setAlgorithmModelId(entityBo.getAlgorithmModelId());
+        entity.setAlgorithmId(entityBo.getAlgorithmId());
+        entity.setParentTaskId(entityBo.getParentTaskId());
+        boolean flag = this.save(entity);
+
+        if (!flag) {
+            return false;
+        }
 
-        targetDetection.setInputOssId(targetDetectionBo.getInputOssId());
-        targetDetection.setUrl(ossEntity.getUrl());
+        entity = updateEntity(entity, entityBo, ossEntity);
 
-        String filePath = ossEntity.getFileName();
-        String localPath = TaaisConfig.getProfile();
-        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
-        targetDetection.setInputPath(resourcePath);
+        // 步骤 6. 保存算法参数到数据库
+        return this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+    }
 
-        String fileName = StringUtils.substringAfterLast(filePath, "/");
-        String fileName_without_suffix = removeFileExtension(fileName);
+    private TargetDetection updateEntity(TargetDetection entity, TargetDetectionBo entityBo, SysOssVo ossEntity) {
+        // 从这里开始,配置任务的algorithm_parameters参数
+        // 步骤 1. 首先根据算法id获取算法配置
+        AlgorithmConfigTrack algorithmConfig = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        if (ObjectUtil.isNull(algorithmConfig)) {
+            throw new RuntimeException("算法配置参数为空");
+        }
 
-        Path path = Paths.get(resourcePath);
-        Path outPath = path.resolveSibling(fileName_without_suffix + "_images" + System.currentTimeMillis());
-        targetDetection.setOutputPath(outPath.toString());
+        Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
+                entityBo.getOtherParams());
+
+        // 步骤4. 构造可以直接传给前端的map数据结构
+        Map<String, Object> result = new HashMap<>();
+
+        result.put("bizId", entity.getId());
+        result.put("bizType", BizConstant.BizType.TARGET_DETECTION);
+
+        if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.TRAIN)) {
+            String source_dir = getTrainInputPath(ossEntity);
+            String result_dir = getTrainOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TARGET_DETECTION_SUFFIX);
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+        } else if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.REASONING)) {
+            String source_dir = getPredictInputPath(ossEntity);
+            String result_dir = getPredictOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TARGET_DETECTION_SUFFIX);
+            String model_path = getModelPath(entity);
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+            result.put("model_path", model_path);
+        } else {
+            throw new RuntimeException("算法类型错误");
+        }
 
-        targetDetection.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
+        result.put("otherParams", algorithmParameters);
 
-        targetDetection.setName(targetDetectionBo.getName());
-        targetDetection.setStatus(NOT_START);
-        targetDetection.setRemarks(targetDetectionBo.getRemarks());
+        entity.setInputPath((String) result.get("source_dir"));
+        entity.setOutputPath((String) result.get("result_dir"));
+        entity.setLogPath((String) result.get("log_path"));
+        // 步骤 5. 将算法参数map序列化为json字符串,保存到数据库中
+        entity.setAlgorithmParameters(JsonUtils.toJsonString(result));
 
-        targetDetection.setAlgorithmModelId(targetDetectionBo.getAlgorithmModelId());
+        makeDir(entity.getInputPath());
+        makeDir(entity.getOutputPath());
 
-        return this.save(targetDetection);// 使用全局配置的雪花算法主键生成器生成ID值
+        File file = new File(entity.getInputPath());
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, entity.getInputPath());
+        }
+
+        return entity;
     }
 
     /**
@@ -204,9 +262,17 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
      */
     @Override
     public boolean update(TargetDetectionBo targetDetectionBo) {
-        TargetDetection targetDetection = MapstructUtils.convert(targetDetectionBo, TargetDetection.class);
-        if (ObjectUtil.isNotNull(targetDetection) && ObjectUtil.isNotNull(targetDetection.getId())) {
-            boolean updated = this.updateById(targetDetection);
+        TargetDetection entity = MapstructUtils.convert(targetDetectionBo, TargetDetection.class);
+
+        SysOssVo ossEntity = ossService.getById(targetDetectionBo.getInputOssId());
+        if (ObjectUtil.isNull(ossEntity)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        entity = updateEntity(entity, targetDetectionBo, ossEntity);
+
+        if (ObjectUtil.isNotNull(entity) && ObjectUtil.isNotNull(entity.getId())) {
+            boolean updated = this.updateById(entity);
             return updated;
         }
         return false;
@@ -224,69 +290,58 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         return this.removeByIds(Arrays.asList(ids));
     }
 
-    @Override
-    public CommonResult start(Long id) {
-        TargetDetection 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);
+    public static String getTrainInputPath(SysOssVo ossEntity) {
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            throw new RuntimeException("文件路径不存在");
+        }
+        File[] listFiles = file.listFiles();
+        if (listFiles == null || listFiles.length == 0) {
+            throw new RuntimeException("文件路径为空!");
+        }
+        for (File f : listFiles) {
+            if (f.isDirectory()) { // 找到第一个目录
+                return f.getAbsolutePath();
+            }
+        }
+        return null;
+    }
 
+    public String getTrainOutputPath(TargetDetection entity, SysOssVo ossEntity) {
+        String resourcePath = getResourcePath(ossEntity);
         Path path = Paths.get(resourcePath);
-        Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
         Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TARGET_DETECTION_SUFFIX);
+        return outputPath.toString();
+    }
 
-//        makeDir(inputPath.toString());
-        makeDir(outputPath.toString());
-
-        File file = new File(inputPath.toString());
-        if (!file.exists()) {
-            ZipUtils.unzip(resourcePath, inputPath.toString());
-        }
-
-        entity.setInputPath(inputPath.toString());
-        entity.setOutputPath(outputPath.toString());
+    public String getPredictInputPath(SysOssVo ossEntity) {
+        // todo
+        return getUnZipDirPath(ossEntity);
+    }
 
-        entity.setStartTime(new Date());
+    public String getPredictOutputPath(TargetDetection entity, SysOssVo ossEntity) {
+        // todo
+        String resourcePath = getResourcePath(ossEntity);
+        Path path = Paths.get(resourcePath);
+        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TARGET_DETECTION_SUFFIX);
+        return outputPath.toString();
+    }
 
+    private String getModelPath(TargetDetection entity) {
         AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
+        return algorithmModelTrack.getModelAddress();
+    }
 
-        StartTaskConfig startTaskConfig = new StartTaskConfig();
-        startTaskConfig.setBizType(BizConstant.BizType.TARGET_DETECTION);
-        startTaskConfig.setBizId(entity.getId());
+    @Override
+    public CommonResult start(Long id) {
+        TargetDetection entity = getById(id);
+        entity.setStartTime(new Date());
 
-        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();
-            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;
-                }
-            }
-        }
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        Map<String, Object> startTaskConfig = JsonUtils.parseMap(entity.getAlgorithmParameters());
 
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getStartApi(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -306,7 +361,9 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
         startTaskConfig.setBizId(entity.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getTerminateApi(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(entity);
@@ -332,42 +389,6 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         }
         updateById(entity);
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        algorithmModelTrack.setModelStatus("200".equals(status) ? BizConstant.ModelStatus.END : BizConstant.ModelStatus.FAILED);
-
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
-        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"));
-
-            System.out.println(parse.get("dataset"));
-            algorithmModelTrackService.updateById(algorithmModelTrack);
-        }
-
-        /*
-         * 这里有很多需要做的:1. 保存所有模型到oss 2. 模型文件保存到算法模型配置表中
-         */
-        /*
-        Path resultsPath = Paths.get(entity.getInputPath());
-        Path modelPath = resultsPath.resolve(BizConstant.MODEL_PATH);
-
-        File modelDir = new File(modelPath.toString());
-
-        if(!modelDir.exists() || !modelDir.isDirectory()) {
-            return CommonResult.fail("模型文件不存在");
-        }
-
-        for (File f : modelDir.listFiles()) {
-            if (f.isFile() && f.getName().endsWith(BizConstant.MODEL_SUFFIX)) {
-                SysOssVo upload = ossService.upload(f);
-                AlgorithmModelTrack algorithmModelTrack = new AlgorithmModelTrack();
-                algorithmModelTrack.set
-                algorithmModelTrackService.insert();
-            }
-        }
-        */
         WebSocketUtils.publishAll("refresh");
         return CommonResult.success();
     }
@@ -396,18 +417,15 @@ 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);
-    }
-
-    private String getLogFileName(TargetDetection entity) {
-        return entity.getId() + BizConstant.TARGET_DETECTION_SUFFIX + ".log";
+        return ResponseEntity.ok()
+                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+                .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     @Override
     public CommonResult getLog(Long id) {
         TargetDetection entity = getById(id);
-        String outPutPath = entity.getOutputPath();
-        String logPath = outPutPath + File.separator + getLogFileName(entity);
+        String logPath = entity.getLogPath();
         System.out.println(logPath);
         File file = new File(logPath);
         if (!file.exists()) {
@@ -421,36 +439,7 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         TargetDetection entity = getById(id);
         String outPutPath = entity.getOutputPath();
         String modelPath = outPutPath;
-        File modelDir = new File(modelPath);
-        if (!modelDir.exists()) {
-            return CommonResult.fail("模型输出目录不存在!");
-        }
-        File[] files = modelDir.listFiles();
-        Integer idx = 0;
-        ArrayList<Map<String, String>> res = new ArrayList<>();
-        for (File file : files) {
-            if (!file.getName().endsWith(BizConstant.TD_TRAIN_MODEL_SUFFIX)) {
-                continue;
-            }
-            idx += 1;
-            Map<String, String> tmp = new HashMap<>();
-            tmp.put("id", idx.toString());
-            tmp.put("name", file.getName());
-            String filePath = file.getPath();
-            tmp.put("path", filePath);
-            // todo 获取真正的url
-            // http://localhost:9090/profile/upload/2024/10/27/1_1729404909511_20241027153840A001.zip
-            String url = "http://localhost:" + port + Constants.RESOURCE_PREFIX + filePath.substring(TaaisConfig.getProfile().length());
-            url = url.replaceAll("\\\\", "/"); // windows
-            tmp.put("url", url);
-
-            double fileSize = (getFileSize(file) / (1024.0 * 1024.0));
-            DecimalFormat decimalFormat = new DecimalFormat("#.##");
-            String formatFileSize = decimalFormat.format(fileSize);
-            tmp.put("size", formatFileSize + "MB");
-            res.add(tmp);
-        }
-        return CommonResult.success(res, "success");
+        return getModelList_(modelPath, TaaisConfig.getProfile());
     }
 
     public static long getFileSize(File file) {

+ 248 - 85
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -50,6 +50,7 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.text.DecimalFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
@@ -60,20 +61,11 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
  * 可见光转红外Service业务层处理
  *
  * @author 0
- * 2024-09-20
+ *         2024-09-20
  */
 @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;
-
     @Autowired
     private ISysOssService ossService;
 
@@ -84,6 +76,12 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     @Autowired
     private AlgorithmModelTrackServiceImpl algorithmModelTrackService;
 
+    public List<ToInfrared> getByParentTaskId(Long parentTaskId) {
+        QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
+        queryWrapper.and(TO_INFRARED.PARENT_TASK_ID.eq(parentTaskId));
+        return this.list(queryWrapper);
+    }
+
     @Override
     public QueryWrapper query() {
         return super.query().from(TO_INFRARED);
@@ -139,16 +137,22 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     @Override
     public PageResult<ToInfraredVo> selectPage(ToInfraredBo toInfraredBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(toInfraredBo);
+        queryWrapper.orderBy(TO_INFRARED.CREATE_TIME, Boolean.FALSE);
         Page<ToInfraredVo> page = this.pageAs(PageQuery.build(), queryWrapper, ToInfraredVo.class);
         page.getRecords().forEach(entity -> {
             Long modelId = entity.getAlgorithmModelId();
-            AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
-            if (ObjectUtil.isNotNull(model)) {
-                AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(model.getAlgorithmId());
+            if (ObjectUtil.isNotNull(modelId)) {
+                AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
+                entity.setModelName(model.getModelName());
+
+            }
+
+            Long algorithmId = entity.getAlgorithmId();
+            if (ObjectUtil.isNotNull(algorithmId)) {
+                AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
                 entity.setType(config.getType());
                 entity.setSubsystem(config.getSubsystem());
                 entity.setAlgorithmName(config.getAlgorithmName());
-                entity.setModelName(model.getModelName());
             }
         });
         page.getRecords().sort(Comparator.comparing(ToInfraredVo::getCreateTime).reversed());
@@ -158,63 +162,196 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     /**
      * 新增可见光转红外
      *
-     * @param toInfraredBo 可见光转红外Bo
+     * @param entityBo 可见光转红外Bo
      * @return 结果:true 操作成功,false 操作失败
      */
     @Override
-    public boolean insert(ToInfraredBo toInfraredBo) {
+    @Transactional
+    public boolean insert(ToInfraredBo entityBo) {
         // 检查input_oss_id是否存在
-        if (ObjectUtil.isNull(toInfraredBo.getInputOssId())) {
+        if (ObjectUtil.isNull(entityBo.getInputOssId())) {
             return false;
         }
 
-        SysOssVo ossEntity = ossService.getById(toInfraredBo.getInputOssId());
+        SysOssVo ossEntity = ossService.getById(entityBo.getInputOssId());
         if (ObjectUtil.isNull(ossEntity)) {
             return false;
         }
 
         ToInfrared entity = new ToInfrared();
-        entity.setInputOssId(toInfraredBo.getInputOssId());
+        entity.setInputOssId(entityBo.getInputOssId());
         entity.setUrl(ossEntity.getUrl());
         entity.setZipFilePath(ossEntity.getFileName());
-        entity.setName(toInfraredBo.getName());
+        entity.setName(entityBo.getName());
         entity.setStatus(NOT_START);
-        entity.setRemarks(toInfraredBo.getRemarks());
-        entity.setAlgorithmModelId(toInfraredBo.getAlgorithmModelId());
-
+        entity.setRemarks(entityBo.getRemarks());
+        entity.setAlgorithmModelId(entityBo.getAlgorithmModelId());
+        entity.setAlgorithmId(entityBo.getAlgorithmId());
+        entity.setParentTaskId(entityBo.getParentTaskId());
         boolean flag = this.save(entity);
 
-        if(!flag) {
+        if (!flag) {
             return false;
         }
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
-
-        if (algorithmConfigTrack.getType().equals(BizConstant.AlgorithmType.TRAIN)) {
-            String inputPath = getTrainInputPath(ossEntity);
-            String outputPath = getTrainOutputPath(entity, ossEntity);
-            entity.setInputPath(inputPath);
-            entity.setOutputPath(outputPath);
-        } else if (algorithmConfigTrack.getType().equals(BizConstant.AlgorithmType.REASONING)) {
-            String inputPath = getPredictInputPath(ossEntity);
-            String outputPath = getPredictOutputPath(entity, ossEntity);
-            entity.setInputPath(inputPath);
-            entity.setOutputPath(outputPath);
+        entity = updateEntity(entity, entityBo, ossEntity);
+
+        // 步骤 6. 保存算法参数到数据库
+        return this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+    }
+
+    @Transactional
+    public ToInfrared insert2(ToInfraredBo entityBo) {
+        // 检查input_oss_id是否存在
+        if (ObjectUtil.isNull(entityBo.getInputOssId())) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        SysOssVo ossEntity = ossService.getById(entityBo.getInputOssId());
+        if (ObjectUtil.isNull(ossEntity)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        ToInfrared entity = new ToInfrared();
+        entity.setInputOssId(entityBo.getInputOssId());
+        entity.setUrl(ossEntity.getUrl());
+        entity.setZipFilePath(ossEntity.getFileName());
+        entity.setName(entityBo.getName());
+        entity.setStatus(NOT_START);
+        entity.setRemarks(entityBo.getRemarks());
+        entity.setAlgorithmModelId(entityBo.getAlgorithmModelId());
+        entity.setAlgorithmId(entityBo.getAlgorithmId());
+        entity.setParentTaskId(entityBo.getParentTaskId());
+        boolean flag = this.save(entity);
+
+        if (!flag) {
+            throw new RuntimeException("新增失败");
+        }
+
+        entity = updateEntity(entity, entityBo, ossEntity);
+
+        // 步骤 6. 保存算法参数到数据库
+        boolean flag_ = this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+        if (!flag_) {
+            throw new RuntimeException("新增失败");
+        }
+        return entity;
+    }
+
+    public static Object strToTargetType(Object val_) {
+        if (ObjectUtil.isEmpty(val_)) {
+            return null;
+        }
+        String val = val_.toString();
+        try {
+            return Integer.parseInt(val);
+        } catch (Exception e1) {
+            try {
+                return Double.parseDouble(val);
+            } catch (Exception e2) {
+                if (val.contains(",")) {
+                    val = val.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s", "");
+                    try {
+                        return Arrays.stream(val.split(",")).map(Integer::parseInt).collect(Collectors.toList());
+                    } catch (Exception e3) {
+                        try {
+                            return Arrays.stream(val.split(",")).map(Double::parseDouble).collect(Collectors.toList());
+                        } catch (Exception e4) {
+                            return "[" + val + "]";
+                        }
+                    }
+                } else {
+                    return Boolean.parseBoolean(val);
+                }
+            }
+        }
+    }
+
+    public static Map<String, Object> getAlgorithmParameters(String algorithmConfigStr,
+            Map<String, Object> otherParams) {
+        Map<String, Object> algorithmParameters = new HashMap<>();
+        List<Dict> config_list = JsonUtils.parseArrayMap(algorithmConfigStr);
+
+        // 步骤 2. 根据算法配置,生成默认参数的map数据结构,同时需要解析default_value字段,生成对应的结果
+        if (ObjectUtil.isEmpty(config_list)) {
+            System.out.println("算法配置参数为空");
+            return algorithmParameters;
+            // throw new RuntimeException("算法配置参数为空");
+        }
+        for (Dict config : config_list) {
+            String key = (String) config.get("agName");
+            Object value = config.get("defaultValue");
+            if (ObjectUtil.isNotNull(key) && ObjectUtil.isNotNull(value)) {
+                algorithmParameters.put(key, value);
+            }
+        }
+        // 步骤 3. 然后根据前端传入的参数,覆盖默认参数
+        if (ObjectUtil.isNotEmpty(otherParams)) {
+            for (String key : algorithmParameters.keySet()) {
+                if (otherParams.containsKey(key) && ObjectUtil.isNotEmpty(otherParams.get(key))) {
+                    algorithmParameters.put(key, strToTargetType(otherParams.get(key)));
+                }
+            }
+        }
+
+        return algorithmParameters;
+    }
+
+    private ToInfrared updateEntity(ToInfrared entity, ToInfraredBo entityBo, SysOssVo ossEntity) {
+        // 从这里开始,配置任务的algorithm_parameters参数
+        // 步骤 1. 首先根据算法id获取算法配置
+        AlgorithmConfigTrack algorithmConfig = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        if (ObjectUtil.isNull(algorithmConfig)) {
+            throw new RuntimeException("算法配置参数为空");
+        }
+
+        Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
+                entityBo.getOtherParams());
+
+        // 步骤4. 构造可以直接传给前端的map数据结构
+        Map<String, Object> result = new HashMap<>();
+
+        result.put("bizId", entity.getId());
+        result.put("bizType", BizConstant.BizType.TO_INFRARED);
+
+        if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.TRAIN)) {
+            String source_dir = getTrainInputPath(ossEntity);
+            String result_dir = getTrainOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TO_INFRARED_SUFFIX);
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+        } else if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.REASONING)) {
+            String source_dir = getPredictInputPath(ossEntity);
+            String result_dir = getPredictOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(source_dir, entity.getId(), BizConstant.TO_INFRARED_SUFFIX);
+            String model_path = getModelPath(entity);
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+            result.put("model_path", model_path);
         } else {
-            throw new RuntimeException("算法类型不支持");
+            throw new RuntimeException("算法类型错误");
         }
 
-        String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+        result.put("otherParams", algorithmParameters);
+
+        entity.setInputPath((String) result.get("source_dir"));
+        entity.setOutputPath((String) result.get("result_dir"));
+        entity.setLogPath((String) result.get("log_path"));
+        // 步骤 5. 将算法参数map序列化为json字符串,保存到数据库中
+        entity.setAlgorithmParameters(JsonUtils.toJsonString(result));
+
         makeDir(entity.getInputPath());
         makeDir(entity.getOutputPath());
 
         File file = new File(entity.getInputPath());
         if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
             ZipUtils.unzip(resourcePath, entity.getInputPath());
         }
 
-        return this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+        return entity;
     }
 
     /**
@@ -226,6 +363,14 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     @Override
     public boolean update(ToInfraredBo toInfraredBo) {
         ToInfrared toInfrared = MapstructUtils.convert(toInfraredBo, ToInfrared.class);
+
+        SysOssVo ossEntity = ossService.getById(toInfraredBo.getInputOssId());
+        if (ObjectUtil.isNull(ossEntity)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        toInfrared = updateEntity(toInfrared, toInfraredBo, ossEntity);
+
         if (ObjectUtil.isNotNull(toInfrared) && ObjectUtil.isNotNull(toInfrared.getId())) {
             boolean updated = this.updateById(toInfrared);
             return updated;
@@ -258,8 +403,13 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         String fileName_without_suffix = removeFileExtension(fileName);
 
         Path path = Paths.get(resourcePath);
-        Path dirPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
-        return dirPath.toString();
+        File file = new File(path.toString());
+        if (file.isDirectory()) {
+            return path.toString();
+        } else {
+            Path dirPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX);
+            return dirPath.toString();
+        }
     }
 
     public String getTrainInputPath(SysOssVo ossEntity) {
@@ -278,44 +428,31 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     }
 
     public String getPredictOutputPath(ToInfrared entity, SysOssVo ossEntity) {
-        return getUnZipDirPath(ossEntity) + File.separator + BizConstant.TO_INFRARED_PREDICT_OUTPUT_DIR;
+        return getPredictInputPath(ossEntity) + File.separator + BizConstant.TO_INFRARED_PREDICT_OUTPUT_DIR;
     }
 
-    private String getLogFileName(ToInfrared entity) {
-        return entity.getId() + BizConstant.TO_INFRARED_SUFFIX + ".log";
-    }
-
-    public String getLogFilePath(ToInfrared entity) {
-        return entity.getOutputPath() + File.separator + getLogFileName(entity);
+    public static String getLogFilePath(String outputPath, Long id, String suffix) {
+        return outputPath + File.separator + id.toString() + suffix + ".log";
     }
 
     public String getStatisticsResultPath(SysOssVo ossEntity) {
         return getUnZipDirPath(ossEntity) + File.separator + BizConstant.RESULT_JSON_NAME;
     }
 
+    private String getModelPath(ToInfrared entity) {
+        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
+        return algorithmModelTrack.getModelAddress();
+    }
+
     @Override
     public CommonResult start(Long id) {
         ToInfrared entity = getById(id);
         entity.setStartTime(new Date());
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
-
-        StartTaskConfig startTaskConfig = new StartTaskConfig();
-        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
-        startTaskConfig.setBizId(entity.getId());
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        Map<String, Object> startTaskConfig = JsonUtils.parseMap(entity.getAlgorithmParameters());
 
-        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
-
-        startTaskConfig.setSource_dir(entity.getInputPath());
-        startTaskConfig.setResult_dir(entity.getOutputPath());
-        startTaskConfig.setLog_path(getLogFilePath(entity));
-
-        if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
-            startTaskConfig.setModel_path(algorithmModelTrack.getModelAddress());
-        }
-
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getStartApi(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -335,7 +472,9 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
         startTaskConfig.setBizId(toInfrared.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(toInfrared.getAlgorithmId());
+
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getTerminateApi(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             toInfrared.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(toInfrared);
@@ -372,8 +511,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
         }
 
-        AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(toInfrared.getAlgorithmModelId());
-        AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(model.getAlgorithmId());
+        AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(toInfrared.getAlgorithmId());
 
         if (BizConstant.AlgorithmType.TRAIN.equals(config.getType())) { // 如果是训练类型,返回模型
             return getLastModelFile(toInfrared);
@@ -387,8 +525,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     @Override
     public CommonResult getLog(Long id) {
         ToInfrared entity = getById(id);
-        String logPath = getLogFilePath(entity);
-        log.info("logPath: {}", logPath);
+        String logPath = entity.getLogPath();
         File file = new File(logPath);
         if (!file.exists()) {
             return CommonResult.fail("日志文件不存在!");
@@ -412,11 +549,22 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         return content;
     }
 
-    @Override
-    public CommonResult getModelList(Long id) {
-        ToInfrared entity = getById(id);
-        String outPutPath = entity.getOutputPath();
-        String modelPath = outPutPath + File.separator + "model";
+    public static long getFolderSize(File folder) {
+        long totalSize = 0;
+        if (folder.isDirectory()) {
+            File[] files = folder.listFiles();
+            if (files != null) {
+                for (File file : files) {
+                    totalSize += getFolderSize(file);
+                }
+            }
+        } else {
+            totalSize = folder.length();
+        }
+        return totalSize;
+    }
+
+    public static CommonResult getModelList_(String modelPath, String profile) {
         File modelDir = new File(modelPath);
         if (!modelDir.exists()) {
             return CommonResult.fail("模型输出目录不存在!");
@@ -425,19 +573,24 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         Integer idx = 0;
         ArrayList<Map<String, String>> res = new ArrayList<>();
         for (File file : files) {
+            if (file.getName().endsWith(".log") || file.getName().endsWith(".json")
+                    || file.getName().startsWith("events.out")) {
+                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
+            // 获取url
             // http://localhost:9090/profile/upload/2024/10/27/1_1729404909511_20241027153840A001.zip
-            String url = "http://localhost:" + port + Constants.RESOURCE_PREFIX + filePath.substring(profile.length());
+            // /profile/upload/2024/10/27/1_1729404909511_20241027153840A001.zip
+            String url = "/api" + Constants.RESOURCE_PREFIX + filePath.substring(profile.length());
             url = url.replaceAll("\\\\", "/"); // windows
             tmp.put("url", url);
 
-            double fileSize = (file.length() / (1024.0 * 1024.0));
+            double fileSize = (getFolderSize(file) / (1024.0 * 1024.0));
             DecimalFormat decimalFormat = new DecimalFormat("#.##");
             String formatFileSize = decimalFormat.format(fileSize);
             tmp.put("size", formatFileSize + "MB");
@@ -446,6 +599,14 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         return CommonResult.success(res, "success");
     }
 
+    @Override
+    public CommonResult getModelList(Long id) {
+        ToInfrared entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String modelPath = outPutPath + File.separator + "model";
+        return getModelList_(modelPath, TaaisConfig.getProfile());
+    }
+
     @Override
     public CommonResult previewPredictResult(Long id) {
         ToInfrared entity = getById(id);
@@ -482,7 +643,6 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         }
     }
 
-
     public static CommonResult getCompareImage(String urlPrefix, String inputPath, String outputPath) {
         try {
             List<String> inputImageList = calculateImagePath(urlPrefix, inputPath);
@@ -493,7 +653,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             if (ObjectUtil.isNotNull(inputImageList)) {
                 for (String imageUrl : inputImageList) {
                     String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
-                    nameToUrl1.put(name, imageUrl);
+                    nameToUrl1.put(name.split("\\.")[0], imageUrl);
                 }
             }
 
@@ -501,7 +661,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             if (ObjectUtil.isNotNull(outputImageList)) {
                 for (String imageUrl : outputImageList) {
                     String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
-                    nameToUrl2.put(name, imageUrl);
+                    nameToUrl2.put(name.split("\\.")[0], imageUrl);
                 }
             }
 
@@ -538,13 +698,14 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             }
         }
 
-
         if (!file.exists() || !file.isFile()) {
             return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
         }
 
         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);
     }
 
     public ResponseEntity<org.springframework.core.io.Resource> getLastModelFile(ToInfrared toInfrared) {
@@ -567,6 +728,8 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         File returnFile = modelFiles[modelFiles.length - 1];
 
         org.springframework.core.io.Resource resource = new FileSystemResource(returnFile);
-        return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + returnFile.getName() + "\"").header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
+        return ResponseEntity.ok()
+                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + returnFile.getName() + "\"")
+                .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 }

+ 243 - 399
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -4,13 +4,6 @@
 
 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.text.DecimalFormat;
-import java.util.*;
-
 import cn.hutool.core.lang.Dict;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSON;
@@ -25,7 +18,6 @@ import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.domain.vo.TrackSequenceVo;
 import com.taais.biz.mapper.TrackSequenceMapper;
 import com.taais.biz.service.ITrackSequenceService;
-import com.taais.biz.utils.CsvReadUtils;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
@@ -33,16 +25,20 @@ import com.taais.common.core.core.domain.CommonResult;
 import com.taais.common.core.core.page.PageResult;
 import com.taais.common.core.utils.MapstructUtils;
 import com.taais.common.core.utils.StringUtils;
+import com.taais.common.json.utils.JsonUtils;
 import com.taais.common.orm.core.page.PageQuery;
-import com.taais.common.core.core.page.PageResult;
 import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import com.taais.common.websocket.utils.WebSocketUtils;
+import com.taais.system.domain.SysOss;
 import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
+import com.taais.system.service.impl.SysOssServiceImpl;
+
 import jakarta.annotation.Resource;
+
+import org.apache.commons.lang3.ObjectUtils;
 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;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -50,29 +46,32 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.DecimalFormat;
+import java.util.*;
+
 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.TargetDetectionServiceImpl.*;
 import static com.taais.biz.service.impl.ToInfraredServiceImpl.*;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
-import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
 
 /**
  * 注视轨迹序列Service业务层处理
  *
  * @author wangkang
- * 2024-09-22
+ *         2024-09-22
  */
 @Service
-public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence> implements ITrackSequenceService {
+public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence>
+        implements ITrackSequenceService {
 
     private static final String MASC = "MASC";
     private static final String CAT = "CAT";
 
-    @Value("${server.task_stop_url_cat}")
-    private String task_stop_url;
-
     @Autowired
     private AlgorithmConfigTrackServiceImpl algorithmConfigTrackService;
     @Autowired
@@ -84,6 +83,55 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
     @Resource
     private TrackSequenceMapper trackSequenceMapper;
 
+    public List<TrackSequence> getByParentTaskId(Long parentTaskId) {
+        QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
+        queryWrapper.and(TRACK_SEQUENCE.PARENT_TASK_ID.eq(parentTaskId));
+        return this.list(queryWrapper);
+    }
+
+    // public String getTrainInputPath(SysOssVo ossEntity) {
+    // return getUnZipDirPath(ossEntity);
+    // }
+
+    public String getTrainOutputPath(TrackSequence entity, SysOssVo ossEntity) {
+        String resourcePath = getResourcePath(ossEntity);
+        Path path = Paths.get(resourcePath);
+        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX);
+        return outputPath.toString();
+    }
+
+    public String getPredictInputPath(SysOssVo ossEntity) {
+        // todo
+        return getUnZipDirPath(ossEntity);
+    }
+
+    public String getPredictOutputPath(TrackSequence entity, SysOssVo ossEntity) {
+        return getTrainOutputPath(entity, ossEntity);
+    }
+
+    public String getTestInputPath(SysOssVo ossEntity) {
+        // todo
+        return getUnZipDirPath(ossEntity);
+    }
+
+    public String getTestOutputPath(TrackSequence entity, SysOssVo ossEntity) {
+        // todo
+        return getTrainOutputPath(entity, ossEntity);
+    }
+
+    private String getModelPath(Long modelId) {
+        if (ObjectUtil.isNull(modelId)) {
+            System.out.println("模型id为空");
+            return "";
+        }
+        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(modelId);
+        if (ObjectUtil.isNull(algorithmModelTrack)) {
+            System.out.println("模型不存在");
+            return "";
+        }
+        return algorithmModelTrack.getModelAddress();
+    }
+
     @Override
     public QueryWrapper query() {
         return super.query().from(TRACK_SEQUENCE);
@@ -145,98 +193,167 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         Page<TrackSequenceVo> page = this.pageAs(PageQuery.build(), queryWrapper, TrackSequenceVo.class);
         page.getRecords().forEach(entity -> {
             Long modelId = entity.getAlgorithmModelId();
-            Long algorithmId = entity.getAlgorithmId();
-            if (modelId != null) {
-                AlgorithmModelTrackVo model = algorithmModelTrackService.selectById(modelId);
-                if (ObjectUtil.isNotNull(model)) {
-                    entity.setModelName(model.getModelName());
-                }
+            if (ObjectUtil.isNotNull(modelId)) {
+                AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
+                entity.setModelName(model.getModelName());
+
             }
-            if (algorithmId != null) {
+
+            Long algorithmId = entity.getAlgorithmId();
+            if (ObjectUtil.isNotNull(algorithmId)) {
                 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());
-                    }
-                }
+                entity.setType(config.getType());
+                entity.setSubsystem(config.getSubsystem());
+                entity.setAlgorithmName(config.getAlgorithmName());
             }
         });
         page.getRecords().sort(Comparator.comparing(TrackSequenceVo::getCreateTime).reversed());
         return PageResult.build(page);
     }
 
+    public TrackSequence packageTrackSequence(TrackSequenceBo entityBo, SysOssVo ossEntity) {
+        TrackSequence entity = new TrackSequence();
+        entity.setInputOssId(entityBo.getInputOssId());
+        entity.setUrl(ossEntity.getUrl());
+        entity.setZipFilePath(ossEntity.getFileName());
+        entity.setName(entityBo.getName());
+        entity.setStatus(NOT_START);
+        entity.setRemarks(entityBo.getRemarks());
+        entity.setAlgorithmModelId(entityBo.getAlgorithmModelId());
+        entity.setAlgorithmId(entityBo.getAlgorithmId());
+        entity.setParentTaskId(entityBo.getParentTaskId());
+        entity.setAlgorithmModelTargetDetectionId(entityBo.getAlgorithmModelTargetDetectionId());
+        entity.setInputLabelOssId(entityBo.getInputLabelOssId());
+        entity.setPredictTaskId(entityBo.getPredictTaskId());
+        return entity;
+    }
+
     /**
      * 新增注视轨迹序列
      *
-     * @param trackSequenceBo 注视轨迹序列Bo
+     * @param entityBo 注视轨迹序列Bo
      * @return 结果:true 操作成功,false 操作失败
      */
     @Override
-    public CommonResult insert(TrackSequenceBo trackSequenceBo) {
-        // 检查任务名称
-        if (ObjectUtil.isEmpty(trackSequenceBo.getName()) || (!trackSequenceBo.getName().startsWith(MASC) && !trackSequenceBo.getName().startsWith(CAT))) {
-            return CommonResult.fail("任务命名错误,需以MASC或CAT开头!");
+    @Transactional
+    public CommonResult insert(TrackSequenceBo entityBo) {
+        Long ossId = entityBo.getInputOssId();
+        if (ObjectUtil.isNotEmpty(entityBo.getPredictTaskId())) { // 如果存在预测任务id,则使用label ossId
+            ossId = entityBo.getInputLabelOssId();
         }
 
         // 检查input_oss_id是否存在
-        if (ObjectUtil.isNull(trackSequenceBo.getInputOssId())) {
-            return CommonResult.fail("请上传模型");
+        if (ObjectUtil.isNull(ossId)) {
+            throw new RuntimeException("oss文件不存在");
         }
 
-        SysOssVo ossEntity = ossService.getById(trackSequenceBo.getInputOssId());
+        SysOssVo ossEntity = ossService.getById(ossId);
         if (ObjectUtil.isNull(ossEntity)) {
-            return CommonResult.fail("找不到指定模型!");
+            throw new RuntimeException("oss文件不存在");
         }
 
-        if (trackSequenceBo.getName().startsWith(MASC)) {
-            if (ObjectUtil.isEmpty(trackSequenceBo.getAlgorithmId())) {
-                return CommonResult.fail("请指定算法!");
-            }
+        TrackSequence entity = packageTrackSequence(entityBo, ossEntity);
+        boolean flag = this.save(entity);
 
-            AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(trackSequenceBo.getAlgorithmId());
-            if (ObjectUtil.isNull(config)) {
-                return CommonResult.fail("找不到指定的算法!");
-            }
+        if (!flag) {
+            throw new RuntimeException("新增注释轨迹序列任务失败");
         }
 
-        TrackSequence trackSequence = new TrackSequence();
+        entity = updateEntity(entity, entityBo, ossEntity);
 
-        BeanUtils.copyProperties(trackSequenceBo, trackSequence);
+        // 步骤 6. 保存算法参数到数据库
+        boolean __ = this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+        if (!__) {
+            throw new RuntimeException("新增注释轨迹序列任务失败");
+        }
+        return CommonResult.success(entity);
+    }
 
-        trackSequence.setUrl(ossEntity.getUrl());
+    private TrackSequence updateEntity(TrackSequence entity, TrackSequenceBo entityBo, SysOssVo ossEntity) {
+        // 从这里开始,配置任务的algorithm_parameters参数
+        // 步骤 1. 首先根据算法id获取算法配置
+        AlgorithmConfigTrack algorithmConfig = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        if (ObjectUtil.isNull(algorithmConfig)) {
+            throw new RuntimeException("算法配置参数为空");
+        }
 
-        String filePath = ossEntity.getFileName();
-        String localPath = TaaisConfig.getProfile();
-        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
-        trackSequence.setInputPath(resourcePath);
+        Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
+                entityBo.getOtherParams());
+
+        // 步骤4. 构造可以直接传给前端的map数据结构
+        Map<String, Object> result = new HashMap<>();
+
+        result.put("bizId", entity.getId());
+        result.put("bizType", BizConstant.BizType.TRACK_SEQUENCE);
+
+        if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.TRAIN)) {
+            String source_dir = getTrainInputPath(ossEntity);
+            String result_dir = getTrainOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TRACK_SEQUENCE_SUFFIX);
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+        } else if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.REASONING)) {
+            String source_dir = getPredictInputPath(ossEntity);
+            String result_dir = getPredictOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TRACK_SEQUENCE_SUFFIX);
+
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+
+            if (ObjectUtil.isNotEmpty(entity.getAlgorithmModelId())) {
+                String model_path = getModelPath(entity.getAlgorithmModelId());
+                result.put("model_path", model_path);
+            }
 
-        String fileName = StringUtils.substringAfterLast(filePath, "/");
-        String fileName_without_suffix = removeFileExtension(fileName);
+            if (ObjectUtil.isNotEmpty(entity.getAlgorithmModelTargetDetectionId())) {
+                String model_path_TD = getModelPath(entity.getAlgorithmModelTargetDetectionId());
+                result.put("model_path_TD", model_path_TD);
+            } else {
+                throw new RuntimeException("目标检测模型不存在!");
+            }
+        } else if (algorithmConfig.getType().equals(BizConstant.AlgorithmType.TEST)) {
+            if (ObjectUtil.isEmpty(entityBo.getPredictTaskId())) {
+                throw new RuntimeException("预测任务id为空");
+            }
+            TrackSequence predictTask = getById(entityBo.getPredictTaskId());
+            if (ObjectUtil.isNull(predictTask)) {
+                throw new RuntimeException("预测任务不存在");
+            }
 
-        Path path = Paths.get(resourcePath);
-        Path outPath = path.resolveSibling(fileName_without_suffix + "_images" + System.currentTimeMillis());
-        trackSequence.setOutputPath(outPath.toString());
+            String source_dir = predictTask.getInputPath();
+            String txt_dir = predictTask.getOutputPath();
+            String result_dir = getTestOutputPath(entity, ossEntity);
+            String log_path = getLogFilePath(result_dir, entity.getId(), BizConstant.TRACK_SEQUENCE_SUFFIX);
+            String label_dir = getResourcePath(ossEntity);
+            result.put("source_dir", source_dir);
+            result.put("result_dir", result_dir);
+            result.put("log_path", log_path);
+            result.put("label_dir", label_dir);
+            result.put("txt_dir", txt_dir);
+        } else {
+            throw new RuntimeException("算法类型错误");
+        }
 
-        trackSequence.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
-        trackSequence.setStatus(NOT_START);
+        result.put("otherParams", algorithmParameters);
 
+        entity.setInputPath((String) result.get("source_dir"));
+        entity.setOutputPath((String) result.get("result_dir"));
+        entity.setLogPath((String) result.get("log_path"));
+        // 步骤 5. 将算法参数map序列化为json字符串,保存到数据库中
+        entity.setAlgorithmParameters(JsonUtils.toJsonString(result));
 
-        boolean __ = this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
-        if (__) {
-            return CommonResult.success();
-        } else {
-            return CommonResult.fail();
+        makeDir(entity.getInputPath());
+        makeDir(entity.getOutputPath());
+
+        File file = new File(entity.getInputPath());
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, entity.getInputPath());
         }
+
+        return entity;
     }
 
     /**
@@ -247,9 +364,27 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
      */
     @Override
     public boolean update(TrackSequenceBo trackSequenceBo) {
-        TrackSequence trackSequence = MapstructUtils.convert(trackSequenceBo, TrackSequence.class);
-        if (ObjectUtil.isNotNull(trackSequence) && ObjectUtil.isNotNull(trackSequence.getId())) {
-            boolean updated = this.updateById(trackSequence);
+        TrackSequence entity = MapstructUtils.convert(trackSequenceBo, TrackSequence.class);
+
+        Long ossId = trackSequenceBo.getInputOssId();
+        if (ObjectUtil.isNotEmpty(trackSequenceBo.getPredictTaskId())) { // 如果存在预测任务id,则使用label ossId
+            ossId = trackSequenceBo.getInputLabelOssId();
+        }
+
+        // 检查input_oss_id是否存在
+        if (ObjectUtil.isNull(ossId)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        SysOssVo ossEntity = ossService.getById(ossId);
+        if (ObjectUtil.isNull(ossEntity)) {
+            throw new RuntimeException("oss文件不存在");
+        }
+
+        entity = updateEntity(entity, trackSequenceBo, ossEntity);
+
+        if (ObjectUtil.isNotNull(entity) && ObjectUtil.isNotNull(entity.getId())) {
+            boolean updated = this.updateById(entity);
             return updated;
         }
         return false;
@@ -269,138 +404,13 @@ 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());
-        }
-
-        StartTaskConfig startTaskConfig = new StartTaskConfig();
-
-        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());
-
-            startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
-
-            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());
+        entity.setStartTime(new Date());
 
-            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);
-            Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX);
-
-//        makeDir(inputPath.toString());
-            makeDir(outputPath.toString());
-
-            File file = new File(inputPath.toString());
-            if (!file.exists()) {
-                ZipUtils.unzip(resourcePath, inputPath.toString());
-            }
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        Map<String, Object> startTaskConfig = JsonUtils.parseMap(entity.getAlgorithmParameters());
 
-            entity.setInputPath(inputPath.toString());
-            entity.setOutputPath(outputPath.toString());
-
-            entity.setStartTime(new Date());
-
-            startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
-            startTaskConfig.setBizId(entity.getId());
-
-            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();
-                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(), startTaskConfig);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getStartApi(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -420,7 +430,9 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
         startTaskConfig.setBizId(entity.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getTerminateApi(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(entity);
@@ -437,33 +449,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
         }
 
-        String outputPath = "";
-        String zipFilePath = "";
-
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
-
-        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();
-            zipFilePath = outputPath + ".zip";
-        } else {
-            System.out.println("未知算法类型!");
-            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
-        }
+        String outputPath = entity.getOutputPath();
+        String zipFilePath = outputPath + ".zip";
 
         File file = new File(zipFilePath);
         if (!file.exists()) {
@@ -479,7 +466,9 @@ 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
@@ -498,42 +487,18 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         }
         updateById(entity);
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-        algorithmModelTrack.setModelStatus("200".equals(status) ? BizConstant.ModelStatus.END : BizConstant.ModelStatus.FAILED);
-
-        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
-        String params = algorithmConfigTrack.getParameterConfig();
-        HashMap<String, Object> parse = (HashMap<String, Object>) JSON.parse((params));
-
-        if ("200".equals(status) && ObjectUtil.isNull(algorithmModelTrack.getModelAddress())) {
-            try {
-                algorithmModelTrack.setModelAddress(entity.getOutputPath() + File.separator + ((HashMap<String, String>) parse.get("dataset")).get("classes"));
-            } catch (Exception e) {
-                System.out.println("未知错误,我也不知道啥原因。。");
-            }
-
-            System.out.println(parse.get("dataset"));
-            algorithmModelTrackService.updateById(algorithmModelTrack);
-        }
         WebSocketUtils.publishAll("refresh");
         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);
+        File file = new File(entity.getLogPath());
         if (!file.exists()) {
             return CommonResult.fail("日志文件不存在!");
         }
-        return CommonResult.success(readLogContent(logPath), "success");
+        return CommonResult.success(readLogContent(entity.getLogPath()), "success");
     }
 
     @Override
@@ -554,7 +519,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             return CommonResult.success(res, "success");
         } else if (entity.getName().startsWith(CAT)) {
             AlgorithmModelTrack modelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
-            AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(modelTrack.getAlgorithmId());
+            AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService
+                    .getById(modelTrack.getAlgorithmId());
 
             AlgorithmModelTrackVo res = new AlgorithmModelTrackVo();
 
@@ -570,168 +536,47 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         }
     }
 
-    @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");
-        } 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");
+        return getModelList_(modelPath, TaaisConfig.getProfile());
     }
 
     @Override
     public CommonResult previewPredictResult(Long id) {
         TrackSequence entity = getById(id);
+        String inputPath = entity.getInputPath() + File.separator + "images";
+        String outputPath = entity.getOutputPath() + File.separator + "gaze" + File.separator + "images";
 
-        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 + "images");
-        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX + File.separator + "gaze" + File.separator + "images");
-
-        File outputPathDir = new File(outputPath.toString());
+        File outputPathDir = new File(outputPath);
         if (!outputPathDir.exists()) {
-            outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX + File.separator + "images");
+            outputPath = entity.getOutputPath() + File.separator + "images";
         }
 
-//        String urlPrefix = inputOssEntity.getUrl().substring(0, inputOssEntity.getUrl().indexOf(Constants.RESOURCE_PREFIX) + Constants.RESOURCE_PREFIX.length());
         String urlPrefix = Constants.RESOURCE_PREFIX;
-        return getCompareImage(urlPrefix, inputPath.toString(), outputPath.toString());
+        return getCompareImage(urlPrefix, inputPath, outputPath);
     }
 
     @Override
     public CommonResult previewEvaluateResult(Long id) {
-        TrackSequence 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 resultPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX + File.separator + BizConstant.RESULT_JSON_NAME);
-
-        if (!new File(resultPath.toString()).exists()) {
-            return CommonResult.fail("评估结果文件不存在!");
-        }
-
-        List<Dict> resultMap = parseJsonMapList(resultPath);
-        if (ObjectUtil.isEmpty(resultMap)) {
-            return CommonResult.fail("获取结果文件失败");
-        }
-
-        return CommonResult.success(resultMap);
+        return getStatisticsResult(id);
     }
 
     @Override
     public CommonResult getStatisticsResult(Long id) {
         TrackSequence 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 resultFilePath = entity.getOutputPath() + File.separator + BizConstant.RESULT_JSON_NAME;
 
-        Path path = Paths.get(resourcePath);
-        Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TRACK_SEQUENCE_SUFFIX);
+        Path resultPath = Paths.get(resultFilePath);
 
-        Path statisticsResultPath = outputPath.resolve(BizConstant.RESULT_JSON_NAME);
+        if (!new File(resultPath.toString()).exists()) {
+            return CommonResult.fail("评估结果文件不存在!");
+        }
 
-        List<Dict> resultMap = parseJsonMapList(statisticsResultPath);
+        List<Dict> resultMap = parseJsonMapList(resultPath);
         if (ObjectUtil.isEmpty(resultMap)) {
             return CommonResult.fail("获取结果文件失败");
         }
@@ -739,5 +584,4 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         return CommonResult.success(resultMap);
     }
 
-
 }

+ 7 - 0
taais-modules/taais-biz/src/main/resources/mapper/demo/AlgorithmTaskTrackMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.taais.biz.mapper.AlgorithmTaskTrackMapper">
+
+</mapper>