浏览代码

log score

丁云鹏 1 年之前
父节点
当前提交
10edc416d5

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

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

+ 21 - 19
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/Recommend.java

@@ -51,7 +51,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\"\255\003\n\020RecommendRequest\022\022\n\nrequest" +
+      "on.proto\"\356\003\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_" +
@@ -60,23 +60,25 @@ public final class Recommend {
       "atus\030\n \001(\005\022\032\n\022recommend_trace_id\030\013 \001(\t\022\020" +
       "\n\010video_id\030\014 \001(\003\022\014\n\004city\030\r \001(\t\022\020\n\010provin" +
       "ce\030\016 \001(\t\022\'\n\014machine_info\030\017 \001(\0132\021.Machine" +
-      "InfoProto\022\025\n\rnew_exp_group\030\020 \001(\t\032.\n\014Even" +
-      "tIdEntry\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\005m" +
-      "odel\030\002 \001(\t\022\020\n\010platform\030\003 \001(\t\022\023\n\013sdk_vers" +
-      "ion\030\004 \001(\t\022\016\n\006system\030\005 \001(\t\022\026\n\016wechat_vers" +
-      "ion\030\006 \001(\t\"H\n\021RecommendResponse\022\027\n\006result" +
-      "\030\001 \001(\0132\007.Result\022\032\n\005video\030\002 \003(\0132\013.VideoPr" +
-      "oto\"\265\001\n\nVideoProto\022\020\n\010video_id\030\001 \001(\003\022\021\n\t" +
-      "rov_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_score\030\005 \001(\001\022\020\n\010posit" +
-      "ion\030\006 \001(\005\022\021\n\tflow_pool\030\007 \001(\t\022\027\n\017is_in_fl" +
-      "ow_pool\030\010 \001(\005\022\014\n\004rand\030\t \001(\0012\212\001\n\020Recommen" +
-      "dService\022:\n\021HomepageRecommend\022\021.Recommen" +
-      "dRequest\032\022.RecommendResponse\022:\n\021Relevant" +
-      "Recommend\022\021.RecommendRequest\032\022.Recommend" +
-      "ResponseB7\n0com.tzld.piaoquan.recommend." +
-      "server.gen.recommendP\001\210\001\001b\006proto3"
+      "InfoProto\022\025\n\rnew_exp_group\030\020 \001(\t\022\022\n\nsess" +
+      "ion_id\030\021 \001(\t\022\026\n\016sub_session_id\030\022 \001(\t\022\023\n\013" +
+      "page_source\030\023 \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\020MachineInfo" +
+      "Proto\022\r\n\005brand\030\001 \001(\t\022\r\n\005model\030\002 \001(\t\022\020\n\010p" +
+      "latform\030\003 \001(\t\022\023\n\013sdk_version\030\004 \001(\t\022\016\n\006sy" +
+      "stem\030\005 \001(\t\022\026\n\016wechat_version\030\006 \001(\t\"H\n\021Re" +
+      "commendResponse\022\027\n\006result\030\001 \001(\0132\007.Result" +
+      "\022\032\n\005video\030\002 \003(\0132\013.VideoProto\"\265\001\n\nVideoPr" +
+      "oto\022\020\n\010video_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\n" +
+      "sort_score\030\005 \001(\001\022\020\n\010position\030\006 \001(\005\022\021\n\tfl" +
+      "ow_pool\030\007 \001(\t\022\027\n\017is_in_flow_pool\030\010 \001(\005\022\014" +
+      "\n\004rand\030\t \001(\0012\212\001\n\020RecommendService\022:\n\021Hom" +
+      "epageRecommend\022\021.RecommendRequest\032\022.Reco" +
+      "mmendResponse\022:\n\021RelevantRecommend\022\021.Rec" +
+      "ommendRequest\032\022.RecommendResponseB7\n0com" +
+      ".tzld.piaoquan.recommend.server.gen.reco" +
+      "mmendP\001\210\001\001b\006proto3"
     };
     descriptor = com.google.protobuf.Descriptors.FileDescriptor
       .internalBuildGeneratedFileFrom(descriptorData,
@@ -89,7 +91,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", });
+        new java.lang.String[] { "RequestId", "Mid", "Uid", "Size", "AppType", "CityCode", "ProvinceCode", "AbExpCode", "EventId", "VersionAuditStatus", "RecommendTraceId", "VideoId", "City", "Province", "MachineInfo", "NewExpGroup", "SessionId", "SubSessionId", "PageSource", });
     internal_static_RecommendRequest_EventIdEntry_descriptor =
       internal_static_RecommendRequest_descriptor.getNestedTypes().get(0);
     internal_static_RecommendRequest_EventIdEntry_fieldAccessorTable = new

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

