19 コミット 0eec43dca9 ... 78a2bd55ce

作者 SHA1 メッセージ 日付
  supeng 78a2bd55ce testing risk region filter video 3 週間 前
  wangyifan 898fcaab0a Merge branch 'feature-20251215-clicksharei2i' of algorithm/recommend-server into master 1 ヶ月 前
  yifan.wang 07026ebda8 clicksharei2i召回 1 ヶ月 前
  zhaohaipeng dd456f9024 Merge branch 'feature-20251211-sharei2i' of algorithm/recommend-server into master 1 ヶ月 前
  yifan.wang 5276640208 sharei2i召回 1 ヶ月 前
  zhaohaipeng 411d67a824 Merge branch 'feature_20251114_zhaohaipeng_group_i2i_recall' of algorithm/recommend-server into master 1 ヶ月 前
  zhaohaipeng 58a3ebffc1 feat:旧召回的数量可控 1 ヶ月 前
  zhaohaipeng e8eddecae3 Merge branch 'feature_20251114_zhaohaipeng_group_i2i_recall' of algorithm/recommend-server into master 2 ヶ月 前
  zhaohaipeng fc2384eb2e feat:修改Bug 2 ヶ月 前
  jiachanghui bde981e6b7 Merge branch 'feature_20251103_zhaohaipeng_add_opengid' of algorithm/recommend-server into master 2 ヶ月 前
  jch 5035068e20 获取opengid 2 ヶ月 前
  zhaohaipeng 79506f32c4 feat:添加openGId字段 2 ヶ月 前
  jiachanghui e275ee338f Merge branch 'feature/priori_province_weight_v2' of algorithm/recommend-server into master 2 ヶ月 前
  jch 90c89d3025 调整地域加权逻辑 2 ヶ月 前
  jiachanghui f237793f98 Merge branch 'feature/priori_province_weight' of algorithm/recommend-server into master 3 ヶ月 前
  jch 53970b7dce 先验地域内容加权 3 ヶ月 前
  supeng e5ed5d6072 Merge branch 'feature_20250929_supeng_opitmize_risk_video_filter' of algorithm/recommend-server into master 3 ヶ月 前
  supeng 5c714e161b 调整风险视频刷新到缓存时间60s -> 600s 3 ヶ月 前
  supeng c3ae9b97f4 Merge branch 'feature_20250929_supeng_opitmize_risk_video_filter' of algorithm/recommend-server into master 3 ヶ月 前
29 ファイル変更755 行追加318 行削除
  1. 1 1
      recommend-server-client/pom.xml
  2. 23 22
      recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/Recommend.java
  3. 138 0
      recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/RecommendRequest.java
  4. 12 0
      recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/RecommendRequestOrBuilder.java
  5. 1 0
      recommend-server-client/src/main/proto/com/tzld/piaoquan/recommend/server/recommend.proto
  6. 1 1
      recommend-server-service/pom.xml
  7. 2 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/model/RecommendParam.java
  8. 12 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/FeatureService.java
  9. 22 2
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java
  10. 2 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/FilterParam.java
  11. 45 8
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/strategy/RiskVideoStrategy.java
  12. 3 2
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankParam.java
  13. 63 5
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelBasic.java
  14. 1 1
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV536.java
  15. 4 4
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV564.java
  16. 23 47
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV565.java
  17. 20 44
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV566.java
  18. 4 4
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV567.java
  19. 44 67
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV568.java
  20. 1 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/FilterParamFactory.java
  21. 4 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallParam.java
  22. 13 8
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java
  23. 0 100
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/PremiumROVRecallStrategy.java
  24. 36 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/PrioriPremiumRovnRecallStrategy.java
  25. 162 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IBasicRecallStrategy.java
  26. 30 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IDirectRecallStrategy.java
  27. 40 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IHistoryClickRecallStrategy.java
  28. 47 0
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IHistoryShareRecallStrategy.java
  29. 1 2
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/util/RecallUtils.java

+ 1 - 1
recommend-server-client/pom.xml

@@ -10,7 +10,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>recommend-server-client</artifactId>
-    <version>1.1.11</version>
+    <version>1.1.12</version>
 
     <dependencies>
         <dependency>

+ 23 - 22
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/Recommend.java

@@ -61,7 +61,7 @@ public final class Recommend {
       "\n2com/tzld/piaoquan/recommend/server/rec" +
       "ommend.proto\032\031google/protobuf/any.proto\032" +
       "/com/tzld/piaoquan/recommend/server/comm" +
-      "on.proto\"\376\005\n\020RecommendRequest\022\022\n\nrequest" +
+      "on.proto\"\217\006\n\020RecommendRequest\022\022\n\nrequest" +
       "_id\030\001 \001(\t\022\013\n\003mid\030\002 \001(\t\022\013\n\003uid\030\003 \001(\t\022\014\n\004s" +
       "ize\030\004 \001(\005\022\020\n\010app_type\030\005 \001(\005\022\021\n\tcity_code" +
       "\030\006 \001(\t\022\025\n\rprovince_code\030\007 \001(\t\022\023\n\013ab_exp_" +
@@ -79,26 +79,27 @@ public final class Recommend {
       "um\030\032 \001(\005\022\025\n\rrootSessionId\030\033 \001(\t\022)\n\nshare" +
       "_list\030\034 \003(\0132\025.VideoActionInfoProto\022\030\n\020re" +
       "quest_video_id\030\035 \001(\003\022\033\n\023current_page_sou" +
-      "rce\030\036 \001(\t\032.\n\014EventIdEntry\022\013\n\003key\030\001 \001(\t\022\r" +
-      "\n\005value\030\002 \001(\t:\0028\001\"\177\n\020MachineInfoProto\022\r\n" +
-      "\005brand\030\001 \001(\t\022\r\n\005model\030\002 \001(\t\022\020\n\010platform\030" +
-      "\003 \001(\t\022\023\n\013sdk_version\030\004 \001(\t\022\016\n\006system\030\005 \001" +
-      "(\t\022\026\n\016wechat_version\030\006 \001(\t\"H\n\021RecommendR" +
-      "esponse\022\027\n\006result\030\001 \001(\0132\007.Result\022\032\n\005vide" +
-      "o\030\002 \003(\0132\013.VideoProto\"\336\001\n\nVideoProto\022\020\n\010v" +
-      "ideo_id\030\001 \001(\003\022\021\n\trov_score\030\002 \001(\001\022\021\n\tpush" +
-      "_from\030\003 \001(\t\022\017\n\007ab_code\030\004 \001(\t\022\022\n\nsort_sco" +
-      "re\030\005 \001(\001\022\020\n\010position\030\006 \001(\005\022\021\n\tflow_pool\030" +
-      "\007 \001(\t\022\027\n\017is_in_flow_pool\030\010 \001(\005\022\014\n\004rand\030\t" +
-      " \001(\001\022\'\n\017push_from_index\030\n \003(\0132\016.PushFrom" +
-      "Index\"1\n\rPushFromIndex\022\021\n\tpush_from\030\001 \001(" +
-      "\t\022\r\n\005index\030\002 \003(\t\"4\n\024VideoActionInfoProto" +
-      "\022\020\n\010video_id\030\001 \001(\003\022\n\n\002ts\030\002 \001(\0032\212\001\n\020Recom" +
-      "mendService\022:\n\021HomepageRecommend\022\021.Recom" +
-      "mendRequest\032\022.RecommendResponse\022:\n\021Relev" +
-      "antRecommend\022\021.RecommendRequest\032\022.Recomm" +
-      "endResponseB7\n0com.tzld.piaoquan.recomme" +
-      "nd.server.gen.recommendP\001\210\001\001b\006proto3"
+      "rce\030\036 \001(\t\022\017\n\007openGId\030\037 \001(\t\032.\n\014EventIdEnt" +
+      "ry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\177\n\020Ma" +
+      "chineInfoProto\022\r\n\005brand\030\001 \001(\t\022\r\n\005model\030\002" +
+      " \001(\t\022\020\n\010platform\030\003 \001(\t\022\023\n\013sdk_version\030\004 " +
+      "\001(\t\022\016\n\006system\030\005 \001(\t\022\026\n\016wechat_version\030\006 " +
+      "\001(\t\"H\n\021RecommendResponse\022\027\n\006result\030\001 \001(\013" +
+      "2\007.Result\022\032\n\005video\030\002 \003(\0132\013.VideoProto\"\336\001" +
+      "\n\nVideoProto\022\020\n\010video_id\030\001 \001(\003\022\021\n\trov_sc" +
+      "ore\030\002 \001(\001\022\021\n\tpush_from\030\003 \001(\t\022\017\n\007ab_code\030" +
+      "\004 \001(\t\022\022\n\nsort_score\030\005 \001(\001\022\020\n\010position\030\006 " +
+      "\001(\005\022\021\n\tflow_pool\030\007 \001(\t\022\027\n\017is_in_flow_poo" +
+      "l\030\010 \001(\005\022\014\n\004rand\030\t \001(\001\022\'\n\017push_from_index" +
+      "\030\n \003(\0132\016.PushFromIndex\"1\n\rPushFromIndex\022" +
+      "\021\n\tpush_from\030\001 \001(\t\022\r\n\005index\030\002 \003(\t\"4\n\024Vid" +
+      "eoActionInfoProto\022\020\n\010video_id\030\001 \001(\003\022\n\n\002t" +
+      "s\030\002 \001(\0032\212\001\n\020RecommendService\022:\n\021Homepage" +
+      "Recommend\022\021.RecommendRequest\032\022.Recommend" +
+      "Response\022:\n\021RelevantRecommend\022\021.Recommen" +
+      "dRequest\032\022.RecommendResponseB7\n0com.tzld" +
+      ".piaoquan.recommend.server.gen.recommend" +
+      "P\001\210\001\001b\006proto3"
     };
     descriptor = com.google.protobuf.Descriptors.FileDescriptor
       .internalBuildGeneratedFileFrom(descriptorData,
@@ -111,7 +112,7 @@ public final class Recommend {
     internal_static_RecommendRequest_fieldAccessorTable = new
       com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
         internal_static_RecommendRequest_descriptor,
-        new java.lang.String[] { "RequestId", "Mid", "Uid", "Size", "AppType", "CityCode", "ProvinceCode", "AbExpCode", "EventId", "VersionAuditStatus", "RecommendTraceId", "VideoId", "City", "Province", "MachineInfo", "NewExpGroup", "SessionId", "SubSessionId", "PageSource", "CategoryId", "HotSceneType", "ClientIp", "VersionCode", "RootSourceId", "UserShareDepth", "PageNum", "RootSessionId", "ShareList", "RequestVideoId", "CurrentPageSource", });
+        new java.lang.String[] { "RequestId", "Mid", "Uid", "Size", "AppType", "CityCode", "ProvinceCode", "AbExpCode", "EventId", "VersionAuditStatus", "RecommendTraceId", "VideoId", "City", "Province", "MachineInfo", "NewExpGroup", "SessionId", "SubSessionId", "PageSource", "CategoryId", "HotSceneType", "ClientIp", "VersionCode", "RootSourceId", "UserShareDepth", "PageNum", "RootSessionId", "ShareList", "RequestVideoId", "CurrentPageSource", "OpenGId", });
     internal_static_RecommendRequest_EventIdEntry_descriptor =
       internal_static_RecommendRequest_descriptor.getNestedTypes().get(0);
     internal_static_RecommendRequest_EventIdEntry_fieldAccessorTable = new

+ 138 - 0
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/RecommendRequest.java

@@ -35,6 +35,7 @@ private static final long serialVersionUID = 0L;
     rootSessionId_ = "";
     shareList_ = java.util.Collections.emptyList();
     currentPageSource_ = "";
+    openGId_ = "";
   }
 
   @java.lang.Override
