Explorar o código

feat:修改定时任务

zhaohaipeng hai 1 ano
pai
achega
5a48be22ee

+ 10 - 9
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/strategy/BlacklistContainer.java

@@ -188,12 +188,12 @@ public class BlacklistContainer {
         LOG.info("同步本地标签ID与视频列表的缓存任务结束");
     }
 
-    public List<Long> filterUnsafeVideoByUser(List<Long> videoIds, String uid, Long hotSceneType, String cityCode, String clientIP, String mid) {
+    public List<Long> filterUnsafeVideoByUser(List<Long> videoIds, String uid, Long hotSceneType, String cityCode, String clientIP, String mid, String usedScene) {
         if (CollectionUtils.isEmpty(videoIds)) {
             return videoIds;
         }
 
-        String userType = this.matchUserBlacklistTypeEnum(uid, hotSceneType, cityCode, clientIP, mid);
+        String userType = this.matchUserBlacklistTypeEnum(uid, hotSceneType, cityCode, clientIP, mid, usedScene);
         Collection<Long> tagIdSet = this.findExcludeTagIds(userType);
         if (CollectionUtils.isEmpty(tagIdSet)) {
             return videoIds;
@@ -209,7 +209,7 @@ public class BlacklistContainer {
         }).collect(Collectors.toList());
     }
 
-    private String matchUserBlacklistTypeEnum(String uid, Long hotSceneType, String cityCode, String clientIP, String mid) {
+    private String matchUserBlacklistTypeEnum(String uid, Long hotSceneType, String cityCode, String clientIP, String mid, String usedScene) {
         try {
             LOG.info("计算用户黑名单类型,判断参数: uid={}, hotSceneType={}, cityCode={}, clientIP={}, mid={}", uid, hotSceneType, cityCode, clientIP, mid);
             if (StringUtils.isNotBlank(uid)) {
@@ -217,7 +217,7 @@ public class BlacklistContainer {
                 Map<String, String> uidBlacklistMap = blacklistCache.get(key);
                 if (uidBlacklistMap.containsKey(uid)) {
                     String userType = uidBlacklistMap.get(uid);
-                    this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "UID", mid);
+                    this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "UID", mid, usedScene);
                     LOG.info("用户 {} 在UID黑名单中命中 {}", uid, userType);
                     return userType;
                 }
@@ -227,7 +227,7 @@ public class BlacklistContainer {
                 Map<String, String> ipBlacklistMap = blacklistCache.get(IP_VISIO_BLACKLIST_HASH_KEY);
                 if (ipBlacklistMap.containsKey(clientIP)) {
                     String userType = ipBlacklistMap.get(clientIP);
-                    this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "IP", mid);
+                    this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "IP", mid, usedScene);
                     LOG.info("用户 {} 在IP黑名单中命中 {}, 参数为: clientIP为: {}", uid, userType, clientIP);
                     return userType;
                 }
@@ -236,7 +236,7 @@ public class BlacklistContainer {
 
             String userType = this.matchGeneralizationUserType(uid, cityCode, hotSceneType);
             if (StringUtils.isNotBlank(userType)) {
-                this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "RegionAndHotSceneType", mid);
+                this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "RegionAndHotSceneType", mid, usedScene);
             }
             return userType;
         } catch (
@@ -305,17 +305,17 @@ public class BlacklistContainer {
         return tagFilterConfig.getRecommendExcludeTag();
     }
 
-    private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String fullUserType, String blacklistType, String mid) {
+    private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String fullUserType, String blacklistType, String mid, String usedScene) {
         try {
             String[] split = fullUserType.split(USER_TYPE_SUB_TYPE_CONNECTOR);
-            this.filterLogUpload(uid, cityCode, hotSceneType, clientIp, split[0], split[1], blacklistType, mid);
+            this.filterLogUpload(uid, cityCode, hotSceneType, clientIp, split[0], split[1], blacklistType, mid, usedScene);
         } catch (
                 Exception e) {
             LOG.error("filterLogUpload error: ", e);
         }
     }
 
-    private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String userType, String userSubType, String blacklistType, String mid) {
+    private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String userType, String userSubType, String blacklistType, String mid, String usedScene) {
         try {
             Map<String, String> logMap = new HashMap<>();
             logMap.put("uid", StringUtils.isNotBlank(uid) ? uid : "");
@@ -323,6 +323,7 @@ public class BlacklistContainer {
             logMap.put("cityCode", StringUtils.isNotBlank(cityCode) ? cityCode : "");
             logMap.put("hotSceneType", Objects.nonNull(hotSceneType) ? hotSceneType.toString() : "");
             logMap.put("clientIp", StringUtils.isNotBlank(clientIp) ? clientIp : "");
+            logMap.put("usedScene", StringUtils.isNotBlank(usedScene) ? usedScene : "");
             logMap.put("userType", userType);
             logMap.put("userSubType", userSubType);
             logMap.put("env", activeProfile);