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

fix: 添加日志路径

WANGKANG преди 8 месеца
родител
ревизия
5a4b07d0b2

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

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

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

@@ -16,8 +16,7 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
 import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
-import com.taais.biz.domain.vo.StartToInfraredTask;
-import com.taais.biz.mapper.ToInfraredMapper;
+import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
@@ -263,22 +262,23 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
         AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TARGET_DETECTION);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TARGET_DETECTION);
+        startTaskConfig.setBizId(entity.getId());
 
-        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
+        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        startToInfraredTask.setSource_dir(entity.getInputPath());
-        startToInfraredTask.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setSource_dir(entity.getInputPath());
+        startTaskConfig.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + "log.log");
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
             String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName();
-            startToInfraredTask.setModel_path(modelPath);
+            startTaskConfig.setModel_path(modelPath);
         }
 
 
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -294,11 +294,11 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
     public CommonResult stop(Long id) {
         TargetDetection entity = getById(id);
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
+        startTaskConfig.setBizId(entity.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(entity);

+ 24 - 32
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -17,7 +17,7 @@ import com.taais.biz.domain.ToInfrared;
 import com.taais.biz.domain.bo.ToInfraredBo;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
 import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
-import com.taais.biz.domain.vo.StartToInfraredTask;
+import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.biz.mapper.ToInfraredMapper;
 import com.taais.biz.service.IToInfraredService;
@@ -226,9 +226,9 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
 
     @Override
     public CommonResult start(Long id) {
-        ToInfrared toInfrared = getById(id);
+        ToInfrared entity = getById(id);
 
-        SysOssVo inputOssEntity = ossService.getById(toInfrared.getInputOssId());
+        SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
 
         String filePath = inputOssEntity.getFileName();
         String localPath = TaaisConfig.getProfile();
@@ -249,45 +249,37 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
             ZipUtils.unzip(resourcePath, inputPath.toString());
         }
 
-        toInfrared.setInputPath(inputPath.toString());
-        toInfrared.setOutputPath(outputPath.toString());
+        entity.setInputPath(inputPath.toString());
+        entity.setOutputPath(outputPath.toString());
 
-        toInfrared.setStartTime(new Date());
+        entity.setStartTime(new Date());
 
-        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(toInfrared.getAlgorithmModelId());
+        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
-        startToInfraredTask.setBizId(toInfrared.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
+        startTaskConfig.setBizId(entity.getId());
 
-        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
-
-//        String osName = System.getProperty("os.name");
-//        if (osName.toLowerCase().contains("windows")) {
-//            startToInfraredTask.setSource_dir("C:" + toInfrared.getInputPath());
-//            startToInfraredTask.setResult_dir("C:" + toInfrared.getOutputPath());
-//        } else {
-        startToInfraredTask.setSource_dir(toInfrared.getInputPath());
-        startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
-//        }
+        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        // startToInfraredTask.setSource_dir(toInfrared.getInputPath());
-        // startToInfraredTask.setResult_dir(toInfrared.getOutputPath());
+        startTaskConfig.setSource_dir(entity.getInputPath());
+        startTaskConfig.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + "log.log");
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
-            startToInfraredTask.setModel_path(algorithmModelTrack.getModelAddress());
+            startTaskConfig.setModel_path(algorithmModelTrack.getModelAddress());
         }
 
 
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
-            toInfrared.setStatus(BizConstant.VideoStatus.RUNNING);
-            updateById(toInfrared);
+            entity.setStatus(BizConstant.VideoStatus.RUNNING);
+            updateById(entity);
             return CommonResult.success("任务开始成功,请等待完成");
         } else {
-            toInfrared.setStatus(BizConstant.VideoStatus.FAILED);
-            updateById(toInfrared);
+            entity.setStatus(BizConstant.VideoStatus.FAILED);
+            updateById(entity);
             return CommonResult.fail("任务开始失败,请检查!");
         }
     }
@@ -296,11 +288,11 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     public CommonResult stop(Long id) {
         ToInfrared toInfrared = getById(id);
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TO_INFRARED);
-        startToInfraredTask.setBizId(toInfrared.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TO_INFRARED);
+        startTaskConfig.setBizId(toInfrared.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             toInfrared.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(toInfrared);

+ 15 - 14
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -17,7 +17,7 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.vo.AlgorithmConfigTrackVo;
 import com.taais.biz.domain.vo.AlgorithmModelTrackVo;
-import com.taais.biz.domain.vo.StartToInfraredTask;
+import com.taais.biz.domain.vo.StartTaskConfig;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
@@ -260,23 +260,24 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(entity.getAlgorithmModelId());
         AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
+        startTaskConfig.setBizId(entity.getId());
 
-        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
+        startTaskConfig.setOtherParams(algorithmConfigTrack.getParameterConfig());
 
-        startToInfraredTask.setSource_dir(entity.getInputPath());
-        startToInfraredTask.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setSource_dir(entity.getInputPath());
+        startTaskConfig.setResult_dir(entity.getOutputPath());
+        startTaskConfig.setLog_path(entity.getOutputPath() + File.separator + "log.log");
 
         if (BizConstant.AlgorithmType.REASONING.equals(algorithmConfigTrack.getType())) {
             if(algorithmModelTrack.getModelName().startsWith("masc") || algorithmModelTrack.getModelName().startsWith("MASC")) {
                 String modelPath = algorithmModelTrack.getModelAddress() + File.separator + algorithmModelTrack.getModelName().substring(5);
-                startToInfraredTask.setModel_path(modelPath);
+                startTaskConfig.setModel_path(modelPath);
             }
             else if(algorithmModelTrack.getModelName().startsWith("cat") || algorithmModelTrack.getModelName().startsWith("CAT")) {
                 String modelPath = algorithmModelTrack.getModelAddress();
-                startToInfraredTask.setModel_path(modelPath);
+                startTaskConfig.setModel_path(modelPath);
             }
             else {
                 return CommonResult.fail("模型命名失败,请以MASC或CAT开头命名模型");
@@ -284,7 +285,7 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         }
 
 
-        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(entity);
@@ -300,11 +301,11 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
     public CommonResult stop(Long id) {
         TrackSequence entity = getById(id);
 
-        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
-        startToInfraredTask.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
-        startToInfraredTask.setBizId(entity.getId());
+        StartTaskConfig startTaskConfig = new StartTaskConfig();
+        startTaskConfig.setBizType(BizConstant.BizType.TRACK_SEQUENCE);
+        startTaskConfig.setBizId(entity.getId());
 
-        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startToInfraredTask);
+        HttpResponseEntity responseEntity = sendPostMsg(task_stop_url, startTaskConfig);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             entity.setStatus(BizConstant.VideoStatus.INTERRUPTED);
             updateById(entity);