Pārlūkot izejas kodu

评分计算报警修改

wangyunpeng 6 dienas atpakaļ
vecāks
revīzija
66f6dd827a

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

@@ -5,7 +5,6 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.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;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.HttpEntity;
@@ -72,6 +71,7 @@ public class NLPRemoteService {
             bodyParam.put("min_time", accountScoreMinTimeMap.get(accountName));
         }
         int retry = 0;
+        int errorCount = 0;
         while (retry < 2) {
             retry++;
             try {
@@ -107,20 +107,18 @@ public class NLPRemoteService {
                     }
                 }
             } catch (Exception e) {
-                feishuMessageSender.sendChat(chatId, "4090计算评分失败",
-                        MapBuilder.<String, String>builder(new LinkedHashMap<>())
-                                .put("url", url)
-                                .put("账号名称", accountName)
-                                .build());
-                FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
-                        "4090计算评分失败\n"
-                        + "url: " + url +"\n"
-                        + "账号名称: " + accountName);
+                errorCount++;
                 url = backUrl;
                 client = HttpPoolFactory.thirtySecondPool();
                 log.error("score error", e);
             }
         }
+        if (errorCount > 0) {
+            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
+                    "4090计算评分失败\n"
+                            + "url: " + url + "\n"
+                            + "账号名称: " + accountName);
+        }
         log.info("score耗时:{}", System.currentTimeMillis() - start);
         return Collections.emptyMap();
     }