浏览代码

feat: 电子稳像自动刷新 + 转图片自动刷新 + 电子稳像日志

WANGKANG 7 月之前
父节点
当前提交
48974b4079

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

@@ -18,6 +18,7 @@ public class BizConstant {
     public static final String TO_INFRARED_SUFFIX = "_to_infrared";
     public static final String TRACK_SEQUENCE_SUFFIX = "_track_sequence";
     public static final String TARGET_DETECTION_SUFFIX = "_target_detection";
+    public static final String VIDEO_STABLE_SUFFIX = "_stable";
 
     public static class ModelStatus {
         public static final String NOT_START = "0";

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

@@ -190,4 +190,9 @@ public class VideoStableController extends BaseController {
     public CommonResult<List<Map<String, String>>> getImages(@PathVariable("ossId") Long ossId) {
         return CommonResult.success(videoStableService.getImages(ossId));
     }
+
+    @GetMapping("/log/{id}")
+    public CommonResult getLog(@PathVariable("id") Long id) {
+        return videoStableService.getLog(id);
+    }
 }

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

@@ -102,4 +102,7 @@ public class VideoStable extends BaseEntity {
     private Integer  lklevel = 3;
     @Builder.Default
     private Integer  lkwinSiz = 15;
+
+    @Column(ignore = true)
+    private String logPath;
 }

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

@@ -79,4 +79,6 @@ public interface IVideoStableService extends IBaseService<VideoStable> {
     CommonResult stop(Long id);
 
     List<Map<String, String>> getImages(Long ossId);
+
+    CommonResult getLog(Long id);
 }

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

@@ -28,6 +28,7 @@ import com.taais.common.core.utils.StringUtils;
 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;
 import com.taais.system.service.ISysOssService;
 import lombok.extern.slf4j.Slf4j;
@@ -289,6 +290,7 @@ public class Video2imageServiceImpl extends BaseServiceImpl<Video2imageMapper, V
                 log.info("视频转图片子线程结束...");
 
                 threads.remove(id);
+                WebSocketUtils.publishAll("refresh");
             }
         });
 

+ 23 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/VideoStableServiceImpl.java

@@ -14,6 +14,7 @@ import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.HttpResponseEntity;
+import com.taais.biz.domain.ToInfrared;
 import com.taais.biz.domain.bo.VideoStableStartResultBo;
 import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
@@ -25,6 +26,7 @@ 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;
 import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
@@ -47,6 +49,7 @@ import com.taais.biz.service.IVideoStableService;
 
 import static com.taais.biz.domain.table.VideoStableTableDef.VIDEO_STABLE;
 import static com.taais.biz.service.impl.DataSeqServiceImpl.isImageFile;
+import static com.taais.biz.service.impl.ToInfraredServiceImpl.readLogContent;
 
 /**
  * 视频去抖动Service业务层处理
@@ -229,6 +232,8 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         videoStable.setStatus(BizConstant.VideoStatus.RUNNING);
         updateById(videoStable);
 
+        videoStable.setLogPath(videoStable.getOutputPath() + File.separator + getLogFileName(videoStable));
+
         HttpResponseEntity responseEntity = sendPostMsg(video_stable_start_url, videoStable);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
             return CommonResult.success("任务开始成功,请等待完成");
@@ -280,6 +285,7 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
             videoStable.setCostSecond(null);
         }
         updateById(videoStable);
+        WebSocketUtils.publishAll("refresh");
         return CommonResult.success();
     }
 
@@ -381,6 +387,23 @@ public class VideoStableServiceImpl extends BaseServiceImpl<VideoStableMapper, V
         }
     }
 
+    private String getLogFileName(VideoStable entity) {
+        return entity.getId() + BizConstant.VIDEO_STABLE_SUFFIX + ".log";
+    }
+
+    @Override
+    public CommonResult getLog(Long id) {
+        VideoStable entity = getById(id);
+        String outPutPath = entity.getOutputPath();
+        String logPath = outPutPath + File.separator + getLogFileName(entity);
+        System.out.println(logPath);
+        File file = new File(logPath);
+        if (!file.exists()) {
+            return CommonResult.fail("日志文件不存在!");
+        }
+        return CommonResult.success(readLogContent(logPath), "success");
+    }
+
     public List<String> getImageUrls(SysOssVo ossEntity, String path, String suffix) {
         String urlPrefix = ossEntity.getUrl().substring(0, ossEntity.getUrl().lastIndexOf(".")) + suffix;
         // 列出unzipPath下所有图片文件