|
@@ -153,6 +153,13 @@ public class ArticleService {
|
|
|
if (Objects.nonNull(publishContent)) {
|
|
|
publishContentId = publishContent.getId();
|
|
|
channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
+ } else {
|
|
|
+ publishContentList = aigcBaseMapper.getLateNearestPublishContent(publishAccount.getId(), publishTimestamp);
|
|
|
+ publishContent = findPublishContent(publishContentList, article.getTitle(), publishTimestamp);
|
|
|
+ if (Objects.nonNull(publishContent)) {
|
|
|
+ publishContentId = publishContent.getId();
|
|
|
+ channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
+ }
|
|
|
}
|
|
|
log.info("syncAigcIdByWxSn titleMatch finish");
|
|
|
if (Objects.isNull(channelContentId)) {
|
|
@@ -172,6 +179,9 @@ public class ArticleService {
|
|
|
private PublishContent findPublishContent(List<PublishContent> publishContentList,
|
|
|
String title,
|
|
|
Long publishTimestamp) {
|
|
|
+ if (CollectionUtils.isEmpty(publishContentList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
Map<String, PublishContent> publishContentMap = publishContentList.stream().collect(
|
|
|
Collectors.toMap(PublishContent::getId, publishContent -> publishContent));
|
|
|
List<String> publishContentIds = publishContentList.stream().map(PublishContent::getId).collect(Collectors.toList());
|
|
@@ -262,6 +272,17 @@ public class ArticleService {
|
|
|
result.setRootPublishContentId(publishContent.getId());
|
|
|
result.setRootProduceContentId(publishContent.getSourceId());
|
|
|
channelContentId = publishContent.getCrawlerChannelContentId();
|
|
|
+ } else {
|
|
|
+ publishContentList = aigcBaseMapper.getLateNearestPublishContent(publishAccount.getId(), publishTimestamp);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
}
|
|
|
// channelContentId未被修改,说明未找到
|
|
|
if (channelContentId.equals(crawlerContent.getChannelContentId())) {
|
|
@@ -287,64 +308,72 @@ public class ArticleService {
|
|
|
}
|
|
|
long now = System.currentTimeMillis();
|
|
|
for (ArticlePoolPromotionSource task : tasks) {
|
|
|
- // 判断文章是否被抓回来,如果没有抓回来,不进行处理 临时方案
|
|
|
- CrawlerContent crawlerContent = aigcBaseMapper.getCrawlerContentByChannelContentId(task.getChannelContentId());
|
|
|
- if (Objects.isNull(crawlerContent)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 溯源
|
|
|
- Article article = articleRepository.getByWxSn(task.getWxSn());
|
|
|
- if (Objects.isNull(article)) {
|
|
|
- task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
- articlePoolPromotionSourceRepository.save(task);
|
|
|
- continue;
|
|
|
- }
|
|
|
- PublishAccount publishAccount = publishAccountRepository.getByGhId(article.getGhId());
|
|
|
- if (Objects.isNull(publishAccount)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- long publishTimestamp = article.getPublishTimestamp() > 0 ? article.getPublishTimestamp() * 1000 : article.getUpdateTime() * 1000;
|
|
|
- List<PublishContent> publishContentList = aigcBaseMapper.getNearestPublishContent(publishAccount.getId(), publishTimestamp, 100);
|
|
|
- PublishContent publishContent = findPublishContent(publishContentList, task.getTitle(), publishTimestamp);
|
|
|
- if (Objects.isNull(publishContent)) {
|
|
|
- task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
- articlePoolPromotionSourceRepository.save(task);
|
|
|
- continue;
|
|
|
- }
|
|
|
- RootPublishContentVO source = getRootPublishContent(publishContent.getCrawlerChannelContentId(), null, publishContent.getId(), publishContent.getSourceId(), 0);
|
|
|
- // 更新
|
|
|
- if (StringUtils.hasText(source.getRootProduceContentId())) {
|
|
|
- task.setStatus(ArticlePoolPromotionSourceStatusEnum.FINISH.getCode());
|
|
|
- task.setSourcePublishContentId(source.getSourcePublishContentId());
|
|
|
- task.setRootProduceContentId(source.getRootProduceContentId());
|
|
|
- task.setRootPublishContentId(source.getRootPublishContentId());
|
|
|
- task.setUpdateTimestamp(now);
|
|
|
- articlePoolPromotionSourceRepository.save(task);
|
|
|
- // 保存中间环节 晋级溯源
|
|
|
- for (String midChannelContentId : source.getMidChannelContentIds()) {
|
|
|
- ArticlePoolPromotionSource item = new ArticlePoolPromotionSource();
|
|
|
- BeanUtils.copyProperties(task, item);
|
|
|
- ArticlePoolPromotionSource dto = articlePoolPromotionSourceRepository.getByChannelContentId(midChannelContentId);
|
|
|
- if (Objects.nonNull(dto)) {
|
|
|
- // 以dto为基础
|
|
|
- dto.setRootProduceContentId(task.getRootProduceContentId());
|
|
|
- dto.setRootPublishContentId(task.getRootPublishContentId());
|
|
|
- dto.setStatus(task.getStatus());
|
|
|
- dto.setLevel(task.getLevel());
|
|
|
- dto.setUpdateTimestamp(task.getUpdateTimestamp());
|
|
|
- item = dto;
|
|
|
- } else {
|
|
|
- // 以新item为基础
|
|
|
- item.setChannelContentId(midChannelContentId);
|
|
|
- item.setCreateTimestamp(item.getUpdateTimestamp());
|
|
|
+ try {
|
|
|
+ // 判断文章是否被抓回来,如果没有抓回来,不进行处理 临时方案
|
|
|
+ CrawlerContent crawlerContent = aigcBaseMapper.getCrawlerContentByChannelContentId(task.getChannelContentId());
|
|
|
+ if (Objects.isNull(crawlerContent)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 溯源
|
|
|
+ Article article = articleRepository.getByWxSn(task.getWxSn());
|
|
|
+ if (Objects.isNull(article)) {
|
|
|
+ task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
+ articlePoolPromotionSourceRepository.save(task);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PublishAccount publishAccount = publishAccountRepository.getByGhId(article.getGhId());
|
|
|
+ if (Objects.isNull(publishAccount)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long publishTimestamp = article.getPublishTimestamp() > 0 ? article.getPublishTimestamp() * 1000 : article.getUpdateTime() * 1000;
|
|
|
+ List<PublishContent> publishContentList = aigcBaseMapper.getNearestPublishContent(publishAccount.getId(), publishTimestamp, 100);
|
|
|
+ PublishContent publishContent = findPublishContent(publishContentList, task.getTitle(), publishTimestamp);
|
|
|
+ if (Objects.isNull(publishContent)) {
|
|
|
+ publishContentList = aigcBaseMapper.getLateNearestPublishContent(publishAccount.getId(), publishTimestamp);
|
|
|
+ publishContent = findPublishContent(publishContentList, task.getTitle(), publishTimestamp);
|
|
|
+ if (Objects.isNull(publishContent)) {
|
|
|
+ task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
+ articlePoolPromotionSourceRepository.save(task);
|
|
|
+ continue;
|
|
|
}
|
|
|
- item.setDeleted(StatusEnum.ZERO.getCode());
|
|
|
- articlePoolPromotionSourceRepository.save(item);
|
|
|
}
|
|
|
- longArticleBaseMapper.updateRootProduceContentLevel(task.getRootProduceContentId(), task.getLevel());
|
|
|
- } else {
|
|
|
- task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
- articlePoolPromotionSourceRepository.save(task);
|
|
|
+ RootPublishContentVO source = getRootPublishContent(publishContent.getCrawlerChannelContentId(), null, publishContent.getId(), publishContent.getSourceId(), 0);
|
|
|
+ // 更新
|
|
|
+ if (StringUtils.hasText(source.getRootProduceContentId())) {
|
|
|
+ task.setStatus(ArticlePoolPromotionSourceStatusEnum.FINISH.getCode());
|
|
|
+ task.setSourcePublishContentId(source.getSourcePublishContentId());
|
|
|
+ task.setRootProduceContentId(source.getRootProduceContentId());
|
|
|
+ task.setRootPublishContentId(source.getRootPublishContentId());
|
|
|
+ task.setUpdateTimestamp(now);
|
|
|
+ articlePoolPromotionSourceRepository.save(task);
|
|
|
+ // 保存中间环节 晋级溯源
|
|
|
+ for (String midChannelContentId : source.getMidChannelContentIds()) {
|
|
|
+ ArticlePoolPromotionSource item = new ArticlePoolPromotionSource();
|
|
|
+ BeanUtils.copyProperties(task, item);
|
|
|
+ ArticlePoolPromotionSource dto = articlePoolPromotionSourceRepository.getByChannelContentId(midChannelContentId);
|
|
|
+ if (Objects.nonNull(dto)) {
|
|
|
+ // 以dto为基础
|
|
|
+ dto.setRootProduceContentId(task.getRootProduceContentId());
|
|
|
+ dto.setRootPublishContentId(task.getRootPublishContentId());
|
|
|
+ dto.setStatus(task.getStatus());
|
|
|
+ dto.setLevel(task.getLevel());
|
|
|
+ dto.setUpdateTimestamp(task.getUpdateTimestamp());
|
|
|
+ item = dto;
|
|
|
+ } else {
|
|
|
+ // 以新item为基础
|
|
|
+ item.setChannelContentId(midChannelContentId);
|
|
|
+ item.setCreateTimestamp(item.getUpdateTimestamp());
|
|
|
+ }
|
|
|
+ item.setDeleted(StatusEnum.ZERO.getCode());
|
|
|
+ articlePoolPromotionSourceRepository.save(item);
|
|
|
+ }
|
|
|
+ longArticleBaseMapper.updateRootProduceContentLevel(task.getRootProduceContentId(), task.getLevel());
|
|
|
+ } else {
|
|
|
+ task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
+ articlePoolPromotionSourceRepository.save(task);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("articlePromotionTraceability error channelContentId:{}", task.getChannelContentId(), e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -424,7 +453,7 @@ public class ArticleService {
|
|
|
List<ProducePlanExeRecord> produceContentList = aigcBaseMapper.getAllByProducePlanId(producePlanIds);
|
|
|
List<String> channelContentIds = produceContentList.stream().map(ProducePlanExeRecord::getChannelContentId).distinct().collect(Collectors.toList());
|
|
|
List<ArticleCategory> articleCategoryList = articleCategoryRepository.getAllByChannelContentIdIn(channelContentIds);
|
|
|
- List<String> articleCategoryIds = articleCategoryList.stream().map(ArticleCategory::getChannelContentId).collect(Collectors.toList());
|
|
|
+ List<String> articleCategoryIds = articleCategoryList.stream().map(ArticleCategory::getChannelContentId).collect(Collectors.toList());
|
|
|
List<ProduceContentCrawlerVO> list = produceContentList.stream().filter(o -> !articleCategoryIds.contains(o.getChannelContentId())).map(o -> {
|
|
|
ProduceContentCrawlerVO item = new ProduceContentCrawlerVO();
|
|
|
item.setChannelContentId(o.getChannelContentId());
|
|
@@ -507,6 +536,12 @@ public class ArticleService {
|
|
|
PublishContent publishContent = findPublishContent(publishContentList, article.getTitle(), publishTimestamp);
|
|
|
if (Objects.nonNull(publishContent)) {
|
|
|
return publishContent.getId();
|
|
|
+ } else {
|
|
|
+ publishContentList = aigcBaseMapper.getLateNearestPublishContent(publishAccount.getId(), publishTimestamp);
|
|
|
+ publishContent = findPublishContent(publishContentList, article.getTitle(), publishTimestamp);
|
|
|
+ if (Objects.nonNull(publishContent)) {
|
|
|
+ return publishContent.getId();
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|