ソースを参照

Merge branch 'develop' of http://101.126.133.7:9001/www/taais into develop

Eagle 2 週間 前
コミット
3715a7f62e

+ 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', '{}', '目标毁伤评估算法配置' );

+ 1 - 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/";

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

+ 0 - 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;
@@ -11,8 +10,6 @@ import com.taais.biz.service.impl.*;
 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;
@@ -20,7 +17,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;
@@ -33,7 +29,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;
 
 /**

+ 36 - 54
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/TargetIdentificationSubtaskDetailsController.java

@@ -289,70 +289,52 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
     public CommonResult<Void> openDir(String directory, String type) throws IOException {
         String path =  profile + "/task" + directory;
         log.info("check dir: {}", path);
-        if("1".equals(type)){
+        if (GraphicsEnvironment.isHeadless()) {
+            log.info("Headless 模式,改用命令行方式");
+            openFolderViaCommandLine(path);
+        } else {
+            log.info("使用Desktop 模式");
             try {
                 Desktop desktop = Desktop.getDesktop();
-                File dir = new File(path);
-                if (dir.exists()) {
-                    desktop.open(dir);
+                if (desktop.isSupported(Desktop.Action.OPEN)) {
+                    desktop.open(new File(path));
                 } else {
-                    System.out.println("文件夹不存在: " + path);
+                    log.info("Desktop.OPEN 不支持,改用命令行方式");
+                    openFolderViaCommandLine(path);
                 }
-            } catch (IOException e) {
-                e.printStackTrace();
+            } catch (Exception e) {
+                log.info("Desktop 失败:" + e.getMessage());
+                openFolderViaCommandLine(path);
             }
         }
+        return CommonResult.success();
+    }
 
-        if("2".equals(type)){
-            try {
-                // 对于Ubuntu/GNOME桌面环境
-                Process process = Runtime.getRuntime().exec(new String[]{"xdg-open", path});
-
-                // 或者使用nautilus(文件管理器)
-                // Process process = Runtime.getRuntime().exec(new String[]{"nautilus", path});
-
-                int exitCode = process.waitFor();
-                if (exitCode != 0) {
-                    System.out.println("打开文件夹失败,退出码: " + exitCode);
-                }
-            } catch (IOException | InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-
-        if("21".equals(type)){
-            try {
-
-                // 或者使用nautilus(文件管理器)
-                Process process = Runtime.getRuntime().exec(new String[]{"nautilus", path});
-
-                int exitCode = process.waitFor();
-                if (exitCode != 0) {
-                    System.out.println("打开文件夹失败,退出码: " + exitCode);
-                }
-            } catch (IOException | InterruptedException e) {
-                e.printStackTrace();
-            }
+    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);
         }
 
-        if("3".equals(type)){
-            try {
-                ProcessBuilder pb = new ProcessBuilder("xdg-open", path);
-                // 或者使用: ProcessBuilder pb = new ProcessBuilder("nautilus", path);
-                pb.start();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        if("4".equals(type)){
-            try {
-                ProcessBuilder pb = new ProcessBuilder("nautilus", path);
-                pb.start();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
+        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);
         }
-        return CommonResult.success();
     }
 
     @GetMapping("/getImgList")

+ 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; // 直接初始化默认值
 
 
 }

+ 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; // 直接初始化默认值
 
 
 }

+ 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;
     }
 
     /** 序号 */

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

@@ -5,7 +5,6 @@
 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;
@@ -18,7 +17,6 @@ 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;
@@ -30,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;
@@ -42,7 +39,6 @@ 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;
@@ -55,11 +51,11 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
  * 目标检测Service业务层处理
  *
  * @author wangkang
- *         2024-09-29
+ * 2024-09-29
  */
 @Service
 public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionMapper, TargetDetection>
-        implements ITargetDetectionService {
+    implements ITargetDetectionService {
     @Resource
     private TargetDetectionMapper targetDetectionMapper;
     @Autowired
@@ -140,16 +136,19 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
             Long modelId = entity.getAlgorithmModelId();
             if (ObjectUtil.isNotNull(modelId)) {
                 AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
-                entity.setModelName(model.getModelName());
-
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
             }
 
             Long algorithmId = entity.getAlgorithmId();
             if (ObjectUtil.isNotNull(algorithmId)) {
                 AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(TargetDetectionVo::getCreateTime).reversed());
@@ -205,8 +204,15 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
             throw new RuntimeException("算法配置参数为空");
         }
 
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, unzipPath);
+        }
+
         Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
-                entityBo.getOtherParams());
+            entityBo.getOtherParams());
 
         // 步骤4. 构造可以直接传给前端的map数据结构
         Map<String, Object> result = new HashMap<>();
@@ -245,12 +251,6 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         makeDir(entity.getInputPath());
         makeDir(entity.getOutputPath());
 
-        File file = new File(entity.getInputPath());
-        if (!file.exists()) {
-            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
-            ZipUtils.unzip(resourcePath, entity.getInputPath());
-        }
-
         return entity;
     }
 
@@ -418,8 +418,8 @@ 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);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     @Override

+ 19 - 18
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;
@@ -61,7 +59,7 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
  * 可见光转红外Service业务层处理
  *
  * @author 0
- *         2024-09-20
+ * 2024-09-20
  */
 @Service
 @Log4j2
