Pārlūkot izejas kodu

Merge branch 'wyp/1126-wuxianliuExport' of Server/long-article-recommend into master

wangyunpeng 7 mēneši atpakaļ
vecāks
revīzija
96ea35522b

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

@@ -10,6 +10,7 @@ import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
@@ -196,9 +197,10 @@ public class DataDashboardService {
                 .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
         List<PublishSortLog> sortLogList = publishSortLogRepository.findByGhIdInAndDateStrBetween(ghIds, beginDate, endDate);
         log.info("newSortStrategyData sortLogList finish");
-        Map<String, Map<String, String>> sortStrategyMap = sortLogList.stream()
+        Map<String, Map<String, Map<String, String>>> sortStrategyMap = sortLogList.stream()
                 .collect(Collectors.groupingBy(PublishSortLog::getGhId,
-                        Collectors.toMap(PublishSortLog::getDateStr, PublishSortLog::getStrategy, (existing, replacement) -> existing)));
+                        Collectors.groupingBy(PublishSortLog::getDateStr, Collectors.toMap(PublishSortLog::getTitle,
+                                PublishSortLog::getStrategy, (existing, replacement) -> existing))));
         Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap = accountAvgInfoList.stream()
                 .filter(o -> Objects.nonNull(o.getReadAvg()) && o.getReadAvg() > 0 && o.getFans() > 1000)
                 .collect(Collectors.groupingBy(AccountAvgInfo::getGhId, Collectors.groupingBy(AccountAvgInfo::getUpdateTime,
@@ -336,7 +338,7 @@ public class DataDashboardService {
             List<ArticleDetailInfo> articleDetailInfos = articleDetailInfoMap.get(article.getWxSn());
             setObjArticleDetailInfo(article, obj, articleDetailInfos);
             Article firstArticle = articleMap.get(article.getGhId()).get(article.getAppMsgId()).get(1);
-            Map<String, String> dateStrategy = sortStrategyMap.get(article.getGhId());
+            Map<String, Map<String, String>> dateStrategy = sortStrategyMap.get(article.getGhId());
             AccountAvgInfo avgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
                     article.getPublishTimestamp(), article.getItemIndex());
             AccountAvgInfo firstAvgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
@@ -350,7 +352,25 @@ public class DataDashboardService {
                 obj.setFirstAvgViewCount(firstAvgInfo.getReadAvg());
             }
             if (Objects.nonNull(dateStrategy)) {
-                obj.setStrategy(dateStrategy.get(date));
+                Map<String, String> titleStrategyMap = dateStrategy.get(date);
+                if (Objects.nonNull(titleStrategyMap)) {
+                    String strategy = titleStrategyMap.get(article.getTitle());
+                    if (!StringUtils.hasText(strategy)) {
+                        if (Objects.equals(articleType, ArticleTypeEnum.WUXIANLIU.getVal())) {
+                            strategy = RankStrategyEnum.INFINITE_STRATEGY.getStrategy();
+                        } else {
+                            for (Map.Entry<String, String> entry : titleStrategyMap.entrySet()) {
+                                strategy = entry.getValue();
+                                break;
+                            }
+                        }
+                    }
+                    obj.setStrategy(strategy);
+                }
+            }
+            if (!StringUtils.hasText(obj.getStrategy()) &&
+                    Objects.equals(articleType, ArticleTypeEnum.WUXIANLIU.getVal())) {
+                obj.setStrategy(RankStrategyEnum.INFINITE_STRATEGY.getStrategy());
             }
             setObjAvgInfo(article, obj, avgInfo);
             setObjHisRateInfo(article, obj, hisArticleMap, accountAvgInfoIndexMap, hisArticleDetailInfoMap);