|
@@ -1,5 +1,6 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.recommend;
|
|
|
|
|
|
+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;
|
|
@@ -8,8 +9,10 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolP
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
|
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.vo.IdNameVO;
|
|
|
import com.tzld.longarticle.recommend.server.model.vo.WxContentDetailResponse;
|
|
|
import com.tzld.longarticle.recommend.server.model.vo.aigc.CommonListDataVO;
|
|
@@ -22,14 +25,17 @@ import com.tzld.longarticle.recommend.server.remote.aigc.AIGCProduceContentListS
|
|
|
import com.tzld.longarticle.recommend.server.remote.aigc.AIGCProducePlanDetailService;
|
|
|
import com.tzld.longarticle.recommend.server.remote.aigc.AIGCProducePlanSaveService;
|
|
|
import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.DatastatSortStrategyRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.longArticle.PublishSingleVideoSourceRepository;
|
|
|
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 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.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -62,6 +68,10 @@ public class ArticlePromotionService {
|
|
|
PublishAccountRepository publishAccountRepository;
|
|
|
@Autowired
|
|
|
ArticleService articleService;
|
|
|
+ @Autowired
|
|
|
+ PublishSortLogRepository publishSortLogRepository;
|
|
|
+ @Autowired
|
|
|
+ PublishSingleVideoSourceRepository publishSingleVideoSourceRepository;
|
|
|
|
|
|
@ApolloJsonValue("${articlePromotionProduceConfig:{}}")
|
|
|
private Map<String, Map<String, Map<String, String>>> produceConfig;
|
|
@@ -75,7 +85,7 @@ public class ArticlePromotionService {
|
|
|
// 获取内部表现
|
|
|
List<DatastatSortStrategy> list = longArticleBaseMapper.getArticlePromotion(viewCountFilter, viewCountRateFilter,
|
|
|
10000, dateStrFilter, positionFilter);
|
|
|
- list = filterEarlyContent(list);
|
|
|
+ list = filterEarlyContent(list, true);
|
|
|
log.info("优质{}文章数量: {}", accountNickName, list.size());
|
|
|
List<DatastatSortStrategy> distinct = filterSameTitle(list);
|
|
|
distinct.sort(Comparator.comparing(DatastatSortStrategy::getDateStr, Comparator.reverseOrder()));
|
|
@@ -83,7 +93,7 @@ public class ArticlePromotionService {
|
|
|
addUrlListToAccount(accountNickName, distinct, pos, way, today, tag);
|
|
|
}
|
|
|
|
|
|
- private List<DatastatSortStrategy> filterEarlyContent(List<DatastatSortStrategy> list) {
|
|
|
+ private List<DatastatSortStrategy> filterEarlyContent(List<DatastatSortStrategy> list, Boolean filterVideoPool) {
|
|
|
List<String> ghIds = list.stream().map(DatastatSortStrategy::getGhId).distinct().collect(Collectors.toList());
|
|
|
List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
|
|
|
Map<String, Long> publishAccountCreateTimeMap = publishAccountList.stream().collect(Collectors.toMap(
|
|
@@ -91,8 +101,13 @@ public class ArticlePromotionService {
|
|
|
list = list.stream().filter(o -> {
|
|
|
long publishTime = DateUtils.dateStrToTimestamp(o.getDateStr(), "yyyyMMdd");
|
|
|
Long accountCreateTime = publishAccountCreateTimeMap.get(o.getGhId());
|
|
|
- return publishTime * 1000 > accountCreateTime
|
|
|
- && !PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal().equals(o.getSourceType());
|
|
|
+ if (filterVideoPool) {
|
|
|
+ return publishTime * 1000 > accountCreateTime
|
|
|
+ && !PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal().equals(o.getSourceType());
|
|
|
+ } else {
|
|
|
+ return publishTime * 1000 > accountCreateTime
|
|
|
+ && PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal().equals(o.getSourceType());
|
|
|
+ }
|
|
|
}).collect(Collectors.toList());
|
|
|
return list;
|
|
|
}
|
|
@@ -356,4 +371,64 @@ public class ArticlePromotionService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void articleVideoPoolPromotion(Integer viewCountFilter, Double viewCountRateFilter,
|
|
|
+ List<Integer> positionFilter, Integer poolLevel) {
|
|
|
+ String dateStrFilter = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 10);
|
|
|
+ // 获取内部表现
|
|
|
+ List<DatastatSortStrategy> list = longArticleBaseMapper.getArticlePromotion(viewCountFilter, viewCountRateFilter,
|
|
|
+ 10000, dateStrFilter, positionFilter);
|
|
|
+ list = filterEarlyContent(list, false);
|
|
|
+ log.info("视频内容池优质文章数量: {}", list.size());
|
|
|
+ List<DatastatSortStrategy> distinct = filterSameTitle(list);
|
|
|
+ distinct.sort(Comparator.comparing(DatastatSortStrategy::getDateStr, Comparator.reverseOrder()));
|
|
|
+ log.info("视频内容池优质文章数量(去重后): {}", distinct.size());
|
|
|
+ saveArticleVideoPoolPromotion(distinct, poolLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveArticleVideoPoolPromotion(List<DatastatSortStrategy> promotionList, Integer poolLevel) {
|
|
|
+ if (CollectionUtils.isEmpty(promotionList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> ghIds = promotionList.stream().map(DatastatSortStrategy::getGhId).distinct().collect(Collectors.toList());
|
|
|
+ List<String> dateStr = promotionList.stream().map(DatastatSortStrategy::getDateStr).distinct().collect(Collectors.toList());
|
|
|
+ List<PublishSortLog> sortLogList = publishSortLogRepository.getByGhIdInAndDateStrIn(ghIds, dateStr);
|
|
|
+ Map<String, Map<String, List<PublishSortLog>>> sortLogMap = sortLogList.stream()
|
|
|
+ .collect(Collectors.groupingBy(PublishSortLog::getGhId,
|
|
|
+ Collectors.groupingBy(PublishSortLog::getDateStr)));
|
|
|
+ for (DatastatSortStrategy data : promotionList) {
|
|
|
+ List<PublishSortLog> logs = sortLogMap.get(data.getGhId()).get(data.getDateStr());
|
|
|
+ if (CollectionUtils.isEmpty(logs)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String sourceId = null;
|
|
|
+ for (PublishSortLog publishSortLog : logs) {
|
|
|
+ if (data.getTitle().equals(publishSortLog.getTitle())) {
|
|
|
+ sourceId = publishSortLog.getSourceId();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(sourceId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PublishSingleVideoSource singleVideoSource = publishSingleVideoSourceRepository.getByContentTraceId(sourceId);
|
|
|
+ if (Objects.isNull(singleVideoSource)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PublishSingleVideoSource exists = publishSingleVideoSourceRepository.getByUpLevelSource(sourceId);
|
|
|
+ if (Objects.nonNull(exists)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PublishSingleVideoSource upLevel = new PublishSingleVideoSource();
|
|
|
+ BeanUtils.copyProperties(singleVideoSource, upLevel);
|
|
|
+ singleVideoSource.setBadStatus(1);
|
|
|
+ singleVideoSource.setUpLevelTimestamp(System.currentTimeMillis() / 1000);
|
|
|
+ publishSingleVideoSourceRepository.save(singleVideoSource);
|
|
|
+ upLevel.setId(null);
|
|
|
+ upLevel.setUpLevelSource(singleVideoSource.getContentTraceId());
|
|
|
+ upLevel.setContentTraceId("video" + UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ upLevel.setFlowPoolLevel(poolLevel);
|
|
|
+ publishSingleVideoSourceRepository.save(upLevel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|