supeng 1 周之前
父節點
當前提交
00820b443d

+ 10 - 2
content-understanding-core/src/main/java/com/tzld/piaoquan/content/understanding/rocketmq/consumer/ContentUnderstandingPipelineTaskConsumer.java

@@ -91,10 +91,14 @@ public class ContentUnderstandingPipelineTaskConsumer implements RocketMQListene
                 return ConsumeResult.SUCCESS;
             }
             //相同视频跳过
+            boolean skipSameVideo = false;
             if (Objects.nonNull(sameVideoUnderstandingSkipSeconds) && sameVideoUnderstandingSkipSeconds > 0) {
+                skipSameVideo = true;
+            }
+            if (skipSameVideo) {
                 String key = String.format(SAME_VIDEO_SKIP_KEY, videoId);
-                Boolean flag = redisUtil.setNx(key, "1", sameVideoUnderstandingSkipSeconds);
-                if (Objects.isNull(flag) || !flag) {
+                Boolean hasKey = redisUtil.hasKey(key);
+                if (Boolean.TRUE.equals(hasKey)) {
                     log.info("相同视频跳过理解 videoId = {} taskId = {} sameVideoUnderstandingSkipSeconds = {}", videoId, taskId, sameVideoUnderstandingSkipSeconds);
                     String reason = "相同视频跳过理解,时间间隔:" + sameVideoUnderstandingSkipSeconds;
                     pipelineService.updateTaskResult(taskId, null, reason, videoId, extMap, false);
@@ -140,6 +144,10 @@ public class ContentUnderstandingPipelineTaskConsumer implements RocketMQListene
             dto1.setExtMap(extMap);
             // 4.按照步骤执行pipeline每一步动作
             pipelineService.executeTaskTreeNodeBFS(root, dto1);
+            if (skipSameVideo) {
+                String key = String.format(SAME_VIDEO_SKIP_KEY, videoId);
+                redisUtil.set(key, "1", sameVideoUnderstandingSkipSeconds);
+            }
             return ConsumeResult.SUCCESS;
         } catch (Exception e) {
             log.error("Message is failed to be acknowledged, messageId={}", messageId, e);