66 Commits c8aa7312b5 ... 819b72954b

Auteur SHA1 Message Date
  28968 819b72954b fix: bug fix il y a 2 mois
  allen fe294f6fb4 Merge branch 'dev_wk2' into develop il y a 2 mois
  allen 5f6c401428 fix openDir bugs il y a 2 mois
  Eagle 42d42fa615 fix: fix open dir function il y a 2 mois
  WANGKANG 75c698f335 fix: 解决训练路径没有解压压缩包的问题 il y a 2 mois
  Eagle 3a78fb88ae fix: 创建任务中算法模型列表去除已删除模型 il y a 2 mois
  WANGKANG e2cbfa5c51 fix: 判断model和config为空的情况 il y a 2 mois
  WANGKANG c69fa23683 fix: 解决没有自动解压的问题 il y a 3 mois
  Suuuuuukang 2634f88ec7 fix: 图片导出带标签txt文件 il y a 3 mois
  Sk18834839360 8a01dd3249 Merge branch 'dev_lsk_0325' of www/taais into develop il y a 3 mois
  Suuuuuukang f0d4740dce fix: todo-打开文件夹重试 il y a 3 mois
  Sk18834839360 c4322e7286 Merge branch 'dev_lsk_0325' of www/taais into develop il y a 3 mois
  Suuuuuukang eec2928bfc feat: 目标检测启动停止,打开文件夹重试 il y a 3 mois
  Sk18834839360 cf2c4a7617 Merge branch 'dev_lsk_sjkz' of www/taais into develop il y a 3 mois
  allen 4a4c9a61e4 Merge remote-tracking branch 'origin/develop' into develop il y a 3 mois
  Li f730016553 fix: update params il y a 4 mois
  Suuuuuukang 070f226895 feat: 打开文件夹功能 il y a 4 mois
  Suuuuuukang ee24f0c20c fix: 数据扩增bug fix il y a 4 mois
  Suuuuuukang 48be7658c9 feat: 数据扩增逻辑重做 il y a 4 mois
  WANGKANG 4e2f8f0df4 feat: add new feature il y a 5 mois
  WANGKANG 61db8f83ab Merge branch 'develop' into dev_wk2 il y a 5 mois
  WANGKANG 782ca293e3 feat: 异常处理 il y a 5 mois
  WANGKANG cfd71d3284 feat: 移除不用方法 il y a 5 mois
  WANGKANG a9ff1b7780 feat: None il y a 5 mois
  WANGKANG 3027ea68dc feat: 总任务初步搞定 il y a 5 mois
  WANGKANG 151257350d featg: cat测试 il y a 5 mois
  WANGKANG 4b8da90eb7 feat: masc测试完毕,优化部分逻辑 il y a 5 mois
  WANGKANG 589f75aca7 feat: MASC预测 il y a 5 mois
  WANGKANG c7d71babd8 feat: 目标检测任务调试 il y a 5 mois
  WANGKANG 3b5110fbd1 fix: 目标检测 il y a 5 mois
  WANGKANG 38d9728b06 fix: 可见光装红外任务修正 il y a 5 mois
  WANGKANG 58655f464c feat: 子任务列表查看功能 il y a 5 mois
  WANGKANG 58b146f20d feat: 封住一个子任务查看Vo il y a 5 mois
  Eagle d721421cb1 [FEATURE] 多源信息融合、异源图像匹配、电子稳相的暂停、继续、停止功能 il y a 5 mois
  WANGKANG 6e71b3c7b2 feat: 初步实现子任务查看 il y a 5 mois
  WANGKANG 808a45ad19 fix: 父任务id添加 il y a 5 mois
  WANGKANG 3f8f55ce0b feat: 总任务新增初步完成 il y a 5 mois
  WANGKANG 7db3ba8253 fix: 标签为空时捕获异常 il y a 5 mois
  WANGKANG b00c0cf4c7 fix: 算法配置为空时修正 il y a 5 mois
  WANGKANG a7ac94a69b feat: 初步完成新增任务 il y a 5 mois
  WANGKANG b2b8a31f8b feat: 修改getUnZipDirPath方法 il y a 5 mois
  WANGKANG 13761e0c80 feat: 总任务Bo修改 il y a 5 mois
  WANGKANG 11b1ac376b feat: 添加一个insert2函数,返回值改为entity il y a 5 mois
  WANGKANG af15ce9061 feat: 去掉多余的验证条件 il y a 5 mois
  WANGKANG 4439d24b1f feat: 可辨识性分析添加基础文件 il y a 5 mois
  WANGKANG 3d74048360 feat: 路径修改 il y a 5 mois
  WANGKANG 529fcc7b47 fix: 回退电子稳相代码 il y a 5 mois
  WANGKANG 87f3037261 feat: 把路径又完善了一下 il y a 5 mois
  WANGKANG 0e981ac093 feat: domain添加parentTaskId il y a 5 mois
  WANGKANG d10eb9e0fb feat: 可辨识性分析部分完成 il y a 5 mois
  WANGKANG 27489514da feat: 目标检测和可见光转红外完善 il y a 5 mois
  WANGKANG 82f6e7280a feat: 目标检测任务展示编辑完成,路径还未完成 il y a 5 mois
  WANGKANG f2375c9844 feat: 修改目标检测Bo il y a 5 mois
  WANGKANG 524958a1e4 feat: 继续优化函数结构,进一步封装程序 il y a 5 mois
  WANGKANG 04f3e11487 feat: 目标检测domain文件修改 il y a 5 mois
  WANGKANG 994ee9f84d feat: 可见光转红外更细接口完善 il y a 5 mois
  WANGKANG 836daa9333 feat: 可见光转红外配置完成 il y a 5 mois
  WANGKANG c31cb44408 feat: 添加otherParams参数,用来保存前端传过来的参数 il y a 5 mois
  WANGKANG 1c0ee51bc6 feat: 可见光转红外domain参数修改 il y a 5 mois
  WANGKANG 623ccabd79 feat: 模型配置新增参数algorithm_parameters il y a 5 mois
  WANGKANG cd6cee8449 feat: 按照id增序排序 il y a 5 mois
  WANGKANG ea51d60ffa feat: 可辨识性分析算法配置表添加参数 il y a 5 mois
  allen 2cb19c6430 Merge branch 'dev_lsk_b12' into develop il y a 5 mois
  WANGKANG 8878798aa1 feat: 去掉video_stable中的配置项,改为数据字典获取开始结束url il y a 6 mois
  WANGKANG ee5a63093a feat: 抽象路径获取方法 il y a 6 mois
  Eagle 98f3e49289 [FEATURE] 数据扩增任务、电子稳相 il y a 6 mois
