|
@@ -39,10 +39,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.tzld.longarticle.recommend.server.common.constant.SceneConstants.FWH_COLD_START;
|
|
@@ -90,6 +87,7 @@ public class RecommendService {
|
|
|
RankResult rankResult = rankService.rank(convertToRankParam(param, recallResult));
|
|
|
long t3 = System.currentTimeMillis();
|
|
|
CostMonitor.logCost("Recommend", "Rank", t3 - t2);
|
|
|
+ excludeArticleIndex(rankResult, request.getExcludeContentIndex());
|
|
|
saveSortLog(param, rankResult);
|
|
|
|
|
|
RecommendResponse response = buildRecommendResponse(recallResult, rankResult, param.getPublishNum());
|
|
@@ -100,6 +98,22 @@ public class RecommendService {
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
+ private void excludeArticleIndex(RankResult rankResult, List<Integer> excludeContentIndex) {
|
|
|
+ if (CollectionUtils.isEmpty(excludeContentIndex)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Content> contentList = rankResult.getContents();
|
|
|
+ Iterator<Content> iterator = contentList.iterator();
|
|
|
+ int index = 1;
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ iterator.next();
|
|
|
+ if (excludeContentIndex.contains(index)) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void setStrategy(RecommendRequest request, RecommendParam param) {
|
|
|
int historyCount = articleRepository.countByGhIdAndTypeAndItemIndex(request.getGhId(),
|
|
|
ArticleTypeEnum.QUNFA.getVal(), 1);
|