|
@@ -47,6 +47,8 @@ public class MatchVideoServiceImpl {
|
|
|
|
|
|
private static final String KIMI_FAIL_COUNT_KEY = "kimi_count_key_%s";
|
|
|
|
|
|
+ private static final String FAIL_KEY = "fail_key_%s";
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
KimiService kimiService;
|
|
@@ -228,6 +230,10 @@ public class MatchVideoServiceImpl {
|
|
|
}
|
|
|
//执行kimi任务
|
|
|
if (kimiText.getKimiStatus() == 0) {
|
|
|
+ //已经存在失败 设置为失败
|
|
|
+ if (setMatchFail(matchVideo)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
String lockKey = String.format(KIMI_LOCK_KEY, matchVideo.getContentId());
|
|
|
String lockValue = UUID.randomUUID().toString();
|
|
|
boolean lock = redisLock.tryLock(lockKey, lockValue, 300, TimeUnit.SECONDS);
|
|
@@ -319,20 +325,9 @@ public class MatchVideoServiceImpl {
|
|
|
boolean existCrawlerVideo = crawlerVideoService.existCrawlerVideo(matchVideo.getContentId());
|
|
|
log.info("processCrawlerMatchContent contentId={} existCrawlerVideo={}", matchVideo.getContentId(), existCrawlerVideo);
|
|
|
if (!existCrawlerVideo) {
|
|
|
- //查询相同的contentId,如果已经匹配失败,则直接更新状态为失败
|
|
|
- MatchVideoExample example = new MatchVideoExample();
|
|
|
- example.createCriteria().andContentIdEqualTo(matchVideo.getContentId());
|
|
|
- List<MatchVideo> matchVideos = matchVideoMapper.selectByExample(example);
|
|
|
- if (!CollectionUtils.isEmpty(matchVideos)) {
|
|
|
- for (MatchVideo matchVideo1 : matchVideos) {
|
|
|
- if (matchVideo1.getId().equals(matchVideo.getId())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (ContentStatusEnum.isFail(matchVideo1.getContentStatus())) {
|
|
|
- updateStatus(matchVideo.getId(), matchVideo1.getContentStatus());
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ //已经存在失败 设置为失败
|
|
|
+ if (setMatchFail(matchVideo)) {
|
|
|
+ return;
|
|
|
}
|
|
|
String lockKey = String.format(CRAWLER_LOCK_KEY, matchVideo.getContentId());
|
|
|
String lockValue = UUID.randomUUID().toString();
|
|
@@ -447,20 +442,9 @@ public class MatchVideoServiceImpl {
|
|
|
boolean existUploadCrawlerVideo = crawlerVideoService.existUploadCrawlerVideo(matchVideo.getContentId());
|
|
|
log.info("processUploadCrawlerVideo contentId={} existCrawlerVideo={}", matchVideo.getContentId(), existUploadCrawlerVideo);
|
|
|
if (!existUploadCrawlerVideo) {
|
|
|
- //查询相同的contentId,如果已经失败,则直接更新状态为失败
|
|
|
- MatchVideoExample example = new MatchVideoExample();
|
|
|
- example.createCriteria().andContentIdEqualTo(matchVideo.getContentId());
|
|
|
- List<MatchVideo> matchVideos = matchVideoMapper.selectByExample(example);
|
|
|
- if (!CollectionUtils.isEmpty(matchVideos)) {
|
|
|
- for (MatchVideo matchVideo1 : matchVideos) {
|
|
|
- if (matchVideo1.getId().equals(matchVideo.getId())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (ContentStatusEnum.isFail(matchVideo1.getContentStatus())) {
|
|
|
- updateStatus(matchVideo.getId(), matchVideo1.getContentStatus());
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ //已经存在失败 设置为失败
|
|
|
+ if (setMatchFail(matchVideo)) {
|
|
|
+ return;
|
|
|
}
|
|
|
String lockKey = String.format(UPLOAD_CRAWLER_LOCK_KEY, matchVideo.getContentId());
|
|
|
String lockValue = UUID.randomUUID().toString();
|
|
@@ -555,7 +539,31 @@ public class MatchVideoServiceImpl {
|
|
|
matchVideoMapper.updateByPrimaryKeySelective(matchVideo);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private boolean setMatchFail(MatchVideo matchVideo) {
|
|
|
+ String failKey = String.format(FAIL_KEY, matchVideo.getContentId());
|
|
|
+ Integer status = (Integer) redisTemplate.opsForValue().get(failKey);
|
|
|
+ if (status != null) {
|
|
|
+ updateStatus(matchVideo.getId(), status);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //查询相同的contentId,如果已经失败,则直接更新状态为失败
|
|
|
+ MatchVideoExample example = new MatchVideoExample();
|
|
|
+ example.createCriteria().andContentIdEqualTo(matchVideo.getContentId());
|
|
|
+ List<MatchVideo> matchVideos = matchVideoMapper.selectByExample(example);
|
|
|
+ if (!CollectionUtils.isEmpty(matchVideos)) {
|
|
|
+ for (MatchVideo matchVideo1 : matchVideos) {
|
|
|
+ if (matchVideo1.getId().equals(matchVideo.getId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ContentStatusEnum.isFail(matchVideo1.getContentStatus())) {
|
|
|
+ updateStatus(matchVideo.getId(), matchVideo1.getContentStatus());
|
|
|
+ redisTemplate.opsForValue().set(failKey, matchVideo1.getContentStatus(), 1, TimeUnit.DAYS);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|