Procházet zdrojové kódy

Merge branch 'wyp/0612-articleCategory' of Server/long-article-recommend into master

wangyunpeng před 1 měsícem
rodič
revize
f609a8e525

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/aigc/ProducePlanRepository.java

@@ -10,4 +10,5 @@ import java.util.List;
 public interface ProducePlanRepository extends JpaRepository<ProducePlan, String> {
 
     List<ProducePlan> findByIdIn(List<String> planIds);
+
 }

+ 23 - 11
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleCategoryService.java

@@ -6,10 +6,12 @@ import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleCategoryStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolPromotionSourceStatusEnum;
+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.ArticleCategoryMapper;
 import com.tzld.longarticle.recommend.server.model.dto.CrawlerContent;
 import com.tzld.longarticle.recommend.server.model.dto.kimi.KimiResult;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlan;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRecord;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCrawlerPlan;
@@ -22,6 +24,7 @@ import com.tzld.longarticle.recommend.server.model.vo.ProduceContentCrawlerVO;
 import com.tzld.longarticle.recommend.server.remote.CrawlerContentByPlanService;
 import com.tzld.longarticle.recommend.server.remote.DeepSeekApiService;
 import com.tzld.longarticle.recommend.server.remote.KimiApiService;
+import com.tzld.longarticle.recommend.server.repository.aigc.ProducePlanRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCrawlerPlanRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
@@ -60,6 +63,8 @@ public class ArticleCategoryService {
     KimiApiService kimiApiService;
     @Autowired
     DeepSeekApiService deepSeekApiService;
+    @Autowired
+    ProducePlanRepository producePlanRepository;
 
     @ApolloJsonValue("${cold.pool.produce.planId:[\"20240802021606053813696\", \"20240802080355355308981\",\n" +
             "\"20240805154433785506170\", \"20240805154359027876170\", \"20241024100016206421084\", " +
@@ -181,6 +186,12 @@ public class ArticleCategoryService {
     }
 
     private void addColdArticleCategoryByProducePlan() {
+        List<String> producePlanIds = aigcBaseMapper.getProducePlanId();
+        List<ProducePlan> producePlanList = producePlanRepository.findByIdIn(producePlanIds);
+        producePlanIds = producePlanList.stream()
+                .filter(o -> StringUtils.hasText(o.getPlanTag())
+                        && o.getPlanTag().contains(ContentPoolEnum.autoArticlePoolLevel4.getContentPool()))
+                .map(ProducePlan::getId).collect(Collectors.toList());
         List<ArticleCategory> saveList = addArticleCategoryByProducePlan(producePlanIds);
         if (CollectionUtils.isNotEmpty(saveList)) {
             articleCategoryMapper.batchInsertArticleCategory(saveList);
@@ -188,17 +199,15 @@ public class ArticleCategoryService {
     }
 
     private void addPromotionArticleCategoryByProducePlan() {
-        List<String> articlePromotionProducePlanIds = new ArrayList<>();
         // 获取晋级生成计划Id
-        for (Map.Entry<String, Map<String, Map<String, String>>> oneEntry : produceConfig.entrySet()) {
-            for (Map.Entry<String, Map<String, String>> twoEntry : oneEntry.getValue().entrySet()) {
-                twoEntry.getValue().forEach((key, value) -> {
-                    if (StringUtils.hasText(value) && !producePlanIds.contains(value)) {
-                        articlePromotionProducePlanIds.add(value);
-                    }
-                });
-            }
-        }
+        List<String> producePlanIds = aigcBaseMapper.getProducePlanId();
+        List<ProducePlan> producePlanList = producePlanRepository.findByIdIn(producePlanIds);
+        List<String> articlePromotionProducePlanIds = producePlanList.stream()
+                .filter(o -> StringUtils.hasText(o.getPlanTag())
+                        && (o.getPlanTag().contains(ContentPoolEnum.autoArticlePoolLevel1.getContentPool())
+                        || o.getPlanTag().contains(ContentPoolEnum.autoArticlePoolLevel2.getContentPool())))
+                .map(ProducePlan::getId).collect(Collectors.toList());
+
         List<ArticleCategory> saveList = addArticleCategoryByProducePlan(articlePromotionProducePlanIds);
         // 已晋级文章 先溯源查找源内容品类,查询不到再用kimi进行分类
         if (CollectionUtils.isNotEmpty(saveList)) {
@@ -266,7 +275,10 @@ public class ArticleCategoryService {
     private List<ArticleCategory> addArticleCategoryByProducePlan(List<String> producePlanIds) {
         List<ProducePlanExeRecord> produceContentList = aigcBaseMapper.getAllByProducePlanId(producePlanIds);
         List<String> channelContentIds = produceContentList.stream().map(ProducePlanExeRecord::getChannelContentId).distinct().collect(Collectors.toList());
-        List<ArticleCategory> articleCategoryList = articleCategoryRepository.getAllByChannelContentIdInAndVersion(channelContentIds, activeVersion);
+        List<ArticleCategory> articleCategoryList = new ArrayList<>();
+        for (List<String> partition : Lists.partition(channelContentIds, 1000)) {
+            articleCategoryList.addAll(articleCategoryRepository.getAllByChannelContentIdInAndVersion(partition, activeVersion));
+        }
         List<String> articleCategoryIds = articleCategoryList.stream().map(ArticleCategory::getChannelContentId).collect(Collectors.toList());
         List<ProduceContentCrawlerVO> list = produceContentList.stream().filter(o -> !articleCategoryIds.contains(o.getChannelContentId())).map(o -> {
             ProduceContentCrawlerVO item = new ProduceContentCrawlerVO();

+ 1 - 1
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -37,7 +37,7 @@
 
     <select id="getAllByProducePlanId"
             resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRecord">
-        select *
+        select plan_exe_id, channel_content_id
         from produce_plan_exe_record
         where plan_id in
         <foreach collection="producePlanIds" item="item" open="(" close=")" separator=",">