56 fichiers modifiés avec 2379 ajouts et 971 suppressions
  1. 40 0
      script/sql/algorithm_config.sql
  2. 3 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/constant/BizConstant.java
  3. 114 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/AlgorithmTaskTrackController.java
  4. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataAugmentationController.java
  5. 1 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataController.java
  6. 58 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ObjectMatchController.java
  7. 84 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ObjectTraceMergeController.java
  8. 20 5
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/PublicController.java
  9. 140 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TargetIdentificationSubtaskDetailsController.java
  10. 0 5
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TrackSequenceController.java
  11. 5 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/controller/VideoStableController.java
  12. 11 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmConfigTrack.java
  13. 2 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmModelTrack.java
  14. 61 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/AlgorithmTaskTrack.java
  15. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/CommonAlgorithmConfig.java
  16. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TargetDetection.java
  17. 5 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/ToInfrared.java
  18. 11 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TrackSequence.java
  19. 27 4
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmConfigTrackBo.java
  20. 3 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmModelTrackBo.java
  21. 81 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/AlgorithmTaskTrackBo.java
  22. 5 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/CommonAlgorithmConfigBo.java
  23. 29 11
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TargetDetectionBo.java
  24. 22 2
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredBo.java
  25. 0 29
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/ToInfraredStartResultBo.java
  26. 33 9
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TrackSequenceBo.java
  27. 0 5
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/dto/DataAmplifyDto.java
  28. 14 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmConfigTrackImportVo.java
  29. 13 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmConfigTrackVo.java
  30. 2 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackImportVo.java
  31. 6 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmModelTrackVo.java
  32. 109 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmSubTaskTrackVo.java
  33. 66 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmTaskTrackImportVo.java
  34. 74 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/AlgorithmTaskTrackVo.java
  35. 10 5
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetDetectionImportVo.java
  36. 13 6
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetDetectionVo.java
  37. 2 2
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TargetIdentificationSubtaskDetailsVo.java
  38. 9 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/ToInfraredImportVo.java
  39. 9 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/ToInfraredVo.java
  40. 18 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceImportVo.java
  41. 20 1
      taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceVo.java
  42. 16 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/mapper/AlgorithmTaskTrackMapper.java
  43. 68 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IAlgorithmTaskTrackService.java
  44. 0 2
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITrackSequenceService.java
  45. 2 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/IVideoStableService.java
  46. 1 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmConfigTrackServiceImpl.java
  47. 342 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/AlgorithmTaskTrackServiceImpl.java
  48. 4 0
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataAmplificationTaskServiceImpl.java
  49. 105 196
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataServiceImpl.java
  50. 165 176
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetDetectionServiceImpl.java
  51. 21 21
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetIdentificationTaskServiceImpl.java
  52. 255 91
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java
  53. 234 393
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java
  54. 29 3
      taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/VideoStableServiceImpl.java
  55. 1 1
      taais-modules/taais-biz/src/main/resources/mapper/ag/AlgorithmModelMapper.xml
  56. 7 0
      taais-modules/taais-biz/src/main/resources/mapper/demo/AlgorithmTaskTrackMapper.xml

+ 40 - 0
script/sql/algorithm_config.sql

@@ -0,0 +1,40 @@
+DROP TABLE
+IF
+	EXISTS common_algorithm_config;
+CREATE TABLE common_algorithm_config (
+	id SERIAL PRIMARY KEY,-- 自增长的主键
+	tool VARCHAR ( 100 ) NOT NULL,-- 工具,长度限制为 100
+	module VARCHAR ( 100 ) NOT NULL,-- 模块,长度限制为 100
+	algorithm_name VARCHAR ( 100 ) NOT NULL,-- 算法名称,长度限制为 100
+	start_api VARCHAR ( 255 ),-- 开始接口,长度限制为 255
+	pause_api VARCHAR ( 255 ),-- 暂停接口,长度限制为 255
+	terminate_api VARCHAR ( 255 ),-- 终止接口,长度限制为 255
+	parameters JSONB,-- 参数,使用 JSONB 类型存储结构化数据
+	create_by INT,-- 创建者 ID
+	create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,-- 创建时间
+	update_by INT,-- 更新者 ID
+	update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,-- 更新时间
+	remarks VARCHAR ( 500 ),-- 备注,长度限制为 500
+	del_flag SMALLINT NOT NULL DEFAULT 0,-- 删除标志,0 表示未删除
+	tenant_id INT,-- 租户 ID
+	version INT DEFAULT 0 NOT NULL-- 版本号
+
+);
+INSERT INTO common_algorithm_config ( tool, module, algorithm_name, start_api, terminate_api, parameters, remarks )
+VALUES
+	( '目标精确捕获技术设计支撑工具', '侦察图像拼接-数据增强', '图像增强', 'http://127.0.0.1:11003/qushachen', 'http://127.0.0.1:11003/qushachen_stop', '{"s_v": 41, "ratio_mix": 0.33}', '图像增强算法配置' );
+INSERT INTO common_algorithm_config ( tool, module, algorithm_name, start_api, terminate_api, parameters, remarks )
+VALUES
+	( '目标精确捕获技术设计支撑工具', '侦察图像拼接-图像逆光', '图像逆光', 'http://127.0.0.1:11004/niguang', 'http://127.0.0.1:11002/niguang_stop', '{"light": 48, "alpha": 0.6, "beta": -20}', '图像逆光算法配置' );
+INSERT INTO common_algorithm_config ( tool, module, algorithm_name, start_api, terminate_api, parameters, remarks )
+VALUES
+	( '目标精确捕获技术设计支撑工具', '侦察图像拼接-图像拼接', '侦察图像拼接算法_sift', 'http://127.0.0.1:11006/imageMosaic', 'http://127.0.0.1:11006/imageMosaic_stop', '{}', '侦察图像拼接算法_sift配置' );
+INSERT INTO common_algorithm_config ( tool, module, algorithm_name, start_api, terminate_api, parameters, remarks )
+VALUES
+	( '目标精确捕获技术设计支撑工具', '侦察图像拼接-图像拼接', '侦察图像拼接算法_coordinate', 'http://127.0.0.1:11006/imageMosaic', 'http://127.0.0.1:11006/imageMosaic_stop', '{}', '侦察图像拼接算法_coordinate配置' );
+INSERT INTO common_algorithm_config ( tool, module, algorithm_name, start_api, terminate_api, parameters, remarks )
+VALUES
+	( '目标精确捕获技术设计支撑工具', '多目标选择-多目标跟踪', '多目标跟踪', 'http://127.0.0.1:10029/targetTrack', 'http://127.0.0.1:10029/targetTrack_stop', '{"imgsz": 960,"conf": 0.5,"iou": 0.7}', '多目标跟踪算法配置' );
+INSERT INTO common_algorithm_config ( tool, module, algorithm_name, start_api, terminate_api, parameters, remarks )
+VALUES
+	( '目标精确捕获技术设计支撑工具', '目标毁伤模块', '目标毁伤评估', 'http://localhost:11009/targetDamageAssessment', 'http://localhost:11009/targetDamageAssessment_stop', '{}', '目标毁伤评估算法配置' );

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

@@ -58,6 +58,7 @@ public class BizConstant {
     }
 
     public static final String TASK_FOLDER_PATH_HEAD = "/task/";
+    public static final String TASK_FOLDER_PATH_HEAD2 = "/task";
 
     public static final String TASK_FOLDER_PATH_MID_TRAIN = "/train/";
     public static final String TASK_FOLDER_PATH_MID_TEST = "/test/";
@@ -126,6 +127,8 @@ public class BizConstant {
     public static final String DOCKER_OBJ_MATCH_PATH = "/objectMatch";
     public static final String TYPE_OBJ_TRACE = "OBJ_TRACE";
     public static final String DOCKER_MAT_TASK = "/obj_track";
+
+    public static final String TYPE_DATA_EXPAND = "DATA_EXPAND";
 //    public static final String MULTI_OBJ_TRACE_URL = "127.0.0.1:10027/objTrace";
 //    public static final String MULTI_OBJ_MATCH_URL = "127.0.0.1:10028/imgMatch";
 }

+ 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);
+    }
+}

+ 1 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataAugmentationController.java