@@ -26,6 +26,9 @@ private static final long serialVersionUID = 0L;
     city_ = "";
     province_ = "";
     newExpGroup_ = "";
+    sessionId_ = "";
+    subSessionId_ = "";
+    pageSource_ = "";
   }
 
   @java.lang.Override
@@ -168,6 +171,24 @@ private static final long serialVersionUID = 0L;
             newExpGroup_ = s;
             break;
           }
+          case 138: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            sessionId_ = s;
+            break;
+          }
+          case 146: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            subSessionId_ = s;
+            break;
+          }
+          case 154: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            pageSource_ = s;
+            break;
+          }
           default: {
             if (!parseUnknownField(
                 input, unknownFields, extensionRegistry, tag)) {
@@ -755,6 +776,120 @@ private static final long serialVersionUID = 0L;
     }
   }
 
+  public static final int SESSION_ID_FIELD_NUMBER = 17;
+  private volatile java.lang.Object sessionId_;
+  /**
+   * <code>string session_id = 17;</code>
+   * @return The sessionId.
+   */
+  @java.lang.Override
+  public java.lang.String getSessionId() {
+    java.lang.Object ref = sessionId_;
+    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();
+      sessionId_ = s;
+      return s;
+    }
+  }
+  /**
+   * <code>string session_id = 17;</code>
+   * @return The bytes for sessionId.
+   */
+  @java.lang.Override
+  public com.google.protobuf.ByteString
+      getSessionIdBytes() {
+    java.lang.Object ref = sessionId_;
+    if (ref instanceof java.lang.String) {
+      com.google.protobuf.ByteString b = 
+          com.google.protobuf.ByteString.copyFromUtf8(
+              (java.lang.String) ref);
+      sessionId_ = b;
+      return b;
+    } else {
+      return (com.google.protobuf.ByteString) ref;
+    }
+  }
+
+  public static final int SUB_SESSION_ID_FIELD_NUMBER = 18;
+  private volatile java.lang.Object subSessionId_;
+  /**
+   * <code>string sub_session_id = 18;</code>
+   * @return The subSessionId.
+   */
+  @java.lang.Override
+  public java.lang.String getSubSessionId() {
+    java.lang.Object ref = subSessionId_;
+    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();
+      subSessionId_ = s;
+      return s;
+    }
+  }
+  /**
+   * <code>string sub_session_id = 18;</code>
+   * @return The bytes for subSessionId.
+   */
+  @java.lang.Override
+  public com.google.protobuf.ByteString
+      getSubSessionIdBytes() {
+    java.lang.Object ref = subSessionId_;
+    if (ref instanceof java.lang.String) {
+      com.google.protobuf.ByteString b = 
+          com.google.protobuf.ByteString.copyFromUtf8(
+              (java.lang.String) ref);
+      subSessionId_ = b;
+      return b;
+    } else {
+      return (com.google.protobuf.ByteString) ref;
+    }
+  }
+
+  public static final int PAGE_SOURCE_FIELD_NUMBER = 19;
+  private volatile java.lang.Object pageSource_;
+  /**
+   * <code>string page_source = 19;</code>
+   * @return The pageSource.
+   */
+  @java.lang.Override
+  public java.lang.String getPageSource() {
+    java.lang.Object ref = pageSource_;
+    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();
+      pageSource_ = s;
+      return s;
+    }
+  }
+  /**
+   * <code>string page_source = 19;</code>
+   * @return The bytes for pageSource.
+   */
+  @java.lang.Override
+  public com.google.protobuf.ByteString
+      getPageSourceBytes() {
+    java.lang.Object ref = pageSource_;
+    if (ref instanceof java.lang.String) {
+      com.google.protobuf.ByteString b = 
+          com.google.protobuf.ByteString.copyFromUtf8(
+              (java.lang.String) ref);
+      pageSource_ = b;
+      return b;
+    } else {
+      return (com.google.protobuf.ByteString) ref;
+    }
+  }
+
   private byte memoizedIsInitialized = -1;
   @java.lang.Override
   public final boolean isInitialized() {
@@ -820,6 +955,15 @@ private static final long serialVersionUID = 0L;
     if (!getNewExpGroupBytes().isEmpty()) {
       com.google.protobuf.GeneratedMessageV3.writeString(output, 16, newExpGroup_);
     }
+    if (!getSessionIdBytes().isEmpty()) {
+      com.google.protobuf.GeneratedMessageV3.writeString(output, 17, sessionId_);
+    }
+    if (!getSubSessionIdBytes().isEmpty()) {
+      com.google.protobuf.GeneratedMessageV3.writeString(output, 18, subSessionId_);
+    }
+    if (!getPageSourceBytes().isEmpty()) {
+      com.google.protobuf.GeneratedMessageV3.writeString(output, 19, pageSource_);
+    }
     unknownFields.writeTo(output);
   }
 
