wangyunpeng 1 неделя назад
Родитель
Сommit
cd26ba0c3d
1 измененных файлов с 41 добавлено и 2 удалено
  1. 41 2
      core/src/main/java/com/tzld/videoVector/job/VideoVectorJob.java

+ 41 - 2
core/src/main/java/com/tzld/videoVector/job/VideoVectorJob.java

@@ -130,7 +130,15 @@ public class VideoVectorJob {
                     }
                     log.info("配置 {} 需要处理 {} 个视频", configCode, needProcessIds.size());
 
-                    // 3.3 批量查询需要处理的视频 raw_result
+                    // 3.3 审核状态过滤:排除审核未通过的视频
+                    needProcessIds = filterAuditPassedIds(needProcessIds);
+                    if (needProcessIds.isEmpty()) {
+                        log.info("配置 {} 待处理视频均未通过审核,跳过", configCode);
+                        continue;
+                    }
+                    log.info("配置 {} 审核通过后需处理 {} 个视频", configCode, needProcessIds.size());
+
+                    // 3.4 批量查询需要处理的视频 raw_result
                     for (List<Long> partition : Lists.partition(needProcessIds, 50)) {
                         Map<Long, String> videoRawResults = batchQueryVideoRawResults(partition);
                         if (videoRawResults.isEmpty()) {
@@ -138,7 +146,7 @@ public class VideoVectorJob {
                             continue;
                         }
 
-                        // 3.4 逐个处理
+                        // 3.5 逐个处理
                         for (Long videoId : partition) {
                             try {
                                 String rawResult = videoRawResults.get(videoId);
@@ -562,6 +570,37 @@ public class VideoVectorJob {
         }
     }
 
+    /**
+     * 过滤审核通过的视频ID
+     * 分批调用审核接口,排除审核未通过或不存在的视频
+     *
+     * @param videoIds 待过滤的视频ID列表
+     * @return 审核通过的视频ID列表
+     */
+    private List<Long> filterAuditPassedIds(List<Long> videoIds) {
+        if (CollectionUtils.isEmpty(videoIds)) {
+            return Collections.emptyList();
+        }
+        Set<Long> notPassedIds = new HashSet<>();
+        for (List<Long> batch : Lists.partition(videoIds, AUDIT_CHECK_BATCH_SIZE)) {
+            try {
+                Set<Long> batchNotPassed = videoApiService.getNotAuditPassedVideoIds(new HashSet<>(batch));
+                notPassedIds.addAll(batchNotPassed);
+            } catch (Exception e) {
+                log.error("审核状态查询失败,batch={}, error={}", batch, e.getMessage(), e);
+            }
+        }
+        if (notPassedIds.isEmpty()) {
+            return videoIds;
+        }
+        List<Long> passed = videoIds.stream()
+                .filter(id -> !notPassedIds.contains(id))
+                .collect(Collectors.toList());
+        log.info("审核过滤:原始 {} 个,过滤掉 {} 个未通过,剩余 {} 个",
+                videoIds.size(), notPassedIds.size(), passed.size());
+        return passed;
+    }
+
     /**
      * 更新内容状态为失败
      */