Просмотр исходного кода

需求来源长文 增加实验ID

wangyunpeng 14 часов назад
Родитель
Сommit
7b36b1b41b
14 измененных файлов с 384 добавлено и 37 удалено
  1. 1 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/PublishArticleData.java
  2. 19 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/VideoArticleMatchQueryParam.java
  3. 58 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/VideoArticleMatchResult.java
  4. 11 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/longarticle/PublishContent.java
  5. 70 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/longarticle/PublishContentExample.java
  6. 12 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/VideoMultiService.java
  7. 119 13
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java
  8. 1 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/PublicContentServiceImpl.java
  9. 31 9
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/VideoMultiServiceImpl.java
  10. 11 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/VideoVectorService.java
  11. 20 0
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/impl/VideoVectorServiceImpl.java
  12. 8 8
      long-article-server/src/main/resources/aigc-mybatis-generator-config.xml
  13. 21 5
      long-article-server/src/main/resources/mapper/longarticle/PublishContentMapper.xml
  14. 2 2
      long-article-server/src/main/resources/mybatis-generator-config.xml

+ 1 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/PublishArticleData.java

@@ -20,4 +20,5 @@ public class PublishArticleData {
     private Double score;
     private String contentPoolType;
     private Integer sourceType;
+    private String experimentId;
 }

+ 19 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/VideoArticleMatchQueryParam.java

@@ -0,0 +1,19 @@
+package com.tzld.piaoquan.longarticle.model.dto;
+
+import lombok.Data;
+
+/**
+ * 按来源文章ID查询匹配视频 请求参数
+ */
+@Data
+public class VideoArticleMatchQueryParam {
+
+    /** 账号,必填 */
+    private String account;
+
+    /** 匹配到的文章ID(matched_article_id),必填 */
+    private String sourceId;
+
+    /** 返回条数,默认3 */
+    private Integer topN = 3;
+}

+ 58 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/VideoArticleMatchResult.java

@@ -0,0 +1,58 @@
+package com.tzld.piaoquan.longarticle.model.dto;
+
+import lombok.Data;
+
+/**
+ * 视频-文章匹配结果
+ */
+@Data
+public class VideoArticleMatchResult {
+
+    /** 记录ID */
+    private Long id;
+
+    /** 数据日期(yyyyMMdd) */
+    private String dt;
+
+    /** 渠道名 */
+    private String channelName;
+
+    /** 三级渠道(账号) */
+    private String channelLevel3;
+
+    /** 账号 */
+    private String account;
+
+    /** 匹配视频ID */
+    private Long matchVideoId;
+
+    /** 视频标题 */
+    private String videoTitle;
+
+    /** 匹配到的文章ID */
+    private String matchedArticleId;
+
+    /** 匹配到的文章标题 */
+    private String matchedArticleTitle;
+
+    /** 匹配得分(0~1,越大越相关) */
+    private Double matchScore;
+
+    /** 匹配配置编码(如 ARTICLE_TITLE / ARTICLE_SUMMARY) */
+    private String matchConfigCode;
+
+    /** 查询文本(视频标题) */
+    private String queryText;
+
+    /** 查询使用的 configCode 列表 */
+    private String configCodes;
+
+    /** 精排参数 JSON 快照 */
+    private String rankingParams;
+
+    /** 创建时间 */
+    private String createTime;
+
+    /** 匹配实验ID */
+    private String experimentId;
+}

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

