Sfoglia il codice sorgente

中间指标表导出fix

wangyunpeng 7 mesi fa
parent
commit
f9f0b74743

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

@@ -912,11 +912,9 @@ public class DataDashboardService {
                 .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
         String lessDateStr = DateUtils.getBeforeDayStr(dateStr, "yyyyMMdd", 7);
         List<PublishSortLog> publishSortLogList = publishSortLogRepository.findByDateStrGreaterThanEqual(lessDateStr);
-        Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap = publishSortLogList.stream()
+        Map<String, Map<String, Map<Integer, List<PublishSortLog>>>> publishSortLogMap = publishSortLogList.stream()
                 .collect(Collectors.groupingBy(PublishSortLog::getGhId,
-                        Collectors.groupingBy(PublishSortLog::getDateStr, Collectors.toMap(
-                                PublishSortLog::getIndex, o -> o, (existing, replacement) -> replacement
-                        ))));
+                        Collectors.groupingBy(PublishSortLog::getDateStr, Collectors.groupingBy(PublishSortLog::getIndex))));
         List<NewSortStrategyExport> newSortStrategyExportList = getNewSortStrategyExportList(todayPublish,
                 articleDetailInfoMap, accountAvgInfoIndexMap);
 
@@ -965,10 +963,10 @@ public class DataDashboardService {
             // 发布表现
             setPublishPerformance(item, data, publishSortLogMap);
             // 发布依赖表现
-            setPublishSourcePerformance(item, accountAvgInfoIndexMap, articleDetailInfoMap, publishSortLogMap,
+            setPublishSourcePerformance(item, data, accountAvgInfoIndexMap, articleDetailInfoMap, publishSortLogMap,
                     type, scoreHisPublishTimeMap, wxsnHisDistinctSetMap, list, poolLevel, small, hisPublishMap);
             // 发布未来表现
-            setPublishFuturePerformance(item, data, poolLevel, promotionSourceMap, futurePublishMap, publishSortLogMap, small);
+            setPublishFuturePerformance(item, data, poolLevel, promotionSourceMap, futurePublishMap, small);
 
             titles.add(data.getTitle());
             poolTitles.add(data.getTitle());
@@ -978,15 +976,19 @@ public class DataDashboardService {
     }
 
     private boolean checkIsAigcPublish(Article article,
-                                       Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap) {
-        Map<String, Map<Integer, PublishSortLog>> dateSortMap = publishSortLogMap.get(article.getGhId());
+                                       Map<String, Map<String, Map<Integer, List<PublishSortLog>>>> publishSortLogMap) {
+        Map<String, Map<Integer, List<PublishSortLog>>> dateSortMap = publishSortLogMap.get(article.getGhId());
         if (Objects.nonNull(dateSortMap)) {
             for (String dateStr : dateSortMap.keySet()) {
-                Map<Integer, PublishSortLog> indexMap = dateSortMap.get(dateStr);
+                Map<Integer, List<PublishSortLog>> indexMap = dateSortMap.get(dateStr);
                 if (Objects.nonNull(indexMap)) {
-                    PublishSortLog log = indexMap.get(article.getItemIndex());
-                    if (Objects.nonNull(log) && log.getTitle().equals(article.getTitle())) {
-                        return true;
+                    List<PublishSortLog> logs = indexMap.get(article.getItemIndex());
+                    if (CollectionUtil.isNotEmpty(logs)) {
+                        for (PublishSortLog log : logs) {
+                            if (log.getTitle().equals(article.getTitle())) {
+                                return true;
+                            }
+                        }
                     }
                 }
             }
@@ -1013,7 +1015,6 @@ public class DataDashboardService {
     private void setPublishFuturePerformance(IntermediateIndicatorsExport item, NewSortStrategyExport data, Integer poolLevel,
                                              Map<String, ArticlePoolPromotionSource> promotionSourceMap,
                                              Map<String, List<Article>> futurePublishMap,
-                                             Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap,
                                              List<String> small) {
         int futurePoolLevel = getPromotionPoolLevel(data.getGhId(), data.getTitle(), promotionSourceMap, small);
         if (futurePoolLevel > poolLevel) {
@@ -1161,9 +1162,10 @@ public class DataDashboardService {
     }
 
     private void setPublishSourcePerformance(IntermediateIndicatorsExport item,
+                                             NewSortStrategyExport data,
                                              Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap,
                                              Map<String, List<ArticleDetailInfo>> articleDetailInfoMap,
-                                             Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap,
+                                             Map<String, Map<String, Map<Integer, List<PublishSortLog>>>> publishSortLogMap,
                                              String type,
                                              Map<String, Integer> scoreHisPublishTimeMap,
                                              Map<String, Set<String>> wxsnHisDistinctSetMap,
@@ -1235,23 +1237,30 @@ public class DataDashboardService {
                         (item.getActualArticleReleaseCount() - 1) + firstLayerFissionToViewBaseRatio) / item.getActualArticleReleaseCount();
             }
             item.setAverageFirstLayerFissionToViewBaseRatio(averageFirstLayerFissionToViewBaseRatio);
-            Map<String, Map<Integer, PublishSortLog>> dateSortMap = publishSortLogMap.get(publish.getGhId());
+            Map<String, Map<Integer, List<PublishSortLog>>> dateSortMap = publishSortLogMap.get(publish.getGhId());
             if (Objects.nonNull(dateSortMap)) {
                 String publishDateStr = DateUtils.timestampToYMDStr(publish.getPublishTimestamp(), "yyyyMMdd");
-                Map<Integer, PublishSortLog> indexMap = dateSortMap.get(publishDateStr);
+                Map<Integer, List<PublishSortLog>> indexMap = dateSortMap.get(publishDateStr);
                 if (Objects.nonNull(indexMap)) {
-                    PublishSortLog log = indexMap.get(publish.getItemIndex());
-                    double scoreAvg = item.getRedundantAccountArticleRelevanceAvg();
-                    double score = 0.0;
-                    if (Objects.nonNull(log) && Objects.nonNull(log.getScore())) {
-                        JSONObject scoreMap = JSONObject.parseObject(log.getScoreMap());
-                        if (scoreMap.containsKey("SimilarityStrategy")) {
-                            score = scoreMap.getDoubleValue("SimilarityStrategy");
+                    List<PublishSortLog> logs = indexMap.get(publish.getItemIndex());
+                    if (CollectionUtil.isNotEmpty(logs)) {
+                        for (PublishSortLog log : logs) {
+                            if (log.getTitle().equals(data.getTitle())) {
+                                double scoreAvg = item.getRedundantAccountArticleRelevanceAvg();
+                                double score = 0.0;
+                                if (Objects.nonNull(log.getScore())) {
+                                    JSONObject scoreMap = JSONObject.parseObject(log.getScoreMap());
+                                    if (scoreMap.containsKey("SimilarityStrategy")) {
+                                        score = scoreMap.getDoubleValue("SimilarityStrategy");
+                                    }
+                                }
+                                scorePublishTime++;
+                                scoreAvg = (scoreAvg * (scorePublishTime - 1) + score) / scorePublishTime;
+                                item.setRedundantAccountArticleRelevanceAvg(scoreAvg);
+                                break;
+                            }
                         }
                     }
-                    scorePublishTime++;
-                    scoreAvg = (scoreAvg * (scorePublishTime - 1) + score) / scorePublishTime;
-                    item.setRedundantAccountArticleRelevanceAvg(scoreAvg);
                 }
             }
             double firstExplorationIntervalAvg = Double.isNaN(item.getFirstExplorationIntervalAvg()) ? 0.0 : item.getFirstExplorationIntervalAvg();
@@ -1264,7 +1273,7 @@ public class DataDashboardService {
     }
 
     private void setPublishPerformance(IntermediateIndicatorsExport item, NewSortStrategyExport data,
-                                       Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap) {
+                                       Map<String, Map<String, Map<Integer, List<PublishSortLog>>>> publishSortLogMap) {
         if (Objects.isNull(data.getFirstLevel())) {
             return;
         }
@@ -1296,21 +1305,28 @@ public class DataDashboardService {
         if (item.getT0FissionCount() + item.getT1FissionCount() + item.getT2FissionCount() > 0 && item.getViewBase() > 0) {
             item.setT2CumulativeFissionRate((item.getT0FissionCount() + item.getT1FissionCount() + item.getT2FissionCount()) / (double) item.getFirstLayerUV());
         }
-        Map<String, Map<Integer, PublishSortLog>> dateSortMap = publishSortLogMap.get(data.getGhId());
+        Map<String, Map<Integer, List<PublishSortLog>>> dateSortMap = publishSortLogMap.get(data.getGhId());
         if (Objects.nonNull(dateSortMap)) {
-            Map<Integer, PublishSortLog> indexMap = dateSortMap.get(item.getDateStr());
+            Map<Integer, List<PublishSortLog>> indexMap = dateSortMap.get(item.getDateStr());
             if (Objects.nonNull(indexMap)) {
-                PublishSortLog log = indexMap.get(data.getPosition());
-                double scoreAvg = item.getAccountArticleRelevanceAvg();
-                double score = 0.0;
-                if (Objects.nonNull(log) && Objects.nonNull(log.getScore())) {
-                    JSONObject scoreMap = JSONObject.parseObject(log.getScoreMap());
-                    if (scoreMap.containsKey("SimilarityStrategy")) {
-                        score = scoreMap.getDoubleValue("SimilarityStrategy");
+                List<PublishSortLog> logs = indexMap.get(data.getPosition());
+                if (CollectionUtil.isNotEmpty(logs)) {
+                    for (PublishSortLog log : logs) {
+                        if (log.getTitle().equals(data.getTitle())) {
+                            double scoreAvg = item.getAccountArticleRelevanceAvg();
+                            double score = 0.0;
+                            if (Objects.nonNull(log.getScore())) {
+                                JSONObject scoreMap = JSONObject.parseObject(log.getScoreMap());
+                                if (scoreMap.containsKey("SimilarityStrategy")) {
+                                    score = scoreMap.getDoubleValue("SimilarityStrategy");
+                                }
+                            }
+                            scoreAvg = (scoreAvg * (item.getActualArticleReleaseCount() - 1) + score) / item.getActualArticleReleaseCount();
+                            item.setAccountArticleRelevanceAvg(scoreAvg);
+                            break;
+                        }
                     }
                 }
-                scoreAvg = (scoreAvg * (item.getActualArticleReleaseCount() - 1) + score) / item.getActualArticleReleaseCount();
-                item.setAccountArticleRelevanceAvg(scoreAvg);
             }
         }
     }