@@ -894,6 +1038,15 @@ private static final long serialVersionUID = 0L;
     if (!getNewExpGroupBytes().isEmpty()) {
       size += com.google.protobuf.GeneratedMessageV3.computeStringSize(16, newExpGroup_);
     }
+    if (!getSessionIdBytes().isEmpty()) {
+      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(17, sessionId_);
+    }
+    if (!getSubSessionIdBytes().isEmpty()) {
+      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(18, subSessionId_);
+    }
+    if (!getPageSourceBytes().isEmpty()) {
+      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(19, pageSource_);
+    }
     size += unknownFields.getSerializedSize();
     memoizedSize = size;
     return size;
@@ -944,6 +1097,12 @@ private static final long serialVersionUID = 0L;
     }
     if (!getNewExpGroup()
         .equals(other.getNewExpGroup())) return false;
+    if (!getSessionId()
+        .equals(other.getSessionId())) return false;
+    if (!getSubSessionId()
+        .equals(other.getSubSessionId())) return false;
+    if (!getPageSource()
+        .equals(other.getPageSource())) return false;
     if (!unknownFields.equals(other.unknownFields)) return false;
     return true;
   }
@@ -994,6 +1153,12 @@ private static final long serialVersionUID = 0L;
     }
     hash = (37 * hash) + NEW_EXP_GROUP_FIELD_NUMBER;
     hash = (53 * hash) + getNewExpGroup().hashCode();
+    hash = (37 * hash) + SESSION_ID_FIELD_NUMBER;
+    hash = (53 * hash) + getSessionId().hashCode();
+    hash = (37 * hash) + SUB_SESSION_ID_FIELD_NUMBER;
+    hash = (53 * hash) + getSubSessionId().hashCode();
+    hash = (37 * hash) + PAGE_SOURCE_FIELD_NUMBER;
+    hash = (53 * hash) + getPageSource().hashCode();
     hash = (29 * hash) + unknownFields.hashCode();
     memoizedHashCode = hash;
     return hash;
@@ -1184,6 +1349,12 @@ private static final long serialVersionUID = 0L;
       }
       newExpGroup_ = "";
 
+      sessionId_ = "";
+
+      subSessionId_ = "";
+
+      pageSource_ = "";
+
       return this;
     }
 
@@ -1236,6 +1407,9 @@ private static final long serialVersionUID = 0L;
         result.machineInfo_ = machineInfoBuilder_.build();
       }
       result.newExpGroup_ = newExpGroup_;
+      result.sessionId_ = sessionId_;
+      result.subSessionId_ = subSessionId_;
+      result.pageSource_ = pageSource_;
       onBuilt();
       return result;
     }
@@ -1347,6 +1521,18 @@ private static final long serialVersionUID = 0L;
         newExpGroup_ = other.newExpGroup_;
         onChanged();
       }
+      if (!other.getSessionId().isEmpty()) {
+        sessionId_ = other.sessionId_;
+        onChanged();
+      }
+      if (!other.getSubSessionId().isEmpty()) {
+        subSessionId_ = other.subSessionId_;
+        onChanged();
+      }
+      if (!other.getPageSource().isEmpty()) {
+        pageSource_ = other.pageSource_;
+        onChanged();
+      }
       this.mergeUnknownFields(other.unknownFields);
       onChanged();
       return this;
@@ -2577,6 +2763,234 @@ private static final long serialVersionUID = 0L;
       onChanged();
       return this;
     }
