wangyunpeng 2 дней назад
Родитель
Сommit
3dbd14f068

+ 56 - 1
core/src/main/java/com/tzld/videoVector/job/ChannelDemandMatchJob.java

@@ -1,6 +1,7 @@
 package com.tzld.videoVector.job;
 
 import com.aliyun.odps.data.Record;
+import com.google.common.collect.Lists;
 import com.tzld.videoVector.dao.mapper.pgVector.ChannelDemandMatchConfigMapper;
 import com.tzld.videoVector.dao.mapper.pgVector.ChannelDemandMatchResultMapper;
 import com.tzld.videoVector.dao.mapper.pgVector.ext.ChannelDemandMatchResultMapperExt;
@@ -19,6 +20,8 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import com.tzld.videoVector.util.Md5Util;
+
 import javax.annotation.Resource;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
@@ -245,7 +248,9 @@ public class ChannelDemandMatchJob {
             return;
         }
 
-        resultMapperExt.batchInsert(allBatchRows);
+        for (List<ChannelDemandMatchResult> partition : Lists.partition(allBatchRows, 1000)) {
+            resultMapperExt.batchInsert(partition);
+        }
         log.info("需求匹配完成, channelName={}, demandId={}, 写入{}条视频",
                 demand.getChannelName(), demand.getDemandId(), allBatchRows.size());
     }
@@ -281,11 +286,61 @@ public class ChannelDemandMatchJob {
             row.setMatchRov(item.getRov());
             row.setMatchText(item.getText());
             row.setMatchStatus((short) 1); // 已匹配
+            // 生成确定性实验ID:相同需求+相同视频 → 相同实验ID
+            row.setExperimentId(generateExperimentId(demand, item.getVideoId(), item.getConfigCode()));
             batchRows.add(row);
         }
         return batchRows;
     }
 
+    /**
+     * 生成确定性实验ID
+     * 格式: 渠道_线上动作_需求策略_特征点类型_视频ID_configCode_短哈希
+     * 短哈希由全19个需求字段+视频ID+configCode拼接后MD5取前8位,确保唯一性
+     */
+    private String generateExperimentId(ChannelDemandMatchResult demand, Long matchVideoId, String matchConfigCode) {
+        // 可读部分:几个关键字段
+        StringJoiner readablePart = new StringJoiner("_");
+        readablePart.add(nullToEmpty(demand.getChannelName()));
+        readablePart.add(nullToEmpty(demand.getOnlineAction()));
+        readablePart.add(nullToEmpty(demand.getDemandStrategy()));
+        readablePart.add(nullToEmpty(demand.getPointType()));
+        readablePart.add(String.valueOf(matchVideoId));
+        readablePart.add(nullToEmpty(matchConfigCode));
+
+        // 唯一性保证:全字段MD5取前8位
+        StringBuilder fullKey = new StringBuilder();
+        fullKey.append(nullToEmpty(demand.getChannelName()));
+        fullKey.append("|").append(nullToEmpty(demand.getOnlineAction()));
+        fullKey.append("|").append(nullToEmpty(demand.getCrowdSegment()));
+        fullKey.append("|").append(nullToEmpty(demand.getCrowdPackage()));
+        fullKey.append("|").append(nullToEmpty(demand.getConversionTarget()));
+        fullKey.append("|").append(nullToEmpty(demand.getPartner()));
+        fullKey.append("|").append(nullToEmpty(demand.getAccount()));
+        fullKey.append("|").append(nullToEmpty(demand.getSceneValue()));
+        fullKey.append("|").append(nullToEmpty(demand.getDemandStrategy()));
+        fullKey.append("|").append(nullToEmpty(demand.getDriveDimensionTime()));
+        fullKey.append("|").append(nullToEmpty(demand.getDimension()));
+        fullKey.append("|").append(nullToEmpty(demand.getDemandFilterSortStrategy()));
+        fullKey.append("|").append(nullToEmpty(demand.getDemandType()));
+        fullKey.append("|").append(nullToEmpty(demand.getDemandContentId()));
+        fullKey.append("|").append(nullToEmpty(demand.getDemandContentTitle()));
+        fullKey.append("|").append(nullToEmpty(demand.getDemandContentTopic()));
+        fullKey.append("|").append(nullToEmpty(demand.getPointType()));
+        fullKey.append("|").append(nullToEmpty(demand.getStandardElement()));
+        fullKey.append("|").append(nullToEmpty(demand.getCategoryName()));
+        fullKey.append("|").append(matchVideoId);
+        fullKey.append("|").append(nullToEmpty(matchConfigCode));
+        String hash = Md5Util.encoderByMd5(fullKey.toString());
+        String shortHash = (hash != null && hash.length() >= 8) ? hash.substring(0, 8) : "00000000";
+
+        return readablePart + "_" + shortHash;
+    }
+
+    private String nullToEmpty(String value) {
+        return value == null ? "" : value;
+    }
+
     /**
      * 复制需求维度字段到新行
      */

+ 24 - 0
core/src/main/java/com/tzld/videoVector/model/param/ChannelDemandMatchQueryParam.java

@@ -25,4 +25,28 @@ public class ChannelDemandMatchQueryParam {
 
     /** 标准化元素,可选 */
     private String standardElement;
+
+    /** 需求ID,可选 */
+    private String demandId;
+
+    /** 需求策略,可选 */
+    private String demandStrategy;
+
+    /** 需求类型,可选 */
+    private String demandType;
+
+    /** 需求内容ID,可选 */
+    private String demandContentId;
+
+    /** 需求筛选排序策略,可选 */
+    private String demandFilterSortStrategy;
+
+    /** 人群包,可选 */
+    private String crowdPackage;
+
+    /** 账号,可选 */
+    private String account;
+
+    /** 场景值,可选 */
+    private String sceneValue;
 }

+ 60 - 102
core/src/main/java/com/tzld/videoVector/model/po/pgVector/ChannelDemandMatchResult.java

@@ -108,6 +108,8 @@ public class ChannelDemandMatchResult {
     private String categoryName;
 
     /**
+     * Database Column Remarks:
+     *   人群数量
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.crowd_count
@@ -117,6 +119,8 @@ public class ChannelDemandMatchResult {
     private Integer crowdCount;
 
     /**
+     * Database Column Remarks:
+     *   视频数量
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.video_count
@@ -126,6 +130,8 @@ public class ChannelDemandMatchResult {
     private Integer videoCount;
 
     /**
+     * Database Column Remarks:
+     *   访问UV
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.visit_uv
@@ -135,33 +141,8 @@ public class ChannelDemandMatchResult {
     private Long visitUv;
 
     /**
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column channel_demand_match_result.visit_pv
-     *
-     * @mbg.generated
-     */
-    private Long visitPv;
-
-    /**
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column channel_demand_match_result.share_pv
-     *
-     * @mbg.generated
-     */
-    private Long sharePv;
-
-    /**
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column channel_demand_match_result.backflow_uv
-     *
-     * @mbg.generated
-     */
-    private Long backflowUv;
-
-    /**
+     * Database Column Remarks:
+     *   总ROV
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.total_rov
@@ -171,6 +152,8 @@ public class ChannelDemandMatchResult {
     private Double totalRov;
 
     /**
+     * Database Column Remarks:
+     *   匹配视频ID
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.match_video_id
@@ -180,6 +163,8 @@ public class ChannelDemandMatchResult {
     private Long matchVideoId;
 
     /**
+     * Database Column Remarks:
+     *   匹配配置编码
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.match_config_code
@@ -189,6 +174,8 @@ public class ChannelDemandMatchResult {
     private String matchConfigCode;
 
     /**
+     * Database Column Remarks:
+     *   匹配得分
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.match_score
@@ -198,6 +185,8 @@ public class ChannelDemandMatchResult {
     private Double matchScore;
 
     /**
+     * Database Column Remarks:
+     *   匹配相似度
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.match_sim
@@ -207,6 +196,8 @@ public class ChannelDemandMatchResult {
     private Double matchSim;
 
     /**
+     * Database Column Remarks:
+     *   匹配ROV
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.match_rov
@@ -216,6 +207,8 @@ public class ChannelDemandMatchResult {
     private Double matchRov;
 
     /**
+     * Database Column Remarks:
+     *   匹配文本
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.match_text
@@ -236,6 +229,8 @@ public class ChannelDemandMatchResult {
     private Short matchStatus;
 
     /**
+     * Database Column Remarks:
+     *   创建时间
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.create_time
@@ -245,6 +240,8 @@ public class ChannelDemandMatchResult {
     private Date createTime;
 
     /**
+     * Database Column Remarks:
+     *   更新时间
      *
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column channel_demand_match_result.update_time
@@ -429,6 +426,17 @@ public class ChannelDemandMatchResult {
      */
     private Double uvRatio;
 
+    /**
+     * Database Column Remarks:
+     *   实验ID,标识相同需求的批次
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column channel_demand_match_result.experiment_id
+     *
+     * @mbg.generated
+     */
+    private String experimentId;
+
     /**
      * This method was generated by MyBatis Generator.
      * This method returns the value of the database column channel_demand_match_result.id
@@ -717,78 +725,6 @@ public class ChannelDemandMatchResult {
         this.visitUv = visitUv;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column channel_demand_match_result.visit_pv
-     *
-     * @return the value of channel_demand_match_result.visit_pv
-     *
-     * @mbg.generated
-     */
-    public Long getVisitPv() {
-        return visitPv;
-    }
-
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column channel_demand_match_result.visit_pv
-     *
-     * @param visitPv the value for channel_demand_match_result.visit_pv
-     *
-     * @mbg.generated
-     */
-    public void setVisitPv(Long visitPv) {
-        this.visitPv = visitPv;
-    }
-
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column channel_demand_match_result.share_pv
-     *
-     * @return the value of channel_demand_match_result.share_pv
-     *
-     * @mbg.generated
-     */
-    public Long getSharePv() {
-        return sharePv;
-    }
-
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column channel_demand_match_result.share_pv
-     *
-     * @param sharePv the value for channel_demand_match_result.share_pv
-     *
-     * @mbg.generated
-     */
-    public void setSharePv(Long sharePv) {
-        this.sharePv = sharePv;
-    }
-
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column channel_demand_match_result.backflow_uv
-     *
-     * @return the value of channel_demand_match_result.backflow_uv
-     *
-     * @mbg.generated
-     */
-    public Long getBackflowUv() {
-        return backflowUv;
-    }
-
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column channel_demand_match_result.backflow_uv
-     *
-     * @param backflowUv the value for channel_demand_match_result.backflow_uv
-     *
-     * @mbg.generated
-     */
-    public void setBackflowUv(Long backflowUv) {
-        this.backflowUv = backflowUv;
-    }
-
     /**
      * This method was generated by MyBatis Generator.
      * This method returns the value of the database column channel_demand_match_result.total_rov
@@ -1413,6 +1349,30 @@ public class ChannelDemandMatchResult {
         this.uvRatio = uvRatio;
     }
 
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column channel_demand_match_result.experiment_id
+     *
+     * @return the value of channel_demand_match_result.experiment_id
+     *
+     * @mbg.generated
+     */
+    public String getExperimentId() {
+        return experimentId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column channel_demand_match_result.experiment_id
+     *
+     * @param experimentId the value for channel_demand_match_result.experiment_id
+     *
+     * @mbg.generated
+     */
+    public void setExperimentId(String experimentId) {
+        this.experimentId = experimentId;
+    }
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table channel_demand_match_result
@@ -1437,9 +1397,6 @@ public class ChannelDemandMatchResult {
         sb.append(", crowdCount=").append(crowdCount);
         sb.append(", videoCount=").append(videoCount);
         sb.append(", visitUv=").append(visitUv);
-        sb.append(", visitPv=").append(visitPv);
-        sb.append(", sharePv=").append(sharePv);
-        sb.append(", backflowUv=").append(backflowUv);
         sb.append(", totalRov=").append(totalRov);
         sb.append(", matchVideoId=").append(matchVideoId);
         sb.append(", matchConfigCode=").append(matchConfigCode);
@@ -1466,6 +1423,7 @@ public class ChannelDemandMatchResult {
         sb.append(", demandContentTitle=").append(demandContentTitle);
         sb.append(", demandContentTopic=").append(demandContentTopic);
         sb.append(", uvRatio=").append(uvRatio);
+        sb.append(", experimentId=").append(experimentId);
         sb.append("]");
         return sb.toString();
     }

+ 70 - 180
core/src/main/java/com/tzld/videoVector/model/po/pgVector/ChannelDemandMatchResultExample.java

@@ -985,186 +985,6 @@ public class ChannelDemandMatchResultExample {
             return (Criteria) this;
         }
 
-        public Criteria andVisitPvIsNull() {
-            addCriterion("visit_pv is null");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvIsNotNull() {
-            addCriterion("visit_pv is not null");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvEqualTo(Long value) {
-            addCriterion("visit_pv =", value, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvNotEqualTo(Long value) {
-            addCriterion("visit_pv <>", value, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvGreaterThan(Long value) {
-            addCriterion("visit_pv >", value, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvGreaterThanOrEqualTo(Long value) {
-            addCriterion("visit_pv >=", value, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvLessThan(Long value) {
-            addCriterion("visit_pv <", value, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvLessThanOrEqualTo(Long value) {
-            addCriterion("visit_pv <=", value, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvIn(List<Long> values) {
-            addCriterion("visit_pv in", values, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvNotIn(List<Long> values) {
-            addCriterion("visit_pv not in", values, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvBetween(Long value1, Long value2) {
-            addCriterion("visit_pv between", value1, value2, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andVisitPvNotBetween(Long value1, Long value2) {
-            addCriterion("visit_pv not between", value1, value2, "visitPv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvIsNull() {
-            addCriterion("share_pv is null");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvIsNotNull() {
-            addCriterion("share_pv is not null");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvEqualTo(Long value) {
-            addCriterion("share_pv =", value, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvNotEqualTo(Long value) {
-            addCriterion("share_pv <>", value, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvGreaterThan(Long value) {
-            addCriterion("share_pv >", value, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvGreaterThanOrEqualTo(Long value) {
-            addCriterion("share_pv >=", value, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvLessThan(Long value) {
-            addCriterion("share_pv <", value, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvLessThanOrEqualTo(Long value) {
-            addCriterion("share_pv <=", value, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvIn(List<Long> values) {
-            addCriterion("share_pv in", values, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvNotIn(List<Long> values) {
-            addCriterion("share_pv not in", values, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvBetween(Long value1, Long value2) {
-            addCriterion("share_pv between", value1, value2, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andSharePvNotBetween(Long value1, Long value2) {
-            addCriterion("share_pv not between", value1, value2, "sharePv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvIsNull() {
-            addCriterion("backflow_uv is null");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvIsNotNull() {
-            addCriterion("backflow_uv is not null");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvEqualTo(Long value) {
-            addCriterion("backflow_uv =", value, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvNotEqualTo(Long value) {
-            addCriterion("backflow_uv <>", value, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvGreaterThan(Long value) {
-            addCriterion("backflow_uv >", value, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvGreaterThanOrEqualTo(Long value) {
-            addCriterion("backflow_uv >=", value, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvLessThan(Long value) {
-            addCriterion("backflow_uv <", value, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvLessThanOrEqualTo(Long value) {
-            addCriterion("backflow_uv <=", value, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvIn(List<Long> values) {
-            addCriterion("backflow_uv in", values, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvNotIn(List<Long> values) {
-            addCriterion("backflow_uv not in", values, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvBetween(Long value1, Long value2) {
-            addCriterion("backflow_uv between", value1, value2, "backflowUv");
-            return (Criteria) this;
-        }
-
-        public Criteria andBackflowUvNotBetween(Long value1, Long value2) {
-            addCriterion("backflow_uv not between", value1, value2, "backflowUv");
-            return (Criteria) this;
-        }
-
         public Criteria andTotalRovIsNull() {
             addCriterion("total_rov is null");
             return (Criteria) this;
@@ -2894,6 +2714,76 @@ public class ChannelDemandMatchResultExample {
             addCriterion("uv_ratio not between", value1, value2, "uvRatio");
             return (Criteria) this;
         }
+
+        public Criteria andExperimentIdIsNull() {
+            addCriterion("experiment_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdIsNotNull() {
+            addCriterion("experiment_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdEqualTo(String value) {
+            addCriterion("experiment_id =", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotEqualTo(String value) {
+            addCriterion("experiment_id <>", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdGreaterThan(String value) {
+            addCriterion("experiment_id >", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdGreaterThanOrEqualTo(String value) {
+            addCriterion("experiment_id >=", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdLessThan(String value) {
+            addCriterion("experiment_id <", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdLessThanOrEqualTo(String value) {
+            addCriterion("experiment_id <=", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdLike(String value) {
+            addCriterion("experiment_id like", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotLike(String value) {
+            addCriterion("experiment_id not like", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdIn(List<String> values) {
+            addCriterion("experiment_id in", values, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotIn(List<String> values) {
+            addCriterion("experiment_id not in", values, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdBetween(String value1, String value2) {
+            addCriterion("experiment_id between", value1, value2, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotBetween(String value1, String value2) {
+            addCriterion("experiment_id not between", value1, value2, "experimentId");
+            return (Criteria) this;
+        }
     }
 
     /**

+ 54 - 0
core/src/main/java/com/tzld/videoVector/model/vo/ChannelDemandMatchVO.java

@@ -31,12 +31,66 @@ public class ChannelDemandMatchVO {
     /** 分类名称 */
     private String categoryName;
 
+    /** 需求ID */
+    private String demandId;
+
+    /** 人群包 */
+    private String crowdPackage;
+
+    /** 转化目标 */
+    private String conversionTarget;
+
+    /** 合作方 */
+    private String partner;
+
+    /** 账号 */
+    private String account;
+
+    /** 场景值 */
+    private String sceneValue;
+
+    /** 需求策略 */
+    private String demandStrategy;
+
+    /** 驱动时间维度 */
+    private String driveDimensionTime;
+
+    /** 需求筛选排序策略 */
+    private String demandFilterSortStrategy;
+
+    /** 需求类型 */
+    private String demandType;
+
+    /** 需求内容ID */
+    private String demandContentId;
+
+    /** 需求内容标题 */
+    private String demandContentTitle;
+
+    /** 需求内容选题 */
+    private String demandContentTopic;
+
+    /** 人群数量 */
+    private Integer crowdCount;
+
+    /** 视频数量 */
+    private Integer videoCount;
+
     /** 访问UV */
     private Long visitUv;
 
+    /** UV占比 */
+    private Double uvRatio;
+
     /** 总ROV */
     private Double totalRov;
 
+    /** 线上应用动作 */
+    private String onlineAction;
+
+    /** 匹配实验ID */
+    private String matchExperimentId;
+
     /** 匹配到的视频列表 */
     private List<MatchedVideo> matchedVideos;
 

+ 84 - 27
core/src/main/java/com/tzld/videoVector/service/impl/VideoSearchServiceImpl.java

@@ -1516,38 +1516,22 @@ public class VideoSearchServiceImpl implements VideoSearchService {
 
     @Override
     public List<ChannelDemandMatchVO> queryDemandMatchResult(ChannelDemandMatchQueryParam param) {
-        // 构造查询条件
-        ChannelDemandMatchResultExample example = new ChannelDemandMatchResultExample();
-        ChannelDemandMatchResultExample.Criteria criteria = example.createCriteria();
-
-        if (StringUtils.hasText(param.getDt())) {
-            criteria.andDtEqualTo(param.getDt());
-        }
-        if (StringUtils.hasText(param.getChannelName())) {
-            criteria.andChannelNameEqualTo(param.getChannelName());
-        }
-        if (StringUtils.hasText(param.getCrowdSegment())) {
-            criteria.andCrowdSegmentEqualTo(param.getCrowdSegment());
-        }
-        if (StringUtils.hasText(param.getDimension())) {
-            criteria.andDimensionEqualTo(param.getDimension());
-        }
-        if (StringUtils.hasText(param.getPointType())) {
-            criteria.andPointTypeEqualTo(param.getPointType());
-        }
-        if (StringUtils.hasText(param.getStandardElement())) {
-            criteria.andStandardElementEqualTo(param.getStandardElement());
-        }
-        // 只查已匹配成功的
-        criteria.andMatchStatusEqualTo((short) 1);
-
+        ChannelDemandMatchResultExample example = buildDemandMatchQueryExample(param);
         List<ChannelDemandMatchResult> results = channelDemandMatchResultMapper.selectByExample(example);
 
         // 按需求维度分组,同一需求下的多个匹配视频聚合到一个VO
         Map<String, ChannelDemandMatchVO> groupMap = new LinkedHashMap<>();
         for (ChannelDemandMatchResult r : results) {
-            String key = r.getDt() + "|" + r.getChannelName() + "|" + r.getCrowdSegment()
-                    + "|" + r.getDimension() + "|" + r.getPointType() + "|" + r.getStandardElement();
+            String key = r.getDt() + "|" + r.getChannelName() + "|" + r.getOnlineAction()
+                    + "|" + r.getCrowdSegment() + "|" + r.getCrowdPackage()
+                    + "|" + r.getConversionTarget() + "|" + r.getPartner()
+                    + "|" + r.getAccount() + "|" + r.getSceneValue()
+                    + "|" + r.getDemandStrategy() + "|" + r.getDriveDimensionTime()
+                    + "|" + r.getDimension() + "|" + r.getDemandFilterSortStrategy()
+                    + "|" + r.getDemandType() + "|" + r.getDemandContentId()
+                    + "|" + r.getDemandContentTitle() + "|" + r.getDemandContentTopic()
+                    + "|" + r.getPointType() + "|" + r.getStandardElement()
+                    + "|" + r.getCategoryName();
 
             ChannelDemandMatchVO vo = groupMap.computeIfAbsent(key, k -> {
                 ChannelDemandMatchVO v = new ChannelDemandMatchVO();
@@ -1558,8 +1542,26 @@ public class VideoSearchServiceImpl implements VideoSearchService {
                 v.setPointType(r.getPointType());
                 v.setStandardElement(r.getStandardElement());
                 v.setCategoryName(r.getCategoryName());
+                v.setDemandId(r.getDemandId());
+                v.setCrowdPackage(r.getCrowdPackage());
+                v.setConversionTarget(r.getConversionTarget());
+                v.setPartner(r.getPartner());
+                v.setAccount(r.getAccount());
+                v.setSceneValue(r.getSceneValue());
+                v.setDemandStrategy(r.getDemandStrategy());
+                v.setDriveDimensionTime(r.getDriveDimensionTime());
+                v.setDemandFilterSortStrategy(r.getDemandFilterSortStrategy());
+                v.setDemandType(r.getDemandType());
+                v.setDemandContentId(r.getDemandContentId());
+                v.setDemandContentTitle(r.getDemandContentTitle());
+                v.setDemandContentTopic(r.getDemandContentTopic());
+                v.setCrowdCount(r.getCrowdCount());
+                v.setVideoCount(r.getVideoCount());
                 v.setVisitUv(r.getVisitUv());
+                v.setUvRatio(r.getUvRatio());
                 v.setTotalRov(r.getTotalRov());
+                v.setOnlineAction(r.getOnlineAction());
+                v.setMatchExperimentId(r.getMatchExperimentId());
                 v.setMatchedVideos(new ArrayList<>());
                 return v;
             });
@@ -1578,4 +1580,59 @@ public class VideoSearchServiceImpl implements VideoSearchService {
 
         return new ArrayList<>(groupMap.values());
     }
+
+    /**
+     * 根据查询参数构建 ChannelDemandMatchResultExample
+     */
+    private ChannelDemandMatchResultExample buildDemandMatchQueryExample(ChannelDemandMatchQueryParam param) {
+        ChannelDemandMatchResultExample example = new ChannelDemandMatchResultExample();
+        ChannelDemandMatchResultExample.Criteria criteria = example.createCriteria();
+
+        if (StringUtils.hasText(param.getDt())) {
+            criteria.andDtEqualTo(param.getDt());
+        }
+        if (StringUtils.hasText(param.getChannelName())) {
+            criteria.andChannelNameEqualTo(param.getChannelName());
+        }
+        if (StringUtils.hasText(param.getCrowdSegment())) {
+            criteria.andCrowdSegmentEqualTo(param.getCrowdSegment());
+        }
+        if (StringUtils.hasText(param.getDimension())) {
+            criteria.andDimensionEqualTo(param.getDimension());
+        }
+        if (StringUtils.hasText(param.getPointType())) {
+            criteria.andPointTypeEqualTo(param.getPointType());
+        }
+        if (StringUtils.hasText(param.getStandardElement())) {
+            criteria.andStandardElementEqualTo(param.getStandardElement());
+        }
+        if (StringUtils.hasText(param.getDemandId())) {
+            criteria.andDemandIdEqualTo(param.getDemandId());
+        }
+        if (StringUtils.hasText(param.getDemandStrategy())) {
+            criteria.andDemandStrategyEqualTo(param.getDemandStrategy());
+        }
+        if (StringUtils.hasText(param.getDemandType())) {
+            criteria.andDemandTypeEqualTo(param.getDemandType());
+        }
+        if (StringUtils.hasText(param.getDemandContentId())) {
+            criteria.andDemandContentIdEqualTo(param.getDemandContentId());
+        }
+        if (StringUtils.hasText(param.getDemandFilterSortStrategy())) {
+            criteria.andDemandFilterSortStrategyEqualTo(param.getDemandFilterSortStrategy());
+        }
+        if (StringUtils.hasText(param.getCrowdPackage())) {
+            criteria.andCrowdPackageEqualTo(param.getCrowdPackage());
+        }
+        if (StringUtils.hasText(param.getAccount())) {
+            criteria.andAccountEqualTo(param.getAccount());
+        }
+        if (StringUtils.hasText(param.getSceneValue())) {
+            criteria.andSceneValueEqualTo(param.getSceneValue());
+        }
+        // 只查已匹配成功的
+        criteria.andMatchStatusEqualTo((short) 1);
+
+        return example;
+    }
 }

+ 29 - 59
core/src/main/resources/mapper/pgVector/ChannelDemandMatchResultMapper.xml

@@ -18,9 +18,6 @@
     <result column="crowd_count" jdbcType="INTEGER" property="crowdCount" />
     <result column="video_count" jdbcType="INTEGER" property="videoCount" />
     <result column="visit_uv" jdbcType="BIGINT" property="visitUv" />
-    <result column="visit_pv" jdbcType="BIGINT" property="visitPv" />
-    <result column="share_pv" jdbcType="BIGINT" property="sharePv" />
-    <result column="backflow_uv" jdbcType="BIGINT" property="backflowUv" />
     <result column="total_rov" jdbcType="DOUBLE" property="totalRov" />
     <result column="match_video_id" jdbcType="BIGINT" property="matchVideoId" />
     <result column="match_config_code" jdbcType="VARCHAR" property="matchConfigCode" />
@@ -47,6 +44,7 @@
     <result column="demand_content_title" jdbcType="VARCHAR" property="demandContentTitle" />
     <result column="demand_content_topic" jdbcType="VARCHAR" property="demandContentTopic" />
     <result column="uv_ratio" jdbcType="DOUBLE" property="uvRatio" />
+    <result column="experiment_id" jdbcType="VARCHAR" property="experimentId" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -120,12 +118,12 @@
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     id, config_id, dt, channel_name, crowd_segment, dimension, point_type, standard_element, 
-    category_name, crowd_count, video_count, visit_uv, visit_pv, share_pv, backflow_uv, 
-    total_rov, match_video_id, match_config_code, match_score, match_sim, match_rov, 
-    match_text, match_status, create_time, update_time, online_action, match_experiment_id, 
-    demand_id, crowd_package, conversion_target, partner, account, scene_value, demand_strategy, 
-    drive_dimension_time, demand_filter_sort_strategy, demand_type, demand_content_id, 
-    demand_content_title, demand_content_topic, uv_ratio
+    category_name, crowd_count, video_count, visit_uv, total_rov, match_video_id, match_config_code, 
+    match_score, match_sim, match_rov, match_text, match_status, create_time, update_time, 
+    online_action, match_experiment_id, demand_id, crowd_package, conversion_target, 
+    partner, account, scene_value, demand_strategy, drive_dimension_time, demand_filter_sort_strategy, 
+    demand_type, demand_content_id, demand_content_title, demand_content_topic, uv_ratio, 
+    experiment_id
   </sql>
   <select id="selectByExample" parameterType="com.tzld.videoVector.model.po.pgVector.ChannelDemandMatchResultExample" resultMap="BaseResultMap">
     <!--
@@ -181,8 +179,7 @@
     insert into channel_demand_match_result (config_id, dt, channel_name, 
       crowd_segment, dimension, point_type, 
       standard_element, category_name, crowd_count, 
-      video_count, visit_uv, visit_pv, 
-      share_pv, backflow_uv, total_rov, 
+      video_count, visit_uv, total_rov, 
       match_video_id, match_config_code, match_score, 
       match_sim, match_rov, match_text, 
       match_status, create_time, update_time, 
@@ -191,12 +188,12 @@
       account, scene_value, demand_strategy, 
       drive_dimension_time, demand_filter_sort_strategy, 
       demand_type, demand_content_id, demand_content_title, 
-      demand_content_topic, uv_ratio)
+      demand_content_topic, uv_ratio, experiment_id
+      )
     values (#{configId,jdbcType=BIGINT}, #{dt,jdbcType=VARCHAR}, #{channelName,jdbcType=VARCHAR}, 
       #{crowdSegment,jdbcType=VARCHAR}, #{dimension,jdbcType=VARCHAR}, #{pointType,jdbcType=VARCHAR}, 
       #{standardElement,jdbcType=VARCHAR}, #{categoryName,jdbcType=VARCHAR}, #{crowdCount,jdbcType=INTEGER}, 
-      #{videoCount,jdbcType=INTEGER}, #{visitUv,jdbcType=BIGINT}, #{visitPv,jdbcType=BIGINT}, 
-      #{sharePv,jdbcType=BIGINT}, #{backflowUv,jdbcType=BIGINT}, #{totalRov,jdbcType=DOUBLE}, 
+      #{videoCount,jdbcType=INTEGER}, #{visitUv,jdbcType=BIGINT}, #{totalRov,jdbcType=DOUBLE}, 
       #{matchVideoId,jdbcType=BIGINT}, #{matchConfigCode,jdbcType=VARCHAR}, #{matchScore,jdbcType=DOUBLE}, 
       #{matchSim,jdbcType=DOUBLE}, #{matchRov,jdbcType=DOUBLE}, #{matchText,jdbcType=VARCHAR}, 
       #{matchStatus,jdbcType=SMALLINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
@@ -205,7 +202,8 @@
       #{account,jdbcType=VARCHAR}, #{sceneValue,jdbcType=VARCHAR}, #{demandStrategy,jdbcType=VARCHAR}, 
       #{driveDimensionTime,jdbcType=VARCHAR}, #{demandFilterSortStrategy,jdbcType=VARCHAR}, 
       #{demandType,jdbcType=VARCHAR}, #{demandContentId,jdbcType=VARCHAR}, #{demandContentTitle,jdbcType=VARCHAR}, 
-      #{demandContentTopic,jdbcType=VARCHAR}, #{uvRatio,jdbcType=DOUBLE})
+      #{demandContentTopic,jdbcType=VARCHAR}, #{uvRatio,jdbcType=DOUBLE}, #{experimentId,jdbcType=VARCHAR}
+      )
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.tzld.videoVector.model.po.pgVector.ChannelDemandMatchResult" useGeneratedKeys="true">
     <!--
@@ -247,15 +245,6 @@
       <if test="visitUv != null">
         visit_uv,
       </if>
-      <if test="visitPv != null">
-        visit_pv,
-      </if>
-      <if test="sharePv != null">
-        share_pv,
-      </if>
-      <if test="backflowUv != null">
-        backflow_uv,
-      </if>
       <if test="totalRov != null">
         total_rov,
       </if>
@@ -334,6 +323,9 @@
       <if test="uvRatio != null">
         uv_ratio,
       </if>
+      <if test="experimentId != null">
+        experiment_id,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="configId != null">
@@ -369,15 +361,6 @@
       <if test="visitUv != null">
         #{visitUv,jdbcType=BIGINT},
       </if>
-      <if test="visitPv != null">
-        #{visitPv,jdbcType=BIGINT},
-      </if>
-      <if test="sharePv != null">
-        #{sharePv,jdbcType=BIGINT},
-      </if>
-      <if test="backflowUv != null">
-        #{backflowUv,jdbcType=BIGINT},
-      </if>
       <if test="totalRov != null">
         #{totalRov,jdbcType=DOUBLE},
       </if>
@@ -456,6 +439,9 @@
       <if test="uvRatio != null">
         #{uvRatio,jdbcType=DOUBLE},
       </if>
+      <if test="experimentId != null">
+        #{experimentId,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.tzld.videoVector.model.po.pgVector.ChannelDemandMatchResultExample" resultType="java.lang.Long">
@@ -511,15 +497,6 @@
       <if test="record.visitUv != null">
         visit_uv = #{record.visitUv,jdbcType=BIGINT},
       </if>
-      <if test="record.visitPv != null">
-        visit_pv = #{record.visitPv,jdbcType=BIGINT},
-      </if>
-      <if test="record.sharePv != null">
-        share_pv = #{record.sharePv,jdbcType=BIGINT},
-      </if>
-      <if test="record.backflowUv != null">
-        backflow_uv = #{record.backflowUv,jdbcType=BIGINT},
-      </if>
       <if test="record.totalRov != null">
         total_rov = #{record.totalRov,jdbcType=DOUBLE},
       </if>
@@ -598,6 +575,9 @@
       <if test="record.uvRatio != null">
         uv_ratio = #{record.uvRatio,jdbcType=DOUBLE},
       </if>
+      <if test="record.experimentId != null">
+        experiment_id = #{record.experimentId,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -621,9 +601,6 @@
       crowd_count = #{record.crowdCount,jdbcType=INTEGER},
       video_count = #{record.videoCount,jdbcType=INTEGER},
       visit_uv = #{record.visitUv,jdbcType=BIGINT},
-      visit_pv = #{record.visitPv,jdbcType=BIGINT},
-      share_pv = #{record.sharePv,jdbcType=BIGINT},
-      backflow_uv = #{record.backflowUv,jdbcType=BIGINT},
       total_rov = #{record.totalRov,jdbcType=DOUBLE},
       match_video_id = #{record.matchVideoId,jdbcType=BIGINT},
       match_config_code = #{record.matchConfigCode,jdbcType=VARCHAR},
@@ -649,7 +626,8 @@
       demand_content_id = #{record.demandContentId,jdbcType=VARCHAR},
       demand_content_title = #{record.demandContentTitle,jdbcType=VARCHAR},
       demand_content_topic = #{record.demandContentTopic,jdbcType=VARCHAR},
-      uv_ratio = #{record.uvRatio,jdbcType=DOUBLE}
+      uv_ratio = #{record.uvRatio,jdbcType=DOUBLE},
+      experiment_id = #{record.experimentId,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -694,15 +672,6 @@
       <if test="visitUv != null">
         visit_uv = #{visitUv,jdbcType=BIGINT},
       </if>
-      <if test="visitPv != null">
-        visit_pv = #{visitPv,jdbcType=BIGINT},
-      </if>
-      <if test="sharePv != null">
-        share_pv = #{sharePv,jdbcType=BIGINT},
-      </if>
-      <if test="backflowUv != null">
-        backflow_uv = #{backflowUv,jdbcType=BIGINT},
-      </if>
       <if test="totalRov != null">
         total_rov = #{totalRov,jdbcType=DOUBLE},
       </if>
@@ -781,6 +750,9 @@
       <if test="uvRatio != null">
         uv_ratio = #{uvRatio,jdbcType=DOUBLE},
       </if>
+      <if test="experimentId != null">
+        experiment_id = #{experimentId,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -801,9 +773,6 @@
       crowd_count = #{crowdCount,jdbcType=INTEGER},
       video_count = #{videoCount,jdbcType=INTEGER},
       visit_uv = #{visitUv,jdbcType=BIGINT},
-      visit_pv = #{visitPv,jdbcType=BIGINT},
-      share_pv = #{sharePv,jdbcType=BIGINT},
-      backflow_uv = #{backflowUv,jdbcType=BIGINT},
       total_rov = #{totalRov,jdbcType=DOUBLE},
       match_video_id = #{matchVideoId,jdbcType=BIGINT},
       match_config_code = #{matchConfigCode,jdbcType=VARCHAR},
@@ -829,7 +798,8 @@
       demand_content_id = #{demandContentId,jdbcType=VARCHAR},
       demand_content_title = #{demandContentTitle,jdbcType=VARCHAR},
       demand_content_topic = #{demandContentTopic,jdbcType=VARCHAR},
-      uv_ratio = #{uvRatio,jdbcType=DOUBLE}
+      uv_ratio = #{uvRatio,jdbcType=DOUBLE},
+      experiment_id = #{experimentId,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>

+ 2 - 2
core/src/main/resources/mapper/pgVector/ext/ChannelDemandMatchResultMapperExt.xml

@@ -14,7 +14,7 @@
       partner, account, scene_value,
       demand_strategy, drive_dimension_time, demand_filter_sort_strategy,
       demand_type, demand_content_id, demand_content_title,
-      demand_content_topic, uv_ratio)
+      demand_content_topic, uv_ratio, experiment_id)
     values
     <foreach collection="list" item="item" separator=",">
       (#{item.configId,jdbcType=BIGINT}, #{item.dt,jdbcType=VARCHAR}, #{item.channelName,jdbcType=VARCHAR},
@@ -29,7 +29,7 @@
       #{item.partner,jdbcType=VARCHAR}, #{item.account,jdbcType=VARCHAR}, #{item.sceneValue,jdbcType=VARCHAR},
       #{item.demandStrategy,jdbcType=VARCHAR}, #{item.driveDimensionTime,jdbcType=VARCHAR}, #{item.demandFilterSortStrategy,jdbcType=VARCHAR},
       #{item.demandType,jdbcType=VARCHAR}, #{item.demandContentId,jdbcType=VARCHAR}, #{item.demandContentTitle,jdbcType=VARCHAR},
-      #{item.demandContentTopic,jdbcType=VARCHAR}, #{item.uvRatio,jdbcType=DOUBLE})
+      #{item.demandContentTopic,jdbcType=VARCHAR}, #{item.uvRatio,jdbcType=DOUBLE}, #{item.experimentId,jdbcType=VARCHAR})
     </foreach>
   </insert>
 </mapper>