| 
					
				 | 
			
			
				@@ -4,15 +4,21 @@ 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.CrawlerContent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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 +39,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 +81,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 +195,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 +204,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 +359,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 +371,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 +448,43 @@ 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> channelContentIds = publishContentList.stream().map(PublishContentDTO::getCrawlerChannelContentId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<CrawlerContent> crawlerContentList = aigcBaseMapper.getCrawlerContentByChannelContentIdIn(channelContentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Long> crawlerContentMap = crawlerContentList.stream().collect(Collectors.toMap( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CrawlerContent::getChannelContentId, CrawlerContent::getId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long crawlerContentId = crawlerContentMap.get(item.getCrawlerChannelContentId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (Objects.isNull(crawlerContentId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            articleAddDependPlan(topProducePlanId, String.valueOf(crawlerContentId), inputSourceLabel, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ProducePlanInputSourceTypeEnum.contentID.getVal()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ReturnT.SUCCESS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |