瀏覽代碼

feat: 返回结果请求完成

WANGKANG 9 月之前
父節點
當前提交
d38ddb95ee

+ 19 - 3
taais-modules/taais-biz/src/main/java/com/taais/biz/controller/PublicController.java

@@ -1,6 +1,7 @@
 package com.taais.biz.controller;
 
 import com.taais.biz.constant.BizConstant;
+import com.taais.biz.domain.TaskTrackResultBo;
 import com.taais.biz.domain.bo.TargetIdentificationSubtaskDetailsBo;
 import com.taais.biz.domain.bo.ToInfraredBo;
 import com.taais.biz.domain.bo.ToInfraredStartResultBo;
@@ -35,6 +36,10 @@ public class PublicController extends BaseController {
     private IVideoStableService videoStableService;
     @Resource
     private IToInfraredService toInfraredService;
+    @Resource
+    private ITrackSequenceService trackSequenceService;
+    @Resource
+    private ITargetDetectionService targetDetectionService;
 
     @Resource
     IAlgorithmDataProcessService dataProcessService;
@@ -104,8 +109,19 @@ public class PublicController extends BaseController {
         return videoStableService.getResult(videoStableStartResultBo);
     }
 
-    @PostMapping("/toInfrared/get_result")
-    public CommonResult getResult(@Valid @RequestBody ToInfraredStartResultBo toInfraredStartResultBo) {
-        return toInfraredService.getResult(toInfraredStartResultBo);
+    @PostMapping("/task_track/get_result")
+    public CommonResult getResult(@Valid @RequestBody TaskTrackResultBo taskTrackResultBo) {
+        if(taskTrackResultBo.getBizType().equals(BizConstant.BizType.TO_INFRARED)) {
+            return toInfraredService.getResult(taskTrackResultBo);
+        }
+        else if(taskTrackResultBo.getBizType().equals(BizConstant.BizType.TRACK_SEQUENCE)) {
+            return trackSequenceService.getResult(taskTrackResultBo);
+        }
+        else if(taskTrackResultBo.getBizType().equals(BizConstant.BizType.TARGET_DETECTION)) {
+            return targetDetectionService.getResult(taskTrackResultBo);
+        }
+        else {
+            return CommonResult.fail("业务类型不支持");
+        }
     }
 }

+ 30 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TaskTrackResultBo.java

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

+ 3 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/ITargetDetectionService.java

@@ -3,6 +3,7 @@ package com.taais.biz.service;
 import java.util.List;
 
 import com.taais.biz.domain.TargetDetection;
+import com.taais.biz.domain.TaskTrackResultBo;
 import com.taais.biz.domain.vo.TargetDetectionVo;
 import com.taais.biz.domain.bo.TargetDetectionBo;
 import com.taais.common.core.core.domain.CommonResult;
@@ -67,4 +68,6 @@ public interface ITargetDetectionService extends IBaseService<TargetDetection> {
     CommonResult start(Long id);
 
     CommonResult stop(Long id);
+
+    CommonResult getResult(TaskTrackResultBo taskTrackResultBo);
 }

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

@@ -1,9 +1,9 @@
 package com.taais.biz.service;
 
 
+import com.taais.biz.domain.TaskTrackResultBo;
 import com.taais.biz.domain.ToInfrared;
 import com.taais.biz.domain.bo.ToInfraredBo;
-import com.taais.biz.domain.bo.ToInfraredStartResultBo;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.common.core.core.domain.CommonResult;
 import com.taais.common.core.core.page.PageResult;
@@ -72,7 +72,7 @@ public interface IToInfraredService extends IBaseService<ToInfrared> {
 
     CommonResult stop(Long id);
 
-    CommonResult getResult(ToInfraredStartResultBo toInfraredStartResultBo);
+    CommonResult getResult(TaskTrackResultBo toInfraredStartResultBo);
 
     ResponseEntity<Resource> zipImages(Long id);
 }

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

@@ -2,6 +2,7 @@ package com.taais.biz.service;
 
 import java.util.List;
 
+import com.taais.biz.domain.TaskTrackResultBo;
 import com.taais.biz.domain.TrackSequence;
 import com.taais.biz.domain.vo.TrackSequenceVo;
 import com.taais.biz.domain.bo.TrackSequenceBo;
@@ -71,4 +72,6 @@ public interface ITrackSequenceService extends IBaseService<TrackSequence> {
     CommonResult stop(Long id);
 
     ResponseEntity<Resource> zipImages(Long id);
+
+    CommonResult getResult(TaskTrackResultBo taskTrackResultBo);
 }

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

@@ -276,4 +276,22 @@ public class TargetDetectionServiceImpl extends BaseServiceImpl<TargetDetectionM
             return CommonResult.fail("终止任务失败");
         }
     }
