Parcourir la source

Merge branch 'wyp/1205-promotionFeishu' of Server/long-article-recommend into master

wangyunpeng il y a 7 mois
Parent
commit
2cd47aadf8

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/FeishuRobotIdEnum.java

@@ -8,6 +8,7 @@ import java.util.Objects;
 public enum FeishuRobotIdEnum {
     RECOMMEND("长文排序报警群", "07026a9f-43f5-448b-ba40-a8d71bd6e634"),
     JOB("定时任务报警群", "186c9798-5b6a-4ff8-b7fc-4ce4b6ea5076"),
+    DAILY("长文每日更新报警群", "b44333f2-16c0-4cb1-af01-d135f8704410"),
 
     ;
 

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -515,7 +515,7 @@ public class XxlJobService {
         articlePromotionService.articlePromotion("【1】", "direct", "头条利用池_v2",
                 "头条利用池_v4", 250, 1.21, Lists.newArrayList(2));
         articlePromotionService.articlePromotion("【2】", "direct", "次条利用池_v1",
-                "条利用池_v4", 100, 1.33, Lists.newArrayList(3, 4, 5, 6, 7, 8));
+                "条利用池_v4", 100, 1.33, Lists.newArrayList(3, 4, 5, 6, 7, 8));
         return ReturnT.SUCCESS;
     }
 }

+ 27 - 17
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticlePromotionService.java

@@ -118,6 +118,8 @@ public class ArticlePromotionService {
             aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, urlList, tag, CrawlerModeEnum.ContentIDs.getVal());
             return;
         }
+        List<String> publishContentIds = new ArrayList<>();
+        List<String> filterUrlList = new ArrayList<>();
         try {
             String level = pos.equals("【1】") ? contentPoolType.get(0) : contentPoolType.get(1);
             String produceId = produceConfig.get(accountNickName).get(pos).get(way).trim();
@@ -129,8 +131,6 @@ public class ArticlePromotionService {
             Set<String> visitedUrlIdList = contentList.stream().map(content -> getUrlId(content.getReferContentLink()))
                     .collect(Collectors.toSet());
             // 筛选URL和标题
-            List<String> publishContentIds = new ArrayList<>();
-            List<String> filterUrlList = new ArrayList<>();
             for (DatastatSortStrategy item : list) {
                 String url = item.getLink();
                 String urlId = getUrlId(item.getLink());
@@ -155,32 +155,42 @@ public class ArticlePromotionService {
                     }
                 }
             }
-            if (filterUrlList.isEmpty()) {
-                log.info("url_list empty: " + accountNickName + ", " + pos + ", " + way);
-                return;
-            }
-            String planName = String.format("%d_%s_%s_%s【%s】_%s", filterUrlList.size(), today, accountNickName, pos, way, today);
-            log.info("url_len: " + list.size() + ", " + filterUrlList.size());
-            IdNameVO<String> planInfo = aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, filterUrlList, tag, CrawlerModeEnum.ContentIDs.getVal());
-            if (StringUtils.hasText(produceId)) {
-                articleAddDependPlan(produceId, planInfo.getId(), planInfo.getName());
+            if (CollectionUtils.isNotEmpty(filterUrlList)) {
+                String planName = String.format("%d_%s_%s_%s【%s】_%s", filterUrlList.size(), today, accountNickName, pos, way, today);
+                log.info("url_len: " + list.size() + ", " + filterUrlList.size());
+                IdNameVO<String> planInfo = aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, filterUrlList, tag, CrawlerModeEnum.ContentIDs.getVal());
+                if (StringUtils.hasText(produceId)) {
+                    articleAddDependPlan(produceId, planInfo.getId(), planInfo.getName());
+                }
+                log.info("{}, {}, produce plan not exist: {}, {}, {}", planInfo.getName(), planInfo.getId(), accountNickName, pos, way);
             }
-            log.info("{}, {}, produce plan not exist: {}, {}, {}", planInfo.getName(), planInfo.getId(), accountNickName, pos, way);
             if (CollectionUtils.isNotEmpty(publishContentIds)) {
-                planName = String.format("%d_%s_%s_%s【%s】_%s", publishContentIds.size(), today, accountNickName, pos, way, today);
-                planInfo = aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, publishContentIds, tag, CrawlerModeEnum.PublishContentIds.getVal());
+                String planName = String.format("%d_%s_%s_%s【%s】_%s", publishContentIds.size(), today, accountNickName, pos, way, today);
+                IdNameVO<String> planInfo = aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, publishContentIds, tag, CrawlerModeEnum.PublishContentIds.getVal());
                 if (StringUtils.hasText(produceId)) {
                     articleAddDependPlan(produceId, planInfo.getId(), planInfo.getName());
                 }
             }
         } catch (Exception e) {
             log.error("articlePromotion error: ", e);
-            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.JOB.getRobotId(),
-                    "文章晋升ERROR:\n" +
-                            "articlePromotion error: " + e.getMessage());
+            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.DAILY.getRobotId(),
+                    "【文章晋升ERROR】\n" +
+                            "晋级任务:" + accountNickName + "\n" +
+                            "articlePromotion error: " + e.getMessage() + "\n"
+                            + "<at user_id=\"all\">所有人</at> ");
+        } finally {
+            sendFeishuJobFinishMessage(accountNickName, filterUrlList.size(), publishContentIds.size());
         }
     }
 
+    private void sendFeishuJobFinishMessage(String accountNickName, Integer urlListSize, Integer contentListSize) {
+        FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.DAILY.getRobotId(),
+                "【文章晋级job完成】\n" +
+                        "晋级任务:" + accountNickName + "\n" +
+                        "url晋级数量:" + urlListSize + "\n" +
+                        "id晋级数量:" + contentListSize + "\n");
+    }
+
     private List<ProduceContentListItemVO> getProduceContentList(String accountNickName, String pos, String way) {
         List<String> planIdList = getProducePlanIdList(accountNickName, pos, way);
         CommonListDataVO<ProduceContentListItemVO> contentData = getProduceContentListByPlanIdList(planIdList);