Przeglądaj źródła

每日发布明细增加品类

wangyunpeng 1 tydzień temu
rodzic
commit
67a4b80689

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -27,6 +27,8 @@ public interface AigcBaseMapper {
 
     List<ProduceContentDTO> getProduceContentByPlanId(String planId);
 
+    List<ProduceContentDTO> getProduceContentByPlanExeIds(List<String> producePlanExeIds);
+
     List<ProducePlanExeRecord> getAllByProducePlanId(List<String> producePlanIds);
 
     List<CrawlerPlan> getColdCrawlerPlan(Long timeStart, Long timeEnd, List<String> planTags);

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/DatastatSortStrategy.java

@@ -173,5 +173,7 @@ public class DatastatSortStrategy implements Serializable {
     private Integer sourceType;
     @Column(name = "source_id")
     private String sourceId;
+    @Column(name = "category")
+    private String category;
 
 }

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/NewSortStrategyExport.java

@@ -55,6 +55,7 @@ public class NewSortStrategyExport {
 
     private Integer position;
     private String ghId;
+    private String category;
     private String title;
     private String link;
 //    private String wxSn;

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

@@ -10,6 +10,7 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolE
 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.ProduceContentDTO;
 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;
@@ -275,34 +276,50 @@ 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<String> producePlanExeIds = produceContentList.stream().map(ProducePlanExeRecord::getPlanExeId).distinct().collect(Collectors.toList());
         List<ArticleCategory> articleCategoryList = new ArrayList<>();
-        for (List<String> partition : Lists.partition(channelContentIds, 1000)) {
-            articleCategoryList.addAll(articleCategoryRepository.getAllByChannelContentIdInAndVersion(partition, activeVersion));
+        for (List<String> partition : Lists.partition(producePlanExeIds, 1000)) {
+            articleCategoryList.addAll(articleCategoryRepository.getByProduceContentIdInAndVersion(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();
-            item.setChannelContentId(o.getChannelContentId());
-            item.setProduceContentId(o.getPlanExeId());
-            return item;
-        }).collect(Collectors.toList());
-        channelContentIds = channelContentIds.stream().filter(o -> !articleCategoryIds.contains(o)).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(channelContentIds)) {
+        List<String> articleCategoryIds = articleCategoryList.stream().map(ArticleCategory::getProduceContentId).collect(Collectors.toList());
+        List<ProduceContentCrawlerVO> list = produceContentList.stream()
+                .filter(o -> !articleCategoryIds.contains(o.getPlanExeId()))
+                .map(o -> {
+                    ProduceContentCrawlerVO item = new ProduceContentCrawlerVO();
+                    item.setChannelContentId(o.getChannelContentId());
+                    item.setProduceContentId(o.getPlanExeId());
+                    return item;
+                }).collect(Collectors.toList());
+        producePlanExeIds = producePlanExeIds.stream().filter(o -> !articleCategoryIds.contains(o)).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(producePlanExeIds)) {
             return Collections.emptyList();
         }
-        List<CrawlerContent> crawlerContentList = aigcBaseMapper.getCrawlerContentByChannelContentIdIn(channelContentIds);
-        Map<String, CrawlerContent> map = crawlerContentList.stream().collect(Collectors.toMap(CrawlerContent::getChannelContentId, Function.identity()));
+        List<ProduceContentDTO> contentList = new ArrayList<>();
+        for (List<String> partition : Lists.partition(producePlanExeIds, 1000)) {
+            contentList.addAll(aigcBaseMapper.getProduceContentByPlanExeIds(partition));
+        }
+        Map<String, ProduceContentDTO> map = contentList.stream().collect(Collectors.toMap(ProduceContentDTO::getContentId, Function.identity()));
+
+        List<String> channelContentIds = list.stream().map(ProduceContentCrawlerVO::getChannelContentId).collect(Collectors.toList());
+        List<CrawlerContent> crawlerContentList = new ArrayList<>();
+
+        for (List<String> partition : Lists.partition(channelContentIds, 1000)) {
+            crawlerContentList.addAll(aigcBaseMapper.getCrawlerContentByChannelContentIdIn(partition));
+        }
+        Map<String, CrawlerContent> crawlerContentMap = crawlerContentList.stream().collect(Collectors.toMap(CrawlerContent::getChannelContentId, Function.identity()));
         long now = System.currentTimeMillis();
         List<ArticleCategory> saveList = new ArrayList<>();
         for (ProduceContentCrawlerVO vo : list) {
             ArticleCategory item = new ArticleCategory();
             item.setChannelContentId(vo.getChannelContentId());
             item.setProduceContentId(vo.getProduceContentId());
-            CrawlerContent crawlerContent = map.get(vo.getChannelContentId());
+            CrawlerContent crawlerContent = crawlerContentMap.get(vo.getChannelContentId());
             if (Objects.nonNull(crawlerContent)) {
-                String title = crawlerContent.getTitle();
                 item.setCrawlerPlanId(crawlerContent.getCrawlerPlanId());
+            }
+            ProduceContentDTO contentDTO = map.get(vo.getChannelContentId());
+            if (Objects.nonNull(contentDTO)) {
+                String title = contentDTO.getTitle();
                 item.setTitle(title);
                 item.setTitleMd5(Md5Util.encoderByMd5(title));
                 item.setCreateTimestamp(now);

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

@@ -400,6 +400,13 @@ public class DataDashboardService {
         log.info("newSortStrategyData hisArticleDetailInfoList finish");
         Map<String, List<ArticleDetailInfo>> hisArticleDetailInfoMap = hisArticleDetailInfoList.stream()
                 .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
+        // 品类查询
+        List<ArticleCategory> categoryList = articleCategoryRepository.getByStatusAndVersion(ArticleCategoryStatusEnum.SUCCESS.getCode(), activeVersion);
+        Map<String, ArticleCategory> categoryMap = categoryList.stream()
+                .collect(Collectors.toMap(ArticleCategory::getProduceContentId, Function.identity()));
+        Map<String, ArticleCategory> titleCategoryMap = categoryList.stream()
+                .collect(Collectors.toMap(ArticleCategory::getTitleMd5, Function.identity(), (a, b) -> a));
+        log.info("newSortStrategyData categoryList finish");
 
         // result
         List<DatastatSortStrategy> saveList = new ArrayList<>();
@@ -458,6 +465,14 @@ public class DataDashboardService {
             setObjAigcInfo(article, obj, date, publishAccountMap, publishContentMap, publishContentLayoutMap,
                     publishPlanMap, miniprogramTaskMap, planExeRecordMap, producePlanMap, inputSourceMap,
                     resultRelMap, crawlerPlanMap, sourceTitlePlanMap, videoPoolSourceMap);
+            ArticleCategory articleCategory = categoryMap.get(obj.getSourceId());
+            if (Objects.isNull(articleCategory)) {
+                String titleMd5 = Md5Util.encoderByMd5(obj.getTitle());
+                articleCategory = titleCategoryMap.get(titleMd5);
+            }
+            if (Objects.nonNull(articleCategory)) {
+                obj.setCategory(articleCategory.getCategory());
+            }
             saveList.add(obj);
         }
         log.info("newSortStrategyData buildData finish");
@@ -1288,6 +1303,13 @@ public class DataDashboardService {
         log.info("newSortStrategyFWHData hisArticleDetailInfoList finish");
         Map<String, List<ArticleDetailInfo>> hisArticleDetailInfoMap = hisArticleDetailInfoList.stream()
                 .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
+        // 品类查询
+        List<ArticleCategory> categoryList = articleCategoryRepository.getByStatusAndVersion(ArticleCategoryStatusEnum.SUCCESS.getCode(), activeVersion);
+        Map<String, ArticleCategory> categoryMap = categoryList.stream()
+                .collect(Collectors.toMap(ArticleCategory::getProduceContentId, Function.identity()));
+        Map<String, ArticleCategory> titleCategoryMap = categoryList.stream()
+                .collect(Collectors.toMap(ArticleCategory::getTitleMd5, Function.identity(), (a, b) -> a));
+        log.info("newSortStrategyFWHData categoryList finish");
 
         // result
         List<DatastatSortStrategy> saveList = new ArrayList<>();
@@ -1338,6 +1360,14 @@ public class DataDashboardService {
             setObjAigcInfo(article, obj, date, publishAccountMap, publishContentMap, publishContentLayoutMap,
                     publishPlanMap, miniprogramTaskMap, planExeRecordMap, producePlanMap, inputSourceMap,
                     resultRelMap, crawlerPlanMap, sourceTitlePlanMap, videoPoolSourceMap);
+            ArticleCategory articleCategory = categoryMap.get(obj.getSourceId());
+            if (Objects.isNull(articleCategory)) {
+                String titleMd5 = Md5Util.encoderByMd5(obj.getTitle());
+                articleCategory = titleCategoryMap.get(titleMd5);
+            }
+            if (Objects.nonNull(articleCategory)) {
+                obj.setCategory(articleCategory.getCategory());
+            }
             saveList.add(obj);
         }
         log.info("newSortStrategyFWHData buildData finish");

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

@@ -35,6 +35,19 @@
         where record.plan_id = #{planId} and record.status = 2 and audit_status in (1, 4, 5, 6)
     </select>
 
+    <select id="getProduceContentByPlanExeIds" resultType="com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO">
+        select distinct record.channel_content_id as contentId,
+               output.output             as title
+        from produce_plan_exe_record record
+         join produce_plan_module_output output
+          on record.plan_exe_id = output.plan_exe_id and output.produce_module_type = 3
+        where record.plan_exe_id in
+        <foreach collection="producePlanExeIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+         and record.status = 2 and audit_status in (1, 4, 5, 6)
+    </select>
+
     <select id="getAllByProducePlanId"
             resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRecord">
         select plan_exe_id, channel_content_id

+ 2 - 2
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -29,7 +29,7 @@
         link, wx_sn, fission0_read_avg_100_rate, fission0_read_avg_500_rate, fission0_read_avg_1000_rate,
         crawler_plan_name, crawler_plan_tag, produce_plan_name, produce_plan_tag, publish_plan_name,
         publish_mini_program_insert_strategy, publish_mini_program_insert_use_type, publish_mini_program_num,
-        source_produce_plan_name, account_create_timestamp, publish_timestamp, type, source_type, source_id)
+        source_produce_plan_name, account_create_timestamp, publish_timestamp, type, source_type, source_id, category)
         VALUES
         <foreach collection="list" item="item" separator=",">
             (#{item.dateStr}, #{item.publishTime}, #{item.accountMode}, #{item.accountSource}, #{item.accountType},
@@ -53,7 +53,7 @@
             #{item.producePlanName}, #{item.producePlanTag}, #{item.publishPlanName},
             #{item.publishMiniProgramInsertStrategy}, #{item.publishMiniProgramInsertUseType},
             #{item.publishMiniProgramNum}, #{item.sourceProducePlanName}, #{item.accountCreateTimestamp},
-            #{item.publishTimestamp}, #{item.type}, #{item.sourceType}, #{item.sourceId})
+            #{item.publishTimestamp}, #{item.type}, #{item.sourceType}, #{item.sourceId}, #{item.category})
         </foreach>
     </insert>