@@ -115,6 +115,7 @@ public class DataAugmentationController extends BaseController {
         // 替换路径
         return Files.list(inputPath)
             .filter(Files::isRegularFile)  // 只处理文件
+            .sorted(Comparator.comparing(path -> path.getFileName().toString()))
             .map(path -> {
                 String fileName = path.getFileName().toString();
                 ImageUrlPair imageUrlPair = new ImageUrlPair();

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/DataController.java

@@ -120,7 +120,7 @@ public class DataController extends BaseController {
                     log.error("图片源文件不存在:{}", srcFile.getName());
                 }
                 if (!StringUtils.isEmpty(dataVo.getLabelurl())) {
-                    String[] labels = dataVo.getUrl().split("/profile");
+                    String[] labels = dataVo.getLabelurl().split("/profile");
                     File labelurlFile = new File(profile + labels[1]);
                     File labelurlDestFile = new File(tempDir, labelurlFile.getName());
                     if (labelurlFile.exists()) {

+ 58 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ObjectMatchController.java

@@ -173,6 +173,64 @@ public class ObjectMatchController extends BaseController {
         return CommonResult.success();
     }
 
+    @GetMapping("/hangup")
+    public CommonResult<Void> hangup(String taskId) {
+        ObjectMatchBo bo = objectMatchService.getById(Long.parseLong(taskId));
+        Map<String, String> params = new HashMap<>();
+
+        params.put("bizId", String.valueOf(bo.getId()));
+        params.put("bizType", TYPE_OBJ_MATCH);
+        params.put("logPath", DOCKER_BASE_PATH + bo.getResultPath() + "/log.log");
+        params.put("sourcePath", DOCKER_BASE_PATH +  bo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH + bo.getResultPath());
+        params.put("otherParams", bo.getParameters());
+
+        log.info("obj_match params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("异源图像匹配定位").getPauseApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            bo.setStatus(TASK_STATUS_PENDING);
+            bo.setEndTime(new Date());
+            bo.setCostSecond((bo.getEndTime().getTime() - bo.getStartTime().getTime()) / 1000);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectMatchService.update(bo);
+        }
+        return CommonResult.success();
+    }
+
+    @GetMapping("/stop")
+    public CommonResult<Void> stop(String taskId) {
+        ObjectMatchBo bo = objectMatchService.getById(Long.parseLong(taskId));
+        Map<String, String> params = new HashMap<>();
+
+        params.put("bizId", String.valueOf(bo.getId()));
+        params.put("bizType", TYPE_OBJ_MATCH);
+        params.put("logPath", DOCKER_BASE_PATH + bo.getResultPath() + "/log.log");
+        params.put("sourcePath", DOCKER_BASE_PATH +  bo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH + bo.getResultPath());
+        params.put("otherParams", bo.getParameters());
+
+        log.info("obj_match params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("异源图像匹配定位").getTerminateApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            bo.setStatus(TASK_STATUS_PENDING);
+            bo.setEndTime(new Date());
+            bo.setCostSecond((bo.getEndTime().getTime() - bo.getStartTime().getTime()) / 1000);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectMatchService.update(bo);
+        }
+        return CommonResult.success();
+    }
+
     @GetMapping("/result")
     public CommonResult<List<String>> getResult(String taskId) {
         ObjectMatchBo bo = objectMatchService.getById(Long.parseLong(taskId));

+ 84 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/ObjectTraceMergeController.java

@@ -163,6 +163,90 @@ public class ObjectTraceMergeController extends BaseController {
         return CommonResult.success();
     }
 
+    @PostMapping("/hangup")
+    public CommonResult<Void> hangup(@RequestBody Map<String, String> _params) {
+        if (!_params.containsKey("taskId")) {
+            return CommonResult.fail("请提供任务ID!");
+        }
+        String taskId = _params.get("taskId");
+        ObjectTraceMergeBo vo = objectTraceMergeService.getById(Long.valueOf(taskId));
+        if (vo == null) {
+            return CommonResult.fail("未找到任务内容!");
+        }
+        if (TASK_STATUS_SUCCEED.equals(vo.getStatus())) {
+            return CommonResult.fail("任务已经执行完毕!");
+        }
+//        if (!(TASK_STATUS_PENDING.equals(vo.getStatus()) || TASK_STATUS_FAILED.equals(vo.getStatus()))) {
+//            return CommonResult.fail("任务正在执行中!");
+//        }
+        vo.setEndTime(new Date());
+
+        Map<String, String> params = new HashMap<>();
+        params.put("bizType", TYPE_OBJ_TRACE);
+        params.put("bizId", String.valueOf(vo.getId()));
+        params.put("logPath", DOCKER_BASE_PATH + vo.getResultPath());
+        params.put("sourcePath", vo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH +  vo.getResultPath());
+        params.put("otherParams", vo.getParameters());
+
+        log.info("obj_trace params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多源信息融合").getPauseApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            vo.setStatus(TASK_STATUS_PENDING);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            vo.setStatus(TASK_STATUS_FAILED);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectTraceMergeService.update(vo);
+        }
+        return CommonResult.success();
+    }
+
+    @PostMapping("/stop")
+    public CommonResult<Void> stop(@RequestBody Map<String, String> _params) {
+        if (!_params.containsKey("taskId")) {
+            return CommonResult.fail("请提供任务ID!");
+        }
+        String taskId = _params.get("taskId");
+        ObjectTraceMergeBo vo = objectTraceMergeService.getById(Long.valueOf(taskId));
+        if (vo == null) {
+            return CommonResult.fail("未找到任务内容!");
+        }
+        if (TASK_STATUS_SUCCEED.equals(vo.getStatus())) {
+            return CommonResult.fail("任务已经执行完毕!");
+        }
+//        if (!(TASK_STATUS_PENDING.equals(vo.getStatus()) || TASK_STATUS_FAILED.equals(vo.getStatus()))) {
+//            return CommonResult.fail("任务正在执行中!");
+//        }
+        vo.setEndTime(new Date());
+
+        Map<String, String> params = new HashMap<>();
+        params.put("bizType", TYPE_OBJ_TRACE);
+        params.put("bizId", String.valueOf(vo.getId()));
+        params.put("logPath", DOCKER_BASE_PATH + vo.getResultPath());
+        params.put("sourcePath", vo.getPreprocessPath());
+        params.put("resultPath", DOCKER_BASE_PATH +  vo.getResultPath());
+        params.put("otherParams", vo.getParameters());
+
+        log.info("obj_trace params: {}", params);
+
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多源信息融合").getTerminateApi();
+            String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+            vo.setStatus(TASK_STATUS_PENDING);
+        } catch (Exception e) {
+            log.error("HTTP请求失败",e);
+            vo.setStatus(TASK_STATUS_FAILED);
+            return CommonResult.fail("HTTP请求失败" + e.getMessage());
+        } finally {
+            objectTraceMergeService.update(vo);
+        }
+        return CommonResult.success();
+    }
+
     @GetMapping("/result")
     public CommonResult<List<String>> execute(String taskId) {
         if (taskId == null) {

+ 20 - 5
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/PublicController.java

@@ -1,6 +1,5 @@
 package com.taais.biz.controller;
 
-import com.alibaba.fastjson2.JSON;
 import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.DataAugmentation;
 import com.taais.biz.domain.TaskTrackResultBo;
@@ -8,13 +7,12 @@ import com.taais.biz.domain.bo.*;
 import com.taais.biz.domain.dto.TaskResultDTO;
 import com.taais.biz.service.*;
 import com.taais.biz.service.impl.AlgorithmModelServiceImpl;
+import com.taais.biz.service.impl.DataAmplificationTaskServiceImpl;
 import com.taais.biz.service.impl.ObjectTraceMergeServiceImpl;
 import com.taais.biz.service.impl.TargetIdentificationSubtaskDetailsServiceImpl;
 import com.taais.biz.service.service.impl.ObjectMatchServiceImpl;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.core.domain.CommonResult;
-import com.taais.common.log.annotation.Log;
-import com.taais.common.log.enums.BusinessType;
 import com.taais.common.web.core.BaseController;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
@@ -22,7 +20,6 @@ import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.InputStreamResource;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -35,7 +32,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.Arrays;
 import java.util.Date;
 
 /**
@@ -79,6 +75,9 @@ public class PublicController extends BaseController {
     @Resource
     ObjectMatchServiceImpl objectMatchService;
 
+    @Resource
+    DataAmplificationTaskServiceImpl dataAmplificationTaskService;
+
     @PostMapping("/taskResult")
     public CommonResult<Void> taskResult(@RequestBody TaskResultDTO resultDTO) {
         log.info("taskResult start,params:{}", resultDTO);
@@ -139,6 +138,22 @@ public class PublicController extends BaseController {
             objectMatchService.update(bo);
         } else if (BizConstant.TYPE_DATA_PROCESS.equals(bizType)) {
             errorMsg = dataProcessService.taskResult(resultDTO);
+        } else if (BizConstant.TYPE_DATA_EXPAND.equals(bizType)) {
+            DataAmplificationTaskBo bo = dataAmplificationTaskService.getById(resultDTO.getBizId());
+            if (bo != null) {
+                try {
+                    bo.setInputImagePath(String.valueOf(Integer.parseInt(bo.getOutputImagePath()) - 1));
+                    if (bo.getInputImagePath().equals("0")) {
+                        bo.setEndTime(new Date());
+                        bo.setCostSecond((int) ((bo.getEndTime().getTime() - bo.getStartTime().getTime()) / 1000));
+                        bo.setStatus(resultDTO.getStatus() == 200 ? BizConstant.TASK_STATUS_SUCCEED : BizConstant.TASK_STATUS_FAILED);
+                    }
+                } catch (Exception e) {
+                    log.error("error: {}", e.getMessage());
+                } finally {
+                    dataAmplificationTaskService.update(bo);
+                }
+            }
         } else {
             log.error("这种情况是不可能发生的,参数:{}",resultDTO);
             return CommonResult.fail("这种情况是不可能发生的");

+ 140 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TargetIdentificationSubtaskDetailsController.java

@@ -1,18 +1,26 @@
 package com.taais.biz.controller;
 
+import java.awt.*;
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONUtil;
 import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.TargetIdentificationSubtask;
 import com.taais.biz.domain.TargetIdentificationSubtaskDetails;
 import com.taais.biz.domain.vo.TargetIdentificationSubtaskVo;
+import com.taais.biz.service.impl.CommonAlgorithmConfigServiceImpl;
 import com.taais.biz.service.impl.TargetIdentificationSubtaskServiceImpl;
 import com.taais.biz.service.impl.TargetIdentificationTaskServiceImpl;
 import com.taais.biz.utils.ZipDirectory;
+import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.utils.StringUtils;
 import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
@@ -34,6 +42,8 @@ import com.taais.biz.service.ITargetIdentificationSubtaskDetailsService;
 
 import com.taais.common.core.core.page.PageResult;
 
+import static com.taais.biz.constant.BizConstant.TYPE_DATA_BIZ_PROCESS;
+
 /**
  * 目标识别子任务Controller
  *
@@ -52,6 +62,9 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
     @Resource
     private TargetIdentificationSubtaskServiceImpl subtaskService;
 
+    @Resource
+    private CommonAlgorithmConfigServiceImpl algorithmConfigService;
+
     /**
      * 查询目标识别子任务列表
      */
@@ -125,6 +138,79 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
         return CommonResult.success();
     }
 
+    @PostMapping("/continueTask")
+    public CommonResult<Void> continueTask(@RequestBody Map<String, String> params) {
+        params.put("bizType", TYPE_DATA_BIZ_PROCESS);
+        if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
+            return CommonResult.fail("Error parameters");
+        }
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多目标检测").getStartApi();
+            HttpUtil.post(url, JSONUtil.toJsonStr(params));
+
+            TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
+            details.setStatus(BizConstant.TASK_STATUS_PROCESSING);
+            details.setStartTime(new Date());
+            details.setEndTime(null);
+            targetIdentificationSubtaskDetailsService.updateById(details);
+
+            return CommonResult.success();
+        } catch (Exception e) {
+            log.error("target identify pause failure");
+            log.error(e.getMessage());
+            return CommonResult.fail(e.getMessage());
+        }
+
+    }
+
+    @PostMapping("/pauseTask")
+    public CommonResult<Void> pauseTask(@RequestBody Map<String, String> params) {
+        params.put("bizType", TYPE_DATA_BIZ_PROCESS);
+        if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
+            return CommonResult.fail("Error parameters");
+        }
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多目标检测").getPauseApi();
+            HttpUtil.post(url, JSONUtil.toJsonStr(params));
+
+            TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
+            details.setStatus(BizConstant.TASK_STATUS_PENDING);
+            details.setEndTime(new Date());
+            targetIdentificationSubtaskDetailsService.updateById(details);
+
+            return CommonResult.success();
+        } catch (Exception e) {
+            log.error("target identify pause failure");
+            log.error(e.getMessage());
+            return CommonResult.fail(e.getMessage());
+        }
+
+    }
+
+    @PostMapping("/stopTask")
+    public CommonResult<Void> stopTask(@RequestBody Map<String, String> params) {
+        params.put("bizType", TYPE_DATA_BIZ_PROCESS);
+        if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
+            return CommonResult.fail("Error parameters");
+        }
+        try {
+            String url = algorithmConfigService.getByAlgorithmName("多目标检测").getTerminateApi();
+            HttpUtil.post(url, JSONUtil.toJsonStr(params));
+
+            TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
+            details.setStatus(BizConstant.TASK_STATUS_PENDING);
+            details.setEndTime(new Date());
+            targetIdentificationSubtaskDetailsService.updateById(details);
+
+            return CommonResult.success();
+        } catch (Exception e) {
+            log.error("target identify pause failure");
+            log.error(e.getMessage());
+            return CommonResult.fail(e.getMessage());
+        }
+
+    }
+
     /**
      * 执行训练任务
      * @param params
@@ -141,6 +227,7 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
             }
 
             details.setStartTime(new Date());
+            details.setEndTime(null);
             targetIdentificationSubtaskDetailsService.updateById(details);
             subtaskService.executeOneTask(taskId);
             return CommonResult.success();
@@ -185,6 +272,7 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
 
             details.setStatus(BizConstant.TASK_STATUS_PENDING);
             details.setStartTime(new Date());
+            details.setEndTime(null);
             targetIdentificationSubtaskDetailsService.updateById(details);
 
             subtaskService.executeOneTask(taskId);
@@ -197,6 +285,58 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
     @Value("${taais.profile}")
     private String profile;
 
+    @GetMapping("/openDir")
+    public CommonResult<Void> openDir(String directory, String type) throws IOException {
+        String path =  profile + "/task" + directory;
+        log.info("check dir: {}", path);
+        if (GraphicsEnvironment.isHeadless()) {
+            log.info("Headless 模式,改用命令行方式");
+            openFolderViaCommandLine(path);
+        } else {
+            log.info("使用Desktop 模式");
+            try {
+                Desktop desktop = Desktop.getDesktop();
+                if (desktop.isSupported(Desktop.Action.OPEN)) {
+                    desktop.open(new File(path));
+                } else {
+                    log.info("Desktop.OPEN 不支持,改用命令行方式");
+                    openFolderViaCommandLine(path);
+                }
+            } catch (Exception e) {
+                log.info("Desktop 失败:" + e.getMessage());
+                openFolderViaCommandLine(path);
+            }
+        }
+        return CommonResult.success();
+    }
+
+    private void openFolderViaCommandLine(String path) {
+        String os = System.getProperty("os.name").toLowerCase();
+        log.info("Headless 模式,改用命令行方式,OS:" + os);
+        String command;
+
+        if (os.contains("linux")) {
+            command = "xdg-open";
+        } else if (os.contains("win")) {
+            command = "explorer";
+        } else if (os.contains("mac")) {
+            command = "open";
+        } else {
+            throw new UnsupportedOperationException("不支持的操作系统: " + os);
+        }
+
+        try {
+            log.info("process start");
+            ProcessBuilder pb = new ProcessBuilder(command, path);
+            pb.redirectOutput(ProcessBuilder.Redirect.DISCARD);
+            pb.redirectError(ProcessBuilder.Redirect.DISCARD);
+            Process process = pb.start();  // 不调用 waitFor(),避免阻塞
+            log.info("process launched (non-blocking)");
+        } catch (IOException e) {
+            log.error("Process error", e);
+        }
+    }
+
     @GetMapping("/getImgList")
     public CommonResult<List<String>> getImgList(String taskId, String subPath) {
         String path = profile + "/task/" + taskId;

+ 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);

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

@@ -113,6 +113,11 @@ public class VideoStableController extends BaseController {
         return videoStableService.stop(id);
     }
 
+    @GetMapping("/hangup/{id}")
+    public CommonResult hangup(@PathVariable("id") Long id) {
+        return videoStableService.hangup(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/CommonAlgorithmConfig.java

@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
 import com.taais.common.orm.core.domain.BaseEntity;
+import org.springframework.data.annotation.Version;
 
 /**
  * 【请填写功能名称】对象 common_algorithm_config
@@ -46,6 +47,7 @@ private static final long serialVersionUID = 1L;
     private String terminateApi;
 
     /** $column.columnComment */
