Ver código fonte

优质内容生成计划生成

wangyunpeng 4 meses atrás
pai
commit
7b0f88951c

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

@@ -63,4 +63,6 @@ public interface AigcBaseMapper {
     List<ProduceContentDTO> getProduceContentById(List<String> planExeIds);
 
     List<IdNameVO<String>> articleVideoAuditPlanFilterValue(List<String> planIds, String searchKeyword);
+
+    List<String> getProduceContentTitleByPlanId(String planId);
 }

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

@@ -83,4 +83,6 @@ public interface LongArticleBaseMapper {
     void batchInsertLongArticleAuditDelete(List<LongArticleAuditDelete> deleteList);
 
     List<String> getPassContentIds();
+
+    List<DatastatSortStrategy> getTopContent(String dateStr);
 }

+ 4 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/aigc/AIGCProducePlanSaveService.java

@@ -28,14 +28,14 @@ public class AIGCProducePlanSaveService {
 
     private static String apiUrl = "http://aigc-api.cybertogether.net/aigc/produce/plan/save";
 
-    public IdNameVO<String> save(String planName, String planId, ProducePlanDetailVO detail) {
+    public IdNameVO<String> save(String inputSourceLabel, String inputSourceValue, ProducePlanDetailVO detail, Integer inputSourceType) {
         // 添加新的依赖计划
         List<ProducePlanInputSourceParam> inputSources = detail.getInputSourceGroups().get(0).getInputSources();
         ProducePlanInputSourceParam newInputSource = new ProducePlanInputSourceParam();
         newInputSource.setContentType(1);
-        newInputSource.setInputSourceType(2);
-        newInputSource.setInputSourceValue(planId);
-        newInputSource.setInputSourceLabel(String.format("原始帖子-长文-微信公众号-内容添加计划-%s", planName));
+        newInputSource.setInputSourceType(inputSourceType);
+        newInputSource.setInputSourceValue(inputSourceValue);
+        newInputSource.setInputSourceLabel(inputSourceLabel);
         newInputSource.setInputSourceModal(3);
         newInputSource.setInputSourceChannel(5);
         inputSources.add(newInputSource);

+ 55 - 8
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticlePromotionService.java

@@ -4,15 +4,20 @@ import cn.hutool.core.lang.UUID;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.CrawlerModeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.ProducePlanInputSourceTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolPromotionSourceStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
+import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
+import com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
 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.DatastatSortStrategy;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
+import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
 import com.tzld.longarticle.recommend.server.model.vo.IdNameVO;
 import com.tzld.longarticle.recommend.server.model.vo.WxContentDetailResponse;
 import com.tzld.longarticle.recommend.server.model.vo.aigc.CommonListDataVO;
@@ -33,10 +38,13 @@ import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.Md5Util;
 import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
 import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -72,9 +80,15 @@ public class ArticlePromotionService {
     PublishSortLogRepository publishSortLogRepository;
     @Autowired
     PublishSingleVideoSourceRepository publishSingleVideoSourceRepository;
+    @Autowired
+    PublishContentMapper publishContentMapper;
+    @Autowired
+    AigcBaseMapper aigcBaseMapper;
 
     @ApolloJsonValue("${articlePromotionProduceConfig:{}}")
     private Map<String, Map<String, Map<String, String>>> produceConfig;
+    @Value("${topProducePlanId:}")
+    private String topProducePlanId;
 
     private final List<String> contentPoolType = Arrays.asList("autoArticlePoolLevel1", "autoArticlePoolLevel3", "autoArticlePoolLevel4");
 
@@ -180,7 +194,8 @@ public class ArticlePromotionService {
                 log.info("url_len: " + list.size() + ", " + filterUrlList.size());
                 IdNameVO<String> planInfo = aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, filterUrlList, tag, CrawlerModeEnum.ContentIDs.getVal());
                 if (StringUtils.hasText(produceId)) {
-                    articleAddDependPlan(produceId, planInfo.getId(), planInfo.getName());
+                    String inputSourceLabel = String.format("原始帖子-长文-微信公众号-内容添加计划-%s", planInfo.getName());
+                    articleAddDependPlan(produceId, planInfo.getId(), inputSourceLabel, ProducePlanInputSourceTypeEnum.contentPlan.getVal());
                 }
                 log.info("{}, {}, produce plan not exist: {}, {}, {}", planInfo.getName(), planInfo.getId(), accountNickName, pos, way);
             }
@@ -188,7 +203,8 @@ public class ArticlePromotionService {
                 String planName = String.format("%d_%s_%s_%s【%s】_%s", publishContentIds.size(), today, accountNickName, pos, way, today);
                 IdNameVO<String> planInfo = aigcCrawlerPlanSaveService.createArticleUrlPlan(planName, publishContentIds, tag, CrawlerModeEnum.PublishContentIds.getVal());
                 if (StringUtils.hasText(produceId)) {
-                    articleAddDependPlan(produceId, planInfo.getId(), planInfo.getName());
+                    String inputSourceLabel = String.format("原始帖子-长文-微信公众号-内容添加计划-%s", planInfo.getName());
+                    articleAddDependPlan(produceId, planInfo.getId(), inputSourceLabel, ProducePlanInputSourceTypeEnum.contentPlan.getVal());
                 }
             }
             sendFeishuJobFinishMessage(accountNickName, filterUrlList.size(), publishContentIds.size());
@@ -342,7 +358,7 @@ public class ArticlePromotionService {
         articlePoolPromotionSourceRepository.save(articlePromotion);
     }
 
-    private void articleAddDependPlan(String produceId, String planId, String planName) {
+    private void articleAddDependPlan(String produceId, String inputSourceValue, String inputSourceLabel, Integer inputSourceType) {
         try {
             // 获取生产计划的详细信息
             ProducePlanDetailVO detail = aigcProducePlanDetailService.articleGetProducePlanDetail(produceId);
@@ -354,16 +370,16 @@ public class ArticlePromotionService {
             }
             // 获取依赖计划 ID 列表
             List<ProducePlanInputSourceParam> inputSources = detail.getInputSourceGroups().get(0).getInputSources();
-            List<String> dependPlanIds = new ArrayList<>();
+            List<String> dependValues = new ArrayList<>();
             for (ProducePlanInputSourceParam inputSource : inputSources) {
-                dependPlanIds.add(inputSource.getInputSourceValue());
+                dependValues.add(inputSource.getInputSourceValue());
             }
             // 如果计划 ID 已存在,直接返回
-            if (dependPlanIds.contains(planId)) {
-                log.info("depend_plan_id exist: {}", planId);
+            if (dependValues.contains(inputSourceValue)) {
+                log.info("depend_value exist: {}", inputSourceValue);
                 return;
             }
-            aigcProducePlanSaveService.save(planName, planId, detail);
+            aigcProducePlanSaveService.save(inputSourceLabel, inputSourceValue, detail, inputSourceType);
         } catch (Exception e) {
             FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.JOB.getRobotId(),
                     "文章晋升ERROR:\n" +
@@ -431,4 +447,35 @@ public class ArticlePromotionService {
         }
     }
 
+    @XxlJob("topContentReSendJob")
+    public ReturnT<String> topContentReSend(String param) {
+        String dateStr = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 60);
+        if (StringUtils.hasText(param)) {
+            dateStr = param;
+        }
+        List<DatastatSortStrategy> topList = longArticleBaseMapper.getTopContent(dateStr);
+        List<String> ghIds = topList.stream().map(DatastatSortStrategy::getGhId).distinct().collect(Collectors.toList());
+        List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
+        Map<String, String> publishContentMap = publishAccountList.stream().collect(Collectors.toMap(
+                PublishAccount::getGhId, PublishAccount::getId));
+        List<PublishContentParam> publishContentParamList = topList.stream().map(top -> {
+            PublishContentParam item = new PublishContentParam();
+            item.setTitle(top.getTitle());
+            String accountId = publishContentMap.get(top.getGhId());
+            item.setPublishAccountId(accountId);
+            return item;
+        }).collect(Collectors.toList());
+        List<PublishContentDTO> publishContentList = publishContentMapper.getPublishContentByTitle(publishContentParamList);
+        List<String> existsTitles = aigcBaseMapper.getProduceContentTitleByPlanId(topProducePlanId);
+        for (PublishContentDTO item : publishContentList) {
+            if (TitleSimilarCheckUtil.isDuplicateContent(item.getTitle(), existsTitles, TitleSimilarCheckUtil.ARTICLE_PROMOTION_THRESHOLD)) {
+                continue;
+            }
+            existsTitles.add(item.getTitle());
+            String inputSourceLabel = String.format("原始帖子-长文-微信公众号-内容IDs-%s", item.getTitle());
+            articleAddDependPlan(topProducePlanId, item.getCrawlerChannelContentId(), inputSourceLabel,
+                    ProducePlanInputSourceTypeEnum.contentID.getVal());
+        }
+        return ReturnT.SUCCESS;
+    }
 }

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

@@ -282,4 +282,12 @@
         limit 100
     </select>
 
+    <select id="getProduceContentTitleByPlanId" resultType="java.lang.String">
+        select output.output
+        from produce_plan_exe_record pper
+        join produce_plan_module_output output on pper.plan_exe_id = output.plan_exe_id
+        where pper.plan_id = #{planId} and pper.status = 2
+          and output.produce_module_type = 3
+    </select>
+
 </mapper>

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

@@ -297,4 +297,20 @@
         </foreach>
     </insert>
 
+    <select id="getTopContent"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
+        select *
+        from datastat_sort_strategy
+        where date_str &lt; #{dateStr}
+          and type = 9
+          and read_rate > 1
+          and view_count > 10000
+          and position in (1, 2)
+          and title not in (select title from article_unsafe_title)
+          and first_level is not null
+          and strategy is not null
+        order by read_rate desc
+        limit 200
+    </select>
+
 </mapper>