|
|
@@ -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;
|
|
|
}
|