+
     private String parameters;
 
     /** $column.columnComment */
@@ -54,6 +56,8 @@ private static final long serialVersionUID = 1L;
     /** $column.columnComment */
     @Column(isLogicDelete = true)
     private Integer delFlag;
+//    @Version
+//    private Integer version = 0; // 直接初始化默认值
 
 
 }

+ 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);
+    }
+}

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

@@ -1,11 +1,13 @@
 package com.taais.biz.domain.bo;
 
+import com.mybatisflex.annotation.Column;
 import com.taais.biz.domain.CommonAlgorithmConfig;
 import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import jakarta.validation.constraints.*;
 import com.taais.common.orm.core.domain.BaseEntity;
+import org.springframework.data.annotation.Version;
 
 /**
  * 【请填写功能名称】业务对象 common_algorithm_config
@@ -55,12 +57,15 @@ public class CommonAlgorithmConfigBo extends BaseEntity{
     /**
      * $column.columnComment
      */
+
     private String parameters;
 
     /**
      * $column.columnComment
      */
     private String remarks;
+//    @Version
+//    private Integer version = 0; // 直接初始化默认值
 
 
 }

+ 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);
+    }
 }

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

@@ -21,22 +21,17 @@ import java.util.Map;
 @Accessors(chain = true)
 public class DataAmplifyDto {
 
-    @NotBlank(message = "id不能为空")
     private String id;
 
-    @NotBlank(message = "批次不能为空")
     private String batchNum;
 
-    @NotBlank(message = "任务名称")
     private String taskName;
 
-    @NotBlank(message = "扩充方式不能为空")
     private String augmentationType;
 
     private String inputImagePath;
 
     private String outputImagePath;
 
-    @NotEmpty(message = "扩充算法配置不能为空")
     private List<Map<String, String>> otherParams;
 }

