|
@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.recommend.recall;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.common.cache.Cache;
|
|
|
+import com.google.common.cache.CacheBuilder;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.CostMonitor;
|
|
|
import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
|
|
@@ -96,11 +98,15 @@ public class RecallService implements ApplicationContextAware {
|
|
|
ArticleTitleHisCacheRepository articleTitleHisCacheRepository;
|
|
|
@Autowired
|
|
|
LongArticleBaseMapper longArticleBaseMapper;
|
|
|
+ @Autowired
|
|
|
+ LongArticlesTextRepository longArticlesTextRepository;
|
|
|
|
|
|
private final Map<String, RecallStrategy> strategyMap = new HashMap<>();
|
|
|
private ApplicationContext applicationContext;
|
|
|
private final ExecutorService pool = ThreadPoolFactory.recallPool();
|
|
|
|
|
|
+ Cache<String, Integer> textCache = CacheBuilder.newBuilder().expireAfterWrite(60 * 10, TimeUnit.SECONDS).build();
|
|
|
+
|
|
|
@Value("${recall.content.his.feishu.enable:false}")
|
|
|
private Boolean contentHisFeishuEnable;
|
|
|
@Value("${morning.noon.fission.rate:0.64}")
|
|
@@ -174,6 +180,8 @@ public class RecallService implements ApplicationContextAware {
|
|
|
List<Content> content = aigcWaitingPublishContentService.getAllContent(param);
|
|
|
long t2 = System.currentTimeMillis();
|
|
|
CostMonitor.logCost("Recall", "GetAllContents", t2 - t1);
|
|
|
+ // 临时过滤文章视频不匹配content
|
|
|
+ filterNotMatchContent(content);
|
|
|
if (CollectionUtils.isEmpty(content)) {
|
|
|
FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
|
|
|
"内容召回失败\n"
|
|
@@ -192,6 +200,25 @@ public class RecallService implements ApplicationContextAware {
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
+ private void filterNotMatchContent(List<Content> content) {
|
|
|
+ if (CollectionUtils.isEmpty(content)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> searchIds = content.stream()
|
|
|
+ .filter(o ->!Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()))
|
|
|
+ .map(Content::getSourceId).filter(o -> Objects.isNull(textCache.getIfPresent(o)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(searchIds)) {
|
|
|
+ List<LongArticlesText> textList = longArticlesTextRepository.getByContentIdIn(searchIds);
|
|
|
+ Map<String, Integer> textMap = textList.stream()
|
|
|
+ .collect(Collectors.toMap(LongArticlesText::getContentId, LongArticlesText::getSimilarityStatus));
|
|
|
+ textCache.putAll(textMap);
|
|
|
+ }
|
|
|
+ content.removeIf(o -> !Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal())
|
|
|
+ && (Objects.isNull(textCache.getIfPresent(o.getSourceId()))
|
|
|
+ || textCache.getIfPresent(o.getSourceId()) == 0));
|
|
|
+ }
|
|
|
+
|
|
|
private void setVideoContent(List<Content> contentList) {
|
|
|
List<String> contentTraceIds = contentList.stream()
|
|
|
.filter(o -> PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal().equals(o.getSourceType()))
|