|
@@ -28,6 +28,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -48,6 +49,8 @@ public class MatchVideoServiceImpl {
|
|
|
|
|
|
private static final String EXIST_RESULT_KEY = "exist_result_key_%s";
|
|
|
|
|
|
+ private static final String SINGLE_VIDEO_LOCK_KEY = "single_video_lock_key_%s";
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
KimiService kimiService;
|
|
@@ -293,7 +296,19 @@ public class MatchVideoServiceImpl {
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(matchVideo.getVideoPoolTraceId())) {
|
|
|
- addCrawlerVideo(matchVideo);
|
|
|
+ //已经存在结果 直接设置
|
|
|
+ if (existMatchVideoResult(matchVideo)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String lockKey = String.format(SINGLE_VIDEO_LOCK_KEY, matchVideo.getContentId());
|
|
|
+ String lockValue = UUID.randomUUID().toString();
|
|
|
+ boolean lock = redisLock.tryLock(lockKey, lockValue, 300, TimeUnit.SECONDS);
|
|
|
+ if (lock) {
|
|
|
+ log.info("singleCrawlerVideo lock lockKey={}", lockKey);
|
|
|
+ addCrawlerVideo(matchVideo);
|
|
|
+ log.info("singleCrawlerVideo unlock lockKey={}", lockKey);
|
|
|
+ redisLock.unlock(lockKey, lockValue);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|