Procházet zdrojové kódy

中间指标数据报警

wangyunpeng před 2 týdny
rodič
revize
b992add6bb

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

@@ -46,6 +46,7 @@ import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.MapBuilder;
 import com.tzld.longarticle.recommend.server.util.Md5Util;
 import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
+import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
@@ -615,7 +616,7 @@ public class DataDashboardService {
                                    Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap,
                                    Map<String, List<ArticleDetailInfo>> hisArticleDetailInfoMap) {
         List<Article> hisArticles = hisArticleMap.getOrDefault(article.getTitle(), new ArrayList<>());
-        hisArticles = hisArticles.stream().filter(o -> o.getPublishTimestamp() < (article.getPublishTimestamp() - 3600 * 8)
+        hisArticles = hisArticles.stream().filter(o -> o.getPublishTimestamp() < (article.getPublishTimestamp() - 60 * 60 * 8)
                 && (1 == o.getItemIndex() || 2 == o.getItemIndex())
                 && !ScoreStrategy.hisContentLateFilter(o.getPublishTimestamp())).collect(Collectors.toList());
         Integer readCount = 0;
@@ -1074,6 +1075,7 @@ public class DataDashboardService {
         for (String dateStr : dateStrList) {
             newContentsYesData.addAll(intermediateIndicatorsData(dateStr));
         }
+        checkViewCountFeishuAlarm(newContentsYesData);
         newContentsYesData.sort(Comparator.comparing(IntermediateIndicatorsExport::getDateStr).reversed()
                 .thenComparing((o1, o2) -> -o1.getType().compareTo(o2.getType())));
         int rowNum = newContentsYesData.size();
@@ -1134,6 +1136,18 @@ public class DataDashboardService {
         doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 3, styles, null, null);
     }
 
+    private void checkViewCountFeishuAlarm(List<IntermediateIndicatorsExport> newContentsYesData) {
+        for (IntermediateIndicatorsExport data : newContentsYesData) {
+            if (!"L4".equals(data.getType())) {
+                continue;
+            }
+            if (data.getViewCount() < 100000){
+                FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
+                        "【中间指标】 " + data.getDateStr() + "-" + data.getType() + " 阅读量异常");
+            }
+        }
+    }
+
     public List<IntermediateIndicatorsExport> intermediateIndicatorsData(String dateStr) {
         List<IntermediateIndicatorsExport> result = buildIntermediateIndicatorsData(dateStr);
         Map<String, IntermediateIndicatorsExport> resultMap = result.stream().collect(Collectors.toMap(
@@ -1195,7 +1209,7 @@ public class DataDashboardService {
             IntermediateIndicatorsExport item = resultMap.get(type);
             List<Article> list = hisPublishMap.get(data.getTitle());
             Integer poolLevel = getArticlePoolLevel(data.getGhId(), list, small);
-            list = list.stream().filter(publish -> publish.getPublishTimestamp() < (article.getPublishTimestamp() - 3600 * 8))
+            list = list.stream().filter(publish -> publish.getPublishTimestamp() < (article.getPublishTimestamp() - 60 * 60 * 8))
                     .collect(Collectors.toList());
             // L1层仅统计历史发布在3-8位置文章
             if (poolLevel > 1 && "L1".equals(item.getType())) {
@@ -1455,7 +1469,7 @@ public class DataDashboardService {
         for (Article publish : hisPublish) {
             if (poolLevel == 1) {
                 List<Article> list = hisPublishMap.get(publish.getTitle());
-                list = list.stream().filter(o -> o.getPublishTimestamp() < (publish.getPublishTimestamp() - 3600 * 8))
+                list = list.stream().filter(o -> o.getPublishTimestamp() < (publish.getPublishTimestamp() - 60 * 60 * 8))
                         .collect(Collectors.toList());
                 Integer hisPublishPoolLevel = getArticlePoolLevel(publish.getGhId(), list, small);
                 if (hisPublishPoolLevel > poolLevel) {