+ 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;
 }

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

@@ -66,7 +66,7 @@ private static final long serialVersionUID = 1L;
 
     // 获取预处理数据路径绝对路径
     public String getAbsolutePreprocessPath(){
-        return TaaisConfig.getProfile() + BizConstant.TASK_FOLDER_PATH_HEAD + preprocessPath;
+        return TaaisConfig.getProfile() + BizConstant.TASK_FOLDER_PATH_HEAD2 + preprocessPath;
     }
 
     /** 结果数据路径 */
@@ -75,7 +75,7 @@ private static final long serialVersionUID = 1L;
 
     // 获取结果数据路径绝对路径
     public String getAbsoluteResultPath(){
-        return TaaisConfig.getProfile() + BizConstant.TASK_FOLDER_PATH_HEAD + resultPath;
+        return TaaisConfig.getProfile() + BizConstant.TASK_FOLDER_PATH_HEAD2 + resultPath;
     }
 
     /** 序号 */

+ 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);

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

@@ -78,6 +78,8 @@ public interface IVideoStableService extends IBaseService<VideoStable> {
 
     CommonResult stop(Long id);
 
+    CommonResult hangup(Long id);
+
     List<Map<String, String>> getImages(Long ossId);
 
     CommonResult getLog(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);
+    }
+}

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

@@ -51,6 +51,10 @@ public class DataAmplificationTaskServiceImpl extends BaseServiceImpl<DataAmplif
         return this.getOneAs(query().where(DATA_AMPLIFICATION_TASK.ID.eq(id)), DataAmplificationTaskVo.class);
     }
 
