Selaa lähdekoodia

每日发布-明细 增加 源生成计划名称

wangyunpeng 9 kuukautta sitten
vanhempi
commit
f132586bf8

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

@@ -1,6 +1,7 @@
 package com.tzld.longarticle.recommend.server.mapper.aigc;
 
 import com.tzld.longarticle.recommend.server.model.dto.NotPublishPlan;
+import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.*;
 import com.tzld.longarticle.recommend.server.model.param.MiniprogramTaskParam;
 import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
@@ -24,4 +25,6 @@ public interface AigcBaseMapper {
     Integer getPublishPlanPushType(String planId);
 
     List<PublishAccount> getPublishAccounts(String planId, Long todayStart);
+
+    List<ProduceContentDTO> getSourceProduceContentByTitles(List<String> titleList);
 }

+ 15 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/ProduceContentDTO.java

@@ -0,0 +1,15 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ProduceContentDTO {
+
+    private String contentId;
+    private String title;
+    private Long produceTimestamp;
+    private String producePlanId;
+
+}

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

@@ -65,5 +65,7 @@ public class NewSortStrategyExport {
     private String publishMiniProgramInsertUseType;
     // 发布内容小程序数量
     private Integer publishMiniProgramNum;
+    // 源生成计划名称
+    private String sourceProducePlanName;
 
 }

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

@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.enums.AccountBusinessTypeEnum;
 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;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.*;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
@@ -247,6 +248,9 @@ public class DataDashboardService {
         }
         Map<String, List<PublishPlanMiniprogramTask>> miniprogramTaskMap = miniprogramTaskList.stream()
                 .collect(Collectors.groupingBy(PublishPlanMiniprogramTask::getPlanId));
+        // 源生成计划
+        List<String> titleList = articleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
+        Map<String, ProducePlan> sourceTitlePlanMap = getTitleSourceProducePlanMap(titleList);
         // result
         List<NewSortStrategyExport> result = new ArrayList<>();
         for (Article article : articleList) {
@@ -427,6 +431,10 @@ public class DataDashboardService {
                     }
                 }
             }
+            ProducePlan sourceProducePlan = sourceTitlePlanMap.get(article.getTitle());
+            if (Objects.nonNull(sourceProducePlan)) {
+                obj.setSourceProducePlanName(sourceProducePlan.getName());
+            }
         }
         result.sort(Comparator.comparing(NewSortStrategyExport::getDateStr).reversed()
                 .thenComparing(NewSortStrategyExport::getGhId).thenComparing(NewSortStrategyExport::getPosition));
@@ -445,6 +453,35 @@ public class DataDashboardService {
         return result;
     }
 
+    private Map<String, ProducePlan> getTitleSourceProducePlanMap(List<String> titleList) {
+        List<ProduceContentDTO> sourceProduceContentList = new ArrayList<>();
+        for (List<String> partitions : Lists.partition(titleList, 1000)) {
+            sourceProduceContentList.addAll(aigcBaseMapper.getSourceProduceContentByTitles(partitions));
+        }
+        Map<String, List<ProduceContentDTO>> sourceProduceContentMap =  sourceProduceContentList.stream()
+                .collect(Collectors.groupingBy(ProduceContentDTO::getTitle));
+        Map<String, String> sourceTitlePlanIdMap = new HashMap<>();
+        List<String> sourceProducePlanIds = new ArrayList<>();
+        for (Map.Entry<String, List<ProduceContentDTO>> entry : sourceProduceContentMap.entrySet()) {
+            String title = entry.getKey();
+            List<ProduceContentDTO> contentList = entry.getValue();
+            contentList.sort(Comparator.comparing(ProduceContentDTO::getProduceTimestamp));
+            sourceTitlePlanIdMap.put(title, contentList.get(0).getProducePlanId());
+            sourceProducePlanIds.add(contentList.get(0).getProducePlanId());
+        }
+        List<ProducePlan> sourceProducePlanList = producePlanRepository.findByIdIn(sourceProducePlanIds);
+        Map<String, ProducePlan> sourceProducePlanMap = sourceProducePlanList.stream()
+                .collect(Collectors.toMap(ProducePlan::getId, o -> o));
+        Map<String, ProducePlan> sourceTitlePlanMap = new HashMap<>();
+        for (Map.Entry<String, String> entry : sourceTitlePlanIdMap.entrySet()) {
+            String title = entry.getKey();
+            String planId = entry.getValue();
+            ProducePlan plan = sourceProducePlanMap.get(planId);
+            sourceTitlePlanMap.put(title, plan);
+        }
+        return sourceTitlePlanMap;
+    }
+
 
     private static void doSendFeishuSheet(List<String> dateStrList, String sheetToken, String sheetId,
                                           int rowNum, List<List<Object>> rows, Integer startRowIndex,

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

@@ -97,6 +97,19 @@
            and content.publish_timestamp > #{todayStart}
         WHERE planAccount.plan_id = #{planId} and content.id is null and planAccount.publish_open_flag = 1
     </select>
+    <select id="getSourceProduceContentByTitles"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO">
+        select record.plan_exe_id as contentId,
+               output.output as title,
+               record.produce_timestamp as produceTimestamp,
+               record.plan_id as producePlanId
+        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 output.output in
+        <foreach collection="titleList" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
 
 
 </mapper>