@@ -29,6 +29,8 @@ public class PublishContent {
 
     private Integer userGroupId;
 
+    private String experimentId;
+
     private Date createTime;
 
     private Date updateTime;
@@ -137,6 +139,14 @@ public class PublishContent {
         this.userGroupId = userGroupId;
     }
 
+    public String getExperimentId() {
+        return experimentId;
+    }
+
+    public void setExperimentId(String experimentId) {
+        this.experimentId = experimentId;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }
@@ -172,6 +182,7 @@ public class PublishContent {
         sb.append(", traceId=").append(traceId);
         sb.append(", rootId=").append(rootId);
         sb.append(", userGroupId=").append(userGroupId);
+        sb.append(", experimentId=").append(experimentId);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);
         sb.append("]");

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

@@ -956,6 +956,76 @@ public class PublishContentExample {
             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;
+        }
+
         public Criteria andCreateTimeIsNull() {
             addCriterion("create_time is null");
             return (Criteria) this;

+ 12 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/VideoMultiService.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.longarticle.service.local;
 
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.longarticle.model.po.growth.VideoGrowthMultiCover;
 import com.tzld.piaoquan.longarticle.model.po.growth.VideoGrowthMultiTitle;
 
@@ -9,6 +10,17 @@ public interface VideoMultiService {
 
     String setVideoMultiTitleCoverPagePath(Long videoId, String pageUrl, String title, String coverUrl);
 
+    /**
+     * 向 pageUrl 的 growthExtData 参数中合并/追加字段
+     * - pageUrl 不含 growthExtData:末尾追加(URL编码)
+     * - pageUrl 已含 growthExtData:解析已有JSON,合并新字段后替换
+     *
+     * @param pageUrl   小程序 pagePath,形如 pages/category?jumpPage=<encoded inner url>
+     * @param extraData 需要合并的字段
+     * @return 处理后的 pageUrl,异常时返回原值
+     */
+    String appendGrowthExtData(String pageUrl, JSONObject extraData);
+
     Long saveMultiTitle(Long videoId, String source, String title);
 
     List<VideoGrowthMultiTitle> getMultiTitleByVideoId(Long videoId);

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

@@ -3,6 +3,7 @@ package com.tzld.piaoquan.longarticle.service.local.impl;
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
 import com.tzld.piaoquan.longarticle.common.constants.TimeConstant;
@@ -17,12 +18,15 @@ import com.tzld.piaoquan.longarticle.model.dto.MiniprogramCardRequest;
 import com.tzld.piaoquan.longarticle.model.dto.PublishArticleData;
 import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreParam;
 import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreVO;
+import com.tzld.piaoquan.longarticle.model.dto.VideoArticleMatchQueryParam;
+import com.tzld.piaoquan.longarticle.model.dto.VideoArticleMatchResult;
 import com.tzld.piaoquan.longarticle.model.po.crawler.FwhDailyPublishDetail;
 import com.tzld.piaoquan.longarticle.model.po.longarticle.*;
 import com.tzld.piaoquan.longarticle.model.vo.*;
 import com.tzld.piaoquan.longarticle.service.local.AccountService;
 import com.tzld.piaoquan.longarticle.service.local.CoreService;
 import com.tzld.piaoquan.longarticle.service.local.PlanAccountService;
+import com.tzld.piaoquan.longarticle.service.local.VideoMultiService;
 import com.tzld.piaoquan.longarticle.service.remote.AigcService;
 import com.tzld.piaoquan.longarticle.service.remote.MatchService;
 import com.tzld.piaoquan.longarticle.service.remote.VideoService;
@@ -103,6 +107,8 @@ public class CoreServiceImpl implements CoreService {
     @Autowired
     private VideoVectorService videoVectorService;
 
+    @Autowired
+    private VideoMultiService videoMultiService;
     @Autowired
     private VectorMatchVideoMapper vectorMatchVideoMapper;
 
@@ -860,22 +866,29 @@ public class CoreServiceImpl implements CoreService {
         List<PublishMiniprogram> publishMiniprogramList = publicContentService.getPublishMiniprograms(publishContent);
         //不存在则重新生成
         if (CollectionUtils.isEmpty(publishMiniprogramList)) {
-            // 优先尝试 recallWithScore 召回的视频(仅配置的账号或配置为ALL时生效)
-            if (isRecallPublishMiniprogramAccount(planAccount.getAccountName())) {
-                publishMiniprogramList = getRecallPublishMiniprograms(publishContent, planAccount);
-                // 开关打开时,同时执行匹配流程获取小程序信息,将标题和封面替换至召回视频
-                if (!CollectionUtils.isEmpty(publishMiniprogramList)
-                        && replaceRecallTitleCoverSwitch != null && replaceRecallTitleCoverSwitch) {
-                    List<PublishMiniprogram> matchedList = getDefaultPublishMiniprograms(publishContent, planAccount, false);
-                    if (!CollectionUtils.isEmpty(matchedList)) {
-                        replaceRecallTitleAndCover(publishMiniprogramList, matchedList);
-                    }
-                }
+            // 如果有experimentId,优先通过queryBySourceId接口获取匹配视频生成小程序卡片
+            if (StringUtils.isNotEmpty(publishContent.getExperimentId())) {
+                publishMiniprogramList = getExperimentMatchMiniprograms(publishContent, planAccount);
             }
+            // experimentId未获取到结果时,继续走原有逻辑
             if (CollectionUtils.isEmpty(publishMiniprogramList)) {
-                publishMiniprogramList = getDefaultPublishMiniprograms(publishContent, planAccount, true);
+                // 优先尝试 recallWithScore 召回的视频(仅配置的账号或配置为ALL时生效)
+                if (isRecallPublishMiniprogramAccount(planAccount.getAccountName())) {
+                    publishMiniprogramList = getRecallPublishMiniprograms(publishContent, planAccount);
+                    // 开关打开时,同时执行匹配流程获取小程序信息,将标题和封面替换至召回视频
+                    if (!CollectionUtils.isEmpty(publishMiniprogramList)
+                            && replaceRecallTitleCoverSwitch != null && replaceRecallTitleCoverSwitch) {
+                        List<PublishMiniprogram> matchedList = getDefaultPublishMiniprograms(publishContent, planAccount, false);
+                        if (!CollectionUtils.isEmpty(matchedList)) {
+                            replaceRecallTitleAndCover(publishMiniprogramList, matchedList);
+                        }
+                    }
+                }
                 if (CollectionUtils.isEmpty(publishMiniprogramList)) {
-                    return null;
+                    publishMiniprogramList = getDefaultPublishMiniprograms(publishContent, planAccount, true);
+                    if (CollectionUtils.isEmpty(publishMiniprogramList)) {
+                        return null;
+                    }
                 }
             }
         }
@@ -1003,6 +1016,99 @@ public class CoreServiceImpl implements CoreService {
         return publishMiniprogramList;
     }
 
+    /**
+     * 通过 experimentId 调用 queryBySourceId 接口获取匹配视频,生成小程序卡片
+     * 返回 null 表示无匹配结果,调用方应回退到原有流程
+     */
+    private List<PublishMiniprogram> getExperimentMatchMiniprograms(PublishContent publishContent, PlanAccount planAccount) {
+        VideoArticleMatchQueryParam param = new VideoArticleMatchQueryParam();
+        param.setAccount(planAccount.getAccountName());
+        param.setSourceId(publishContent.getSourceId());
+        param.setTopN(miniVideoNum);
+
+        List<VideoArticleMatchResult> matchResults = videoVectorService.queryBySourceId(param);
+        if (CollectionUtils.isEmpty(matchResults)) {
+            log.info("getExperimentMatchMiniprograms no results, experimentId={}, sourceId={}",
+                    publishContent.getExperimentId(), publishContent.getSourceId());
+            return null;
+        }
+        log.info("getExperimentMatchMiniprograms found {} results, experimentId={}, sourceId={}",
+                matchResults.size(), publishContent.getExperimentId(), publishContent.getSourceId());
+
+        List<VideoDetail> videoDetails = new ArrayList<>();
+        Map<Long, String> videoExperimentMap = new LinkedHashMap<>();
+        for (VideoArticleMatchResult matchResult : matchResults) {
+            if (matchResult.getMatchVideoId() == null) {
+                continue;
+            }
+            VideoDetail videoDetail = VideoUtils.getVideoDetail(matchResult.getMatchVideoId());
+            if (videoDetail == null) {
+                log.warn("getVideoDetail null for matchVideoId={}", matchResult.getMatchVideoId());
+                continue;
+            }
+            videoDetail.setSource("piaoquan");
+            videoDetail.setKimiTitle(matchResult.getVideoTitle());
+            videoDetail.setVideoOss(videoDetail.getOssVideoPath());
+            videoDetail.setCoverOss(videoDetail.getShareImgPath());
+            videoDetails.add(videoDetail);
+            videoExperimentMap.put(matchResult.getMatchVideoId(), matchResult.getExperimentId());
+        }
+
+        if (CollectionUtils.isEmpty(videoDetails)) {
+            return null;
+        }
+
+        // 数量不足时用第一个视频补足,超出则截断(补足的视频复用第一个视频的experimentId)
+        if (videoDetails.size() < miniVideoNum) {
+            VideoDetail first = videoDetails.get(0);
+            int needAddCount = miniVideoNum - videoDetails.size();
+            for (int i = 0; i < needAddCount; i++) {
+                VideoDetail copy = new VideoDetail();
+                BeanUtils.copyProperties(first, copy);
+                videoDetails.add(copy);
+            }
+        }
+        if (videoDetails.size() > miniVideoNum) {
+            videoDetails = videoDetails.subList(0, miniVideoNum);
+        }
+
+        List<PublishMiniprogram> publishMiniprogramList = cardService.generateCards(videoDetails, planAccount, publishContent);
+        if (!CollectionUtils.isEmpty(publishMiniprogramList)) {
+            // 为每张卡片的 productionPath 拼接对应视频的 growthExtData 参数
+            appendGrowthExtDataToCards(publishMiniprogramList, videoExperimentMap);
+            for (PublishMiniprogram publishMiniprogram : publishMiniprogramList) {
+                rootSourceService.addRootSource(publishMiniprogram, planAccount, publishContent);
+                publishMiniprogramMapper.insertSelective(publishMiniprogram);
+            }
+            log.info("getExperimentMatchMiniprograms success, cards={}, experimentId={}",
+                    publishMiniprogramList.size(), publishContent.getExperimentId());
+        }
+        return publishMiniprogramList;
+    }
+
+    /**
+     * 为每张卡片的 productionPath 拼接对应视频的 growthExtData 参数
+     * 参照 TouLiuHttpClient.sendAdFlowAddRequest 的拼接方式
+     */
+    private void appendGrowthExtDataToCards(List<PublishMiniprogram> cards, Map<Long, String> videoExperimentMap) {
+        if (CollectionUtils.isEmpty(cards) || videoExperimentMap == null || videoExperimentMap.isEmpty()) {
+            return;
+        }
+        for (PublishMiniprogram card : cards) {
+            String experimentId = videoExperimentMap.get(card.getVideoId());
+            if (StringUtils.isEmpty(experimentId)) {
+                continue;
+            }
+            String productionPath = card.getProductionPath();
+            if (StringUtils.isNotEmpty(productionPath)) {
+                JSONObject extData = new JSONObject();
+                extData.put("experimentId", experimentId);
+                card.setProductionPath(videoMultiService.appendGrowthExtData(productionPath, extData));
+            }
+        }
+        log.info("appendGrowthExtDataToCards done, {} cards", cards.size());
+    }
+
     private List<PublishMiniprogram> getPublishMiniprogramList(List<VideoDetail> videoDetails, PlanAccount planAccount,
                                                                PublishContent publishContent) {
         if (CollectionUtils.isEmpty(videoDetails)) {

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

@@ -64,6 +64,7 @@ public class PublicContentServiceImpl {
         }
         publishContent.setContentPoolType(publishArticleData.getContentPoolType());
         publishContent.setSourceType(publishArticleData.getSourceType());
+        publishContent.setExperimentId(publishArticleData.getExperimentId());
         publishContentMapper.insertSelective(publishContent);
         return publishContent;
     }

+ 31 - 9
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/VideoMultiServiceImpl.java

@@ -135,6 +135,35 @@ public class VideoMultiServiceImpl implements VideoMultiService {
      * - pageUrl 已含 growthExtData:解析出已有 JSON 对象,将新字段合并进去后再替换回原位置
      */
     private String mergeOrAppendGrowthExtData(String pageUrl, PageUrlExtData extData) throws Exception {
+        JSONObject json = new JSONObject();
+        if (Objects.nonNull(extData.getGrowthTitleId())) {
+            json.put("growthTitleId", extData.getGrowthTitleId());
+            json.put("growthTitleSource", extData.getGrowthTitleSource());
+        }
+        if (Objects.nonNull(extData.getGrowthCoverId())) {
+            json.put("growthCoverId", extData.getGrowthCoverId());
+            json.put("growthCoverSource", extData.getGrowthCoverSource());
+        }
+        return doAppendGrowthExtData(pageUrl, json);
+    }
+
+    @Override
+    public String appendGrowthExtData(String pageUrl, JSONObject extraData) {
+        if (extraData == null || extraData.isEmpty()) {
+            return pageUrl;
+        }
+        try {
+            return doAppendGrowthExtData(pageUrl, extraData);
+        } catch (Exception e) {
+            log.error("appendGrowthExtData error", e);
+            return pageUrl;
+        }
+    }
+
+    /**
+     * 核心逻辑:查找 growthExtData 参数,存在则合并,不存在则追加
+     */
+    private String doAppendGrowthExtData(String pageUrl, JSONObject extraData) throws Exception {
         int valueStart = -1;
         int valueEnd = -1;
         int gIdx = pageUrl.indexOf("growthExtData");
@@ -172,20 +201,13 @@ public class VideoMultiServiceImpl implements VideoMultiService {
             if (existing == null) {
                 existing = new JSONObject();
             }
-            if (Objects.nonNull(extData.getGrowthTitleId())) {
-                existing.put("growthTitleId", extData.getGrowthTitleId());
-                existing.put("growthTitleSource", extData.getGrowthTitleSource());
-            }
-            if (Objects.nonNull(extData.getGrowthCoverId())) {
-                existing.put("growthCoverId", extData.getGrowthCoverId());
-                existing.put("growthCoverSource", extData.getGrowthCoverSource());
-            }
+            existing.putAll(extraData);
             String newEncodedJson = URLEncoder.encode(JSONObject.toJSONString(existing), "UTF-8");
             return pageUrl.substring(0, valueStart) + newEncodedJson + pageUrl.substring(valueEnd);
         }
 
         // pageUrl 中不存在 growthExtData:直接在末尾拼接
-        return pageUrl + URLEncoder.encode("&growthExtData=" + JSONObject.toJSONString(extData), "UTF-8");
+        return pageUrl + URLEncoder.encode("&growthExtData=" + JSONObject.toJSONString(extraData), "UTF-8");
     }
 
     @Override

+ 11 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/VideoVectorService.java

@@ -2,6 +2,8 @@ package com.tzld.piaoquan.longarticle.service.remote;
 
 import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreParam;
 import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreVO;
+import com.tzld.piaoquan.longarticle.model.dto.VideoArticleMatchQueryParam;
+import com.tzld.piaoquan.longarticle.model.dto.VideoArticleMatchResult;
 
 import java.util.List;
 
@@ -25,4 +27,13 @@ public interface VideoVectorService {
      * @return 合并去重后按综合分降序排列的结果,全部失败返回 null
      */
     RecallVideoScoreVO recallWithScore(RecallVideoScoreParam param, List<String> configCodes);
+
+    /**
+     * 按来源文章ID查询匹配视频
+     * 根据账号(channel_level3)和文章ID,查询该文章匹配到的视频列表,结果按匹配得分降序排列
+     *
+     * @param param 查询参数(account、sourceId 必填,topN 可选默认10)
+     * @return 匹配结果列表,无数据返回空列表,失败返回 null
+     */
+    List<VideoArticleMatchResult> queryBySourceId(VideoArticleMatchQueryParam param);
 }

+ 20 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/impl/VideoVectorServiceImpl.java

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreParam;
 import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreVO;
+import com.tzld.piaoquan.longarticle.model.dto.VideoArticleMatchQueryParam;
+import com.tzld.piaoquan.longarticle.model.dto.VideoArticleMatchResult;
 import com.tzld.piaoquan.longarticle.service.remote.VideoVectorService;
 import com.tzld.piaoquan.longarticle.utils.HttpClientUtil;
 import com.tzld.piaoquan.longarticle.utils.HttpPoolClientUtil;
@@ -102,6 +104,24 @@ public class VideoVectorServiceImpl implements VideoVectorService {
         return mergedResult;
     }
 
+    @Override
+    public List<VideoArticleMatchResult> queryBySourceId(VideoArticleMatchQueryParam param) {
+        String apiUrl = videoVectorApiHost + "/videoArticleMatch/queryBySourceId";
+        try {
+            log.info("queryBySourceId request={}", JSON.toJSONString(param));
+            String res = HTTP_CLIENT.post(apiUrl, JSON.toJSONString(param));
+            JSONObject jsonObject = JSON.parseObject(res);
+            log.info("queryBySourceId res code={}, msg={}", jsonObject.getInteger("code"), jsonObject.getString("msg"));
+
+            if (jsonObject.getInteger("code") != null && jsonObject.getInteger("code") == 0) {
+                return JSON.parseArray(jsonObject.getString("data"), VideoArticleMatchResult.class);
+            }
+        } catch (Exception e) {
+            log.error("queryBySourceId error, param={}", JSON.toJSONString(param), e);
+        }
+        return null;
+    }
+
     private RecallVideoScoreVO doSingleRecall(RecallVideoScoreParam param) {
         String apiUrl = videoVectorApiHost + "/videoSearch/recallWithScore";
         try {

+ 8 - 8
long-article-server/src/main/resources/aigc-mybatis-generator-config.xml

@@ -49,22 +49,22 @@
                              targetProject="/Users/shimeng/Desktop/project/long-article-manage/long-article-server/src/main/java">
             <property name="enableSubPackages" value="true"/>
         </javaClientGenerator>
-<!--        <table tableName="long_articles_match_videos" domainObjectName="MatchVideo" alias="" />-->
-<!--            <columnOverride column="response" javaType="java.lang.String" jdbcType="LONGVARCHAR" />-->
+<!--        <table tableName="long_articles_match_videos" domainObjectName="MatchVideo" alias="">-->
+<!--            <columnOverride column="response" javaType="java.lang.String" jdbcType="LONGVARCHAR"/>-->
 <!--        </table>-->
 <!--        <table tableName="long_articles_text" domainObjectName="LongArticlesText" alias="">-->
-<!--            <columnOverride column="article_text" javaType="java.lang.String" jdbcType="LONGVARCHAR" />-->
+<!--            <columnOverride column="article_text" javaType="java.lang.String" jdbcType="LONGVARCHAR"/>-->
 <!--        </table>-->
 <!--        <table tableName="long_articles_crawler_videos" domainObjectName="CrawlerVideo" alias="">-->
-<!--            <columnOverride column="video_url" javaType="java.lang.String" jdbcType="LONGVARCHAR" />-->
-<!--            <columnOverride column="cover_url" javaType="java.lang.String" jdbcType="LONGVARCHAR" />-->
+<!--            <columnOverride column="video_url" javaType="java.lang.String" jdbcType="LONGVARCHAR"/>-->
+<!--            <columnOverride column="cover_url" javaType="java.lang.String" jdbcType="LONGVARCHAR"/>-->
 <!--        </table>-->
 <!--        <table tableName="long_articles_root_source_id" domainObjectName="RootSource" alias=""/>-->
         <table tableName="produce_plan_exe_record" domainObjectName="ProducePlanExeRecord" alias=""/>
-<!--            <table tableName="long_articles_plan" domainObjectName="Plan" alias=""/>-->
+<!--        <table tableName="long_articles_plan" domainObjectName="Plan" alias=""/>-->
 
-<!--                <table tableName="long_articles_publish_content" domainObjectName="PublishContent" alias=""/>-->
-<!--                <table tableName="long_articles_publish_miniprogram" domainObjectName="PublishMiniprogram" alias=""/>-->
+<!--        <table tableName="long_articles_publish_content" domainObjectName="PublishContent" alias=""/>-->
+<!--        <table tableName="long_articles_publish_miniprogram" domainObjectName="PublishMiniprogram" alias=""/>-->
 <!--        <table tableName="get_off_videos" domainObjectName="OffVideo" alias=""/>-->
 
     </context>

+ 21 - 5
long-article-server/src/main/resources/mapper/longarticle/PublishContentMapper.xml

@@ -15,6 +15,7 @@
     <result column="trace_id" jdbcType="VARCHAR" property="traceId" />
     <result column="root_id" jdbcType="BIGINT" property="rootId" />
     <result column="user_group_id" jdbcType="INTEGER" property="userGroupId" />
+    <result column="experiment_id" jdbcType="VARCHAR" property="experimentId" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
@@ -78,7 +79,8 @@
   </sql>
   <sql id="Base_Column_List">
     id, plan_account_id, publish_content_id, source_id, score, content_pool_type, source_type, 
-    `status`, push_id, reason, trace_id, root_id, user_group_id, create_time, update_time
+    `status`, push_id, reason, trace_id, root_id, user_group_id, experiment_id, create_time, 
+    update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.longarticle.model.po.longarticle.PublishContentExample" resultMap="BaseResultMap">
     select
@@ -118,14 +120,14 @@
       source_id, score, content_pool_type, 
       source_type, `status`, push_id, 
       reason, trace_id, root_id, 
-      user_group_id, create_time, update_time
-      )
+      user_group_id, experiment_id, create_time, 
+      update_time)
     values (#{id,jdbcType=BIGINT}, #{planAccountId,jdbcType=BIGINT}, #{publishContentId,jdbcType=VARCHAR}, 
       #{sourceId,jdbcType=VARCHAR}, #{score,jdbcType=DOUBLE}, #{contentPoolType,jdbcType=VARCHAR}, 
       #{sourceType,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{pushId,jdbcType=VARCHAR}, 
       #{reason,jdbcType=VARCHAR}, #{traceId,jdbcType=VARCHAR}, #{rootId,jdbcType=BIGINT}, 
-      #{userGroupId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
-      )
+      #{userGroupId,jdbcType=INTEGER}, #{experimentId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.longarticle.model.po.longarticle.PublishContent" useGeneratedKeys="true" keyProperty="id">
     insert into long_articles_publish_content
@@ -169,6 +171,9 @@
       <if test="userGroupId != null">
         user_group_id,
       </if>
+      <if test="experimentId != null">
+        experiment_id,
+      </if>
       <if test="createTime != null">
         create_time,
       </if>
@@ -216,6 +221,9 @@
       <if test="userGroupId != null">
         #{userGroupId,jdbcType=INTEGER},
       </if>
+      <if test="experimentId != null">
+        #{experimentId,jdbcType=VARCHAR},
+      </if>
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -275,6 +283,9 @@
       <if test="record.userGroupId != null">
         user_group_id = #{record.userGroupId,jdbcType=INTEGER},
       </if>
+      <if test="record.experimentId != null">
+        experiment_id = #{record.experimentId,jdbcType=VARCHAR},
+      </if>
       <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
       </if>
@@ -301,6 +312,7 @@
       trace_id = #{record.traceId,jdbcType=VARCHAR},
       root_id = #{record.rootId,jdbcType=BIGINT},
       user_group_id = #{record.userGroupId,jdbcType=INTEGER},
+      experiment_id = #{record.experimentId,jdbcType=VARCHAR},
       create_time = #{record.createTime,jdbcType=TIMESTAMP},
       update_time = #{record.updateTime,jdbcType=TIMESTAMP}
     <if test="_parameter != null">
@@ -346,6 +358,9 @@
       <if test="userGroupId != null">
         user_group_id = #{userGroupId,jdbcType=INTEGER},
       </if>
+      <if test="experimentId != null">
+        experiment_id = #{experimentId,jdbcType=VARCHAR},
+      </if>
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -369,6 +384,7 @@
       trace_id = #{traceId,jdbcType=VARCHAR},
       root_id = #{rootId,jdbcType=BIGINT},
       user_group_id = #{userGroupId,jdbcType=INTEGER},
+      experiment_id = #{experimentId,jdbcType=VARCHAR},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}

+ 2 - 2
long-article-server/src/main/resources/mybatis-generator-config.xml

@@ -62,12 +62,12 @@
 <!--        <table tableName="long_articles_root_source_id" domainObjectName="RootSource" alias=""/>-->
 <!--        <table tableName="long_articles_plan_account" domainObjectName="PlanAccount" alias=""/>-->
 <!--        <table tableName="long_articles_plan" domainObjectName="Plan" alias=""/>-->
-<!--        <table tableName="long_articles_publish_content" domainObjectName="PublishContent" alias=""/>-->
+        <table tableName="long_articles_publish_content" domainObjectName="PublishContent" alias=""/>
 <!--        <table tableName="long_articles_new_match_videos" domainObjectName="NewMatchVideo" alias=""/>-->
 <!--        <table tableName="video_keywords_map" domainObjectName="VideoKeywordsMap" alias=""/>-->
 <!--        <table tableName="long_articles_publish_miniprogram" domainObjectName="PublishMiniprogram" alias=""/>-->
 <!--        <table tableName="get_off_videos" domainObjectName="OffVideo" alias=""/>-->
-        <table tableName="long_articles_vector_match_videos" domainObjectName="VectorMatchVideo" alias=""/>
+<!--        <table tableName="long_articles_vector_match_videos" domainObjectName="VectorMatchVideo" alias=""/>-->
 
     </context>