+    public DataAmplificationTaskBo getById(Long id) {
+        return this.getOneAs(query().where(DATA_AMPLIFICATION_TASK.ID.eq(id)), DataAmplificationTaskBo.class);
+    }
+
     @Override
     public List<DataAmplificationTaskVo> selectList(DataAmplificationTaskBo taskBo) {
         QueryWrapper queryWrapper = buildQueryWrapper(taskBo);

+ 105 - 196
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/DataServiceImpl.java

@@ -2,6 +2,10 @@ package com.taais.biz.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson2.JSON;
+import com.esotericsoftware.minlog.Log;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.mybatisflex.core.paginate.Page;
@@ -27,6 +31,7 @@ import com.taais.common.core.utils.StringUtils;
 import com.taais.common.core.utils.file.FileUploadUtils;
 import com.taais.common.core.utils.file.FileUtils;
 import com.taais.common.core.utils.file.UnPackedUtil;
+import com.taais.common.core.utils.uuid.UUID;
 import com.taais.common.json.utils.JsonUtils;
 import com.taais.common.orm.core.page.PageQuery;
 import com.taais.common.orm.core.service.impl.BaseServiceImpl;
@@ -55,6 +60,8 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static com.taais.biz.constant.BizConstant.*;
+import static com.taais.biz.constant.BizConstant.TASK_STATUS_FAILED;
 import static com.taais.biz.domain.table.DataTableDef.DATA;
 
 /**
@@ -79,7 +86,7 @@ public class DataServiceImpl extends BaseServiceImpl<DataMapper, Data> implement
     private DataMapper dataMapper;
 
     @Resource
-    private IDataAmplificationTaskService dataAmplificationTaskService;
+    private DataAmplificationTaskServiceImpl dataAmplificationTaskService;
 
     @Resource
     private ISysDictDataService dictDataService;
@@ -439,215 +446,117 @@ public class DataServiceImpl extends BaseServiceImpl<DataMapper, Data> implement
     @Override
     @Transactional
     public CommonResult<Boolean> amplifyForData(String id) {
-        DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(Long.valueOf(id));
-        DataAmplifyDto dataAmplifyDto = new DataAmplifyDto();
-        dataAmplifyDto.setId(taskVo.getId().toString());
-        dataAmplifyDto.setAugmentationType(taskVo.getAugmentationType());
-        List<Map<String, String>> maps = JsonUtils.parseArray(taskVo.getParameters(), Map.class);
-        dataAmplifyDto.setOtherParams(maps);
-        dataAmplifyDto.setBatchNum(taskVo.getDataBatchNums());
-        return this.doAmplify(dataAmplifyDto);
-    }
-
-    private CommonResult<Boolean> doAmplify(DataAmplifyDto dataAmplifyDto) {
-        this.updateEmp(Long.valueOf(dataAmplifyDto.getId()));
-        String[] split = dataAmplifyDto.getBatchNum().split(",");
-        SysDictDataVo sysDictDataVo = dictDataService.selectDictDataByTypeAndLabel("python_api_address", "python_expand_data");
-
-        for (String batchNum : split) {
-            QueryWrapper query = query();
-            query.eq(Data::getBatchNum, batchNum);
-            List<Data> dataList = dataMapper.selectListByQuery(query);
-            if (dataList.isEmpty()) {
-                this.updateFail(Long.valueOf(dataAmplifyDto.getId()));
-                continue;
-            }
+        DataAmplificationTaskBo taskVo = dataAmplificationTaskService.getById(Long.valueOf(id));
+        taskVo.setStartTime(new Date());
+        List<Map<String, String>> otherParams = JsonUtils.parseArray(taskVo.getParameters(), Map.class);
+        Map<String, String> realOtherParams = new HashMap<>();
+        otherParams.forEach(param -> {
+            realOtherParams.put(param.get("agName"), param.containsKey("value") ? param.get("value") : param.get("defaultValue"));
+        });
+        // move data
+        String[] batches = taskVo.getDataBatchNums().split(",");
+        String filepath = "/" + UUID.randomUUID().toString().replace("-", "_");
+        for (String batch : batches) {
+            copyFilesToPath(batch, filepath, "e_");
+        }
 
-            List<Data> dataListInfo = dataList.stream().filter(data -> !StringUtils.isEmpty(data.getUrl())).toList();
-            if (dataListInfo.isEmpty()) {
-                this.updateFail(Long.valueOf(dataAmplifyDto.getId()));
-                continue;
-            }
-            String filePath = TaaisConfig.getUploadPath();
-            LocalDate currentDate = LocalDate.now();
-            // 定义日期格式器
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
-            String formattedDate = currentDate.format(formatter);
-            filePath = filePath + File.separator + formattedDate;
-            String finalFilePath = filePath;
-            Map<String, String> otherParams = new HashMap<>();
-            for (Map<String, String> param : dataAmplifyDto.getOtherParams()) {
-                otherParams.put(param.get("agName"), param.get("defaultValue"));
+        // post request
+        Map<String, Object> params = new HashMap<>();
+        params.put("bizType", TYPE_DATA_EXPAND);
+        params.put("bizId", String.valueOf(taskVo.getId()));
+        params.put("logPath", PATH_PREFIX + filepath + "/log.log");
+        params.put("inputImagePath", PATH_PREFIX + filepath);
+        params.put("otherParams", realOtherParams);
+
+        String[] outputs = taskVo.getOutputImagePath().split(";");
+        log.info("check outputs: {} ; {}", outputs, outputs[0]);
+        taskVo.setInputImagePath(String.valueOf(outputs.length));
+        for (String path : outputs) {
+            final String resultPath = TargetIdentificationTaskServiceImpl.PATH_PREFIX + path;
+            params.put("outputImagePath", resultPath);
+
+            log.info("check data expand: {}", params);
+            try {
+                String url = "http://127.0.0.1:11001/augment";
+                String res = HttpUtil.post(url, JSONUtil.toJsonStr(params));
+                taskVo.setStatus(TASK_STATUS_PROCESSING);
+            } catch (Exception e) {
+                log.error("HTTP请求失败",e);
+                taskVo.setStatus(TASK_STATUS_FAILED);
+                return CommonResult.fail("HTTP请求失败" + e.getMessage());
+            } finally {
+                dataAmplificationTaskService.update(taskVo);
             }
-            dataListInfo.forEach(dataInfo -> {
-                try {
-                    boolean success = true;
-                    String message = "";
-                    Date startTime = new Date();
-
-                    //循环调用Python扩增接口
-                    Map<String, Object> bodyJson = new HashMap<>();
-                    bodyJson.put("bizType", "数据扩增");
-                    bodyJson.put("bizId", dataAmplifyDto.getId());
-                    bodyJson.put("augmentationType", dataAmplifyDto.getAugmentationType());
-                    bodyJson.put("inputImagePath", dataInfo.getUrl());
-                    String outputImagePath = finalFilePath + AMPLIFY + System.currentTimeMillis();
-                    File desc = new File(outputImagePath);
-                    if (!desc.exists()) {
-                        log.info("创建文件目录: {}", desc.mkdirs());
-                    }
-                    bodyJson.put("outputImagePath", outputImagePath);
-                    bodyJson.put("otherParams", otherParams);
-                    String logPath = TaaisConfig.getProfile() + "/task/log/" + dataAmplifyDto.getId() + "_log.log";
-                    System.out.println("logPath===>" + logPath);
-                    bodyJson.put("logPath", logPath);
-                    //实际请求接口,接口未提供,暂且注释
-                    String response = HttpRequest.post(sysDictDataVo.getDictValue())
-                        .body(JsonUtils.toJsonString(bodyJson))
-                        .execute().body();
-//                String response = "{\"status\":200,\"msg\":\"扩增成功\"}";
-                    ObjectMapper objectMapper = new ObjectMapper();
-                    JsonNode rootNode = objectMapper.readTree(response);
-                    String resultCode = rootNode.path(RESULT_CODE).asText();
-                    //判断接口是否响应成功
-                    if (!RESULT_STATUS.equals(resultCode)) {
-                        success = false;
-                    }
-                    message = rootNode.path("msg").asText();
-                    //处理当前目录文件,并进行入库
-                    saveDataInfo(outputImagePath, dataInfo);
-
-                    DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(Long.valueOf(dataAmplifyDto.getId()));
-                    Date endTime = new Date();
-                    DataAmplificationTaskBo update = new DataAmplificationTaskBo();
-                    if (taskVo.getInputImagePath() != null) {
-                        update.setInputImagePath(taskVo.getInputImagePath() + "|" + dataInfo.getUrl());
-                    } else {
-                        update.setInputImagePath(dataInfo.getUrl());
-                    }
-                    if (taskVo.getOutputImagePath() != null) {
-                        update.setOutputImagePath(taskVo.getOutputImagePath() + "|" + outputImagePath);
-                    } else {
-                        update.setOutputImagePath(outputImagePath);
-                    }
-                    update.setId(Long.valueOf(dataAmplifyDto.getId()));
-                    update.setStartTime(startTime);
-                    update.setEndTime(endTime);
-                    update.setCostSecond((int) (endTime.getTime() - startTime.getTime()));
-                    update.setStatus(success ? BizConstant.TASK_STATUS_SUCCEED : BizConstant.TASK_STATUS_FAILED);
-                    update.setLog(taskVo.getLog() + "|" + message);
-                    update.setVersion(taskVo.getVersion());
-                    update.setRemarks(taskVo.getRemarks() + "|" + (int) (endTime.getTime() - startTime.getTime()));
-                    dataAmplificationTaskService.update(update);
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-            });
         }
-        //根据批次号获取该批次的所有文件数据
-        return CommonResult.success();
-    }
 
-    private void updateFail(Long id) {
-        DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(id);
-        DataAmplificationTaskBo update = new DataAmplificationTaskBo();
-        update.setId(taskVo.getId());
-        update.setStatus(BizConstant.TASK_STATUS_FAILED);
-        update.setLog(taskVo.getLog() + "|" + "该批次下没有文件数据,请重新选择批次!");
-        update.setVersion(taskVo.getVersion());
-        dataAmplificationTaskService.update(update);
+        return CommonResult.success();
     }
 
-    private void updateEmp(Long id) {
-        DataAmplificationTaskVo taskVo = dataAmplificationTaskService.selectById(id);
-        DataAmplificationTaskBo update = new DataAmplificationTaskBo();
-        update.setOutputImagePath("");
-        update.setInputImagePath("");
-        update.setId(id);
-        update.setLog("");
-        update.setVersion(taskVo.getVersion());
-        update.setRemarks("");
-        dataAmplificationTaskService.update(update);
-    }
 
+    public static final String PATH_PREFIX = TaaisConfig.getProfile() + "/amplify";
+    public static final String WORK_DIR = TaaisConfig.getProfile();
     /**
-     * 解析目标目录所有文件,进行文件更名并入库
-     *
-     * @param directoryPath:目录地址
-     * @param dataInfo:深拷贝对象
+     * 移动文件到对应文件夹
+     * @param batch
+     * @param path
+     * @param namePrefix 文件名前缀
      */
-    public void saveDataInfo(String directoryPath, Data dataInfo) {
-        try {
-            // 获取指定目录下所有文件
-            File directory = new File(directoryPath);
-            List<File> extractedImagesFileList = new ArrayList<>();
-            if (directory.exists() && directory.isDirectory()) {
-                File[] files = directory.listFiles();
-                if (files != null) {
-                    for (File file : files) {
-                        initFileInfo(directoryPath, extractedImagesFileList, file.isDirectory(), file.getName());
-                    }
-                }
-            }
+    private void copyFilesToPath(String batch, String path, String namePrefix) {
+        String[] batches = batch.split(",");
 
-            // 获取ID集合
-            List<Long> ids = dataMapper.getIds(extractedImagesFileList.size());
-            if (ids.isEmpty()) {
-                return;
-            }
-
-            List<Data> dataList = new ArrayList<>();
-            AtomicInteger countSize = new AtomicInteger();
-            extractedImagesFileList.forEach(fileInfo -> {
-                Long id = ids.get(countSize.get());
-                Data data = new Data();
-                BeanUtils.copyProperties(dataInfo, data);
+        File dir = new File(PATH_PREFIX + path);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        dir = new File(PATH_PREFIX + path + "/images");
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        dir = new File(PATH_PREFIX + path + "/labels");
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        dir = new File(PATH_PREFIX + path + "/result");
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
 
-                if (checkLabeled(fileInfo.getPath())) {
-                    data.setLabeled(Boolean.TRUE);
-                } else {
-                    data.setLabeled(Boolean.FALSE);
+        System.out.println(dir.getAbsolutePath());
+
+        for (String batchNum : batches) {
+            List<DataVo> dataVoList = getDataByBatchNum(batchNum);
+            for (DataVo dataVo : dataVoList) {
+                String[] strings = dataVo.getUrl().split("/profile");
+                String relativePath = WORK_DIR + strings[strings.length - 1];
+                relativePath = relativePath.replace("\\", "/").replace("//", "/");
+                File file = new File(relativePath);
+                System.out.println(file.getAbsolutePath());
+                if (file.exists()) {
+                    try {
+                        File dist = new File(PATH_PREFIX + path + "/images/" + namePrefix + file.getName());
+                        org.apache.commons.io.FileUtils.copyFile(file, dist);
+                        System.out.println("file dist: " + dist.getAbsolutePath());
+                    } catch (IOException e) {
+                        Log.debug("bug found");
+                        continue;
+                    }
                 }
-
-                try {
-                    Path path = Paths.get(fileInfo.getAbsolutePath());
-                    BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
-                    Instant creationTime = attrs.lastModifiedTime().toInstant();
-                    Date date = Date.from(creationTime);
-
-                    data.setId(id);
-                    data.setGatherTime(date);
-                    data.setName(fileInfo.getName());
-
-                    // 更改图片文件名称
-                    String fileHeaderSuffix = StringUtils.substring(fileInfo.getName(), fileInfo.getName().lastIndexOf("."), fileInfo.getName().length());
-                    String destInfo = fileInfo.getPath().replaceAll(fileInfo.getName(), "");
-                    File newFile = new File(destInfo, id + fileHeaderSuffix);
-                    File oldFile = new File(destInfo, fileInfo.getName());
-                    log.info("saveDataInfo更改用户上传图片文件名称:{}", oldFile.renameTo(newFile));
-
-                    String imagePath = FileUploadUtils.getPathFileName(destInfo, id + fileHeaderSuffix);
-                    data.setUrl(imagePath);
-
-                    if (data.getLabeled()) {
-                        String labeledPath = fileInfo.getPath().replaceFirst("[.][^.]+$", "") + ".txt";
-                        File labeledNewFile = new File(destInfo, id + ".txt");
-                        File labeledOldFile = new File(labeledPath);
-                        log.info("saveDataInfo更改用户上传标注文件名称:{}", labeledOldFile.renameTo(labeledNewFile));
-                        String labelUrl = FileUploadUtils.getPathFileName(destInfo, id + ".txt");
-                        data.setLabelurl(labelUrl);
+                if (dataVo.getLabelurl() != null) {
+                    strings = dataVo.getLabelurl().split("/profile");
+                    relativePath = WORK_DIR + strings[strings.length - 1];
+                    relativePath = relativePath.replace("\\", "/").replace("//", "/");
+                    file = new File(relativePath);
+                    if (file.exists()) {
+                        try {
+                            File dist = new File(PATH_PREFIX + path + "/labels/" + namePrefix + file.getName());
+                            org.apache.commons.io.FileUtils.copyFile(file, dist);
+                            System.out.println("file dist: " + dist.getAbsolutePath());
+                        } catch (IOException e) {
+                            Log.debug("bug found");
+                        }
                     }
-                    dataList.add(data);
-                } catch (IOException e) {
-                    throw new RuntimeException(e);
                 }
-                countSize.getAndIncrement();
-            });
-
-            dataMapper.insertBatch(dataList);
-        } catch (Exception e) {
-            log.error("[saveDataInfo]数据集处理出现未知异常.e:", e);
+            }
         }
     }
-
 }

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

@@ -5,25 +5,22 @@
 package com.taais.biz.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson2.JSON;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 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;
 import com.taais.biz.service.ITargetDetectionService;
 import com.taais.biz.utils.ZipUtils;
 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.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;
@@ -31,7 +28,6 @@ import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
 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;
@@ -43,13 +39,13 @@ 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.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业务层处理
@@ -58,13 +54,8 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
  * 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 +66,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 +117,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 +130,25 @@ 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());
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
-                entity.setModelName(model.getModelName());
+            if (ObjectUtil.isNotNull(modelId)) {
+                AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
+            }
+
+            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());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(TargetDetectionVo::getCreateTime).reversed());
@@ -153,47 +158,100 @@ 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;
+        }
+
+        entity = updateEntity(entity, entityBo, ossEntity);
 
-        targetDetection.setInputOssId(targetDetectionBo.getInputOssId());
-        targetDetection.setUrl(ossEntity.getUrl());
+        // 步骤 6. 保存算法参数到数据库
+        return this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+    }
 
