Explorar o código

ADD: regionCode -> cityCode

sunxy hai 1 ano
pai
achega
42af9a190b

+ 2 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java

@@ -217,6 +217,7 @@ public class RecommendService {
         recallParam.setSpecialRecommend(true);
         recallParam.setSize(request.getSize());
         recallParam.setProvince(request.getProvince());
+        recallParam.setCityCode(request.getCityCode());
 
         RecallResult recallResult = recallService.recall(recallParam);
 
@@ -520,6 +521,7 @@ public class RecommendService {
         recallParam.setProvince(param.getProvince());
         recallParam.setExpIdMap(param.getExpIdMap());
         recallParam.setCategoryId(param.getCategoryId());
+        recallParam.setCityCode(param.getCityCode());
 
         return recallParam;
     }

+ 2 - 2
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/ViewedService.java

@@ -43,7 +43,7 @@ public class ViewedService {
 
 
     // TODO 如果过滤失败,那么认为所有视频都被过滤掉
-    public List<Long> filterViewedVideo(int appType, String mid, String uid, List<Long> videoIds, String regionCode) {
+    public List<Long> filterViewedVideo(int appType, String mid, String uid, List<Long> videoIds, String cityCode) {
 
         Stopwatch stopwatch = Stopwatch.createStarted();
         List<Integer> viewedTypes = viewedTypesMap.getOrDefault(appType, defaultViewedTypes);
@@ -58,7 +58,7 @@ public class ViewedService {
             param.put("uid", uid);
             param.put("types", viewedTypes);
             param.put("videoIds", videoIds);
-            param.put("cityCode", regionCode);
+            param.put("cityCode", cityCode);
             List<Integer> recommendStatus = new ArrayList<>();
             recommendStatus.add(-6);
             param.put("recommendStatus", recommendStatus);

+ 9 - 11
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/AbstractFilterService.java

@@ -35,7 +35,7 @@ public abstract class AbstractFilterService {
     @Autowired
     private ViewedService viewedService;
 
-    private ExecutorService pool = ThreadPoolFactory.filterPool();
+    private final ExecutorService pool = ThreadPoolFactory.filterPool();
 
     @Value("${newFilterGlobalSwitch:false}")
     private boolean newFilterGlobalSwitch;
@@ -68,9 +68,10 @@ public abstract class AbstractFilterService {
             videoIds = filterByPreViewed(param.getAppType(), param.getMid(), videoIds);
         }
         if (param.isConcurrent()) {
-            videoIds = filterByViewedConcurrent(param.getAppType(), param.getMid(), param.getUid(), videoIds, param.getRegionCode());
+            videoIds = filterByViewedConcurrent(param.getAppType(), param.getMid(), param.getUid(), videoIds,
+                    param.getCityCode());
         } else {
-            videoIds = filterByViewed(param.getAppType(), param.getMid(), param.getUid(), videoIds, param.getRegionCode());
+            videoIds = filterByViewed(param.getAppType(), param.getMid(), param.getUid(), videoIds, param.getCityCode());
         }
         return videoIds;
     }
@@ -96,7 +97,7 @@ public abstract class AbstractFilterService {
         }
     }
 
-    private List<Long> filterByViewedConcurrent(int appType, String mid, String uid, List<Long> videoIds, String regionCode) {
+    private List<Long> filterByViewedConcurrent(int appType, String mid, String uid, List<Long> videoIds, String cityCode) {
         // TODO uid为空时,还需要过滤么?
         if (StringUtils.isBlank(mid)
                 || CollectionUtils.isEmpty(videoIds)) {
@@ -118,7 +119,7 @@ public abstract class AbstractFilterService {
         List<Future<List<Long>>> futures = new ArrayList<>();
         for (final List<Long> ids : chunks) {
             Future<List<Long>> future = pool.submit(() ->
-                    viewedService.filterViewedVideo(appType, mid, uid, ids, regionCode));
+                    viewedService.filterViewedVideo(appType, mid, uid, ids, cityCode));
             futures.add(future);
         }
         try {
@@ -142,13 +143,13 @@ public abstract class AbstractFilterService {
 
     }
 
-    private List<Long> filterByViewed(int appType, String mid, String uid, List<Long> videoIds, String regionCode) {
+    private List<Long> filterByViewed(int appType, String mid, String uid, List<Long> videoIds, String cityCode) {
         // TODO uid为空时,还需要过滤么?
         if (StringUtils.isBlank(mid)
                 || CollectionUtils.isEmpty(videoIds)) {
             return videoIds;
         }
-        return viewedService.filterViewedVideo(appType, mid, uid, videoIds, regionCode);
+        return viewedService.filterViewedVideo(appType, mid, uid, videoIds, cityCode);
 
     }
 
@@ -177,10 +178,7 @@ public abstract class AbstractFilterService {
         // 1 判断是否过滤,不展示的app+区域列表。
         boolean filterFlag;
         if (rules.containsKey(appType)) {
-            filterFlag = false;
-            if (rules.get(appType).contains(regionCode)) {
-                filterFlag = true;
-            }
+            filterFlag = rules.get(appType).contains(regionCode);
         } else {
             filterFlag = true;
         }

+ 1 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/FilterParam.java

@@ -22,6 +22,7 @@ public class FilterParam {
     private Map<Integer, List<String>> appRegionFiltered;
     private List<Long> videosWithRisk;
     private String regionCode;
+    private String cityCode;
     private int forceTruncation;
     private Set<String> abExpCodes;
 

+ 1 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/FilterParamFactory.java

@@ -36,7 +36,7 @@ public class FilterParamFactory {
         filterParam.setMid(param.getMid());
         filterParam.setUid(param.getUid());
         filterParam.setExpIdMap(param.getExpIdMap());
-        
+        filterParam.setCityCode(param.getCityCode());
         // 风险过滤
         filterParam.setRiskFilterFlag(param.getRiskFilterFlag());
         filterParam.setVideosWithRisk(param.getVideosWithRisk());

+ 1 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallParam.java

@@ -12,6 +12,7 @@ import java.util.Set;
 @Data
 public class RecallParam {
     private String regionCode;
+    private String cityCode;
     private String mid;
     private int appType;
     private String dataKey;