Explorar o código

向量匹配视频 匹配参数修改

wangyunpeng hai 5 días
pai
achega
5c7118102f

+ 2 - 2
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/controller/JobController.java

@@ -20,8 +20,8 @@ public class JobController {
     }
 
     @GetMapping("/vectorMatchVideoJob")
-    public void vectorMatchVideoJob() {
-        newMatchVideoJob.vectorMatchVideoJob(null);
+    public void vectorMatchVideoJob(String flowPoolLevel) {
+        newMatchVideoJob.vectorMatchVideoJob(flowPoolLevel);
     }
 }
 

+ 18 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/dao/mapper/longarticle/UnmatchedArticleMapper.java

@@ -0,0 +1,18 @@
+package com.tzld.piaoquan.longarticle.dao.mapper.longarticle;
+
+import com.tzld.piaoquan.longarticle.model.po.longarticle.UnmatchedArticle;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 待向量匹配文章查询,独立于 LongArticlesTextMapper
+ */
+public interface UnmatchedArticleMapper {
+
+    /**
+     * 查询有标题但尚未在 vector_match_videos 中有匹配记录的文章
+     * @param flowPoolLevel 流量池等级过滤,传 null 则不过滤
+     */
+    List<UnmatchedArticle> selectUnmatchedArticles(@Param("flowPoolLevel") String flowPoolLevel);
+}

+ 1 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/job/NewMatchVideoJob.java

