Browse Source

文章溯源查找修改

wangyunpeng 7 months ago
parent
commit
7226e5d20c

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -33,6 +33,8 @@ public interface AigcBaseMapper {
 
     List<PublishContent> getNearestPublishContent(String publishAccountId, Long publishTimestamp, Integer size);
 
+    List<PublishContent> getLateNearestPublishContent(String publishAccountId, Long publishTimestamp);
+
     CrawlerContent getCrawlerContentByChannelContentId(String channelContentId);
 
     List<CrawlerContent> getCrawlerContentByChannelContentIdIn(List<String> channelContentIds);

+ 35 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleService.java

@@ -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())) {
@@ -307,9 +328,13 @@ public class ArticleService {
             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;
+                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;
+                }
             }
             RootPublishContentVO source = getRootPublishContent(publishContent.getCrawlerChannelContentId(), null, publishContent.getId(), publishContent.getSourceId(), 0);
             // 更新
@@ -424,7 +449,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 +532,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;
     }

+ 13 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -160,6 +160,19 @@
         </if>
     </select>
 
+    <select id="getLateNearestPublishContent"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.PublishContent">
+        select *
+        from publish_content
+        where publish_account_id = #{publishAccountId}
+        and channel = 5
+        and status = 2
+        <if test="publishTimestamp != null">
+            and publish_timestamp > (#{publishTimestamp})
+        </if>
+        order by publish_timestamp
+    </select>
+
     <select id="getCrawlerContentByChannelContentId"
             resultType="com.tzld.longarticle.recommend.server.model.dto.CrawlerContent">
         select cc.channel_content_id, ca.wx_gh as ghId, cc.title, cc.publish_timestamp