Browse Source

Merge branch 'wyp/0110-filterAuditContent' of Server/long-article-recommend into master

wangyunpeng 6 months ago
parent
commit
4510ed0e0c

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleTitleAuditRepository.java

@@ -16,4 +16,6 @@ public interface LongArticleTitleAuditRepository extends JpaRepository<LongArtic
     long countByAuditTimestampBetween(Long start, Long end);
 
     long countByStatusAndAuditTimestampBetween(Integer status, Long start, Long end);
+
+    List<LongArticleTitleAudit> getByContentIdIn(List<String> sourceIds);
 }

+ 18 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/recall/RecallService.java

@@ -10,6 +10,7 @@ import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.common.enums.LongArticleTextSimilarityStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.*;
 import com.tzld.longarticle.recommend.server.mapper.crawler.ArticleMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
@@ -101,6 +102,8 @@ public class RecallService implements ApplicationContextAware {
     LongArticleBaseMapper longArticleBaseMapper;
     @Autowired
     LongArticlesTextRepository longArticlesTextRepository;
+    @Autowired
+    LongArticleTitleAuditRepository titleAuditRepository;
 
     private final Map<String, RecallStrategy> strategyMap = new HashMap<>();
     private ApplicationContext applicationContext;
@@ -183,6 +186,8 @@ public class RecallService implements ApplicationContextAware {
         CostMonitor.logCost("Recall", "GetAllContents", t2 - t1);
         // 临时过滤文章视频不匹配content
         filterNotMatchContent(content);
+        // 过滤仅保留审核通过content
+        filterAuditPassContent(content);
         if (CollectionUtils.isEmpty(content)) {
             FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
                     "内容召回失败\n"
@@ -201,6 +206,19 @@ public class RecallService implements ApplicationContextAware {
         return content;
     }
 
+    private void filterAuditPassContent(List<Content> content) {
+        if (CollectionUtils.isEmpty(content)) {
+            return;
+        }
+        List<String> sourceIds = content.stream().map(Content::getSourceId).collect(Collectors.toList());
+        List<LongArticleTitleAudit> titleAuditList = titleAuditRepository.getByContentIdIn(sourceIds);
+        Map<String, Integer> titleAuditMap = titleAuditList.stream()
+                .collect(Collectors.toMap(LongArticleTitleAudit::getContentId, LongArticleTitleAudit::getStatus));
+        content.removeIf(o -> !Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal())
+                && (Objects.isNull(titleAuditMap.get(o.getSourceId()))
+                || titleAuditMap.get(o.getSourceId()) != ArticleVideoAuditStatusEnum.PASS.getCode()));
+    }
+
     private void filterNotMatchContent(List<Content> content) {
         if (CollectionUtils.isEmpty(content)) {
             return;