|
@@ -301,71 +301,13 @@ public class MatchVideoServiceImpl {
|
|
|
if (matchVideo.getContentStatus() != ContentStatusEnum.DEFAULT.getStatusCode()) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(matchVideo.getVideoPoolTraceId())) {
|
|
|
- //已经存在结果 直接设置
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
- //1.执行kimi任务
|
|
|
LongArticlesText kimiText = kimiService.getKimiText(matchVideo.getContentId());
|
|
|
if (kimiText == null) {
|
|
|
return;
|
|
|
}
|
|
|
- //执行kimi任务
|
|
|
- if (kimiText.getKimiStatus() == 0) {
|
|
|
- //已经存在结果 直接设置
|
|
|
- if (existMatchVideoResult(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);
|
|
|
- if (lock) {
|
|
|
- log.info("processKimiMatchContent lock lockKey={}", lockKey);
|
|
|
- addStartProcessingTime(matchVideo.getContentId());
|
|
|
- boolean res = kimiService.updateKimiContent(matchVideo.getContentId());
|
|
|
- if (res) {
|
|
|
- updateStatus(matchVideo.getId(), ContentStatusEnum.KIMI_SUCCESS.getStatusCode());
|
|
|
- } else {
|
|
|
- String countKey = String.format(KIMI_FAIL_COUNT_KEY, matchVideo.getContentId());
|
|
|
- Integer count = (Integer) redisTemplate.opsForValue().get(countKey);
|
|
|
- if (count != null && count >= 3) {
|
|
|
- //更新状态为失败
|
|
|
- LarkRobotUtil.sendMessage("kimiService updateKimiContent fail contentId=" + matchVideo.getContentId());
|
|
|
- log.error("kimiService updateKimiContent fail contentId={}", matchVideo.getContentId());
|
|
|
- kimiService.updateKimiContentStatus(matchVideo.getContentId(), 2);
|
|
|
- failMatchVideo(matchVideo);
|
|
|
- } else {
|
|
|
- if (count == null) {
|
|
|
- redisTemplate.opsForValue().set(countKey, 1, 3, TimeUnit.DAYS);
|
|
|
- } else {
|
|
|
- redisTemplate.opsForValue().set(countKey, count + 1, 3, TimeUnit.DAYS);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("processKimiMatchContent unlock lockKey={}", lockKey);
|
|
|
- redisLock.unlock(lockKey, lockValue);
|
|
|
- }
|
|
|
- } else if (kimiText.getKimiStatus() == 1) {
|
|
|
- //更新状态为kimi执行完成
|
|
|
+ if(kimiText.getKimiStatus() == 1){
|
|
|
updateStatus(matchVideo.getId(), ContentStatusEnum.KIMI_SUCCESS.getStatusCode());
|
|
|
- } else if (kimiText.getKimiStatus() == 2) {
|
|
|
- failMatchVideo(matchVideo);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public void matchCrawlerVideo() throws InterruptedException {
|
|
@@ -423,46 +365,7 @@ public class MatchVideoServiceImpl {
|
|
|
return;
|
|
|
}
|
|
|
boolean existCrawlerVideo = crawlerVideoService.existCrawlerVideo(matchVideo.getContentId());
|
|
|
- log.info("processCrawlerMatchContent contentId={} existCrawlerVideo={}", matchVideo.getContentId(), existCrawlerVideo);
|
|
|
- if (!existCrawlerVideo) {
|
|
|
- //已经存在结果 直接设置
|
|
|
- if (existMatchVideoResult(matchVideo)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- String lockKey = String.format(CRAWLER_LOCK_KEY, matchVideo.getContentId());
|
|
|
- String lockValue = UUID.randomUUID().toString();
|
|
|
- boolean lock = redisLock.tryLock(lockKey, lockValue, 20, TimeUnit.MINUTES);
|
|
|
- if (lock) {
|
|
|
- LongArticlesText kimiText = kimiService.getKimiText(matchVideo.getContentId());
|
|
|
- if (kimiText.getKimiStatus() == 1) {
|
|
|
- String rootContentId = getRootContentId(matchVideo.getContentId());
|
|
|
- boolean res = crawlerVideoService.addCrawlerVideo(matchVideo.getContentId(), rootContentId, kimiText);
|
|
|
- if (res) {
|
|
|
- updateStatus(matchVideo.getId(), ContentStatusEnum.CRAWLER_SUCCESS.getStatusCode());
|
|
|
- } else {
|
|
|
- //匹配失败记录
|
|
|
- String countKey = String.format(CRAWLER_FAIL_COUNT_KEY, matchVideo.getContentId());
|
|
|
- Integer count = (Integer) redisTemplate.opsForValue().get(countKey);
|
|
|
- if (count != null && count >= 3) {
|
|
|
- //更新状态为失败
|
|
|
-// LarkRobotUtil.sendMessage("crawlerVideoService addCrawlerVideo fail contentId=" + matchVideo.getContentId());
|
|
|
- log.error("crawlerVideoService addCrawlerVideo fail contentId={}", matchVideo.getContentId());
|
|
|
- failMatchVideo(matchVideo);
|
|
|
- } else {
|
|
|
- if (count == null) {
|
|
|
- redisTemplate.opsForValue().set(countKey, 1, 3, TimeUnit.DAYS);
|
|
|
- } else {
|
|
|
- redisTemplate.opsForValue().set(countKey, count + 1, 3, TimeUnit.DAYS);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (kimiText.getKimiStatus() == 2) {
|
|
|
- failMatchVideo(matchVideo);
|
|
|
- }
|
|
|
- redisLock.unlock(lockKey, lockValue);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //更新状态为爬虫执行完成
|
|
|
+ if(existCrawlerVideo){
|
|
|
updateStatus(matchVideo.getId(), ContentStatusEnum.CRAWLER_SUCCESS.getStatusCode());
|
|
|
}
|
|
|
}
|