|
@@ -1,18 +1,22 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.filter.strategy;
|
|
|
|
|
|
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.tzld.longarticle.recommend.server.model.Content;
|
|
|
import com.tzld.longarticle.recommend.server.model.remote.Article;
|
|
|
import com.tzld.longarticle.recommend.server.remote.ArticleListRemoteService;
|
|
|
+import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfig;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
|
|
|
import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -28,6 +32,9 @@ public class HistoryTitleStrategy implements FilterStrategy {
|
|
|
private static final List<Integer> firstSecondIndex = Arrays.asList(1, 2);
|
|
|
private static final List<Integer> allIndex = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);
|
|
|
|
|
|
+ @ApolloJsonValue("${accountContentPoolConfig:[]}")
|
|
|
+ private List<AccountContentPoolConfig> accountContentPoolConfigList;
|
|
|
+
|
|
|
@Override
|
|
|
public List<String> filter(FilterParam param) {
|
|
|
List<String> result = new ArrayList<>();
|
|
@@ -35,10 +42,19 @@ public class HistoryTitleStrategy implements FilterStrategy {
|
|
|
List<String> firstSecondTitleList = firstSecondArticleList.stream().map(Article::getTitle).collect(Collectors.toList());
|
|
|
List<Article> allArticleList = articleListRemoteService.articleList(param.getAccountName(), allIndex);
|
|
|
List<String> allTitleList = allArticleList.stream().map(Article::getTitle).collect(Collectors.toList());
|
|
|
+ AccountContentPoolConfig contentPoolConfig = getContentPoolConfig(param.getAccountName());
|
|
|
+ List<String> firstSecondContentPool = new ArrayList<>();
|
|
|
+ if (Objects.nonNull(contentPoolConfig)) {
|
|
|
+ firstSecondContentPool = Arrays.asList(contentPoolConfig.getContentPools()[0], contentPoolConfig.getContentPools()[1]);
|
|
|
+ }
|
|
|
for (Content content : param.getContents()) {
|
|
|
boolean isDuplicate;
|
|
|
- if (content.getProducePlanName().contains("【1】")
|
|
|
- || content.getProducePlanName().contains("【2】")) {
|
|
|
+ if (CollectionUtils.isNotEmpty(firstSecondContentPool) && firstSecondContentPool.contains(content.getContentPoolType())) {
|
|
|
+ // 四个内容池 配置 判断头条,次头条
|
|
|
+ isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), firstSecondTitleList);
|
|
|
+ } else if (CollectionUtils.isEmpty(firstSecondContentPool) && (content.getProducePlanName().contains("【1】")
|
|
|
+ || content.getProducePlanName().contains("【2】"))) {
|
|
|
+ // 原始发布内容 生成计划名称判断头条,次头条
|
|
|
isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), firstSecondTitleList);
|
|
|
} else {
|
|
|
isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), allTitleList);
|
|
@@ -50,4 +66,13 @@ public class HistoryTitleStrategy implements FilterStrategy {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private AccountContentPoolConfig getContentPoolConfig(String accountName) {
|
|
|
+ for (AccountContentPoolConfig contentPoolConfig : accountContentPoolConfigList) {
|
|
|
+ if (accountName.equals(contentPoolConfig.getAccount())) {
|
|
|
+ return contentPoolConfig;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|