|
@@ -2,7 +2,9 @@ package com.tzld.longarticle.recommend.server.service.recommend;
|
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
import com.tzld.longarticle.recommend.server.common.CommonThreadPoolExecutor;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishContentTypeEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolPromotionSourceStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
@@ -115,33 +117,13 @@ public class ArticleService {
|
|
|
if (CollectionUtils.isEmpty(publishContentList)) {
|
|
|
return;
|
|
|
}
|
|
|
- log.info("syncAigcIdByWxSn publishContentList finish");
|
|
|
- Map<String, PublishContent> publishContentMap = publishContentList.stream().collect(
|
|
|
- Collectors.toMap(PublishContent::getId, publishContent -> publishContent));
|
|
|
- List<String> publishContentIds = publishContentList.stream().map(PublishContent::getId).collect(Collectors.toList());
|
|
|
- List<PublishContentOutput> publishContentOutputList = publishContentOutputRepository.
|
|
|
- getByPublishContentIdInAndContentTypeAndSelectStatus(publishContentIds, PublishContentTypeEnum.title.getVal(), 1);
|
|
|
- Map<String, List<PublishContentOutput>> publishContentOutputMap = publishContentOutputList.stream().collect(
|
|
|
- Collectors.groupingBy(PublishContentOutput::getOutput));
|
|
|
- log.info("syncAigcIdByWxSn publishContentOutputList finish");
|
|
|
- List<String> titles = publishContentOutputList.stream().map(PublishContentOutput::getOutput).collect(Collectors.toList());
|
|
|
String publishContentId = null;
|
|
|
String channelContentId = null;
|
|
|
- if (titles.contains(title)) {
|
|
|
- PublishContent publishContent = getPublishContentByTitle(publishContentOutputMap,
|
|
|
- publishContentMap, title, article.getUpdateTime() * 1000);
|
|
|
+ Long publishTimestamp = article.getUpdateTime() * 1000;
|
|
|
+ PublishContent publishContent = findPublishContent(publishContentList, title, publishTimestamp);
|
|
|
+ if (Objects.nonNull(publishContent)) {
|
|
|
publishContentId = publishContent.getId();
|
|
|
channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
- } else {
|
|
|
- for (String aTitle : titles) {
|
|
|
- if (TitleSimilarCheckUtil.isSimilar(title, aTitle, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
|
|
|
- PublishContent publishContent = getPublishContentByTitle(publishContentOutputMap,
|
|
|
- publishContentMap, aTitle, article.getUpdateTime() * 1000);
|
|
|
- publishContentId = publishContent.getId();
|
|
|
- channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
log.info("syncAigcIdByWxSn titleMatch finish");
|
|
|
if (Objects.isNull(channelContentId)) {
|
|
@@ -158,6 +140,33 @@ public class ArticleService {
|
|
|
result.getRootProduceContentId());
|
|
|
}
|
|
|
|
|
|
+ private PublishContent findPublishContent(List<PublishContent> publishContentList,
|
|
|
+ String title,
|
|
|
+ Long publishTimestamp) {
|
|
|
+ Map<String, PublishContent> publishContentMap = publishContentList.stream().collect(
|
|
|
+ Collectors.toMap(PublishContent::getId, publishContent -> publishContent));
|
|
|
+ List<String> publishContentIds = publishContentList.stream().map(PublishContent::getId).collect(Collectors.toList());
|
|
|
+ List<PublishContentOutput> publishContentOutputList = publishContentOutputRepository.
|
|
|
+ getByPublishContentIdInAndContentTypeAndSelectStatus(publishContentIds, PublishContentTypeEnum.title.getVal(), 1);
|
|
|
+ Map<String, List<PublishContentOutput>> publishContentOutputMap = publishContentOutputList.stream().collect(
|
|
|
+ Collectors.groupingBy(PublishContentOutput::getOutput));
|
|
|
+ List<String> titles = publishContentOutputList.stream().map(PublishContentOutput::getOutput).collect(Collectors.toList());
|
|
|
+ PublishContent publishContent = null;
|
|
|
+ if (titles.contains(title)) {
|
|
|
+ publishContent = getPublishContentByTitle(publishContentOutputMap, publishContentMap, title,
|
|
|
+ publishTimestamp);
|
|
|
+ } else {
|
|
|
+ for (String aTitle : titles) {
|
|
|
+ if (TitleSimilarCheckUtil.isSimilar(title, aTitle, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
|
|
|
+ publishContent = getPublishContentByTitle(publishContentOutputMap, publishContentMap, aTitle,
|
|
|
+ publishTimestamp);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return publishContent;
|
|
|
+ }
|
|
|
+
|
|
|
private PublishContent getPublishContentByTitle(Map<String, List<PublishContentOutput>> publishContentOutputMap,
|
|
|
Map<String, PublishContent> publishContentMap,
|
|
|
String title,
|
|
@@ -216,37 +225,15 @@ public class ArticleService {
|
|
|
if (CollectionUtils.isEmpty(publishContentList)) {
|
|
|
return result;
|
|
|
}
|
|
|
- Map<String, PublishContent> publishContentMap = publishContentList.stream().collect(
|
|
|
- Collectors.toMap(PublishContent::getId, publishContent -> publishContent));
|
|
|
- List<String> publishContentIds = publishContentList.stream().map(PublishContent::getId).collect(Collectors.toList());
|
|
|
- List<PublishContentOutput> publishContentOutputList = publishContentOutputRepository.
|
|
|
- getByPublishContentIdInAndContentTypeAndSelectStatus(publishContentIds, PublishContentTypeEnum.title.getVal(), 1);
|
|
|
- Map<String, List<PublishContentOutput>> publishContentOutputMap = publishContentOutputList.stream().collect(
|
|
|
- Collectors.groupingBy(PublishContentOutput::getOutput));
|
|
|
- List<String> titles = publishContentOutputList.stream().map(PublishContentOutput::getOutput).collect(Collectors.toList());
|
|
|
- if (titles.contains(title)) {
|
|
|
- PublishContent publishContent = getPublishContentByTitle(publishContentOutputMap,
|
|
|
- publishContentMap, title, crawlerContent.getPublishTimestamp());
|
|
|
+ Long publishTimestamp = crawlerContent.getPublishTimestamp();
|
|
|
+ PublishContent publishContent = findPublishContent(publishContentList, title, publishTimestamp);
|
|
|
+ if (Objects.nonNull(publishContent)) {
|
|
|
if (!StringUtils.hasText(sourcePublishContentId)) {
|
|
|
result.setSourcePublishContentId(publishContent.getId());
|
|
|
}
|
|
|
result.setRootPublishContentId(publishContent.getId());
|
|
|
result.setRootProduceContentId(publishContent.getSourceId());
|
|
|
channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
- } else {
|
|
|
- for (String aTitle : titles) {
|
|
|
- if (TitleSimilarCheckUtil.isSimilar(title, aTitle, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
|
|
|
- PublishContent publishContent = getPublishContentByTitle(publishContentOutputMap,
|
|
|
- publishContentMap, aTitle, crawlerContent.getPublishTimestamp());
|
|
|
- if (!StringUtils.hasText(sourcePublishContentId)) {
|
|
|
- result.setSourcePublishContentId(publishContent.getId());
|
|
|
- }
|
|
|
- result.setRootPublishContentId(publishContent.getId());
|
|
|
- result.setRootProduceContentId(publishContent.getSourceId());
|
|
|
- channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
// channelContentId未被修改,说明未找到
|
|
|
if (channelContentId.equals(crawlerContent.getChannelContentId())) {
|
|
@@ -270,17 +257,17 @@ public class ArticleService {
|
|
|
} else {
|
|
|
tasks = articlePoolPromotionSourceRepository.getByStatus(0);
|
|
|
}
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
for (ArticlePoolPromotionSource task : tasks) {
|
|
|
// 溯源
|
|
|
RootPublishContentVO source = getRootPublishContent(task.getChannelContentId(), null, null, null, 0);
|
|
|
// 更新
|
|
|
if (StringUtils.hasText(source.getRootProduceContentId())) {
|
|
|
- // TODO(11-06): enum
|
|
|
- task.setStatus(1);
|
|
|
+ task.setStatus(ArticlePoolPromotionSourceStatusEnum.FINISH.getCode());
|
|
|
task.setSourcePublishContentId(source.getSourcePublishContentId());
|
|
|
task.setRootProduceContentId(source.getRootProduceContentId());
|
|
|
task.setRootPublishContentId(source.getRootPublishContentId());
|
|
|
- task.setUpdateTimestamp(System.currentTimeMillis());
|
|
|
+ task.setUpdateTimestamp(now);
|
|
|
articlePoolPromotionSourceRepository.save(task);
|
|
|
// 保存中间环节 晋级溯源
|
|
|
for (String midChannelContentId : source.getMidChannelContentIds()) {
|
|
@@ -304,9 +291,10 @@ public class ArticleService {
|
|
|
}
|
|
|
longArticleBaseMapper.updateRootProduceContentLevel(task.getRootProduceContentId(), task.getLevel());
|
|
|
} else {
|
|
|
- // TODO(11-06): 要修改
|
|
|
- task.setDeleted(1);
|
|
|
- articlePoolPromotionSourceRepository.save(task);
|
|
|
+ if (task.getCreateTimestamp() < now - 86400) {
|
|
|
+ task.setDeleted(StatusEnum.SUCCESS.getCode());
|
|
|
+ articlePoolPromotionSourceRepository.save(task);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|