+
+    private java.lang.Object sessionId_ = "";
+    /**
+     * <code>string session_id = 17;</code>
+     * @return The sessionId.
+     */
+    public java.lang.String getSessionId() {
+      java.lang.Object ref = sessionId_;
+      if (!(ref instanceof java.lang.String)) {
+        com.google.protobuf.ByteString bs =
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        sessionId_ = s;
+        return s;
+      } else {
+        return (java.lang.String) ref;
+      }
+    }
+    /**
+     * <code>string session_id = 17;</code>
+     * @return The bytes for sessionId.
+     */
+    public com.google.protobuf.ByteString
+        getSessionIdBytes() {
+      java.lang.Object ref = sessionId_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        sessionId_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    /**
+     * <code>string session_id = 17;</code>
+     * @param value The sessionId to set.
+     * @return This builder for chaining.
+     */
+    public Builder setSessionId(
+        java.lang.String value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  
+      sessionId_ = value;
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string session_id = 17;</code>
+     * @return This builder for chaining.
+     */
+    public Builder clearSessionId() {
+      
+      sessionId_ = getDefaultInstance().getSessionId();
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string session_id = 17;</code>
+     * @param value The bytes for sessionId to set.
+     * @return This builder for chaining.
+     */
+    public Builder setSessionIdBytes(
+        com.google.protobuf.ByteString value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+      
+      sessionId_ = value;
+      onChanged();
+      return this;
+    }
+
+    private java.lang.Object subSessionId_ = "";
+    /**
+     * <code>string sub_session_id = 18;</code>
+     * @return The subSessionId.
+     */
+    public java.lang.String getSubSessionId() {
+      java.lang.Object ref = subSessionId_;
+      if (!(ref instanceof java.lang.String)) {
+        com.google.protobuf.ByteString bs =
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        subSessionId_ = s;
+        return s;
+      } else {
+        return (java.lang.String) ref;
+      }
+    }
+    /**
+     * <code>string sub_session_id = 18;</code>
+     * @return The bytes for subSessionId.
+     */
+    public com.google.protobuf.ByteString
+        getSubSessionIdBytes() {
+      java.lang.Object ref = subSessionId_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        subSessionId_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    /**
+     * <code>string sub_session_id = 18;</code>
+     * @param value The subSessionId to set.
+     * @return This builder for chaining.
+     */
+    public Builder setSubSessionId(
+        java.lang.String value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  
+      subSessionId_ = value;
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string sub_session_id = 18;</code>
+     * @return This builder for chaining.
+     */
+    public Builder clearSubSessionId() {
+      
+      subSessionId_ = getDefaultInstance().getSubSessionId();
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string sub_session_id = 18;</code>
+     * @param value The bytes for subSessionId to set.
+     * @return This builder for chaining.
+     */
+    public Builder setSubSessionIdBytes(
+        com.google.protobuf.ByteString value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+      
+      subSessionId_ = value;
+      onChanged();
+      return this;
+    }
+
+    private java.lang.Object pageSource_ = "";
+    /**
+     * <code>string page_source = 19;</code>
+     * @return The pageSource.
+     */
+    public java.lang.String getPageSource() {
+      java.lang.Object ref = pageSource_;
+      if (!(ref instanceof java.lang.String)) {
+        com.google.protobuf.ByteString bs =
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        pageSource_ = s;
+        return s;
+      } else {
+        return (java.lang.String) ref;
+      }
+    }
+    /**
+     * <code>string page_source = 19;</code>
+     * @return The bytes for pageSource.
+     */
+    public com.google.protobuf.ByteString
+        getPageSourceBytes() {
+      java.lang.Object ref = pageSource_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        pageSource_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    /**
+     * <code>string page_source = 19;</code>
+     * @param value The pageSource to set.
+     * @return This builder for chaining.
+     */
+    public Builder setPageSource(
+        java.lang.String value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  
+      pageSource_ = value;
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string page_source = 19;</code>
+     * @return This builder for chaining.
+     */
+    public Builder clearPageSource() {
+      
+      pageSource_ = getDefaultInstance().getPageSource();
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string page_source = 19;</code>
+     * @param value The bytes for pageSource to set.
+     * @return This builder for chaining.
+     */
+    public Builder setPageSourceBytes(
+        com.google.protobuf.ByteString value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+      
+      pageSource_ = value;
+      onChanged();
+      return this;
+    }
     @java.lang.Override
     public final Builder setUnknownFields(
         final com.google.protobuf.UnknownFieldSet unknownFields) {

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

@@ -224,4 +224,40 @@ public interface RecommendRequestOrBuilder extends
    */
   com.google.protobuf.ByteString
       getNewExpGroupBytes();
+
+  /**
+   * <code>string session_id = 17;</code>
+   * @return The sessionId.
+   */
+  java.lang.String getSessionId();
+  /**
+   * <code>string session_id = 17;</code>
+   * @return The bytes for sessionId.
+   */
+  com.google.protobuf.ByteString
+      getSessionIdBytes();
+
+  /**
+   * <code>string sub_session_id = 18;</code>
+   * @return The subSessionId.
+   */
+  java.lang.String getSubSessionId();
+  /**
+   * <code>string sub_session_id = 18;</code>
+   * @return The bytes for subSessionId.
+   */
+  com.google.protobuf.ByteString
+      getSubSessionIdBytes();
+
+  /**
+   * <code>string page_source = 19;</code>
+   * @return The pageSource.
+   */
+  java.lang.String getPageSource();
+  /**
+   * <code>string page_source = 19;</code>
+   * @return The bytes for pageSource.
+   */
+  com.google.protobuf.ByteString
+      getPageSourceBytes();
 }

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

@@ -25,6 +25,9 @@ message RecommendRequest {
   string province = 14;
   MachineInfoProto machine_info = 15;
   string new_exp_group = 16;
+  string session_id = 17;
+  string sub_session_id = 18;
+  string page_source = 19;
 }
 
 message MachineInfoProto {

+ 45 - 3
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java

@@ -26,6 +26,7 @@ import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
 import com.tzld.piaoquan.recommend.server.util.CommonCollectionUtils;
 import com.tzld.piaoquan.recommend.server.util.JSONUtils;
 import com.tzld.piaoquan.recommend.server.util.ParserUtils;
+import com.tzld.piaoquan.recommend.server.util.TraceUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
@@ -129,7 +130,7 @@ public class RecommendService {
         stopwatch.reset().start();
         updateCache(request, param, videos);
 
-        logStatisticsInfo(param, videos);
+        logStatisticsInfo(request, param, videos);
         // 更新position
         List<VideoProto> vps = new ArrayList<>();
         for (int i = 0; i < videos.size(); i++) {
@@ -153,8 +154,49 @@ public class RecommendService {
 
     }
 
-    private void logStatisticsInfo(RecommendParam param, List<Video> videos) {
-        statisticsLogService.log();
+    private void logStatisticsInfo(RecommendRequest request, RecommendParam param, List<Video> videos) {
+
+        if (CollectionUtils.isEmpty(videos)) {
+            return;
+        }
+
+        List<Map<String, String>> data = videos.stream().map(v -> {
+            Map<String, String> map = new HashMap<>();
+
+            map.put("traceId", String.valueOf(TraceUtils.currentTraceId()));
+
+            // TODO user
+            map.put("sessionId", String.valueOf(request.getSessionId()));
+            map.put("subsessionid", String.valueOf(request.getSubSessionId()));
+            map.put("mid", param.getMid());
+
+            // scene
+            map.put("pagesource", String.valueOf(request.getPageSource()));
+
+            // ab
+
+
+            // video
+            map.put("videoId", String.valueOf(v.getVideoId()));
+            map.put("rovScore", String.valueOf(v.getRovScore()));
+            map.put("sortScore", String.valueOf(v.getSortScore()));
+            map.put("pushFrom", String.valueOf(v.getPushFrom()));
+
+            map.put("flowPool", String.valueOf(v.getFlowPool()));
+            map.put("level", String.valueOf(v.getLevel()));
+            map.put("flowPoolAbtestGroup", String.valueOf(v.getFlowPoolAbtestGroup()));
+            map.put("inFlowPool", String.valueOf(v.isInFlowPool()));
+
+            map.put("scoreRos", String.valueOf(v.getScoreRos()));
+            map.put("scoreStr", String.valueOf(v.getScoreStr()));
+            map.put("score", String.valueOf(v.getScore()));
+            map.put("scoresMap", JSONUtils.toJson(String.valueOf(v.getScoresMap())));
+
+            return map;
+
+        }).collect(Collectors.toList());
+
+        statisticsLogService.log(data);
     }
 
     private RecommendResponse specialMidRecommend(RecommendRequest request) {

+ 23 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/StatisticsLogService.java

@@ -6,12 +6,15 @@ import com.aliyun.openservices.aliyun.log.producer.ProducerConfig;
 import com.aliyun.openservices.aliyun.log.producer.ProjectConfig;
 import com.aliyun.openservices.log.common.LogItem;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -55,4 +58,24 @@ public class StatisticsLogService {
         }
     }
 
+    public void log(List<Map<String, String>> data) {
+        if (CollectionUtils.isEmpty(data)) {
+            return;
+        }
+        try {
+            List<LogItem> items = data.stream().map(d -> {
+                LogItem logItem = new LogItem();
+                d.entrySet().stream().forEach(e -> {
+                    logItem.PushBack(e.getKey(), e.getValue());
+                });
+                return logItem;
+            }).collect(Collectors.toList());
+            producer.send(project, logStore, items);
+        } catch (InterruptedException e) {
+            log.warn("The current thread has been interrupted during send logs.");
+        } catch (Exception e) {
+            log.error("Failed to send logs", e);
+        }
+    }
+
 }

+ 4 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/util/TraceUtils.java

@@ -17,6 +17,10 @@ public class TraceUtils {
         MDC.put(TraceUtils.TRACE_ID_KEY, genTraceId());
     }
 
+    public static String currentTraceId() {
+        return MDC.get(TraceUtils.TRACE_ID_KEY);
+    }
+
     public static void removeMDC() {
         MDC.remove(TraceUtils.TRACE_ID_KEY);
     }