@@ -116,7 +116,7 @@ public class NewMatchVideoJob {
     @XxlJob("vectorMatchVideoJob")
     public ReturnT<String> vectorMatchVideoJob(String param) {
         try {
-            newMatchVideoService.vectorMatchVideo();
+            newMatchVideoService.vectorMatchVideo(param);
         } catch (Exception e) {
             LarkRobotUtil.sendMessage("vectorMatchVideoJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
             log.error("vectorMatchVideoJob error:{}", e.getMessage());

+ 49 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/longarticle/UnmatchedArticle.java

@@ -0,0 +1,49 @@
+package com.tzld.piaoquan.longarticle.model.po.longarticle;
+
+/**
+ * 待向量匹配的文章查询结果,仅包含匹配流程需要的字段
+ */
+public class UnmatchedArticle {
+
+    private String contentId;
+
+    private String articleTitle;
+
+    private String flowPoolLevel;
+
+    public String getContentId() {
+        return contentId;
+    }
+
+    public void setContentId(String contentId) {
+        this.contentId = contentId;
+    }
+
+    public String getArticleTitle() {
+        return articleTitle;
+    }
+
+    public void setArticleTitle(String articleTitle) {
+        this.articleTitle = articleTitle;
+    }
+
+    public String getFlowPoolLevel() {
+        return flowPoolLevel;
+    }
+
+    public void setFlowPoolLevel(String flowPoolLevel) {
+        this.flowPoolLevel = flowPoolLevel;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("contentId=").append(contentId);
+        sb.append(", articleTitle=").append(articleTitle);
+        sb.append(", flowPoolLevel=").append(flowPoolLevel);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 22 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/longarticle/VectorMatchVideo.java

@@ -7,10 +7,14 @@ public class VectorMatchVideo {
 
     private String contentId;
 
+    private String flowPoolLevel;
+
     private Long videoId;
 
     private Double score;
 
+    private Double rov;
+
     private String configCode;
 
     private String videoTitle;
@@ -39,6 +43,14 @@ public class VectorMatchVideo {
         this.contentId = contentId;
     }
 
+    public String getFlowPoolLevel() {
+        return flowPoolLevel;
+    }
+
+    public void setFlowPoolLevel(String flowPoolLevel) {
+        this.flowPoolLevel = flowPoolLevel;
+    }
+
     public Long getVideoId() {
         return videoId;
     }
@@ -55,6 +67,14 @@ public class VectorMatchVideo {
         this.score = score;
     }
 
+    public Double getRov() {
+        return rov;
+    }
+
+    public void setRov(Double rov) {
+        this.rov = rov;
+    }
+
     public String getConfigCode() {
         return configCode;
     }
@@ -111,8 +131,10 @@ public class VectorMatchVideo {
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
         sb.append(", contentId=").append(contentId);
+        sb.append(", flowPoolLevel=").append(flowPoolLevel);
         sb.append(", videoId=").append(videoId);
         sb.append(", score=").append(score);
+        sb.append(", rov=").append(rov);
         sb.append(", configCode=").append(configCode);
         sb.append(", videoTitle=").append(videoTitle);
         sb.append(", videoOssPath=").append(videoOssPath);

+ 130 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/longarticle/VectorMatchVideoExample.java

@@ -246,6 +246,76 @@ public class VectorMatchVideoExample {
             return (Criteria) this;
         }
 
+        public Criteria andFlowPoolLevelIsNull() {
+            addCriterion("flow_pool_level is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelIsNotNull() {
+            addCriterion("flow_pool_level is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelEqualTo(String value) {
+            addCriterion("flow_pool_level =", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelNotEqualTo(String value) {
+            addCriterion("flow_pool_level <>", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelGreaterThan(String value) {
+            addCriterion("flow_pool_level >", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelGreaterThanOrEqualTo(String value) {
+            addCriterion("flow_pool_level >=", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelLessThan(String value) {
+            addCriterion("flow_pool_level <", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelLessThanOrEqualTo(String value) {
+            addCriterion("flow_pool_level <=", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelLike(String value) {
+            addCriterion("flow_pool_level like", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelNotLike(String value) {
+            addCriterion("flow_pool_level not like", value, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelIn(List<String> values) {
+            addCriterion("flow_pool_level in", values, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelNotIn(List<String> values) {
+            addCriterion("flow_pool_level not in", values, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelBetween(String value1, String value2) {
+            addCriterion("flow_pool_level between", value1, value2, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFlowPoolLevelNotBetween(String value1, String value2) {
+            addCriterion("flow_pool_level not between", value1, value2, "flowPoolLevel");
+            return (Criteria) this;
+        }
+
         public Criteria andVideoIdIsNull() {
             addCriterion("video_id is null");
             return (Criteria) this;
@@ -366,6 +436,66 @@ public class VectorMatchVideoExample {
             return (Criteria) this;
         }
 
+        public Criteria andRovIsNull() {
+            addCriterion("rov is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovIsNotNull() {
+            addCriterion("rov is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovEqualTo(Double value) {
+            addCriterion("rov =", value, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovNotEqualTo(Double value) {
+            addCriterion("rov <>", value, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovGreaterThan(Double value) {
+            addCriterion("rov >", value, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovGreaterThanOrEqualTo(Double value) {
+            addCriterion("rov >=", value, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovLessThan(Double value) {
+            addCriterion("rov <", value, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovLessThanOrEqualTo(Double value) {
+            addCriterion("rov <=", value, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovIn(List<Double> values) {
+            addCriterion("rov in", values, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovNotIn(List<Double> values) {
+            addCriterion("rov not in", values, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovBetween(Double value1, Double value2) {
+            addCriterion("rov between", value1, value2, "rov");
+            return (Criteria) this;
+        }
+
+        public Criteria andRovNotBetween(Double value1, Double value2) {
+            addCriterion("rov not between", value1, value2, "rov");
+            return (Criteria) this;
+        }
+
         public Criteria andConfigCodeIsNull() {
             addCriterion("config_code is null");
             return (Criteria) this;

+ 5 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/NewMatchVideoService.java

@@ -19,5 +19,9 @@ public interface NewMatchVideoService {
 
     void uploadCrawlerVideo() throws InterruptedException;
 
-    void vectorMatchVideo() throws InterruptedException;
+    /**
+     * 向量匹配视频,支持按流量池等级过滤待匹配文章
+     * @param flowPoolLevel 流量池等级过滤,传 null 则处理所有
+     */
+    void vectorMatchVideo(String flowPoolLevel) throws InterruptedException;
 }

+ 4 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -578,6 +578,10 @@ public class CoreServiceImpl implements CoreService {
             recallRecord.setVideoOssPath(ossVideoPath);
             recallRecord.setCoverUrl(shareImgPath);
             recallRecord.setStatus(1);
+            recallRecord.setFlowPoolLevel(matchContent.getFlowPoolLevelTag());
+            if (item.getRov() != null) {
+                recallRecord.setRov(item.getRov());
+            }
             recallRecord.setCreateTime(new Date());
             vectorMatchVideoMapper.insertSelective(recallRecord);
             savedCount++;

+ 13 - 4
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/NewMatchVideoServiceImpl.java

@@ -5,6 +5,7 @@ import com.tzld.piaoquan.longarticle.dao.mapper.aigc.ProducePlanExeRecordMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.LongArticlesTextMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.NewMatchVideoMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.PromotionSourceMapper;
+import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.UnmatchedArticleMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.VectorMatchVideoMapper;
 import com.tzld.piaoquan.longarticle.model.po.aigc.ProducePlanExeRecord;
 import com.tzld.piaoquan.longarticle.model.po.aigc.ProducePlanExeRecordExample;
@@ -61,6 +62,9 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
     @Autowired
     private VectorMatchVideoMapper vectorMatchVideoMapper;
 
+    @Autowired
+    private UnmatchedArticleMapper unmatchedArticleMapper;
+
     @Value("${recall.video.config.code:VIDEO_TOPIC}")
     private String recallVideoConfigCode;
 
@@ -221,13 +225,13 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
     }
 
     @Override
-    public void vectorMatchVideo() throws InterruptedException {
-        List<LongArticlesText> articles = longArticlesTextMapper.selectUnmatchedArticles();
+    public void vectorMatchVideo(String flowPoolLevel) throws InterruptedException {
+        List<UnmatchedArticle> articles = unmatchedArticleMapper.selectUnmatchedArticles(flowPoolLevel);
         if (CollectionUtils.isEmpty(articles)) {
             return;
         }
         CountDownLatch countDownLatch = new CountDownLatch(articles.size());
-        for (LongArticlesText article : articles) {
+        for (UnmatchedArticle article : articles) {
             newVectorMatchVideoPoolExecutor.execute(() -> {
                 try {
                     processVectorMatchContent(article);
@@ -239,7 +243,7 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
         countDownLatch.await();
     }
 
-    private void processVectorMatchContent(LongArticlesText article) {
+    private void processVectorMatchContent(UnmatchedArticle article) {
         String title = article.getArticleTitle();
         if (StringUtils.isEmpty(title)) {
             return;
@@ -262,6 +266,7 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
             VectorMatchVideo placeholder = new VectorMatchVideo();
             placeholder.setContentId(article.getContentId());
             placeholder.setStatus(0);
+            placeholder.setFlowPoolLevel(article.getFlowPoolLevel());
             placeholder.setCreateTime(new Date());
             vectorMatchVideoMapper.insertSelective(placeholder);
             return;
@@ -297,6 +302,10 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
             recallRecord.setVideoOssPath(ossVideoPath);
             recallRecord.setCoverUrl(shareImgPath);
             recallRecord.setStatus(1);
+            recallRecord.setFlowPoolLevel(article.getFlowPoolLevel());
+            if (item.getRov() != null) {
+                recallRecord.setRov(item.getRov());
+            }
             recallRecord.setCreateTime(new Date());
             vectorMatchVideoMapper.insertSelective(recallRecord);
             savedCount++;

+ 24 - 0
long-article-server/src/main/resources/mapper/longarticle/UnmatchedArticleMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.piaoquan.longarticle.dao.mapper.longarticle.UnmatchedArticleMapper">
+
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.longarticle.model.po.longarticle.UnmatchedArticle">
+    <result column="content_id" jdbcType="VARCHAR" property="contentId" />
+    <result column="article_title" jdbcType="VARCHAR" property="articleTitle" />
+    <result column="flow_pool_level" jdbcType="VARCHAR" property="flowPoolLevel" />
+  </resultMap>
+
+  <select id="selectUnmatchedArticles" resultMap="BaseResultMap">
+    select t.content_id, t.article_title, a.flow_pool_level
+    from long_articles_text t
+    left join long_articles_vector_match_videos v on t.content_id = v.content_id
+    left join long_articles_title_audit a on t.content_id = a.content_id
+    where v.content_id is null
+      and t.article_title is not null
+      and t.article_title != ''
+    <if test="flowPoolLevel != null and flowPoolLevel != ''">
+      and a.flow_pool_level = #{flowPoolLevel,jdbcType=VARCHAR}
+    </if>
+  </select>
+
+</mapper>

+ 40 - 10
long-article-server/src/main/resources/mapper/longarticle/VectorMatchVideoMapper.xml

@@ -4,8 +4,10 @@
   <resultMap id="BaseResultMap" type="com.tzld.piaoquan.longarticle.model.po.longarticle.VectorMatchVideo">
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="content_id" jdbcType="VARCHAR" property="contentId" />
+    <result column="flow_pool_level" jdbcType="VARCHAR" property="flowPoolLevel" />
     <result column="video_id" jdbcType="BIGINT" property="videoId" />
     <result column="score" jdbcType="DOUBLE" property="score" />
+    <result column="rov" jdbcType="DOUBLE" property="rov" />
     <result column="config_code" jdbcType="VARCHAR" property="configCode" />
     <result column="video_title" jdbcType="VARCHAR" property="videoTitle" />
     <result column="video_oss_path" jdbcType="VARCHAR" property="videoOssPath" />
@@ -72,8 +74,8 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, content_id, video_id, score, config_code, video_title, video_oss_path, cover_url, 
-    `status`, create_time
+    id, content_id, flow_pool_level, video_id, score, rov, config_code, video_title, 
+    video_oss_path, cover_url, `status`, create_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.longarticle.model.po.longarticle.VectorMatchVideoExample" resultMap="BaseResultMap">
     select
@@ -109,14 +111,14 @@
     </if>
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.longarticle.model.po.longarticle.VectorMatchVideo">
-    insert into long_articles_vector_match_videos (id, content_id, video_id, 
-      score, config_code, video_title, 
-      video_oss_path, cover_url, `status`, 
-      create_time)
-    values (#{id,jdbcType=BIGINT}, #{contentId,jdbcType=VARCHAR}, #{videoId,jdbcType=BIGINT}, 
-      #{score,jdbcType=DOUBLE}, #{configCode,jdbcType=VARCHAR}, #{videoTitle,jdbcType=VARCHAR}, 
-      #{videoOssPath,jdbcType=VARCHAR}, #{coverUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
-      #{createTime,jdbcType=TIMESTAMP})
+    insert into long_articles_vector_match_videos (id, content_id, flow_pool_level, 
+      video_id, score, rov, config_code, 
+      video_title, video_oss_path, cover_url, 
+      `status`, create_time)
+    values (#{id,jdbcType=BIGINT}, #{contentId,jdbcType=VARCHAR}, #{flowPoolLevel,jdbcType=VARCHAR}, 
+      #{videoId,jdbcType=BIGINT}, #{score,jdbcType=DOUBLE}, #{rov,jdbcType=DOUBLE}, #{configCode,jdbcType=VARCHAR}, 
+      #{videoTitle,jdbcType=VARCHAR}, #{videoOssPath,jdbcType=VARCHAR}, #{coverUrl,jdbcType=VARCHAR}, 
+      #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.longarticle.model.po.longarticle.VectorMatchVideo">
     insert into long_articles_vector_match_videos
@@ -127,12 +129,18 @@
       <if test="contentId != null">
         content_id,
       </if>
+      <if test="flowPoolLevel != null">
+        flow_pool_level,
+      </if>
       <if test="videoId != null">
         video_id,
       </if>
       <if test="score != null">
         score,
       </if>
+      <if test="rov != null">
+        rov,
+      </if>
       <if test="configCode != null">
         config_code,
       </if>
@@ -159,12 +167,18 @@
       <if test="contentId != null">
         #{contentId,jdbcType=VARCHAR},
       </if>
+      <if test="flowPoolLevel != null">
+        #{flowPoolLevel,jdbcType=VARCHAR},
+      </if>
       <if test="videoId != null">
         #{videoId,jdbcType=BIGINT},
       </if>
       <if test="score != null">
         #{score,jdbcType=DOUBLE},
       </if>
+      <if test="rov != null">
+        #{rov,jdbcType=DOUBLE},
+      </if>
       <if test="configCode != null">
         #{configCode,jdbcType=VARCHAR},
       </if>
@@ -200,12 +214,18 @@
       <if test="record.contentId != null">
         content_id = #{record.contentId,jdbcType=VARCHAR},
       </if>
+      <if test="record.flowPoolLevel != null">
+        flow_pool_level = #{record.flowPoolLevel,jdbcType=VARCHAR},
+      </if>
       <if test="record.videoId != null">
         video_id = #{record.videoId,jdbcType=BIGINT},
       </if>
       <if test="record.score != null">
         score = #{record.score,jdbcType=DOUBLE},
       </if>
+      <if test="record.rov != null">
+        rov = #{record.rov,jdbcType=DOUBLE},
+      </if>
       <if test="record.configCode != null">
         config_code = #{record.configCode,jdbcType=VARCHAR},
       </if>
@@ -233,8 +253,10 @@
     update long_articles_vector_match_videos
     set id = #{record.id,jdbcType=BIGINT},
       content_id = #{record.contentId,jdbcType=VARCHAR},
+      flow_pool_level = #{record.flowPoolLevel,jdbcType=VARCHAR},
       video_id = #{record.videoId,jdbcType=BIGINT},
       score = #{record.score,jdbcType=DOUBLE},
+      rov = #{record.rov,jdbcType=DOUBLE},
       config_code = #{record.configCode,jdbcType=VARCHAR},
       video_title = #{record.videoTitle,jdbcType=VARCHAR},
       video_oss_path = #{record.videoOssPath,jdbcType=VARCHAR},
@@ -251,12 +273,18 @@
       <if test="contentId != null">
         content_id = #{contentId,jdbcType=VARCHAR},
       </if>
+      <if test="flowPoolLevel != null">
+        flow_pool_level = #{flowPoolLevel,jdbcType=VARCHAR},
+      </if>
       <if test="videoId != null">
         video_id = #{videoId,jdbcType=BIGINT},
       </if>
       <if test="score != null">
         score = #{score,jdbcType=DOUBLE},
       </if>
+      <if test="rov != null">
+        rov = #{rov,jdbcType=DOUBLE},
+      </if>
       <if test="configCode != null">
         config_code = #{configCode,jdbcType=VARCHAR},
       </if>
@@ -281,8 +309,10 @@
   <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.longarticle.model.po.longarticle.VectorMatchVideo">
     update long_articles_vector_match_videos
     set content_id = #{contentId,jdbcType=VARCHAR},
+      flow_pool_level = #{flowPoolLevel,jdbcType=VARCHAR},
       video_id = #{videoId,jdbcType=BIGINT},
       score = #{score,jdbcType=DOUBLE},
+      rov = #{rov,jdbcType=DOUBLE},
       config_code = #{configCode,jdbcType=VARCHAR},
       video_title = #{videoTitle,jdbcType=VARCHAR},
       video_oss_path = #{videoOssPath,jdbcType=VARCHAR},