瀏覽代碼

Merge branch 'feature_20240509_zhaohaipeng_recommendflowpool_whiltelist' of algorithm/recommend-server into master

zhaohaipeng 11 月之前
父節點
當前提交
e24c776839

+ 15 - 6
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java

@@ -7,6 +7,7 @@ import com.tzld.piaoquan.recommend.server.service.filter.strategy.BlacklistConta
 import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConstants;
 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
@@ -36,6 +37,12 @@ public class RecallService implements ApplicationContextAware {
     @Resource
     private BlacklistContainer blacklistContainer;
 
+    /**
+     * 在流量池场景下,哪些appType用判断黑名单
+     */
+    @ApolloJsonValue("${content.security.recommendflowpool.blacklist.apptype.config:[]}")
+    private Set<Integer> blacklistAppTypeSet;
+
     @PostConstruct
     public void init() {
         Map<String, RecallStrategy> type = applicationContext.getBeansOfType(RecallStrategy.class);
@@ -83,9 +90,11 @@ public class RecallService implements ApplicationContextAware {
             strategies.add(strategyMap.get(SpecialRecallStrategy.class.getSimpleName()));
             return strategies;
         }
-        String matchUserBlacklistTypeEnum = blacklistContainer.matchUserBlacklistTypeEnum(param.getUid(), param.getHotSceneType(), param.getCityCode(),
-                param.getClientIp(), param.getMid(), "recommend-flow-pool", param.getAppType());
-        boolean hitUserBlacklist = StringUtils.isNotBlank(matchUserBlacklistTypeEnum);
+
+            String matchUserBlacklistTypeEnum = blacklistContainer.matchUserBlacklistTypeEnum(param.getUid(), param.getHotSceneType(), param.getCityCode(),
+                    param.getClientIp(), param.getMid(), "recommend-flow-pool", param.getAppType());
+        boolean hitUserBlacklist =  StringUtils.isNotBlank(matchUserBlacklistTypeEnum);
+        boolean isInBlacklist = CollectionUtils.isNotEmpty(blacklistAppTypeSet) && blacklistAppTypeSet.contains(param.getAppType());
 
         String abCode = param.getAbCode();
         //1:通过“产品”控制“召回子策略”
@@ -163,7 +172,7 @@ public class RecallService implements ApplicationContextAware {
                     strategies.addAll(getRegionRecallStrategy(param));
             }
             // 命中用户黑名单不走流量池
-            if (!hitUserBlacklist) {
+            if (!hitUserBlacklist || !isInBlacklist) {
                 //2:通过“流量池标记”控制“流量池召回子策略” 其中有9组会走EXPERIMENTAL_FLOW_SET_LEVEL 有1组会走EXPERIMENTAL_FLOW_SET_LEVEL_SCORE
                 if ("60116".equals(abCode)) {
                     int lastDigit = param.getLastDigit();
@@ -277,7 +286,7 @@ public class RecallService implements ApplicationContextAware {
                 case "60115": // 565
                 case "60117": // 567
                 case "60118": // 568
-                    if (!hitUserBlacklist) {
+                    if (!hitUserBlacklist || !isInBlacklist) {
                         strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
                     }
                     strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
@@ -289,7 +298,7 @@ public class RecallService implements ApplicationContextAware {
                     break;
                 case "60110": // 新内容的召回(流量池的Top内容)
                     strategies.add(strategyMap.get(TopGoodPerformanceVideoRecallStrategy.class.getSimpleName()));
-                    if (!hitUserBlacklist) {
+                    if (!hitUserBlacklist || !isInBlacklist) {
                         strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
                     }
                     strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));