+
+    @Override
+    public CommonResult getResult(TaskTrackResultBo taskTrackResultBo) {
+        Long id = taskTrackResultBo.getId();
+        String status = taskTrackResultBo.getStatus();
+        String msg = taskTrackResultBo.getMsg();
+        TargetDetection entity = getById(id);
+        entity.setLog(msg);
+        entity.setStatus("200".equals(status) ? BizConstant.VideoStatus.END : BizConstant.VideoStatus.FAILED);
+        entity.setEndTime(new Date());
+        try {
+            entity.setCostSecond((entity.getEndTime().getTime() - entity.getStartTime().getTime()) / 1000);
+        } catch (Exception e) {
+            entity.setCostSecond(null);
+        }
+        updateById(entity);
+        return CommonResult.success();
+    }
 }

+ 11 - 15
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/ToInfraredServiceImpl.java

@@ -14,8 +14,6 @@ import com.taais.biz.constant.BizConstant;
 import com.taais.biz.domain.*;
 import com.taais.biz.domain.ToInfrared;
 import com.taais.biz.domain.bo.ToInfraredBo;
-import com.taais.biz.domain.bo.ToInfraredStartResultBo;
-import com.taais.biz.domain.bo.VideoStableStartResultBo;
 import com.taais.biz.domain.vo.StartToInfraredTask;
 import com.taais.biz.domain.vo.ToInfraredVo;
 import com.taais.biz.mapper.ToInfraredMapper;
@@ -32,7 +30,6 @@ import com.taais.common.orm.core.service.impl.BaseServiceImpl;
 import com.taais.system.domain.vo.SysOssVo;
 import com.taais.system.service.ISysOssService;
 import jakarta.annotation.Resource;
-import lombok.extern.log4j.Log4j;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -46,7 +43,6 @@ import org.springframework.transaction.annotation.Transactional;
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
 import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
-import static com.taais.biz.constant.BizConstant.AlgorithmType;
 
 /**
  * 可见光转红外Service业务层处理
@@ -284,20 +280,20 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
     }
 
     @Override
-    public CommonResult getResult(ToInfraredStartResultBo toInfraredStartResultBo) {
-        Long id = toInfraredStartResultBo.getId();
-        String status = toInfraredStartResultBo.getStatus();
-        String msg = toInfraredStartResultBo.getMsg();
-        ToInfrared toInfrared = getById(id);
-        toInfrared.setLog(msg);
-        toInfrared.setStatus("200".equals(status) ? BizConstant.VideoStatus.END : BizConstant.VideoStatus.FAILED);
-        toInfrared.setEndTime(new Date());
+    public CommonResult getResult(TaskTrackResultBo taskTrackResultBo) {
+        Long id = taskTrackResultBo.getId();
+        String status = taskTrackResultBo.getStatus();
+        String msg = taskTrackResultBo.getMsg();
+        ToInfrared entity = getById(id);
+        entity.setLog(msg);
+        entity.setStatus("200".equals(status) ? BizConstant.VideoStatus.END : BizConstant.VideoStatus.FAILED);
+        entity.setEndTime(new Date());
         try {
-            toInfrared.setCostSecond((toInfrared.getEndTime().getTime() - toInfrared.getStartTime().getTime()) / 1000);
+            entity.setCostSecond((entity.getEndTime().getTime() - entity.getStartTime().getTime()) / 1000);
         } catch (Exception e) {
-            toInfrared.setCostSecond(null);
+            entity.setCostSecond(null);
         }
-        updateById(toInfrared);
+        updateById(entity);
         return CommonResult.success();
     }
 

+ 18 - 0
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -302,4 +302,22 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
             .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
             .body(resource);
     }
+
+    @Override
+    public CommonResult getResult(TaskTrackResultBo taskTrackResultBo) {
+        Long id = taskTrackResultBo.getId();
+        String status = taskTrackResultBo.getStatus();
+        String msg = taskTrackResultBo.getMsg();
+        TrackSequence entity = getById(id);
+        entity.setLog(msg);
+        entity.setStatus("200".equals(status) ? BizConstant.VideoStatus.END : BizConstant.VideoStatus.FAILED);
+        entity.setEndTime(new Date());
+        try {
+            entity.setCostSecond((entity.getEndTime().getTime() - entity.getStartTime().getTime()) / 1000);
+        } catch (Exception e) {
+            entity.setCostSecond(null);
+        }
+        updateById(entity);
+        return CommonResult.success();
+    }
 }