瀏覽代碼

修改kimi失败状态

xueyiming 5 月之前
父節點
當前提交
e1c3ff169d

+ 2 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/KimiService.java

@@ -7,4 +7,6 @@ public interface KimiService {
     LongArticlesText getKimiText(String contentId);
 
     boolean updateKimiContent(String contentId);
+
+    void updateKimiContentStatus(String contentId, Integer status);
 }

+ 10 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/KimiServiceImpl.java

@@ -76,4 +76,14 @@ public class KimiServiceImpl implements KimiService {
         return false;
     }
 
+    public void updateKimiContentStatus(String contentId, Integer status) {
+        LongArticlesTextExample example = new LongArticlesTextExample();
+        example.createCriteria().andContentIdEqualTo(contentId);
+        List<LongArticlesText> longArticlesTexts = longArticlesTextMapper.selectByExampleWithBLOBs(example);
+        if (!CollectionUtils.isEmpty(longArticlesTexts)) {
+            LongArticlesText longArticlesText = longArticlesTexts.get(0);
+            longArticlesText.setKimiStatus(status);
+            longArticlesTextMapper.updateByPrimaryKeySelective(longArticlesText);
+        }
+    }
 }

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

@@ -249,6 +249,7 @@ public class MatchVideoServiceImpl {
                         //更新状态为失败
                         LarkRobotUtil.sendMessage("kimiService updateKimiContent fail contentId=" + matchVideo.getContentId());
                         log.error("kimiService updateKimiContent fail contentId={}", matchVideo.getContentId());
+                        kimiService.updateKimiContentStatus(matchVideo.getContentId(), 2);
                         updateStatus(matchVideo.getId(), ContentStatusEnum.ERROR_99.getStatusCode());
                     } else {
                         if (count == null) {
@@ -334,26 +335,30 @@ public class MatchVideoServiceImpl {
             boolean lock = redisLock.tryLock(lockKey, lockValue, 20, TimeUnit.MINUTES);
             if (lock) {
                 LongArticlesText kimiText = kimiService.getKimiText(matchVideo.getContentId());
-                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());
-                        updateStatus(matchVideo.getId(), ContentStatusEnum.ERROR_99.getStatusCode());
+                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 {
-                        if (count == null) {
-                            redisTemplate.opsForValue().set(countKey, 1, 3, TimeUnit.DAYS);
+                        //匹配失败记录
+                        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());
+                            updateStatus(matchVideo.getId(), ContentStatusEnum.ERROR_99.getStatusCode());
                         } else {
-                            redisTemplate.opsForValue().set(countKey, count + 1, 3, TimeUnit.DAYS);
+                            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) {
+                    updateStatus(matchVideo.getId(), ContentStatusEnum.ERROR_99.getStatusCode());
                 }
                 redisLock.unlock(lockKey, lockValue);
             }