-        String filePath = ossEntity.getFileName();
-        String localPath = TaaisConfig.getProfile();
-        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
-        targetDetection.setInputPath(resourcePath);
+    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("算法配置参数为空");
+        }
 
-        String fileName = StringUtils.substringAfterLast(filePath, "/");
-        String fileName_without_suffix = removeFileExtension(fileName);
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, unzipPath);
+        }
 
-        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值
+        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) {

+ 21 - 21
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TargetIdentificationTaskServiceImpl.java

@@ -222,7 +222,7 @@ public class TargetIdentificationTaskServiceImpl extends BaseServiceImpl<TargetI
         // 创建扩增子任务
         if (taskDto.getHasTrainAugmentation()) {
             if (taskDto.getTrainAugmentationParams() != null && StringUtils.isNotEmpty(taskDto.getTrainAugmentationParams().getOtherParams())) {
-                createDataAmplifyTask(taskBo.getId(), taskDto);
+                createDataAmplifyTask(taskBo.getId(), taskDto, records);
             }
         }
         return null;
@@ -535,27 +535,27 @@ public class TargetIdentificationTaskServiceImpl extends BaseServiceImpl<TargetI
         }
     }
 
-    private void createDataAmplifyTask(Long taskId, CreateTargetIdentificationTaskDto taskDto) {
+    private void createDataAmplifyTask(Long taskId, CreateTargetIdentificationTaskDto taskDto, Map<String, String> records) {
         List<String> trainBatchNumList = taskDto.getTrainBatchNumList();
-        for (String batchNumber : trainBatchNumList) {
-            TargetIdentificationSubtaskBo subtask = new TargetIdentificationSubtaskBo();
-            subtask.setName("数据扩增");
-            subtask.setStatus(BizConstant.TASK_STATUS_PENDING);
-            subtask.setTaskId(taskId);
-            subtask.setRemarks("DEFAULT_REMARK");
-            TargetIdentificationSubtask insertSubtask = subtaskService.insertSubtask(subtask);
-
-            DataAmplifyDto amplifyDto = taskDto.getTrainAugmentationParams();
-            DataAmplificationTaskBo dataAmplificationTaskBo = new DataAmplificationTaskBo();
-            dataAmplificationTaskBo.setSubTaskId(insertSubtask.getId());
-            dataAmplificationTaskBo.setName(amplifyDto.getTaskName());
-            dataAmplificationTaskBo.setStatus(BizConstant.TASK_STATUS_PENDING);
-            dataAmplificationTaskBo.setDataBatchNums(batchNumber);
-            dataAmplificationTaskBo.setAugmentationType(amplifyDto.getAugmentationType());
-            dataAmplificationTaskBo.setParameters(JsonUtils.toJsonString(amplifyDto.getOtherParams()));
-            dataAmplificationTaskBo.setDelFlag(0);
-            dataAmplificationTaskService.insert(dataAmplificationTaskBo);
-        }
+
+        TargetIdentificationSubtaskBo subtask = new TargetIdentificationSubtaskBo();
+        subtask.setName("数据扩增");
+        subtask.setStatus(BizConstant.TASK_STATUS_PENDING);
+        subtask.setTaskId(taskId);
+        subtask.setRemarks("DEFAULT_REMARK");
+        TargetIdentificationSubtask insertSubtask = subtaskService.insertSubtask(subtask);
+
+        DataAmplifyDto amplifyDto = taskDto.getTrainAugmentationParams();
+        DataAmplificationTaskBo dataAmplificationTaskBo = new DataAmplificationTaskBo();
+        dataAmplificationTaskBo.setSubTaskId(insertSubtask.getId());
+        dataAmplificationTaskBo.setName(amplifyDto.getTaskName());
+        dataAmplificationTaskBo.setStatus(BizConstant.TASK_STATUS_PENDING);
+        dataAmplificationTaskBo.setDataBatchNums(amplifyDto.getBatchNum());
+        dataAmplificationTaskBo.setAugmentationType(amplifyDto.getAugmentationType());
+        dataAmplificationTaskBo.setParameters(JsonUtils.toJsonString(amplifyDto.getOtherParams()));
+        dataAmplificationTaskBo.setOutputImagePath(String.join(";", records.values()));
+        dataAmplificationTaskBo.setDelFlag(0);
+        dataAmplificationTaskService.insert(dataAmplificationTaskBo);
     }
 
 

+ 255 - 91
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -12,7 +12,6 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.bo.ToInfraredBo;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
-import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
 import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.biz.mapper.ToInfraredMapper;
@@ -33,7 +32,6 @@ import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
 import lombok.extern.log4j.Log4j2;
 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,6 +48,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;
@@ -65,15 +64,6 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
 @Service
 @Log4j2
 public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToInfrared> implements IToInfraredService {
-    @Value("${server.port}")
-    String port;
-
-    @Value("${taais.profile}")
-    String profile;
-
-    @Value("${server.task_stop_url}")
-    private String task_stop_url;
-
     @Autowired
     private ISysOssService ossService;
 
@@ -84,6 +74,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 +135,25 @@ 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());
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
-                entity.setModelName(model.getModelName());
+            if (ObjectUtil.isNotNull(modelId)) {
+                AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
+            }
+
+            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());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(ToInfraredVo::getCreateTime).reversed());
@@ -158,63 +163,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()));
-        makeDir(entity.getInputPath());
-        makeDir(entity.getOutputPath());
+        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));
 
         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值
