Ver Fonte

导出兼容无裂变数据

wangyunpeng há 8 meses atrás
pai
commit
0366359ed4

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

@@ -280,7 +280,7 @@ public class DataDashboardService {
         for (Article article : articleList) {
             NewSortStrategyExport obj = new NewSortStrategyExport();
             List<ArticleDetailInfo> articleDetailInfos = articleDetailInfoMap.get(article.getWxSn());
-            setObjLongDetailInfo(article, obj, articleDetailInfos);
+            setObjArticleDetailInfo(article, obj, articleDetailInfos);
             Article firstArticle = articleMap.get(article.getGhId()).get(article.getAppMsgId()).get(1);
             Map<String, String> dateStrategy = sortStrategyMap.get(article.getGhId());
             AccountAvgInfo avgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
@@ -444,7 +444,7 @@ public class DataDashboardService {
         obj.setWxSn(article.getWxSn());
     }
 
-    private void setObjLongDetailInfo(Article article, NewSortStrategyExport obj, List<ArticleDetailInfo> articleDetailInfos) {
+    private void setObjArticleDetailInfo(Article article, NewSortStrategyExport obj, List<ArticleDetailInfo> articleDetailInfos) {
         if (CollectionUtils.isNotEmpty(articleDetailInfos)) {
             Date publishDate = DateUtils.getStartDateOfDay(article.getUpdateTime());
             articleDetailInfos = articleDetailInfos.stream().filter(o -> !o.getRecallDt().before(publishDate))
@@ -510,22 +510,24 @@ public class DataDashboardService {
             obj.setAvgViewCount(avgInfo.getReadAvg());
             if (avgInfo.getReadAvg() > 0) {
                 obj.setReadRate((article.getShowViewCount() * 1.0) / avgInfo.getReadAvg());
-                obj.setFission0ReadAvgRate((obj.getFission0() * 1.0) / avgInfo.getReadAvg());
-                obj.setFission0ReadAvg100Rate((obj.getFission0() * 1.0) / (avgInfo.getReadAvg() + 100));
-                obj.setFission0ReadAvg500Rate((obj.getFission0() * 1.0) / (avgInfo.getReadAvg() + 500));
-                obj.setFission0ReadAvg1000Rate((obj.getFission0() * 1.0) / (avgInfo.getReadAvg() + 1000));
+                if (Objects.nonNull(obj.getFission0())) {
+                    obj.setFission0ReadAvgRate((obj.getFission0() * 1.0) / avgInfo.getReadAvg());
+                    obj.setFission0ReadAvg100Rate((obj.getFission0() * 1.0) / (avgInfo.getReadAvg() + 100));
+                    obj.setFission0ReadAvg500Rate((obj.getFission0() * 1.0) / (avgInfo.getReadAvg() + 500));
+                    obj.setFission0ReadAvg1000Rate((obj.getFission0() * 1.0) / (avgInfo.getReadAvg() + 1000));
+                }
             }
             if (avgInfo.getFans() > 0) {
                 obj.setReadFansRate((article.getShowViewCount() * 1.0) / avgInfo.getFans());
             }
         }
-        if (obj.getFirstLevel() > 0) {
+        if (Objects.nonNull(obj.getFirstLevel()) && obj.getFirstLevel() > 0 && Objects.nonNull(obj.getFission0())) {
             obj.setFission0FirstRate((obj.getFission0() * 1.0) / obj.getFirstLevel());
         }
-        if (article.getShowViewCount() > 0) {
+        if (article.getShowViewCount() > 0 && Objects.nonNull(obj.getFirstLevel())) {
             obj.setFirstReadRate((obj.getFirstLevel() * 1.0) / article.getShowViewCount());
         }
-        if (obj.getFission0() > 0) {
+        if (Objects.nonNull(obj.getFission0()) && obj.getFission0() > 0 && Objects.nonNull(obj.getFission1())) {
             obj.setFission1Fission0Rate((obj.getFission1() * 1.0) / obj.getFission0());
         }
     }
@@ -999,7 +1001,7 @@ public class DataDashboardService {
         for (Article article : todayPublish) {
             NewSortStrategyExport obj = new NewSortStrategyExport();
             List<ArticleDetailInfo> articleDetailInfos = articleDetailInfoMap.get(article.getWxSn());
-            setObjLongDetailInfo(article, obj, articleDetailInfos);
+            setObjArticleDetailInfo(article, obj, articleDetailInfos);
             AccountAvgInfo avgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
                     article.getUpdateTime(), article.getItemIndex());
             String date = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
@@ -1049,19 +1051,21 @@ public class DataDashboardService {
                 item.setAverageViewToBaseRatio(item.getRedundantViewCount() / (double) item.getRedundantViewBase());
             }
             List<ArticleDetailInfo> articleDetailInfos = articleDetailInfoMap.get(publish.getWxSn());
-            if (CollectionUtils.isNotEmpty(articleDetailInfos)) {
-                int sumFirstLevel = 0;
-                int sumFission0 = 0;
-                Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
-                for (ArticleDetailInfo articleDetailInfo : articleDetailInfos) {
-                    if (articleDetailInfo.getRecallDt().equals(minDate)) {
-                        sumFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
-                        sumFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
-                    }
+
+            if (CollectionUtils.isEmpty(articleDetailInfos)) {
+                continue;
+            }
+            int sumFirstLevel = 0;
+            int sumFission0 = 0;
+            Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
+            for (ArticleDetailInfo articleDetailInfo : articleDetailInfos) {
+                if (articleDetailInfo.getRecallDt().equals(minDate)) {
+                    sumFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
+                    sumFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
                 }
-                item.setRedundantFirstLayerUV(item.getRedundantFirstLayerUV() + sumFirstLevel);
-                item.setRedundantT0FissionUV(item.getRedundantT0FissionUV() + sumFission0);
             }
+            item.setRedundantFirstLayerUV(item.getRedundantFirstLayerUV() + sumFirstLevel);
+            item.setRedundantT0FissionUV(item.getRedundantT0FissionUV() + sumFission0);
             double averageMiniAppOpenRate = item.getAverageMiniAppOpenRate();
             if (item.getRedundantFirstLayerUV() > 0 && item.getRedundantViewCount() > 0) {
                 double miniAppOpenRate = item.getRedundantFirstLayerUV() / (double) item.getRedundantViewCount();