Browse Source

Merge branch 'wyp/1122-exportPromotion' of Server/long-article-recommend into master

wangyunpeng 7 months ago
parent
commit
ad8bdcca50

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

@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
 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.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
@@ -17,6 +18,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.PublishSortLog;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatScore;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy;
 import com.tzld.longarticle.recommend.server.model.param.MiniprogramTaskParam;
@@ -31,6 +33,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInf
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.DatastatScoreRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
@@ -85,6 +88,8 @@ public class DataDashboardService {
     private DatastatScoreRepository datastatScoreRepository;
     @Autowired
     private ArticleCategoryRepository articleCategoryRepository;
+    @Autowired
+    private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
 
     @ApolloJsonValue("${export.account.ghId:[]}")
     private static List<String> ghIdList;
@@ -873,6 +878,10 @@ public class DataDashboardService {
         List<Article> futurePublishList = articleRepository.getByPublishTimestampGreaterThanAndTypeEquals(dateEnd, ArticleTypeEnum.QUNFA.getVal());
         Map<String, List<Article>> futurePublishMap = futurePublishList.stream().collect(Collectors.groupingBy(Article::getTitle));
 
+        List<ArticlePoolPromotionSource> promotionSourceList = articlePoolPromotionSourceRepository.getByStatusAndDeleted(1, 0);
+        Map<String, ArticlePoolPromotionSource> promotionSourceMap = promotionSourceList.stream()
+                .collect(Collectors.toMap(ArticlePoolPromotionSource::getTitle, Function.identity(), (a, b) -> a));
+
         Map<String, List<String>> titleTypeMap = new HashMap<>();
         Map<String, Integer> scoreHisPublishTimeMap = new HashMap<>();
         Map<String, Map<Integer, List<String>>> titleTypePoolMap = new HashMap<>();
@@ -914,7 +923,7 @@ public class DataDashboardService {
             setPublishSourcePerformance(item, accountAvgInfoIndexMap, articleDetailInfoMap, publishSortLogMap,
                     type, scoreHisPublishTimeMap, wxsnHisDistinctSetMap, list, poolLevel, small, hisPublishMap);
             // 发布未来表现
-            setPublishFuturePerformance(item, data, poolLevel, futurePublishMap, publishSortLogMap, small);
+            setPublishFuturePerformance(item, data, poolLevel, promotionSourceMap, futurePublishMap, publishSortLogMap, small);
 
             titles.add(data.getTitle());
             poolTitles.add(data.getTitle());
@@ -957,14 +966,11 @@ 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) {
-        List<Article> futurePublishList = futurePublishMap.get(data.getTitle());
-        if (CollectionUtils.isEmpty(futurePublishList)) {
-            return;
-        }
-        int futurePoolLevel = getArticlePoolLevel(data.getGhId(), futurePublishList, small);
+        int futurePoolLevel = getPromotionPoolLevel(data.getGhId(), data.getTitle(), promotionSourceMap, small);
         if (futurePoolLevel > poolLevel) {
             if (futurePoolLevel == 2) {
                 item.setPromotionCountL2(item.getPromotionCountL2() + 1);
@@ -977,6 +983,10 @@ public class DataDashboardService {
                 item.setPromotionRateL4((item.getPromotionCountL4() * 1.0) / item.getActualArticleReleaseCount());
             }
         }
+        List<Article> futurePublishList = futurePublishMap.get(data.getTitle());
+        if (CollectionUtils.isEmpty(futurePublishList)) {
+            return;
+        }
         if (Objects.isNull(data.getSecondFirstLevel())) {
             return;
         }
@@ -1067,6 +1077,26 @@ public class DataDashboardService {
         item.setT3PlusDayViewBase(item.getT3PlusDayViewBase());
     }
 
+    private int getPromotionPoolLevel(String ghId, String title,
+                                      Map<String, ArticlePoolPromotionSource> promotionSourceMap,
+                                      List<String> small) {
+        ArticlePoolPromotionSource promotionSource = promotionSourceMap.get(title);
+        if (Objects.isNull(promotionSource)) {
+            return 1;
+        }
+        if (promotionSource.getLevel().equals(ContentPoolEnum.autoArticlePoolLevel1.getContentPool())) {
+            if (small.contains(ghId)) {
+                return 3;
+            } else {
+                return 4;
+            }
+        } else if (promotionSource.getLevel().equals(ContentPoolEnum.autoArticlePoolLevel3.getContentPool())) {
+            return 2;
+        } else {
+            return 1;
+        }
+    }
+
     private List<NewSortStrategyExport> getNewSortStrategyExportList(List<Article> todayPublish,
                                                                      Map<String, List<ArticleDetailInfo>> articleDetailInfoMap,
                                                                      Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap) {

+ 5 - 1
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/DataDashboardTest.java

@@ -1,11 +1,14 @@
 package com.tzld.longarticle.recommend.server;
 
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.model.vo.IntermediateIndicatorsExport;
 import com.tzld.longarticle.recommend.server.service.recommend.DataDashboardService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 @SpringBootTest(classes = Application.class)
 @Slf4j
@@ -16,6 +19,7 @@ public class DataDashboardTest {
 
     @Test
     public void test() {
-        dataDashboardService.intermediateIndicatorsData("20241008");
+        List<IntermediateIndicatorsExport> result = dataDashboardService.intermediateIndicatorsData("20241122");
+        log.info(JSONObject.toJSONString(result));
     }
 }