|
@@ -308,68 +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)) {
|
|
|
- publishContentList = aigcBaseMapper.getLateNearestPublishContent(publishAccount.getId(), publishTimestamp);
|
|
|
- publishContent = findPublishContent(publishContentList, task.getTitle(), publishTimestamp);
|
|
|
- if (Objects.isNull(publishContent)) {
|
|
|
+ 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;
|
|
|
}
|
|
|
- }
|
|
|
- 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());
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
}
|