Преглед на файлове

Merge branch 'master' into wyp/1017-rank1314

wangyunpeng преди 9 месеца
родител
ревизия
2dd555e205

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

@@ -0,0 +1,31 @@
+package com.tzld.longarticle.recommend.server.common.enums;
+
+import lombok.Getter;
+
+import java.util.Objects;
+
+@Getter
+public enum FeishuRobotIdEnum {
+    recommend("长文排序报警群", "07026a9f-43f5-448b-ba40-a8d71bd6e634"),
+    job("定时任务报警群", "186c9798-5b6a-4ff8-b7fc-4ce4b6ea5076"),
+
+    ;
+
+    private final String groupName;
+    private final String robotId;
+
+
+    FeishuRobotIdEnum(String groupName, String robotId) {
+        this.groupName = groupName;
+        this.robotId = robotId;
+    }
+
+    public static FeishuRobotIdEnum from(String groupName) {
+        for (FeishuRobotIdEnum robotEnum : FeishuRobotIdEnum.values()) {
+            if (Objects.equals(robotEnum.groupName, groupName)) {
+                return robotEnum;
+            }
+        }
+        return recommend;
+    }
+}

+ 3 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/NLPRemoteService.java

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.remote;
 import com.alibaba.fastjson.JSONObject;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
+import com.tzld.longarticle.recommend.server.common.enums.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.util.MapBuilder;
 import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
@@ -17,7 +18,6 @@ import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
 
 import java.nio.charset.StandardCharsets;
 import java.util.*;
@@ -101,7 +101,8 @@ public class NLPRemoteService {
                                 .put("url", url)
                                 .put("账号名称", accountName)
                                 .build());
-                FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634", "4090计算评分失败\n"
+                FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.recommend.getRobotId(),
+                        "4090计算评分失败\n"
                         + "url: " + url +"\n"
                         + "账号名称: " + accountName);
                 url = backUrl;

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

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.service;
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.enums.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.NotPublishPlan;
@@ -80,7 +81,7 @@ public class XxlJobService {
         if (CollectionUtil.isNotEmpty(publishAccounts)) {
             accountNames = publishAccounts.stream().map(PublishAccount::getName).collect(Collectors.toList());
         }
-        FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
+        FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.recommend.getRobotId(),
                 "发布计划超1H未发送完成\n"
                         + "发布计划ID: " + publishPlan.getPlanId() + "\n"
                         + "发布计划名称: " + publishPlan.getPlanName() + "\n"
@@ -146,6 +147,10 @@ public class XxlJobService {
             }
         } catch (Exception e) {
             log.error("Error processCrawlerEachData: {}", JSONObject.toJSONString(longArticlesVideo), e);
+            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.job.getRobotId(),
+                    "processCrawlerEachData 异常\n"
+                    + "异常数据: " + JSONObject.toJSONString(longArticlesVideo) + "\n"
+                    + "错误信息:" + e.getMessage());
         }
     }
 
@@ -193,6 +198,10 @@ public class XxlJobService {
             }
         } catch (Exception e) {
             log.error("Error processArticleEachData: {}", JSONObject.toJSONString(longArticlesMatchVideo), e);
+            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.job.getRobotId(),
+                    "processArticleEachData 异常\n"
+                            + "异常数据: " + JSONObject.toJSONString(longArticlesMatchVideo) + "\n"
+                            + "错误信息:" + e.getMessage());
         }
     }
 

+ 7 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallService.java

@@ -2,6 +2,7 @@ package com.tzld.longarticle.recommend.server.service.recall;
 
 import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.tzld.longarticle.recommend.server.common.enums.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.dto.ContentHisPublishArticle;
@@ -141,7 +142,8 @@ public class RecallService implements ApplicationContextAware {
     private List<Content> getAllContent(RecallParam param) {
         List<Content> content = aigcRemoteService.getAllContent(param);
         if (CollectionUtils.isEmpty(content)) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634", "内容召回失败\n"
+            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.recommend.getRobotId(),
+                    "内容召回失败\n"
                     + "ghId: " + param.getGhId() + "\n"
                     + "账号名称: " + param.getAccountName());
             return content;
@@ -298,7 +300,8 @@ public class RecallService implements ApplicationContextAware {
                         avgViewCount = Optional.ofNullable(indexMap.get(hisArticle.getItemIndex().toString()).getReadAvg())
                                 .orElse(0.0).intValue();
                     } else {
-                        FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634", "历史表现阅读均值获取失败\n"
+                        FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.recommend.getRobotId(),
+                                "历史表现阅读均值获取失败\n"
                                 + "ghId: " + hisArticle.getGhId() + "\n"
                                 + "账号名称: " + hisArticle.getAccountName() + "\n"
                                 + "日期: " + hisPublishDate + "\n"
@@ -356,7 +359,8 @@ public class RecallService implements ApplicationContextAware {
             if (CollectionUtils.isEmpty(article.getArticleDetailInfoList())) {
                 // 仅判断7.12以后发布文章
                 if (article.getUpdateTime() > 1720713600 && contentHisFeishuEnable) {
-                    FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634", "历史表现裂变特征获取失败\n"
+                    FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.recommend.getRobotId(),
+                            "历史表现裂变特征获取失败\n"
                             + "ghId: " + article.getGhId() + "\n"
                             + "账号名称: " + article.getAccountName() + "\n"
                             + "位置: " + article.getItemIndex() + "\n"