+        makeDir(entity.getInputPath());
+        makeDir(entity.getOutputPath());
+
+        return entity;
     }
 
     /**
@@ -226,6 +364,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 +404,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 +429,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;
-    }
-
-    private String getLogFileName(ToInfrared entity) {
-        return entity.getId() + BizConstant.TO_INFRARED_SUFFIX + ".log";
+        return getPredictInputPath(ossEntity) + File.separator + BizConstant.TO_INFRARED_PREDICT_OUTPUT_DIR;
     }
 
-    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());
-
-        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(entity.getAlgorithmId());
+        Map<String, Object> startTaskConfig = JsonUtils.parseMap(entity.getAlgorithmParameters());
 
-        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 +473,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 +512,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 +526,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 +550,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 +574,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 +600,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 +644,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 +654,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 +662,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 +699,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 +729,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);
     }
 }

+ 234 - 393
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -4,16 +4,8 @@
 
 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;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.constant.BizConstant;
@@ -25,16 +17,14 @@ 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;
 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.vo.SysOssVo;
@@ -42,7 +32,6 @@ import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -50,13 +39,18 @@ 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.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.getTrainInputPath;
 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;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
 
 /**
  * 注视轨迹序列Service业务层处理
@@ -65,14 +59,12 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
  * 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 +76,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 +186,171 @@ 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(modelId)) {
+                AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
                 if (ObjectUtil.isNotNull(model)) {
                     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());
-                    }
-                }
             }
         });
         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();
-
-        BeanUtils.copyProperties(trackSequenceBo, trackSequence);
-
-        trackSequence.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);
-        trackSequence.setInputPath(resourcePath);
+        // 步骤 6. 保存算法参数到数据库
+        boolean __ = this.updateById(entity);// 使用全局配置的雪花算法主键生成器生成ID值
+        if (!__) {
+            throw new RuntimeException("新增注释轨迹序列任务失败");
+        }
+        return CommonResult.success(entity);
+    }
 
-        String fileName = StringUtils.substringAfterLast(filePath, "/");
-        String fileName_without_suffix = removeFileExtension(fileName);
+    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("算法配置参数为空");
+        }
 
-        Path path = Paths.get(resourcePath);
-        Path outPath = path.resolveSibling(fileName_without_suffix + "_images" + System.currentTimeMillis());
-        trackSequence.setOutputPath(outPath.toString());
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, unzipPath);
+        }
 
-        trackSequence.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
-        trackSequence.setStatus(NOT_START);
+        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);
+            }
 
+            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("预测任务不存在");
+            }
 
-        boolean __ = this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
-        if (__) {
-            return CommonResult.success();
+            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 {
-            return CommonResult.fail();
+            throw new RuntimeException("算法类型错误");
         }
+
+        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());
+
+        return entity;
     }
 
     /**
@@ -247,9 +361,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 +401,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();
+        entity.setStartTime(new Date());
 
-        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());
+        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(entity.getOutputPath() + File.separator + getLogFileName(entity));
-        } else {
-            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);
-            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());
-            }
-
-            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 +427,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 +446,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 +463,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 +484,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 +516,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 +533,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 +581,4 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         return CommonResult.success(resultMap);
     }
 
-
 }

+ 29 - 3
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/VideoStableServiceImpl.java

@@ -203,6 +203,9 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         return this.removeByIds(Arrays.asList(ids));
     }
 
+    @Resource
+    private CommonAlgorithmConfigServiceImpl algorithmConfigService;
+
     @Override
     public CommonResult start(Long id) {
         VideoStable videoStable = getById(id);
@@ -235,7 +238,9 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
 
         videoStable.setLogPath(videoStable.getOutputPath() + File.separator + getLogFileName(videoStable));
 
-        HttpResponseEntity responseEntity = sendPostMsg(video_stable_start_url, videoStable);
+        String url = algorithmConfigService.getByAlgorithmName("电子稳相").getStartApi();
+
+        HttpResponseEntity responseEntity = sendPostMsg(url, videoStable);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             return CommonResult.success("任务开始成功,请等待完成");
         } else {
@@ -329,9 +334,12 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         VideoStable videoStable = getById(id);
 
         videoStable.setLogPath(videoStable.getOutputPath() + File.separator + getLogFileName(videoStable));
-        HttpResponseEntity responseEntity = sendPostMsg(video_stable_stop_url, videoStable);
+
+        String url = algorithmConfigService.getByAlgorithmName("电子稳相").getTerminateApi();
+
+        HttpResponseEntity responseEntity = sendPostMsg(url, videoStable);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
-            videoStable.setStatus(BizConstant.VideoStatus.INTERRUPTED);
+            videoStable.setStatus(BizConstant.VideoStatus.NOT_START);
             updateById(videoStable);
             return CommonResult.fail("终止任务成功");
         } else {
@@ -339,6 +347,24 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         }
     }
 
+    @Override
+    public CommonResult hangup(Long id) {
+        VideoStable videoStable = getById(id);
+
+        videoStable.setLogPath(videoStable.getOutputPath() + File.separator + getLogFileName(videoStable));
+
+        String url = algorithmConfigService.getByAlgorithmName("电子稳相").getPauseApi();
+
+        HttpResponseEntity responseEntity = sendPostMsg(url, videoStable);
+        if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
+            videoStable.setStatus(BizConstant.VideoStatus.INTERRUPTED);
+            updateById(videoStable);
+            return CommonResult.fail("暂停任务成功");
+        } else {
+            return CommonResult.fail("暂停任务失败");
+        }
+    }
+
     @Override
     public List<Map<String, String>> getImages(Long inputOdssId) {
         // 检查input_oss_id是否存在

+ 1 - 1
taais-modules/taais-biz/src/main/resources/mapper/ag/AlgorithmModelMapper.xml

@@ -11,7 +11,7 @@
         (select ac.algorithm_name from algorithm_config ac where ac.id = #{algorithmId} limit 1)
     </select>
     <select id="getModelByAlgorithmId" resultType="com.taais.biz.domain.vo.AlgorithmModelVo">
-        select * from algorithm_model am where am.algorithm_id = #{algorithmId}
+        select * from algorithm_model am where am.algorithm_id = #{algorithmId} and am.del_flag = 0
     </select>
     <select id="getModelById" resultType="com.taais.biz.domain.vo.AlgorithmModelVo">
         select * from algorithm_model am where am.id = #{id}

+ 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>