@@ -143,16 +141,19 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             Long modelId = entity.getAlgorithmModelId();
             if (ObjectUtil.isNotNull(modelId)) {
                 AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
-                entity.setModelName(model.getModelName());
-
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
             }
 
             Long algorithmId = entity.getAlgorithmId();
             if (ObjectUtil.isNotNull(algorithmId)) {
                 AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(ToInfraredVo::getCreateTime).reversed());
@@ -268,7 +269,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     }
 
     public static Map<String, Object> getAlgorithmParameters(String algorithmConfigStr,
-            Map<String, Object> otherParams) {
+                                                             Map<String, Object> otherParams) {
         Map<String, Object> algorithmParameters = new HashMap<>();
         List<Dict> config_list = JsonUtils.parseArrayMap(algorithmConfigStr);
 
@@ -306,7 +307,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         }
 
         Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
-                entityBo.getOtherParams());
+            entityBo.getOtherParams());
 
         // 步骤4. 构造可以直接传给前端的map数据结构
         Map<String, Object> result = new HashMap<>();
@@ -342,15 +343,15 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         // 步骤 5. 将算法参数map序列化为json字符串,保存到数据库中
         entity.setAlgorithmParameters(JsonUtils.toJsonString(result));
 
-        makeDir(entity.getInputPath());
-        makeDir(entity.getOutputPath());
-
         File file = new File(entity.getInputPath());
         if (!file.exists()) {
             String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
             ZipUtils.unzip(resourcePath, entity.getInputPath());
         }
 
+        makeDir(entity.getInputPath());
+        makeDir(entity.getOutputPath());
+
         return entity;
     }
 
@@ -574,7 +575,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
         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")) {
+                || file.getName().startsWith("events.out")) {
                 continue;
             }
             idx += 1;
@@ -704,8 +705,8 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         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);
+            .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) {
@@ -729,7 +730,7 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
         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);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + returnFile.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 }

+ 24 - 27
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -6,7 +6,6 @@ package com.taais.biz.service.impl;
 
 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;
@@ -24,19 +23,13 @@ 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;
-import com.taais.system.domain.SysOss;
 import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
-import com.taais.system.service.impl.SysOssServiceImpl;
-
 import jakarta.annotation.Resource;
-
-import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.FileSystemResource;
@@ -50,24 +43,24 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.text.DecimalFormat;
 import java.util.*;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
-import static com.taais.biz.service.impl.TargetDetectionServiceImpl.*;
+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业务层处理
  *
  * @author wangkang
- *         2024-09-22
+ * 2024-09-22
  */
 @Service
 public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMapper, TrackSequence>
-        implements ITrackSequenceService {
+    implements ITrackSequenceService {
 
     private static final String MASC = "MASC";
     private static final String CAT = "CAT";
@@ -195,16 +188,19 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             Long modelId = entity.getAlgorithmModelId();
             if (ObjectUtil.isNotNull(modelId)) {
                 AlgorithmModelTrack model = algorithmModelTrackService.getById(modelId);
-                entity.setModelName(model.getModelName());
-
+                if (ObjectUtil.isNotNull(model)) {
+                    entity.setModelName(model.getModelName());
+                }
             }
 
             Long algorithmId = entity.getAlgorithmId();
             if (ObjectUtil.isNotNull(algorithmId)) {
                 AlgorithmConfigTrackVo config = algorithmConfigTrackService.selectById(algorithmId);
-                entity.setType(config.getType());
-                entity.setSubsystem(config.getSubsystem());
-                entity.setAlgorithmName(config.getAlgorithmName());
+                if (ObjectUtil.isNotNull(config)) {
+                    entity.setType(config.getType());
+                    entity.setSubsystem(config.getSubsystem());
+                    entity.setAlgorithmName(config.getAlgorithmName());
+                }
             }
         });
         page.getRecords().sort(Comparator.comparing(TrackSequenceVo::getCreateTime).reversed());
@@ -277,8 +273,15 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             throw new RuntimeException("算法配置参数为空");
         }
 
+        String unzipPath = getUnZipDirPath(ossEntity);
+        File file = new File(unzipPath);
+        if (!file.exists()) {
+            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
+            ZipUtils.unzip(resourcePath, unzipPath);
+        }
+
         Map<String, Object> algorithmParameters = getAlgorithmParameters(algorithmConfig.getParameters(),
-                entityBo.getOtherParams());
+            entityBo.getOtherParams());
 
         // 步骤4. 构造可以直接传给前端的map数据结构
         Map<String, Object> result = new HashMap<>();
@@ -347,12 +350,6 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         makeDir(entity.getInputPath());
         makeDir(entity.getOutputPath());
 
-        File file = new File(entity.getInputPath());
-        if (!file.exists()) {
-            String resourcePath = getResourcePath(ossService.getById(entity.getInputOssId()));
-            ZipUtils.unzip(resourcePath, entity.getInputPath());
-        }
-
         return entity;
     }
 
@@ -467,8 +464,8 @@ 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);
+            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
+            .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream").body(resource);
     }
 
     @Override
@@ -520,7 +517,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         } else if (entity.getName().startsWith(CAT)) {
             AlgorithmModelTrack modelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
             AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService
-                    .getById(modelTrack.getAlgorithmId());
+                .getById(modelTrack.getAlgorithmId());
 
             AlgorithmModelTrackVo res = new AlgorithmModelTrackVo();