Просмотр исходного кода

增加kimi失败3次设置为失败

xueyiming 5 месяцев назад
Родитель
Сommit
07da847383

+ 16 - 2
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/MatchVideoServiceImpl.java

@@ -45,6 +45,8 @@ public class MatchVideoServiceImpl {
 
     private static final String UPLOAD_CRAWLER_FAIL_COUNT_KEY = "upload_crawler_count_key_%s";
 
+    private static final String KIMI_FAIL_COUNT_KEY = "kimi_count_key_%s";
+
 
     @Autowired
     KimiService kimiService;
@@ -235,8 +237,20 @@ public class MatchVideoServiceImpl {
                 if (res) {
                     updateStatus(matchVideo.getId(), ContentStatusEnum.KIMI_SUCCESS.getStatusCode());
                 } else {
-                    LarkRobotUtil.sendMessage("kimiService updateKimiContent fail contentId=" + matchVideo.getContentId());
-                    log.error("kimiService updateKimiContent fail contentId={}", matchVideo.getContentId());
+                    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());
+                        updateStatus(matchVideo.getId(), ContentStatusEnum.ERROR_99.getStatusCode());
+                    } 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);