@@ -259,6 +260,12 @@ private static final long serialVersionUID = 0L;
             currentPageSource_ = s;
             break;
           }
+          case 250: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            openGId_ = s;
+            break;
+          }
           default: {
             if (!parseUnknownField(
                 input, unknownFields, extensionRegistry, tag)) {
@@ -1252,6 +1259,44 @@ private static final long serialVersionUID = 0L;
     }
   }
 
+  public static final int OPENGID_FIELD_NUMBER = 31;
+  private volatile java.lang.Object openGId_;
+  /**
+   * <code>string openGId = 31;</code>
+   * @return The openGId.
+   */
+  @java.lang.Override
+  public java.lang.String getOpenGId() {
+    java.lang.Object ref = openGId_;
+    if (ref instanceof java.lang.String) {
+      return (java.lang.String) ref;
+    } else {
+      com.google.protobuf.ByteString bs = 
+          (com.google.protobuf.ByteString) ref;
+      java.lang.String s = bs.toStringUtf8();
+      openGId_ = s;
+      return s;
+    }
+  }
+  /**
+   * <code>string openGId = 31;</code>
+   * @return The bytes for openGId.
+   */
+  @java.lang.Override
+  public com.google.protobuf.ByteString
+      getOpenGIdBytes() {
+    java.lang.Object ref = openGId_;
+    if (ref instanceof java.lang.String) {
+      com.google.protobuf.ByteString b = 
+          com.google.protobuf.ByteString.copyFromUtf8(
+              (java.lang.String) ref);
+      openGId_ = b;
+      return b;
+    } else {
+      return (com.google.protobuf.ByteString) ref;
+    }
+  }
+
   private byte memoizedIsInitialized = -1;
   @java.lang.Override
   public final boolean isInitialized() {
@@ -1359,6 +1404,9 @@ private static final long serialVersionUID = 0L;
     if (!getCurrentPageSourceBytes().isEmpty()) {
       com.google.protobuf.GeneratedMessageV3.writeString(output, 30, currentPageSource_);
     }
+    if (!getOpenGIdBytes().isEmpty()) {
+      com.google.protobuf.GeneratedMessageV3.writeString(output, 31, openGId_);
+    }
     unknownFields.writeTo(output);
   }
 
@@ -1481,6 +1529,9 @@ private static final long serialVersionUID = 0L;
     if (!getCurrentPageSourceBytes().isEmpty()) {
       size += com.google.protobuf.GeneratedMessageV3.computeStringSize(30, currentPageSource_);
     }
+    if (!getOpenGIdBytes().isEmpty()) {
+      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(31, openGId_);
+    }
     size += unknownFields.getSerializedSize();
     memoizedSize = size;
     return size;
@@ -1559,6 +1610,8 @@ private static final long serialVersionUID = 0L;
         != other.getRequestVideoId()) return false;
     if (!getCurrentPageSource()
         .equals(other.getCurrentPageSource())) return false;
+    if (!getOpenGId()
+        .equals(other.getOpenGId())) return false;
     if (!unknownFields.equals(other.unknownFields)) return false;
     return true;
   }
@@ -1641,6 +1694,8 @@ private static final long serialVersionUID = 0L;
         getRequestVideoId());
     hash = (37 * hash) + CURRENT_PAGE_SOURCE_FIELD_NUMBER;
     hash = (53 * hash) + getCurrentPageSource().hashCode();
+    hash = (37 * hash) + OPENGID_FIELD_NUMBER;
+    hash = (53 * hash) + getOpenGId().hashCode();
     hash = (29 * hash) + unknownFields.hashCode();
     memoizedHashCode = hash;
     return hash;
@@ -1864,6 +1919,8 @@ private static final long serialVersionUID = 0L;
 
       currentPageSource_ = "";
 
+      openGId_ = "";
+
       return this;
     }
 
@@ -1938,6 +1995,7 @@ private static final long serialVersionUID = 0L;
       }
       result.requestVideoId_ = requestVideoId_;
       result.currentPageSource_ = currentPageSource_;
+      result.openGId_ = openGId_;
       onBuilt();
       return result;
     }
@@ -2122,6 +2180,10 @@ private static final long serialVersionUID = 0L;
         currentPageSource_ = other.currentPageSource_;
         onChanged();
       }
+      if (!other.getOpenGId().isEmpty()) {
+        openGId_ = other.openGId_;
+        onChanged();
+      }
       this.mergeUnknownFields(other.unknownFields);
       onChanged();
       return this;
@@ -4367,6 +4429,82 @@ private static final long serialVersionUID = 0L;
       onChanged();
       return this;
     }
