Przeglądaj źródła

aiUnderstanding 数据源改读 Redis video:detail

- 复用 syncVideoDetailJob 已写入的 Redis key (video:detail:{videoId})
- 中文维度名映射: 内容选题→contentTopic, 视频主题→videoTheme, 视频关键词→videoKeywords
- 三字段全空时返回 null, 避免前端展示空壳
- videoNarration 暂留 null (口播字段不在 video_dimension_detail_add_column 维度表)
- 删掉 VideoAiUnderstandingMapper 注入与 PO 引用 (result_log → MySQL 同步链路未实施, 短期不需要)
刘立冬 1 dzień temu
rodzic
commit
f5883e7150

+ 4 - 5
core/src/main/java/com/tzld/videoVector/model/vo/recall/AIUnderstandingVO.java

@@ -5,11 +5,10 @@ import lombok.Data;
 /**
  * AI理解结果 VO
  *
- * 数据来源: ODPS loghubods.result_log (大数据,慢) → 经 DataWorks 同步Job
- * 同步到本地表 video_ai_understanding。
- *
- * MVP 期间本地表为空,该 VO 全部为 null,前端展示"AI理解数据未就绪,等待同步Job"。
- * 严禁后端伪造任何字段返回。
+ * 数据来源: Redis key video:detail:{videoId}, 由 syncVideoDetailJob 从
+ * ODPS loghubods.video_dimension_detail_add_column 同步而来.
+ * 字段对应: 内容选题→contentTopic, 视频主题→videoTheme, 视频关键词→videoKeywords.
+ * videoNarration 暂未接入(口播字段不在该 ODPS 维度表中).
  */
 @Data
 public class AIUnderstandingVO {

+ 26 - 18
core/src/main/java/com/tzld/videoVector/service/recall/impl/VectorRecallTestServiceImpl.java

@@ -2,15 +2,15 @@ package com.tzld.videoVector.service.recall.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.videoVector.api.VideoApiService;
+import com.tzld.videoVector.common.constant.VectorConstants;
 import com.tzld.videoVector.common.enums.Modality;
-import com.tzld.videoVector.dao.mapper.videoVector.VideoAiUnderstandingMapper;
 import com.tzld.videoVector.dao.mapper.videoVector.deconstruct.MysqlDeconstructContentMapper;
 import com.tzld.videoVector.model.entity.VideoDetail;
 import com.tzld.videoVector.model.param.MatchTopNVideoParam;
 import com.tzld.videoVector.model.param.recall.MatchByTextParam;
 import com.tzld.videoVector.model.param.recall.MatchByVideoIdParam;
-import com.tzld.videoVector.model.po.videoVector.VideoAiUnderstanding;
 import com.tzld.videoVector.model.po.videoVector.deconstruct.MysqlDeconstructContent;
 import com.tzld.videoVector.model.po.videoVector.deconstruct.MysqlDeconstructContentExample;
 import com.tzld.videoVector.model.vo.VideoMatchResult;
@@ -56,9 +56,6 @@ public class VectorRecallTestServiceImpl implements VectorRecallTestService {
     @Autowired
     private MysqlDeconstructContentMapper mysqlDeconstructContentMapper;
 
-    @Autowired(required = false)
-    private VideoAiUnderstandingMapper videoAiUnderstandingMapper;
-
     @Autowired(required = false)
     private StringRedisTemplate stringRedisTemplate;
 
@@ -169,27 +166,38 @@ public class VectorRecallTestServiceImpl implements VectorRecallTestService {
         if (videoId == null || videoId <= 0L) {
             return null;
         }
-        if (videoAiUnderstandingMapper == null) {
-            // 表/Mapper 未就绪(同步Job尚未实施)
-            log.info("getAiUnderstanding: mapper not available, returning null. videoId={}", videoId);
+        // 数据源切换: 复用 syncVideoDetailJob 写入的 Redis (key: video:detail:{videoId}),
+        // 字段从中文维度名映射到 VO. result_log 同步链路尚未建, 留给后续如需"视频口播"再补.
+        if (stringRedisTemplate == null) {
+            log.info("getAiUnderstanding: redisTemplate not available, returning null. videoId={}", videoId);
             return null;
         }
         try {
-            VideoAiUnderstanding po = videoAiUnderstandingMapper.selectByVideoId(videoId);
-            if (po == null) {
+            String json = stringRedisTemplate.opsForValue()
+                    .get(VectorConstants.VIDEO_DETAIL_KEY_PREFIX + videoId);
+            if (!StringUtils.hasText(json)) {
+                return null;
+            }
+            JSONObject detail = JSON.parseObject(json);
+            String topic = detail.getString("内容选题");
+            String theme = detail.getString("视频主题");
+            String keywords = detail.getString("视频关键词");
+            // 三个核心字段全空 → 视为无 AI 理解数据, 返回 null 避免前端展示空壳
+            if (!StringUtils.hasText(topic)
+                    && !StringUtils.hasText(theme)
+                    && !StringUtils.hasText(keywords)) {
                 return null;
             }
             AIUnderstandingVO vo = new AIUnderstandingVO();
-            vo.setVideoId(po.getVideoId());
-            vo.setContentTopic(po.getContentTopic());
-            vo.setVideoTheme(po.getVideoTheme());
-            vo.setVideoKeywords(po.getVideoKeywords());
-            vo.setVideoNarration(po.getVideoNarration());
-            vo.setDt(po.getDt());
+            vo.setVideoId(videoId);
+            vo.setContentTopic(topic);
+            vo.setVideoTheme(theme);
+            vo.setVideoKeywords(keywords);
+            // "视频口播" 不在 video_dimension_detail_add_column 维度字段里, 暂留 null
+            vo.setVideoNarration(null);
             return vo;
         } catch (Exception e) {
-            // 表可能尚未创建(BadSqlGrammarException等),按真实"未就绪"返回 null
-            log.warn("getAiUnderstanding: query failed, table may not exist yet. videoId={}, err={}",
+            log.warn("getAiUnderstanding: redis read/parse failed, videoId={}, err={}",
                     videoId, e.getMessage());
             return null;
         }