Przeglądaj źródła

素材解构结果查询

wangyunpeng 16 godzin temu
rodzic
commit
d15ddb4de1

+ 7 - 0
core/src/main/java/com/tzld/videoVector/service/VideoSearchService.java

@@ -33,6 +33,13 @@ public interface VideoSearchService {
      */
     List<VideoMatchResult> matchTopNVideo(MatchTopNVideoParam param);
 
+    /**
+     * 根据 channelContentId 查询解构结果
+     * @param channelContentId 业务内容ID
+     * @return 解构结果JSON
+     */
+    JSONObject getDeconstructResultByChannelContentId(String channelContentId);
+
     /**
      * 获取所有启用的 configCode 列表
      * @return configCode -> configName 的映射

+ 36 - 0
core/src/main/java/com/tzld/videoVector/service/impl/VideoSearchServiceImpl.java

@@ -765,6 +765,42 @@ public class VideoSearchServiceImpl implements VideoSearchService {
         return filteredMatches;
     }
 
+    @Override
+    public JSONObject getDeconstructResultByChannelContentId(String channelContentId) {
+        if (!StringUtils.hasText(channelContentId)) {
+            log.error("getDeconstructResultByChannelContentId channelContentId为空");
+            return null;
+        }
+
+        log.info("通过channelContentId查询解构结果,channelContentId={}", channelContentId);
+
+        // 从数据库查询
+        DeconstructContent content = getDeconstructContentByChannelContentId(channelContentId);
+        if (content == null) {
+            log.info("未找到channelContentId={}对应的解构记录", channelContentId);
+            return null;
+        }
+
+        // 如果状态非终态,尝试从API刷新
+        boolean needRefresh = content.getStatus() == null
+                || content.getStatus() == 0
+                || content.getStatus() == 1;
+
+        if (needRefresh && StringUtils.hasText(content.getTaskId())) {
+            log.info("解构任务未完成,调用API刷新,channelContentId={}, taskId={}, status={}",
+                    channelContentId, content.getTaskId(), content.getStatus());
+            DeconstructResult result = deconstructService.getDeconstructResult(content.getTaskId());
+            if (result != null) {
+                GetDeconstructParam param = new GetDeconstructParam();
+                param.setChannelContentId(channelContentId);
+                updateContentFromResult(content, result, content.getTaskId(), param);
+                return buildResultFromApiResult(result);
+            }
+        }
+
+        return buildResultFromContent(content);
+    }
+
     @Override
     public Map<String, String> getAllConfigCodes() {
         try {

+ 5 - 0
server/src/main/java/com/tzld/videoVector/controller/VideoSearchController.java

@@ -30,6 +30,11 @@ public class VideoSearchController {
         return CommonResponse.success(videoSearchService.getDeconstructResult(param));
     }
 
+    @GetMapping("/getDeconstructResultByChannelContentId")
+    public CommonResponse<JSONObject> getDeconstructResultByChannelContentId(@RequestParam String channelContentId) {
+        return CommonResponse.success(videoSearchService.getDeconstructResultByChannelContentId(channelContentId));
+    }
+
     @PostMapping("/matchTopNVideo")
     public CommonResponse<List<VideoMatchResult>> matchTopNVideo(@RequestBody MatchTopNVideoParam param) {
         return CommonResponse.success(videoSearchService.matchTopNVideo(param));