+
+    private java.lang.Object openGId_ = "";
+    /**
+     * <code>string openGId = 31;</code>
+     * @return The openGId.
+     */
+    public java.lang.String getOpenGId() {
+      java.lang.Object ref = openGId_;
+      if (!(ref instanceof java.lang.String)) {
+        com.google.protobuf.ByteString bs =
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        openGId_ = s;
+        return s;
+      } else {
+        return (java.lang.String) ref;
+      }
+    }
+    /**
+     * <code>string openGId = 31;</code>
+     * @return The bytes for openGId.
+     */
+    public com.google.protobuf.ByteString
+        getOpenGIdBytes() {
+      java.lang.Object ref = openGId_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        openGId_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    /**
+     * <code>string openGId = 31;</code>
+     * @param value The openGId to set.
+     * @return This builder for chaining.
+     */
+    public Builder setOpenGId(
+        java.lang.String value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  
+      openGId_ = value;
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string openGId = 31;</code>
+     * @return This builder for chaining.
+     */
+    public Builder clearOpenGId() {
+      
+      openGId_ = getDefaultInstance().getOpenGId();
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string openGId = 31;</code>
+     * @param value The bytes for openGId to set.
+     * @return This builder for chaining.
+     */
+    public Builder setOpenGIdBytes(
+        com.google.protobuf.ByteString value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+      
+      openGId_ = value;
+      onChanged();
+      return this;
+    }
     @java.lang.Override
     public final Builder setUnknownFields(
         final com.google.protobuf.UnknownFieldSet unknownFields) {

+ 12 - 0
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/RecommendRequestOrBuilder.java

@@ -378,4 +378,16 @@ public interface RecommendRequestOrBuilder extends
    */
   com.google.protobuf.ByteString
       getCurrentPageSourceBytes();
+
+  /**
+   * <code>string openGId = 31;</code>
+   * @return The openGId.
+   */
+  java.lang.String getOpenGId();
+  /**
+   * <code>string openGId = 31;</code>
+   * @return The bytes for openGId.
+   */
+  com.google.protobuf.ByteString
+      getOpenGIdBytes();
 }

+ 1 - 0
recommend-server-client/src/main/proto/com/tzld/piaoquan/recommend/server/recommend.proto

@@ -39,6 +39,7 @@ message RecommendRequest {
   repeated VideoActionInfoProto share_list = 28;
   int64 request_video_id = 29;
   string current_page_source = 30;
+  string openGId = 31;
 }
 
 message MachineInfoProto {

+ 1 - 1
recommend-server-service/pom.xml

@@ -175,7 +175,7 @@
         <dependency>
             <groupId>com.tzld.piaoquan</groupId>
             <artifactId>recommend-server-client</artifactId>
-            <version>1.1.11</version>
+            <version>1.1.12</version>
         </dependency>
         <dependency>
             <groupId>com.tzld.piaoquan</groupId>

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

@@ -37,6 +37,7 @@ public class RecommendParam {
     private String city;
     private Set<String> abExpCodes;
     private boolean riskUser;
+    private boolean testingRiskRegion;
 
     private Integer categoryId;
 
@@ -60,5 +61,6 @@ public class RecommendParam {
     private String currentPageSource;
 
     private Map<String, String> creativeInfoFeature;
+    private String openGId;
 }
 

+ 12 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/FeatureService.java

@@ -347,6 +347,18 @@ public class FeatureService {
         return null;
     }
 
+    public Map<String, String> getUserSocialRecallInfo(String mid) {
+        if (StringUtils.isEmpty(mid)) {
+            return new HashMap<>();
+        }
+
+
+        List<FeatureKeyProto> protos = new ArrayList<>();
+        protos.add(genWithMid("alg_recsys_user_social_recall_feature_day", mid));
+        Feature feature = getFeatureByProto(protos);
+        return feature.getUserFeature().getOrDefault("alg_recsys_user_social_recall_feature_day", new HashMap<>());
+    }
+
     private Feature getFeatureByProto(List<FeatureKeyProto> protos) {
         Map<String, String> result = remoteService.getFeature(protos);
         Feature feature = new Feature();

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

@@ -46,7 +46,6 @@ import org.springframework.stereotype.Service;
 import javax.annotation.PostConstruct;
 import java.time.Duration;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -95,6 +94,11 @@ public class RecommendService {
     @ApolloJsonValue("${none.user.risk.exclude.apptype:[]}")
     private Set<Integer> noneUserRiskExcludeAppTypes;
 
+    @ApolloJsonValue("${testing.risk.province:[]}")
+    private Set<String> testingRiskProvince;
+    @ApolloJsonValue("${testing.risk.city:[]}")
+    private Set<String> testingRiskCity;
+
     public static final String channelGroupPrefix = "alg_recsys_user_channel_group";
     /**
      * wx_user_info 表信息
@@ -399,7 +403,15 @@ public class RecommendService {
                     || isNoneUserRisk;
             param.setRiskUser(riskUser);
         }
-
+        //根据地域屏蔽视频
+        boolean isTestingRiskProvince = Objects.nonNull(testingRiskProvince) && !testingRiskProvince.isEmpty()
+                && Objects.nonNull(param.getProvince()) && !Objects.equals("", param.getProvince().trim())
+                && testingRiskProvince.contains(param.getProvince());
+        boolean isTestingRiskCity = Objects.nonNull(testingRiskCity) && !testingRiskCity.isEmpty()
+                && Objects.nonNull(param.getCity()) && !Objects.equals("", param.getCity().trim())
+                && testingRiskCity.contains(param.getCity());
+        boolean isTestingRiskRegion = isTestingRiskProvince || isTestingRiskCity;
+        param.setTestingRiskRegion(isTestingRiskRegion);
 
         if (request.hasMachineInfo()) {
             MachineInfoProto machineInfoProto = request.getMachineInfo();
@@ -428,6 +440,7 @@ public class RecommendService {
         param.setRecommendType(recommendType);
         param.setRequestVideoId(request.getRequestVideoId());
         param.setCurrentPageSource(request.getCurrentPageSource());
+        param.setOpenGId(request.getOpenGId());
 
         Map<String, String> creativeInfoFeature = this.getCreativeInfoFeature(request.getRootSourceId(), channelName, request.getUserShareDepth());
         param.setCreativeInfoFeature(creativeInfoFeature);
@@ -494,6 +507,9 @@ public class RecommendService {
         String vid = String.valueOf(param.getVideoId());
         UserShareReturnProfile userProfile = featureService.getUserProfile(param.getUid(), param.getMid());
         Map<String, Map<String, String>> behaviorVideos = featureService.getBehaviorVideos(vid, userProfile);
+
+        Map<String, String> userSocialRecallInfo = featureService.getUserSocialRecallInfo(param.getMid());
+
         Map<String, String> headVideoInfo;
         if (null != behaviorVideos && behaviorVideos.containsKey(vid)) {
             headVideoInfo = behaviorVideos.get(vid);
@@ -509,6 +525,7 @@ public class RecommendService {
         recallParam.setHeadInfo(headVideoInfo);
         recallParam.setUserRTShareList(param.getUserRTShareList());
         recallParam.setBehaviorVideos(behaviorVideos);
+        recallParam.setUserSocialRecallInfo(userSocialRecallInfo);
         RecallResult recallResult = recallService.recall(recallParam);
 
         long recallTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
@@ -562,6 +579,7 @@ public class RecommendService {
         recallParam.setUid(param.getUid());
         // 风险过滤
         recallParam.setRiskUser(param.isRiskUser());
+        recallParam.setTestingRiskRegion(param.isTestingRiskRegion());
         recallParam.setAbExpCodes(param.getAbExpCodes());
 
         recallParam.setProvince(param.getProvince());
@@ -580,6 +598,7 @@ public class RecommendService {
         recallParam.setRequestVideoId(param.getRequestVideoId());
         recallParam.setCurrentPageSource(param.getCurrentPageSource());
         recallParam.setCreativeInfoFeature(param.getCreativeInfoFeature());
+        recallParam.setOpenGId(param.getOpenGId());
         return recallParam;
     }
 
@@ -612,6 +631,7 @@ public class RecommendService {
         rankParam.setRequestVideoId(param.getRequestVideoId());
         rankParam.setCurrentPageSource(param.getCurrentPageSource());
         rankParam.setCreativeInfoFeature(param.getCreativeInfoFeature());
+        rankParam.setOpenGId(param.getOpenGId());
         return rankParam;
     }
 

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

@@ -27,4 +27,6 @@ public class FilterParam {
 
     private boolean riskUser;
 
+    private boolean testingRiskRegion;
+
 }

+ 45 - 8
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/strategy/RiskVideoStrategy.java

@@ -33,6 +33,12 @@ public class RiskVideoStrategy implements FilterStrategy {
     @ApolloJsonValue("${risk.video.tag:[]}")
     private List<Long> riskVideoTagIds;
 
+    /**
+     * 安全测试 风险标签
+     */
+    @ApolloJsonValue("${testing.risk.video.tag:[]}")
+    private List<Long> testingRiskVideoTagIds;
+
     @Autowired
     private RedisTemplate<String, String> redisTemplate;
 
@@ -41,9 +47,9 @@ public class RiskVideoStrategy implements FilterStrategy {
     // 内存持久保存不淘汰
     private LoadingCache<String, Set<Long>> riskVideoCache = CacheBuilder.newBuilder()
             .maximumSize(10)
-            .refreshAfterWrite(60, TimeUnit.SECONDS)
-            .expireAfterWrite(60, TimeUnit.SECONDS)
-            .expireAfterAccess(60, TimeUnit.SECONDS)
+            .refreshAfterWrite(600, TimeUnit.SECONDS)
+            .expireAfterWrite(600, TimeUnit.SECONDS)
+            .expireAfterAccess(600, TimeUnit.SECONDS)
             .build(new CacheLoader<String, Set<Long>>() {
                 @Override
                 public Set<Long> load(String key) {
@@ -69,6 +75,27 @@ public class RiskVideoStrategy implements FilterStrategy {
                 }
             });
 
+    private LoadingCache<String, Set<Long>> testingRiskVideoCache = CacheBuilder.newBuilder()
+            .maximumSize(10)
+            .refreshAfterWrite(600, TimeUnit.SECONDS)
+            .expireAfterWrite(600, TimeUnit.SECONDS)
+            .expireAfterAccess(600, TimeUnit.SECONDS)
+            .build(new CacheLoader<String, Set<Long>>() {
+                @Override
+                public Set<Long> load(String key) {
+                    Set<Long> riskVideoIdSet = new HashSet<>();
+                    if (Objects.nonNull(testingRiskVideoTagIds) && !testingRiskVideoTagIds.isEmpty()) {
+                        //数量有限,一次查询,后续考虑优化
+                        List<WxVideoTagRel> rels = repository.findAllByTagIdIn(testingRiskVideoTagIds);
+                        Set<Long> tagVideoIds = CommonCollectionUtils.toSet(rels, WxVideoTagRel::getVideoId);
+                        if (Objects.nonNull(tagVideoIds) && !tagVideoIds.isEmpty()) {
+                            riskVideoIdSet = tagVideoIds;
+                        }
+                    }
+                    return riskVideoIdSet;
+                }
+            });
+
     @Override
     public List<Long> filter(FilterParam param) {
         if (param == null) {
@@ -78,14 +105,24 @@ public class RiskVideoStrategy implements FilterStrategy {
             return param.getVideoIds();
         }
 
-        if (!param.isRiskUser()) {
+        if (!param.isRiskUser() && !param.isTestingRiskRegion()) {
             return param.getVideoIds();
         }
 
-        Set<Long> riskVids = riskVideoCache.getUnchecked("");
-        List<Long> videoIds = param.getVideoIds().stream()
-                .filter(l -> !riskVids.contains(l))
-                .collect(Collectors.toList());
+        List<Long> videoIds = param.getVideoIds();
+        if (param.isRiskUser()) {
+            Set<Long> riskVids = riskVideoCache.getUnchecked("");
+            videoIds = videoIds.stream()
+                    .filter(l -> !riskVids.contains(l))
+                    .collect(Collectors.toList());
+        }
+
+        if (param.isTestingRiskRegion()) {
+            Set<Long> riskVids = testingRiskVideoCache.getUnchecked("");
+            videoIds = videoIds.stream()
+                    .filter(l -> !riskVids.contains(l))
+                    .collect(Collectors.toList());
+        }
 
         log.info("RiskVideoStrategy \t param={} \t before={} \t after={}",
                 JSONUtils.toJson(param),

+ 3 - 2
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankParam.java

@@ -28,8 +28,8 @@ public class RankParam {
     private String city;
     private MachineInfo machineInfo;
     private Set<String> abExpCodes;
-    private Long headVid=0L;
-    private Long hotSceneType=0L;
+    private Long headVid = 0L;
+    private Long hotSceneType = 0L;
 
     private Integer categoryId;
     private Integer versionCode;
@@ -48,4 +48,5 @@ public class RankParam {
     private String currentPageSource;
     private Map<String, String> creativeInfoFeature;
     private Map<String, Map<String, String>> behaviorVideos;
+    private String openGId;
 }

+ 63 - 5
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelBasic.java

@@ -19,6 +19,7 @@ import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorTa
 import com.tzld.piaoquan.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang.math.NumberUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -55,6 +56,7 @@ public abstract class RankStrategy4RegionMergeModelBasic extends RankService {
     private Set<String> strPlusCalibrationMergeCate2;
 
     public static final String STR_PLUS_CALIBRATION_ATTRIBUTE_KEY_PREFIX = "alg_rec_model_calibration_str:";
+    public static final String prioriProvinceWeightPrefix = "priori_province_weight";
 
     String CLASS_NAME = this.getClass().getSimpleName();
 
@@ -392,19 +394,23 @@ public abstract class RankStrategy4RegionMergeModelBasic extends RankService {
         return map;
     }
 
-    protected Map<String, String> getUserRegion(RankParam param) {
-        Map<String, String> regionMap = new HashMap<>();
+    protected Map<String, String> getContextInfo(RankParam param) {
+        Map<String, String> contextInfo = new HashMap<>();
         if (null != param) {
             String province = param.getProvince();
             if (null != province && !province.isEmpty()) {
-                regionMap.put("province", province.replaceAll("省$", ""));
+                contextInfo.put("province", province.replaceAll("省$", ""));
             }
             String city = param.getCity();
             if (null != city && !city.isEmpty()) {
-                regionMap.put("city", city.replaceAll("市$", ""));
+                contextInfo.put("city", city.replaceAll("市$", ""));
+            }
+            String openGId = param.getOpenGId();
+            if (null != openGId && !openGId.isEmpty()) {
+                contextInfo.put("openGId", openGId);
             }
         }
-        return regionMap;
+        return contextInfo;
     }
 
     /**
@@ -442,6 +448,58 @@ public abstract class RankStrategy4RegionMergeModelBasic extends RankService {
         return 1d;
     }
 
+    /**
+     * 获取先验地域加权
+     */
+    protected Map<String, Double> getPrioriVidProvinceRovn(String province, List<RankItem> items, Map<String, Map<String, Map<String, String>>> videoBaseInfoMap) {
+        Map<String, Double> map = new HashMap<>();
+        try {
+            if (null != province && !province.isEmpty() && null != items && !items.isEmpty() && null != videoBaseInfoMap && !videoBaseInfoMap.isEmpty()) {
+                List<String> vids = new ArrayList<>();
+                List<String> keys = new ArrayList<>();
+                for (RankItem item : items) {
+                    String vid = String.valueOf(item.getVideoId());
+                    Map<String, String> videoInfo = videoBaseInfoMap.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
+                    String attributeProvince = videoInfo.get("attribute_province");
+                    if (null != attributeProvince && !attributeProvince.isEmpty()) {
+                        vids.add(vid);
+                        keys.add(String.format("%s:%s:%s:%s", prioriProvinceWeightPrefix, vid, province, "rovn"));
+                    }
+                }
+                if (!keys.isEmpty()) {
+                    List<String> values = redisTemplate.opsForValue().multiGet(keys);
+                    if (null != values && vids.size() == values.size()) {
+                        for (int i = 0; i < vids.size(); i++) {
+                            String vid = vids.get(i);
+                            String value = values.get(i);
+                            if (null != value && !value.isEmpty()) {
+                                double v = NumberUtils.toDouble(value, -1);
+                                if (v > 0) {
+                                    map.put(vid, v);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("priori province weight", e);
+        }
+        return map;
+    }
+
+    protected double getPrioriVidProvinceWeight(double highValue, double highWeight, double lowValue, double lowWeight, String vid, Map<String, Double> map) {
+        if (null != map && map.containsKey(vid)) {
+            double value = map.get(vid);
+            if (value > highValue) {
+                return 1.0 + (value - 1.0) * 10.0;
+            } else if (value <= lowValue) {
+                return value * value;
+            }
+        }
+        return 1.0;
+    }
+
     private boolean isInsertDouHotFlowPoolVideo() {
         double rand = RandomUtils.nextDouble(0, 1);
         return rand <= newFlowPoolSelectRate;

+ 1 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV536.java

@@ -47,7 +47,7 @@ public class RankStrategy4RegionMergeModelV536 extends RankStrategy4RegionMergeM
         Set<Long> setVideo = new HashSet<>();
         List<Video> rovRecallRank = new ArrayList<>();
         // -------------------5路特殊旧召回------------------
-        RecallUtils.extractOldSpecialRecall(param, setVideo, rovRecallRank);
+        RecallUtils.extractOldSpecialRecall(mergeWeight.getOrDefault("oldSpecialN", (double) param.getSize()).intValue(), param, setVideo, rovRecallRank);
         //-------------------return相似召回------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("v6", 5.0).intValue(), param, ReturnVideoRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
         //-------------------新地域召回------------------

+ 4 - 4
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV564.java

@@ -48,7 +48,7 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
         setVideo.add(param.getHeadVid());
         List<Video> rovRecallRank = new ArrayList<>();
         // -------------------5路特殊旧召回------------------
-        RecallUtils.extractOldSpecialRecall(param, setVideo, rovRecallRank);
+        RecallUtils.extractOldSpecialRecall(mergeWeight.getOrDefault("oldSpecialN", (double) param.getSize()).intValue(), param, setVideo, rovRecallRank);
         //-------------------return相似召回------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("v6", 5.0).intValue(), param, ReturnVideoRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
         //-------------------新地域召回------------------
@@ -125,7 +125,7 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
             cate2Coefficient.putAll(simCateScore);
         }
         Double cate2CoefficientDenominator = mergeWeight.getOrDefault("cate2CoefficientDenominator", 1d);
-        Map<String, String> regionMap = getUserRegion(param);
+        Map<String, String> contextInfo = getContextInfo(param);
 
         List<Video> result = new ArrayList<>();
         for (RankItem item : items) {
@@ -177,8 +177,8 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
             if (MapUtils.isNotEmpty(param.getCreativeInfoFeature())) {
                 video.getMetaFeatureMap().put("creativeInfo", param.getCreativeInfoFeature());
             }
-            if (MapUtils.isNotEmpty(regionMap)) {
-                video.getMetaFeatureMap().put("region", regionMap);
+            if (MapUtils.isNotEmpty(contextInfo)) {
+                video.getMetaFeatureMap().put("context", contextInfo);
             }
             result.add(video);
         }

+ 23 - 47
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV565.java

@@ -8,7 +8,6 @@ import com.tzld.piaoquan.recommend.server.model.MachineInfo;
 import com.tzld.piaoquan.recommend.server.model.Video;
 import com.tzld.piaoquan.recommend.server.service.FeatureService;
 import com.tzld.piaoquan.recommend.server.service.rank.RankParam;
-import com.tzld.piaoquan.recommend.server.service.rank.bo.UserSRBO;
 import com.tzld.piaoquan.recommend.server.service.rank.bo.UserShareReturnProfile;
 import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractVideoMergeCate;
 import com.tzld.piaoquan.recommend.server.service.rank.tansform.FeatureV6;
@@ -30,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeModelBasic {
     @ApolloJsonValue("${rank.score.merge.weightv565:}")
     private Map<String, Double> mergeWeight;
+
     @Autowired
     private FeatureService featureService;
 
@@ -47,7 +47,7 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
         setVideo.add(param.getHeadVid());
         List<Video> rovRecallRank = new ArrayList<>();
         // -------------------5路特殊旧召回------------------
-        RecallUtils.extractOldSpecialRecall(param, setVideo, rovRecallRank);
+        RecallUtils.extractOldSpecialRecall(mergeWeight.getOrDefault("oldSpecialN", (double) param.getSize()).intValue(), param, setVideo, rovRecallRank);
         //-------------------return相似召回------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("v6", 5.0).intValue(), param, ReturnVideoRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
         //-------------------新地域召回------------------
@@ -74,6 +74,10 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
         RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriProvinceStr", 1.0).intValue(), param, PrioriProvinceStrRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
         //-------------------priori province ros------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriProvinceRos", 1.0).intValue(), param, PrioriProvinceRosRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
+        //-------------------return1 cate2 ros------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("return1Cate2Ros", 5.0).intValue(), param, Return1Cate2RosRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
+        //-------------------return1 cate2 str------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("return1Cate2Str", 5.0).intValue(), param, Return1Cate2StrRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
 
         //-------------------排-------------------
         //-------------------序-------------------
@@ -83,29 +87,29 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
 
         // 1. 批量获取特征  省份参数要对齐  headvid  要传递过来!
         // k1:视频、k2:表、k3:特征、v:特征值
+        Map<String, String> headVideoInfo = param.getHeadInfo();
         List<String> vids = CommonCollectionUtils.toListDistinct(rovRecallRank, v -> String.valueOf(v.getVideoId()));
-        String headVid = String.valueOf(param.getHeadVid());
-        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo(headVid, vids);
-        FeatureService.Feature feature = featureService.getFeatureV3(param, videoBaseInfoMap, vids);
+        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo("", vids);
+        FeatureService.Feature feature = featureService.getFeatureV4(param, headVideoInfo, videoBaseInfoMap, vids);
         Map<String, Map<String, String>> featureOriginUser = feature.getUserFeature();
         Map<String, Map<String, Map<String, String>>> featureOriginVideo = feature.getVideoFeature();
-        Map<String, String> headVideoInfo = videoBaseInfoMap.getOrDefault(headVid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
 
         // 2. 用户信息预处理
         Map<String, Map<String, String[]>> newC7Map = FeatureV6.parseUCFScore(featureOriginUser.getOrDefault("alg_mid_feature_sharecf", new HashMap<>()));
         Map<String, Map<String, String[]>> newC8Map = FeatureV6.parseUCFScore(featureOriginUser.getOrDefault("alg_mid_feature_returncf", new HashMap<>()));
         UserShareReturnProfile userProfile = parseUserProfile(featureOriginUser);
-        Map<String, Map<String, String>> userBehaviorVideoMap = getUserBehaviorVideoMap(userProfile);
+        Map<String, Map<String, String>> userBehaviorVideoMap = param.getBehaviorVideos();
+        Map<String, String> creativeInfo = param.getCreativeInfoFeature();
 
         // 3. 特征处理
         List<RankItem> rankItems = CommonCollectionUtils.toList(rovRecallRank, RankItem::new);
-        Map<String, Float> userFeatureMap = getUserFeature(currentMs, param, headVideoInfo, userProfile, featureOriginUser);
-        batchGetVideoFeature(currentMs, userProfile, headVideoInfo, videoBaseInfoMap,
+        Map<String, Float> userFeatureMap = getUserFeature(currentMs, param, creativeInfo, headVideoInfo, userProfile, featureOriginUser);
+        batchGetVideoFeature(currentMs, userProfile, creativeInfo, headVideoInfo, videoBaseInfoMap,
                 newC7Map, newC8Map, featureOriginUser, userBehaviorVideoMap, featureOriginVideo, rankItems);
 
         // 4. 排序模型计算
         Map<String, Float> sceneFeatureMap = new HashMap<>(0);
-        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_fm_xgb_20250317.conf").scoring(sceneFeatureMap, userFeatureMap, userFeatureMap, rankItems);
+        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_fm_xgb_20250729.conf").scoring(sceneFeatureMap, userFeatureMap, userFeatureMap, rankItems);
 
         // 5. 排序公式特征
         double xgbRovNegRate = mergeWeight.getOrDefault("xgbRovNegRate", 0.059);
@@ -124,12 +128,11 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
             cate2Coefficient.putAll(simCateScore);
         }
         Double cate2CoefficientDenominator = mergeWeight.getOrDefault("cate2CoefficientDenominator", 1d);
-        Map<String, String> regionMap = getUserRegion(param);
+        Map<String, String> contextInfo = getContextInfo(param);
 
         List<Video> result = new ArrayList<>();
         for (RankItem item : items) {
             String vidMergeCate2 = this.findVideoMergeCate2(videoBaseInfoMap, String.valueOf(item.getVideoId()));
-
             double strPlusCalibrationCoefficient = this.calcStrPlusCalibrationCoefficientByMergeCate2(vidMergeCate2);
 
             double score;
@@ -137,7 +140,6 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
             item.getScoresMap().put("fmRovOrigin", fmRovOrigin);
             double fmRovCoefficientBefore = restoreScore(fmRovOrigin, xgbRovNegRate);
             item.getScoresMap().put("fmRovCoefficientBefore", fmRovCoefficientBefore);
-
             double fmRov = fmRovCoefficientBefore * strPlusCalibrationCoefficient;
             item.getScoresMap().put("fmRov", fmRov);
             item.getScoresMap().put("strPlusCalibrationCoefficient", strPlusCalibrationCoefficient);
@@ -183,8 +185,8 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
             if (MapUtils.isNotEmpty(param.getCreativeInfoFeature())) {
                 video.getMetaFeatureMap().put("creativeInfo", param.getCreativeInfoFeature());
             }
-            if (MapUtils.isNotEmpty(regionMap)) {
-                video.getMetaFeatureMap().put("region", regionMap);
+            if (MapUtils.isNotEmpty(contextInfo)) {
+                video.getMetaFeatureMap().put("context", contextInfo);
             }
             result.add(video);
         }
@@ -210,42 +212,13 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
         return null;
     }
 
-    private Map<String, Map<String, String>> getUserBehaviorVideoMap(UserShareReturnProfile userProfile) {
-        Set<String> vidSet = new HashSet<>();
-        if (null != userProfile) {
-            for (List<UserSRBO> list : Arrays.asList(userProfile.getM_s_s(), userProfile.getM_r_s(), userProfile.getL_s_s(), userProfile.getL_r_s())) {
-                if (null != list) {
-                    for (UserSRBO u : list) {
-                        if (null != u) {
-                            vidSet.add(u.getId() + "");
-                        }
-                    }
-                }
-            }
-        }
-
-        Map<String, Map<String, String>> historyVideoMap = new HashMap<>();
-        if (!vidSet.isEmpty()) {
-            Map<String, Map<String, Map<String, String>>> videoMap = featureService.getVideoBaseInfo("", new ArrayList<>(vidSet));
-            if (null != videoMap && !videoMap.isEmpty()) {
-                for (Map.Entry<String, Map<String, Map<String, String>>> entry : videoMap.entrySet()) {
-                    String vid = entry.getKey();
-                    Map<String, Map<String, String>> map = entry.getValue();
-                    if (null != map && map.containsKey("alg_vid_feature_basic_info")) {
-                        historyVideoMap.put(vid, map.get("alg_vid_feature_basic_info"));
-                    }
-                }
-            }
-        }
-        return historyVideoMap;
-    }
-
-    private Map<String, Float> getUserFeature(long currentMs, RankParam param, Map<String, String> headInfo, UserShareReturnProfile userProfile, Map<String, Map<String, String>> userOriginInfo) {
+    private Map<String, Float> getUserFeature(long currentMs, RankParam param, Map<String, String> creativeInfo, Map<String, String> headInfo, UserShareReturnProfile userProfile, Map<String, Map<String, String>> userOriginInfo) {
         Map<String, Double> featMap = new HashMap<>();
         // context feature
         String appType = String.valueOf(param.getAppType());
         String hotSceneType = String.valueOf(param.getHotSceneType());
         FeatureV6.getContextFeature(currentMs, appType, hotSceneType, featMap);
+        FeatureV6.getCreativeBaseFeature("e1", creativeInfo, featMap);
 
         // head video feature
         FeatureV6.getVideoBaseFeature("h", currentMs, headInfo, featMap);
@@ -260,6 +233,7 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
 
     private Map<String, Float> getVideoFeature(long currentMs, String vid,
                                                UserShareReturnProfile userProfile,
+                                               Map<String, String> creativeInfo,
                                                Map<String, String> headInfo, Map<String, String> rankInfo,
                                                Map<String, Map<String, String[]>> c7Map,
                                                Map<String, Map<String, String[]>> c8Map,
@@ -279,6 +253,7 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
 
         // head&rank cross feature
         FeatureV6.getHeadRankVideoCrossFeature(headInfo, rankInfo, featMap);
+        FeatureV6.getCreativeCrossFeature("e1", creativeInfo, rankInfo, featMap);
 
         // user profile & rank cross
         FeatureV6.getProfileVideoCrossFeature(currentMs, userProfile, rankInfo, historyVideoMap, featMap);
@@ -288,6 +263,7 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
 
     private void batchGetVideoFeature(long currentMs,
                                       UserShareReturnProfile userProfile,
+                                      Map<String, String> creativeInfo,
                                       Map<String, String> headInfo,
                                       Map<String, Map<String, Map<String, String>>> videoBaseInfoMap,
                                       Map<String, Map<String, String[]>> c7Map,
@@ -302,7 +278,7 @@ public class RankStrategy4RegionMergeModelV565 extends RankStrategy4RegionMergeM
                 String vid = item.getVideoId() + "";
                 Map<String, String> rankInfo = videoBaseInfoMap.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
                 Future<Integer> future = ThreadPoolFactory.defaultPool().submit(() -> {
-                    item.featureMap = getVideoFeature(currentMs, vid, userProfile, headInfo, rankInfo, c7Map, c8Map, userOriginInfo, historyVideoMap, videoOriginInfo);
+                    item.featureMap = getVideoFeature(currentMs, vid, userProfile, creativeInfo, headInfo, rankInfo, c7Map, c8Map, userOriginInfo, historyVideoMap, videoOriginInfo);
                     item.norFeatureMap = item.featureMap;
                     return 1;
                 });

+ 20 - 44
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV566.java

@@ -8,9 +8,9 @@ import com.tzld.piaoquan.recommend.server.model.MachineInfo;
 import com.tzld.piaoquan.recommend.server.model.Video;
 import com.tzld.piaoquan.recommend.server.service.FeatureService;
 import com.tzld.piaoquan.recommend.server.service.rank.RankParam;
-import com.tzld.piaoquan.recommend.server.service.rank.bo.UserSRBO;
 import com.tzld.piaoquan.recommend.server.service.rank.bo.UserShareReturnProfile;
 import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractVideoMergeCate;
+import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractorUtils;
 import com.tzld.piaoquan.recommend.server.service.rank.tansform.FeatureV6;
 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
 import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils;
@@ -48,7 +48,7 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
         setVideo.add(param.getHeadVid());
         List<Video> rovRecallRank = new ArrayList<>();
         // -------------------5路特殊旧召回------------------
-        RecallUtils.extractOldSpecialRecall(param, setVideo, rovRecallRank);
+        RecallUtils.extractOldSpecialRecall(mergeWeight.getOrDefault("oldSpecialN", (double) param.getSize()).intValue(), param, setVideo, rovRecallRank);
         //-------------------return相似召回------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("v6", 5.0).intValue(), param, ReturnVideoRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
         //-------------------新地域召回------------------
@@ -75,10 +75,17 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
         RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriProvinceStr", 1.0).intValue(), param, PrioriProvinceStrRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
         //-------------------priori province ros------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriProvinceRos", 1.0).intValue(), param, PrioriProvinceRosRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
-        //-------------------channel layer rovn------------------
-        RecallUtils.extractRecall(mergeWeight.getOrDefault("channelLayerRov", 5.0).intValue(), param, ChannelLayerRovnRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
-        //-------------------channel layer head rovn------------------
-        RecallUtils.extractRecall(mergeWeight.getOrDefault("channelLayerHeadRov", 5.0).intValue(), param, ChannelLayerHeadRovnRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
+        //-------------------return1 cate2 ros------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("return1Cate2Ros", 5.0).intValue(), param, Return1Cate2RosRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
+        //-------------------return1 cate2 str------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("return1Cate2Str", 5.0).intValue(), param, Return1Cate2StrRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
+        //-------------------social direct recall---------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("socialDirect", 5.0).intValue(), param, SocialI2IDirectRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
+        //---------------social history share recall------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("socialHistoryShare", 5.0).intValue(), param, SocialI2IHistoryShareRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
+        //---------------social history click recall------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("socialHistoryClick", 5.0).intValue(), param, SocialI2IHistoryClickRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
+
 
         //-------------------排-------------------
         //-------------------序-------------------
@@ -88,10 +95,9 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
 
         // 1. 批量获取特征  省份参数要对齐  headvid  要传递过来!
         // k1:视频、k2:表、k3:特征、v:特征值
+        Map<String, String> headVideoInfo = param.getHeadInfo();
         List<String> vids = CommonCollectionUtils.toListDistinct(rovRecallRank, v -> String.valueOf(v.getVideoId()));
-        String headVid = String.valueOf(param.getHeadVid());
-        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo(headVid, vids);
-        Map<String, String> headVideoInfo = videoBaseInfoMap.getOrDefault(headVid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
+        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo("", vids);
         FeatureService.Feature feature = featureService.getFeatureV4(param, headVideoInfo, videoBaseInfoMap, vids);
         Map<String, Map<String, String>> featureOriginUser = feature.getUserFeature();
         Map<String, Map<String, Map<String, String>>> featureOriginVideo = feature.getVideoFeature();
@@ -100,7 +106,7 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
         Map<String, Map<String, String[]>> newC7Map = FeatureV6.parseUCFScore(featureOriginUser.getOrDefault("alg_mid_feature_sharecf", new HashMap<>()));
         Map<String, Map<String, String[]>> newC8Map = FeatureV6.parseUCFScore(featureOriginUser.getOrDefault("alg_mid_feature_returncf", new HashMap<>()));
         UserShareReturnProfile userProfile = parseUserProfile(featureOriginUser);
-        Map<String, Map<String, String>> userBehaviorVideoMap = getUserBehaviorVideoMap(userProfile);
+        Map<String, Map<String, String>> userBehaviorVideoMap = param.getBehaviorVideos();
         Map<String, String> creativeInfo = param.getCreativeInfoFeature();
 
         // 3. 特征处理
@@ -111,7 +117,7 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
 
         // 4. 排序模型计算
         Map<String, Float> sceneFeatureMap = new HashMap<>(0);
-        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_fm_xgb_20250808.conf").scoring(sceneFeatureMap, userFeatureMap, userFeatureMap, rankItems);
+        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_fm_xgb_20250729.conf").scoring(sceneFeatureMap, userFeatureMap, userFeatureMap, rankItems);
 
         // 5. 排序公式特征
         double xgbRovNegRate = mergeWeight.getOrDefault("xgbRovNegRate", 0.059);
@@ -130,7 +136,7 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
             cate2Coefficient.putAll(simCateScore);
         }
         Double cate2CoefficientDenominator = mergeWeight.getOrDefault("cate2CoefficientDenominator", 1d);
-        Map<String, String> regionMap = getUserRegion(param);
+        Map<String, String> contextInfo = getContextInfo(param);
 
         List<Video> result = new ArrayList<>();
         for (RankItem item : items) {
@@ -182,8 +188,8 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
             if (MapUtils.isNotEmpty(param.getCreativeInfoFeature())) {
                 video.getMetaFeatureMap().put("creativeInfo", param.getCreativeInfoFeature());
             }
-            if (MapUtils.isNotEmpty(regionMap)) {
-                video.getMetaFeatureMap().put("region", regionMap);
+            if (MapUtils.isNotEmpty(contextInfo)) {
+                video.getMetaFeatureMap().put("context", contextInfo);
             }
             result.add(video);
         }
@@ -209,36 +215,6 @@ public class RankStrategy4RegionMergeModelV566 extends RankStrategy4RegionMergeM
         return null;
     }
 
-    private Map<String, Map<String, String>> getUserBehaviorVideoMap(UserShareReturnProfile userProfile) {
-        Set<String> vidSet = new HashSet<>();
-        if (null != userProfile) {
-            for (List<UserSRBO> list : Arrays.asList(userProfile.getM_s_s(), userProfile.getM_r_s(), userProfile.getL_s_s(), userProfile.getL_r_s())) {
-                if (null != list) {
-                    for (UserSRBO u : list) {
-                        if (null != u) {
-                            vidSet.add(u.getId() + "");
-                        }
-                    }
-                }
-            }
-        }
-
-        Map<String, Map<String, String>> historyVideoMap = new HashMap<>();
-        if (!vidSet.isEmpty()) {
-            Map<String, Map<String, Map<String, String>>> videoMap = featureService.getVideoBaseInfo("", new ArrayList<>(vidSet));
-            if (null != videoMap && !videoMap.isEmpty()) {
-                for (Map.Entry<String, Map<String, Map<String, String>>> entry : videoMap.entrySet()) {
-                    String vid = entry.getKey();
-                    Map<String, Map<String, String>> map = entry.getValue();
-                    if (null != map && map.containsKey("alg_vid_feature_basic_info")) {
-                        historyVideoMap.put(vid, map.get("alg_vid_feature_basic_info"));
-                    }
-                }
-            }
-        }
-        return historyVideoMap;
-    }
-
     private Map<String, Float> getUserFeature(long currentMs, RankParam param, Map<String, String> creativeInfo, Map<String, String> headInfo, UserShareReturnProfile userProfile, Map<String, Map<String, String>> userOriginInfo) {
         Map<String, Double> featMap = new HashMap<>();
         // context feature

+ 4 - 4
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV567.java

@@ -47,7 +47,7 @@ public class RankStrategy4RegionMergeModelV567 extends RankStrategy4RegionMergeM
         setVideo.add(param.getHeadVid());
         List<Video> rovRecallRank = new ArrayList<>();
         // -------------------5路特殊旧召回------------------
-        RecallUtils.extractOldSpecialRecall(param, setVideo, rovRecallRank);
+        RecallUtils.extractOldSpecialRecall(mergeWeight.getOrDefault("oldSpecialN", (double) param.getSize()).intValue(), param, setVideo, rovRecallRank);
         //-------------------return相似召回------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("v6", 5.0).intValue(), param, ReturnVideoRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
         //-------------------新地域召回------------------
@@ -128,7 +128,7 @@ public class RankStrategy4RegionMergeModelV567 extends RankStrategy4RegionMergeM
             cate2Coefficient.putAll(simCateScore);
         }
         Double cate2CoefficientDenominator = mergeWeight.getOrDefault("cate2CoefficientDenominator", 1d);
-        Map<String, String> regionMap = getUserRegion(param);
+        Map<String, String> contextInfo = getContextInfo(param);
 
         List<Video> result = new ArrayList<>();
         for (RankItem item : items) {
@@ -180,8 +180,8 @@ public class RankStrategy4RegionMergeModelV567 extends RankStrategy4RegionMergeM
             if (MapUtils.isNotEmpty(param.getCreativeInfoFeature())) {
                 video.getMetaFeatureMap().put("creativeInfo", param.getCreativeInfoFeature());
             }
-            if (MapUtils.isNotEmpty(regionMap)) {
-                video.getMetaFeatureMap().put("region", regionMap);
+            if (MapUtils.isNotEmpty(contextInfo)) {
+                video.getMetaFeatureMap().put("context", contextInfo);
             }
             result.add(video);
         }

+ 44 - 67
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV568.java

@@ -8,9 +8,9 @@ import com.tzld.piaoquan.recommend.server.model.MachineInfo;
 import com.tzld.piaoquan.recommend.server.model.Video;
 import com.tzld.piaoquan.recommend.server.service.FeatureService;
 import com.tzld.piaoquan.recommend.server.service.rank.RankParam;
-import com.tzld.piaoquan.recommend.server.service.rank.bo.UserSRBO;
 import com.tzld.piaoquan.recommend.server.service.rank.bo.UserShareReturnProfile;
 import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractVideoMergeCate;
+import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractorUtils;
 import com.tzld.piaoquan.recommend.server.service.rank.tansform.FeatureV6;
 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
 import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils;
@@ -48,7 +48,7 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
         setVideo.add(param.getHeadVid());
         List<Video> rovRecallRank = new ArrayList<>();
         // -------------------5路特殊旧召回------------------
-        RecallUtils.extractOldSpecialRecall(param, setVideo, rovRecallRank);
+        RecallUtils.extractOldSpecialRecall(mergeWeight.getOrDefault("oldSpecialN", (double) param.getSize()).intValue(), param, setVideo, rovRecallRank);
         //-------------------return相似召回------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("v6", 5.0).intValue(), param, ReturnVideoRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
         //-------------------新地域召回------------------
@@ -75,6 +75,12 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
         RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriProvinceStr", 1.0).intValue(), param, PrioriProvinceStrRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
         //-------------------priori province ros------------------
         RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriProvinceRos", 1.0).intValue(), param, PrioriProvinceRosRecallStrategy.PUSH_FROM, setVideo, rovRecallRank);
+        //-------------------return1 cate2 ros------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("return1Cate2Ros", 5.0).intValue(), param, Return1Cate2RosRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
+        //-------------------return1 cate2 str------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("return1Cate2Str", 5.0).intValue(), param, Return1Cate2StrRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
+        //-------------------priori premium rovn------------------
+        RecallUtils.extractRecall(mergeWeight.getOrDefault("prioriPremiumRovn", 0.0).intValue(), param, PrioriPremiumRovnRecallStrategy.PUSH_FORM, setVideo, rovRecallRank);
 
         //-------------------排-------------------
         //-------------------序-------------------
@@ -84,36 +90,38 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
 
         // 1. 批量获取特征  省份参数要对齐  headvid  要传递过来!
         // k1:视频、k2:表、k3:特征、v:特征值
+        Map<String, String> headVideoInfo = param.getHeadInfo();
         List<String> vids = CommonCollectionUtils.toListDistinct(rovRecallRank, v -> String.valueOf(v.getVideoId()));
-        String headVid = String.valueOf(param.getHeadVid());
-        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo(headVid, vids);
-        FeatureService.Feature feature = featureService.getFeatureV3(param, videoBaseInfoMap, vids);
+        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo("", vids);
+        FeatureService.Feature feature = featureService.getFeatureV4(param, headVideoInfo, videoBaseInfoMap, vids);
         Map<String, Map<String, String>> featureOriginUser = feature.getUserFeature();
         Map<String, Map<String, Map<String, String>>> featureOriginVideo = feature.getVideoFeature();
-        Map<String, String> headVideoInfo = videoBaseInfoMap.getOrDefault(headVid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
 
         // 2. 用户信息预处理
         Map<String, Map<String, String[]>> newC7Map = FeatureV6.parseUCFScore(featureOriginUser.getOrDefault("alg_mid_feature_sharecf", new HashMap<>()));
         Map<String, Map<String, String[]>> newC8Map = FeatureV6.parseUCFScore(featureOriginUser.getOrDefault("alg_mid_feature_returncf", new HashMap<>()));
         UserShareReturnProfile userProfile = parseUserProfile(featureOriginUser);
-        Map<String, Map<String, String>> userBehaviorVideoMap = getUserBehaviorVideoMap(userProfile);
+        Map<String, Map<String, String>> userBehaviorVideoMap = param.getBehaviorVideos();
+        Map<String, String> creativeInfo = param.getCreativeInfoFeature();
 
         // 3. 特征处理
         List<RankItem> rankItems = CommonCollectionUtils.toList(rovRecallRank, RankItem::new);
-        Map<String, Float> userFeatureMap = getUserFeature(currentMs, param, headVideoInfo, userProfile, featureOriginUser);
-        batchGetVideoFeature(currentMs, userProfile, headVideoInfo, videoBaseInfoMap,
+        Map<String, Float> userFeatureMap = getUserFeature(currentMs, param, creativeInfo, headVideoInfo, userProfile, featureOriginUser);
+        batchGetVideoFeature(currentMs, userProfile, creativeInfo, headVideoInfo, videoBaseInfoMap,
                 newC7Map, newC8Map, featureOriginUser, userBehaviorVideoMap, featureOriginVideo, rankItems);
 
         // 4. 排序模型计算
         Map<String, Float> sceneFeatureMap = new HashMap<>(0);
-        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_fm_xgb_20250317.conf").scoring(sceneFeatureMap, userFeatureMap, userFeatureMap, rankItems);
+        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_fm_xgb_20250729.conf").scoring(sceneFeatureMap, userFeatureMap, userFeatureMap, rankItems);
 
         // 5. 排序公式特征
         double xgbRovNegRate = mergeWeight.getOrDefault("xgbRovNegRate", 0.059);
         double xgbNorPowerWeight = mergeWeight.getOrDefault("xgbNorPowerWeight", 1.22);
         double xgbNorPowerExp = mergeWeight.getOrDefault("xgbNorPowerExp", 1.15);
-        double modelNorWeight = mergeWeight.getOrDefault("modelNorWeight", 0.5);
-        double statNorWeight = mergeWeight.getOrDefault("statNorWeight", 0.5);
+        double prioriHighValue = mergeWeight.getOrDefault("prioriHighValue", 1.5);
+        double prioriHighWeight = mergeWeight.getOrDefault("prioriHighWeight", 1.0);
+        double prioriLowValue = mergeWeight.getOrDefault("prioriLowValue", 0.5);
+        double prioriLowWeight = mergeWeight.getOrDefault("prioriLowWeight", 0.8);
         Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_vor:");
 
         // 获取权重
@@ -127,29 +135,34 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
             cate2Coefficient.putAll(simCateScore);
         }
         Double cate2CoefficientDenominator = mergeWeight.getOrDefault("cate2CoefficientDenominator", 1d);
-        Map<String, String> regionMap = getUserRegion(param);
+        Map<String, String> contextInfo = getContextInfo(param);
+        Map<String, Double> prioriVidProvinceRovn = this.getPrioriVidProvinceRovn(param.getProvince(), items, videoBaseInfoMap);
 
         List<Video> result = new ArrayList<>();
         for (RankItem item : items) {
             double score;
+            String vid = String.valueOf(item.getVideoId());
             double fmRovOrigin = item.getScoreRov();
             item.getScoresMap().put("fmRovOrigin", fmRovOrigin);
             double fmRov = restoreScore(fmRovOrigin, xgbRovNegRate);
             item.getScoresMap().put("fmRov", fmRov);
-            double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("rov", "0"));
+            double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(vid, new HashMap<>()).getOrDefault("rov", "0"));
             item.getScoresMap().put("hasReturnRovScore", hasReturnRovScore);
             double norXGBScore = item.getScoresMap().getOrDefault("NorXGBScore", 0d);
             double newNorXGBScore = norPowerCalibration(xgbNorPowerWeight, xgbNorPowerExp, norXGBScore);
-            newNorXGBScore = norFusion(modelNorWeight, newNorXGBScore, statNorWeight, hasReturnRovScore);
-            double vor = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("vor", "0"));
+            double vor = Double.parseDouble(vid2MapFeature.getOrDefault(vid, new HashMap<>()).getOrDefault("vor", "0"));
             item.getScoresMap().put("vor", vor);
 
-            String vidMergeCate2 = this.findVideoMergeCate2(videoBaseInfoMap, String.valueOf(item.getVideoId()));
+            String vidMergeCate2 = this.findVideoMergeCate2(videoBaseInfoMap, vid);
             Double scoreCoefficient = cate2Coefficient.getOrDefault(vidMergeCate2, 0d);
             item.getScoresMap().put("scoreCoefficient", scoreCoefficient);
             item.getScoresMap().put("cate2CoefficientDenominator", cate2CoefficientDenominator);
 
-            score = fmRov * (0.1 + newNorXGBScore) * (0.1 + vor) * (1 + scoreCoefficient / cate2CoefficientDenominator);
+            double prioriWeight = getPrioriVidProvinceWeight(prioriHighValue, prioriHighWeight, prioriLowValue, prioriLowWeight, vid, prioriVidProvinceRovn);
+            score = prioriWeight * fmRov * (0.1 + newNorXGBScore) * (0.1 + vor) * (1 + scoreCoefficient / cate2CoefficientDenominator);
+            if (!ExtractorUtils.isDoubleEqualToZero(prioriWeight - 1.0)) {
+                item.getScoresMap().put("prioriWeight", prioriWeight);
+            }
 
             Video video = item.getVideo();
             video.setScore(score);
@@ -157,16 +170,16 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
             video.setScoresMap(item.getScoresMap());
             // video.setAllFeatureMap(item.getAllFeatureMap());
 
-            String mergeCate2 = ExtractVideoMergeCate.parseMergeCate2(String.valueOf(item.getVideoId()), videoBaseInfoMap);
+            String mergeCate2 = ExtractVideoMergeCate.parseMergeCate2(vid, videoBaseInfoMap);
             if (StringUtils.isNotBlank(mergeCate2)) {
                 video.getMergeCateList().add(mergeCate2);
             }
 
-            if (MapUtils.isNotEmpty(feature.getVideoFeature()) && MapUtils.isNotEmpty(feature.getVideoFeature().get(item.getVideoId() + ""))) {
-                video.getMetaFeatureMap().putAll(feature.getVideoFeature().get(item.getVideoId() + ""));
+            if (MapUtils.isNotEmpty(feature.getVideoFeature()) && MapUtils.isNotEmpty(feature.getVideoFeature().get(vid))) {
+                video.getMetaFeatureMap().putAll(feature.getVideoFeature().get(vid));
             }
-            if (MapUtils.isNotEmpty(videoBaseInfoMap) && MapUtils.isNotEmpty(videoBaseInfoMap.get(item.getVideoId() + ""))) {
-                video.getMetaFeatureMap().putAll(videoBaseInfoMap.get(item.getVideoId() + ""));
+            if (MapUtils.isNotEmpty(videoBaseInfoMap) && MapUtils.isNotEmpty(videoBaseInfoMap.get(vid))) {
+                video.getMetaFeatureMap().putAll(videoBaseInfoMap.get(vid));
             }
             if (MapUtils.isNotEmpty(headVideoInfo)) {
                 video.getMetaFeatureMap().put("head_video", headVideoInfo);
@@ -180,8 +193,8 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
             if (MapUtils.isNotEmpty(param.getCreativeInfoFeature())) {
                 video.getMetaFeatureMap().put("creativeInfo", param.getCreativeInfoFeature());
             }
-            if (MapUtils.isNotEmpty(regionMap)) {
-                video.getMetaFeatureMap().put("region", regionMap);
+            if (MapUtils.isNotEmpty(contextInfo)) {
+                video.getMetaFeatureMap().put("context", contextInfo);
             }
             result.add(video);
         }
@@ -207,42 +220,13 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
         return null;
     }
 
-    private Map<String, Map<String, String>> getUserBehaviorVideoMap(UserShareReturnProfile userProfile) {
-        Set<String> vidSet = new HashSet<>();
-        if (null != userProfile) {
-            for (List<UserSRBO> list : Arrays.asList(userProfile.getM_s_s(), userProfile.getM_r_s(), userProfile.getL_s_s(), userProfile.getL_r_s())) {
-                if (null != list) {
-                    for (UserSRBO u : list) {
-                        if (null != u) {
-                            vidSet.add(u.getId() + "");
-                        }
-                    }
-                }
-            }
-        }
-
-        Map<String, Map<String, String>> historyVideoMap = new HashMap<>();
-        if (!vidSet.isEmpty()) {
-            Map<String, Map<String, Map<String, String>>> videoMap = featureService.getVideoBaseInfo("", new ArrayList<>(vidSet));
-            if (null != videoMap && !videoMap.isEmpty()) {
-                for (Map.Entry<String, Map<String, Map<String, String>>> entry : videoMap.entrySet()) {
-                    String vid = entry.getKey();
-                    Map<String, Map<String, String>> map = entry.getValue();
-                    if (null != map && map.containsKey("alg_vid_feature_basic_info")) {
-                        historyVideoMap.put(vid, map.get("alg_vid_feature_basic_info"));
-                    }
-                }
-            }
-        }
-        return historyVideoMap;
-    }
-
-    private Map<String, Float> getUserFeature(long currentMs, RankParam param, Map<String, String> headInfo, UserShareReturnProfile userProfile, Map<String, Map<String, String>> userOriginInfo) {
+    private Map<String, Float> getUserFeature(long currentMs, RankParam param, Map<String, String> creativeInfo, Map<String, String> headInfo, UserShareReturnProfile userProfile, Map<String, Map<String, String>> userOriginInfo) {
         Map<String, Double> featMap = new HashMap<>();
         // context feature
         String appType = String.valueOf(param.getAppType());
         String hotSceneType = String.valueOf(param.getHotSceneType());
         FeatureV6.getContextFeature(currentMs, appType, hotSceneType, featMap);
+        FeatureV6.getCreativeBaseFeature("e1", creativeInfo, featMap);
 
         // head video feature
         FeatureV6.getVideoBaseFeature("h", currentMs, headInfo, featMap);
@@ -257,6 +241,7 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
 
     private Map<String, Float> getVideoFeature(long currentMs, String vid,
                                                UserShareReturnProfile userProfile,
+                                               Map<String, String> creativeInfo,
                                                Map<String, String> headInfo, Map<String, String> rankInfo,
                                                Map<String, Map<String, String[]>> c7Map,
                                                Map<String, Map<String, String[]>> c8Map,
@@ -276,6 +261,7 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
 
         // head&rank cross feature
         FeatureV6.getHeadRankVideoCrossFeature(headInfo, rankInfo, featMap);
+        FeatureV6.getCreativeCrossFeature("e1", creativeInfo, rankInfo, featMap);
 
         // user profile & rank cross
         FeatureV6.getProfileVideoCrossFeature(currentMs, userProfile, rankInfo, historyVideoMap, featMap);
@@ -285,6 +271,7 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
 
     private void batchGetVideoFeature(long currentMs,
                                       UserShareReturnProfile userProfile,
+                                      Map<String, String> creativeInfo,
                                       Map<String, String> headInfo,
                                       Map<String, Map<String, Map<String, String>>> videoBaseInfoMap,
                                       Map<String, Map<String, String[]>> c7Map,
@@ -299,7 +286,7 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
                 String vid = item.getVideoId() + "";
                 Map<String, String> rankInfo = videoBaseInfoMap.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
                 Future<Integer> future = ThreadPoolFactory.defaultPool().submit(() -> {
-                    item.featureMap = getVideoFeature(currentMs, vid, userProfile, headInfo, rankInfo, c7Map, c8Map, userOriginInfo, historyVideoMap, videoOriginInfo);
+                    item.featureMap = getVideoFeature(currentMs, vid, userProfile, creativeInfo, headInfo, rankInfo, c7Map, c8Map, userOriginInfo, historyVideoMap, videoOriginInfo);
                     item.norFeatureMap = item.featureMap;
                     return 1;
                 });
@@ -416,14 +403,4 @@ public class RankStrategy4RegionMergeModelV568 extends RankStrategy4RegionMergeM
         Map<String, String> videoInfo = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>());
         return videoInfo.get("merge_second_level_cate");
     }
-
-    private double norFusion(double modelWeight, double modelScore, double statWeight, double statScore) {
-        if (modelScore < 1E-8) {
-            return statScore;
-        } else if (statScore < 1E-8) {
-            return modelScore;
-        } else {
-            return modelWeight * modelScore + statWeight * statScore;
-        }
-    }
 }

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

@@ -19,6 +19,7 @@ public class FilterParamFactory {
 
         // 风险过滤
         filterParam.setRiskUser(param.isRiskUser());
+        filterParam.setTestingRiskRegion(param.isTestingRiskRegion());
         filterParam.setRegionCode(param.getRegionCode());
         filterParam.setAbExpCodes(param.getAbExpCodes());
         filterParam.setCityCode(param.getCityCode());

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

@@ -34,6 +34,7 @@ public class RecallParam {
     private String clientIp;
 
     private boolean riskUser;
+    private boolean testingRiskRegion;
     private String rootSourceId;
     private Integer userShareDepth;
 
@@ -48,4 +49,7 @@ public class RecallParam {
     private String currentPageSource;
     private Map<String, String> creativeInfoFeature;
     private Map<String, Map<String, String>> behaviorVideos;
+    private String openGId;
+
+    private Map<String, String> userSocialRecallInfo;
 }

+ 13 - 8
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java

@@ -121,18 +121,23 @@ public class RecallService implements ApplicationContextAware {
         strategies.add(strategyMap.get(PrioriProvinceRovnRecallStrategy.class.getSimpleName()));
         strategies.add(strategyMap.get(PrioriProvinceStrRecallStrategy.class.getSimpleName()));
         strategies.add(strategyMap.get(PrioriProvinceRosRecallStrategy.class.getSimpleName()));
+        strategies.add(strategyMap.get(Return1Cate2RosRecallStrategy.class.getSimpleName()));
+        strategies.add(strategyMap.get(Return1Cate2StrRecallStrategy.class.getSimpleName()));
         Set<String> abExpCodes = param.getAbExpCodes();
-        if (CollectionUtils.isNotEmpty(abExpCodes) && abExpCodes.contains("566")) {
-            strategies.add(strategyMap.get(ChannelLayerRovnRecallStrategy.class.getSimpleName()));
-            strategies.add(strategyMap.get(ChannelLayerHeadRovnRecallStrategy.class.getSimpleName()));
-        }
-        if (CollectionUtils.isNotEmpty(abExpCodes) && abExpCodes.contains("567")) {
-            strategies.add(strategyMap.get(Return1Cate2RosRecallStrategy.class.getSimpleName()));
-            strategies.add(strategyMap.get(Return1Cate2StrRecallStrategy.class.getSimpleName()));
+        if (CollectionUtils.isNotEmpty(abExpCodes)) {
+            if (abExpCodes.contains("568")) {
+                strategies.add(strategyMap.get(PrioriPremiumRovnRecallStrategy.class.getSimpleName()));
+            }
+            if (abExpCodes.contains("566")){
+                strategies.add(strategyMap.get(SocialI2IDirectRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(SocialI2IHistoryShareRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(SocialI2IHistoryClickRecallStrategy.class.getSimpleName()));
+            }
         }
 
         // 命中用户黑名单不走流量池
-        if (!param.isRiskUser()) {
+        // 命中安全测试风险地域不走流量池
+        if (!param.isRiskUser() && !param.isTestingRiskRegion()) {
             strategies.add(strategyMap.get(QuickFlowPoolWithLevelRecallStrategy.class.getSimpleName()));
             strategies.add(strategyMap.get(FlowPoolWithLevelRecallStrategyTomson.class.getSimpleName()));
             strategies.add(strategyMap.get(DouHotFlowPoolRecallStrategy.class.getSimpleName()));

+ 0 - 100
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/PremiumROVRecallStrategy.java

@@ -1,100 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.tzld.piaoquan.recommend.server.model.Video;
-import com.tzld.piaoquan.recommend.server.service.filter.FilterParam;
-import com.tzld.piaoquan.recommend.server.service.filter.FilterResult;
-import com.tzld.piaoquan.recommend.server.service.filter.FilterService;
-import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
-import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
-import com.tzld.piaoquan.recommend.server.service.recall.RecallStrategy;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.MutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Component
-@Slf4j
-public class PremiumROVRecallStrategy implements RecallStrategy {
-    private final String CLASS_NAME = this.getClass().getSimpleName();
-    @Autowired
-    private FilterService filterService;
-    @Autowired
-    @Qualifier("redisTemplate")
-    public RedisTemplate<String, String> redisTemplate;
-
-    public static final String PUSH_FROM = "premium_rov";
-    public static final String redisKey = "high_rovn_low_exp_recall:all";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FROM;
-    }
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        List<Video> videosResult = new ArrayList<>();
-        try {
-            String redisValue = redisTemplate.opsForValue().get(redisKey);
-            if (null == redisValue || redisValue.isEmpty()) {
-                return videosResult;
-            }
-            Pair<List<Long>, Map<Long, Double>> pair = parsePair(redisValue, param.getVideoId(), 100);
-            fillVideoResult(param, pair, videosResult);
-        } catch (Exception e) {
-            log.error("recall is wrong in {}, error={}", CLASS_NAME, e);
-        }
-        return videosResult;
-    }
-
-    private Pair<List<Long>, Map<Long, Double>> parsePair(String data, long headVid, int size) {
-        List<Long> idsList = new ArrayList<>();
-        Map<Long, Double> scoresMap = new HashMap<>();
-        if (!StringUtils.isBlank(data)) {
-            String[] cells = data.split("\t");
-            if (2 == cells.length) {
-                List<Long> ids = Arrays.stream(cells[0].split(",")).map(Long::valueOf).collect(Collectors.toList());
-                List<Double> scores = Arrays.stream(cells[1].split(",")).map(Double::valueOf).collect(Collectors.toList());
-                if (!ids.isEmpty() && ids.size() == scores.size()) {
-                    int minSize = Math.min(size, ids.size());
-                    for (int i = 0; i < minSize; ++i) {
-                        long id = ids.get(i);
-                        double score = scores.get(i);
-                        if (score > 0.01 && headVid != id && !scoresMap.containsKey(id)) {
-                            idsList.add(id);
-                            scoresMap.put(id, score);
-                        }
-                    }
-                }
-            }
-        }
-        return new MutablePair<>(idsList, scoresMap);
-    }
-
-    private void fillVideoResult(RecallParam param, Pair<List<Long>, Map<Long, Double>> pair, List<Video> videosResult) {
-        if (null != pair) {
-            List<Long> ids = pair.getLeft();
-            Map<Long, Double> scoresMap = pair.getRight();
-            if (null != ids && null != scoresMap && !ids.isEmpty()) {
-                FilterParam filterParam = FilterParamFactory.create(param, ids);
-                FilterResult filterResult = filterService.filter(filterParam);
-                if (null != filterResult && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-                    filterResult.getVideoIds().forEach(vid -> {
-                        Video video = new Video();
-                        video.setVideoId(vid);
-                        video.setRovScore(scoresMap.getOrDefault(vid, 0D));
-                        video.setPushFrom(pushFrom());
-                        videosResult.add(video);
-                    });
-                }
-            }
-        }
-    }
-}

+ 36 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/PrioriPremiumRovnRecallStrategy.java

@@ -0,0 +1,36 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class PrioriPremiumRovnRecallStrategy extends AbstractRedisRecallStrategy {
+    private static final int topN = 60;
+    public static final String PUSH_FORM = "priori_premium_rovn";
+    private static final String redisKeyPrefix = "priori_premium_rovn_recall";
+
+    @Override
+    public String pushFrom() {
+        return PUSH_FORM;
+    }
+
+    @Override
+    protected List<String> getRedisKeys(RecallParam param) {
+        List<String> keys = new ArrayList<>();
+        if (null != param) {
+            String province = param.getProvince();
+            if (null != province && !province.isEmpty()) {
+                keys.add(String.format("%s:%s", redisKeyPrefix, province));
+            }
+        }
+        return keys;
+    }
+
+    @Override
+    protected int getTopN() {
+        return topN;
+    }
+}

+ 162 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IBasicRecallStrategy.java

@@ -0,0 +1,162 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.model.Video;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterParam;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterResult;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterService;
+import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import com.tzld.piaoquan.recommend.server.service.recall.RecallStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+public abstract class SocialI2IBasicRecallStrategy implements RecallStrategy {
+
+    private final String CLASS_NAME = this.getClass().getSimpleName();
+
+//    private static final String REDIS_KEY_FORMAT = "user_social_i2i_recall:";
+//    private static final String REDIS_KEY_FORMAT = "user_shares_i2i_recall:";
+//    private static final String DEFAULT_REDIS_KEY_FORMAT = "user_social_i2i_recall:";
+    private static final String DEFAULT_REDIS_KEY_FORMAT = "clicks_user_shares_i2i_recall:";
+
+    @Autowired
+    private FilterService filterService;
+
+    @Autowired
+    @Qualifier("redisTemplate")
+    public RedisTemplate<String, String> redisTemplate;
+
+    protected abstract List<Long> genLeftItemList(RecallParam param);
+
+    protected String getRedisKeyFormat() {
+        return DEFAULT_REDIS_KEY_FORMAT;
+    }
+
+    @Override
+    public List<Video> recall(RecallParam param) {
+        List<Video> videos = new ArrayList<>();
+
+        try {
+
+            List<Long> leftItems = this.genLeftItemList(param);
+            if (CollectionUtils.isEmpty(leftItems)) {
+                return videos;
+            }
+
+//            Map<Long, List<Pair<Long, Double>>> recallResult = this.multiGetRecallResult(REDIS_KEY_FORMAT, leftItems);
+            Map<Long, List<Pair<Long, Double>>> recallResult = this.multiGetRecallResult(this.getRedisKeyFormat(), leftItems);
+
+            // 打平多个视频的召回,并按照分数从大到小排序
+            List<Pair<Long, Double>> recallPair = this.flatAndSortRecallResult(recallResult);
+            recallPair.sort(Comparator.comparingDouble(p -> -p.getValue()));
+
+            List<Long> videoIds = recallPair.stream().map(Pair::getKey).collect(Collectors.toList());
+
+
+            // 视频过滤
+            FilterParam filterParam = FilterParamFactory.create(param, videoIds);
+            FilterResult filterResult = filterService.filter(filterParam);
+            if (Objects.isNull(filterResult) || CollectionUtils.isEmpty(filterResult.getVideoIds())) {
+                return videos;
+            }
+
+            // 返回结果
+            Map<Long, Double> videoScoreMap = recallPair.stream()
+                    .collect(Collectors.toMap(Pair::getKey, Pair::getValue, (o1, o2) -> o1));
+            for (Long videoId : filterResult.getVideoIds()) {
+                Video video = new Video();
+                video.setVideoId(videoId);
+                video.setRovScore(videoScoreMap.getOrDefault(videoId, 0D));
+                video.setPushFrom(pushFrom());
+                videos.add(video);
+            }
+        } catch (Exception e) {
+            log.error("recall error strategy is {}, pushFrom is {} \n", CLASS_NAME, pushFrom(), e);
+        }
+        return videos;
+
+    }
+
+    /**
+     * 获取多个视频的I2I召回结果
+     */
+    private Map<Long, List<Pair<Long, Double>>> multiGetRecallResult(String keyPrefix, List<Long> keySuffix) {
+        if (StringUtils.isBlank(keyPrefix) || CollectionUtils.isEmpty(keySuffix)) {
+            return new HashMap<>();
+        }
+        List<String> keys = keySuffix.stream()
+                .map(i -> keyPrefix + i)
+                .collect(Collectors.toList());
+
+        List<String> values = redisTemplate.opsForValue().multiGet(keys);
+        if (CollectionUtils.isEmpty(values)) {
+            return new HashMap<>();
+        }
+
+        Map<Long, List<Pair<Long, Double>>> resultMap = new HashMap<>();
+        for (int i = 0; i < keySuffix.size(); i++) {
+            String value = values.get(i);
+            List<Pair<Long, Double>> recallVideos = this.parseRedisValue(value);
+            if (CollectionUtils.isEmpty(recallVideos)) {
+                continue;
+            }
+            resultMap.put(keySuffix.get(i), recallVideos);
+        }
+        return resultMap;
+    }
+
+
+    private List<Pair<Long, Double>> parseRedisValue(String value) {
+        if (StringUtils.isBlank(value)) {
+            return new ArrayList<>();
+        }
+        String[] split = value.split("\t");
+        if (split.length != 2) {
+            return new ArrayList<>();
+        }
+
+        List<Long> videoIds = Arrays.stream(split[0].split(","))
+                .filter(StringUtils::isNotBlank)
+                .map(String::trim)
+                .map(Long::parseLong)
+                .collect(Collectors.toList());
+
+        List<Double> scores = Arrays.stream(split[1].split(","))
+                .filter(StringUtils::isNotBlank)
+                .map(String::trim)
+                .map(Double::parseDouble)
+                .collect(Collectors.toList());
+
+        if (videoIds.size() != scores.size()) {
+            return new ArrayList<>();
+        }
+
+        List<Pair<Long, Double>> recallVideos = new ArrayList<>();
+        for (int i = 0; i < videoIds.size(); i++) {
+            recallVideos.add(Pair.of(videoIds.get(i), scores.get(i)));
+        }
+        return recallVideos;
+    }
+
+    /**
+     * 打平多个视频的召回结果,同一个被召回的视频对其分数求和
+     */
+    private List<Pair<Long, Double>> flatAndSortRecallResult(Map<Long, List<Pair<Long, Double>>> resultMap) {
+        return resultMap.values().stream()
+                .flatMap(Collection::stream)
+                .collect(Collectors.groupingBy(Pair::getKey, Collectors.summingDouble(Pair::getValue)))
+                .entrySet()
+                .stream()
+                .map(i -> Pair.of(i.getKey(), i.getValue()))
+                .collect(Collectors.toList());
+    }
+}

+ 30 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IDirectRecallStrategy.java

@@ -0,0 +1,30 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 用户本次访问视频的社交I2I召回
+ */
+@Slf4j
+@Component
+public class SocialI2IDirectRecallStrategy extends SocialI2IBasicRecallStrategy {
+
+    public static final String PUSH_FROM = "social_i2i_direct_recall";
+
+    @Override
+    protected List<Long> genLeftItemList(RecallParam param) {
+        return new ArrayList<>(Collections.singletonList(param.getVideoId()));
+    }
+
+
+    @Override
+    public String pushFrom() {
+        return SocialI2IDirectRecallStrategy.PUSH_FROM;
+    }
+}

+ 40 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IHistoryClickRecallStrategy.java

@@ -0,0 +1,40 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 用户历史分享视频的社交I2I召回
+ */
+@Slf4j
+@Component
+public class SocialI2IHistoryClickRecallStrategy extends SocialI2IBasicRecallStrategy {
+
+    public static final String PUSH_FROM = "social_i2i_history_click_recall";
+
+    @Override
+    protected List<Long> genLeftItemList(RecallParam param) {
+        if (MapUtils.isEmpty(param.getUserSocialRecallInfo())) {
+            return new ArrayList<>();
+        }
+        String clickVidList = param.getUserSocialRecallInfo().getOrDefault("click_vids", "");
+        return Arrays.stream(clickVidList.split(","))
+                .map(String::trim)
+                .filter(StringUtils::isNotBlank)
+                .map(Long::valueOf)
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public String pushFrom() {
+        return PUSH_FROM;
+    }
+}

+ 47 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SocialI2IHistoryShareRecallStrategy.java

@@ -0,0 +1,47 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 用户历史分享视频的社交I2I召回
+ */
+@Slf4j
+@Component
+public class SocialI2IHistoryShareRecallStrategy extends SocialI2IBasicRecallStrategy {
+
+    public static final String PUSH_FROM = "social_i2i_history_share_recall";
+
+    private static final String CUSTOM_REDIS_KEY_FORMAT = "user_shares_i2i_recall:";
+    @Override
+    protected List<Long> genLeftItemList(RecallParam param) {
+        if (MapUtils.isEmpty(param.getUserSocialRecallInfo())) {
+            return new ArrayList<>();
+        }
+        String shareVidList = param.getUserSocialRecallInfo().getOrDefault("share_vids", "");
+        return Arrays.stream(shareVidList.split(","))
+                .map(String::trim)
+                .filter(StringUtils::isNotBlank)
+                .map(Long::valueOf)
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public String pushFrom() {
+        return PUSH_FROM;
+    }
+
+
+    @Override
+    protected String getRedisKeyFormat() {
+        return CUSTOM_REDIS_KEY_FORMAT;
+    }
+}

+ 1 - 2
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/util/RecallUtils.java

@@ -45,7 +45,7 @@ public class RecallUtils {
         return Collections.emptyList();
     }
 
-    public static void extractOldSpecialRecall(RankParam param, Set<Long> setVideo, List<Video> rovRecallRank) {
+    public static void extractOldSpecialRecall(int sizeReturn, RankParam param, Set<Long> setVideo, List<Video> rovRecallRank) {
         List<Video> oldRovs = new ArrayList<>();
         oldRovs.addAll(extractAndSort(param, RegionHRecallStrategy.PUSH_FORM));
         oldRovs.addAll(extractAndSort(param, RegionHDupRecallStrategy.PUSH_FORM));
@@ -54,7 +54,6 @@ public class RecallUtils {
         oldRovs.addAll(extractAndSort(param, RegionRelative24HDupRecallStrategy.PUSH_FORM));
         removeDuplicate(oldRovs);
         oldRovs = oldRovs.stream().filter(r -> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
-        int sizeReturn = param.getSize();
         List<Video> v0 = oldRovs.size() <= sizeReturn
                 ? oldRovs
                 : oldRovs.subList(0, sizeReturn);