shikeying
2022-09-24 7b3b249a7f2320f97e21e94e26a65f4b4ead0b6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.iplatform.recvideo.service;
 
import com.iplatform.model.po.Rc_video_t1;
import com.iplatform.model.po.Rc_video_t2;
import com.walker.jdbc.service.BaseServiceImpl;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
 
@Service
public class VideoExecutorServiceImpl extends BaseServiceImpl {
 
    private static final String SQL_CHECK_VIDEO_STATUS = "select * from milvus_video_status where id=?";
    private static final String SQL_CLEAR_VIDEO_T1 = "delete from rc_video_t1 where src_img=?";
    private static final String SQL_CLEAR_VIDEO_T2 = "delete from rc_video_t2 where src_video_id=?";
 
    /**
     * 写入视频相似度第一级临时数据,每个图像包含多个相似视频记录。
     * @param list
     * @param srcImageId 原始图像ID
     */
    public void execBatchInsertVideoT1(List<Rc_video_t1> list, String srcImageId){
        // 写入新数据之前,先清除老视频数据,后续分析避免数据重复(每个视频)
        this.execute(SQL_CLEAR_VIDEO_T1, new Object[]{srcImageId});
        this.insert(list);
    }
 
    /**
     * 写入视频相似度第二临时数据,每个原始视频对应多个相似视频,已排序存储。
     * @param list
     * @param srcVideoId
     */
    public void execBatchInsertVideoT2(List<Rc_video_t2> list, String srcVideoId){
        this.execute(SQL_CLEAR_VIDEO_T2, new Object[]{srcVideoId});
        this.insert(list);
    }
 
    /**
     * 根据原始视频ID返回相似记录集合。
     * @param srcVideoId
     * @return
     */
    public List<Rc_video_t1> queryVideoT_1List(String srcVideoId){
        return this.select(new Rc_video_t1(), "where src_video_id=?", new Object[]{srcVideoId});
    }
 
    /**
     * 查询视频加载状态表,是否已经完成加载(第一步),如果记录不存在说明还没有开始加载。
     * @param videoStatusId
     * @return
     */
    public boolean queryLoadVideoDone(String videoStatusId){
        Map<String, Object> map = this.get(SQL_CHECK_VIDEO_STATUS, new Object[]{videoStatusId});
        if(map == null){
            return false;
        }
        int status = Integer.parseInt(map.get("status").toString());
        if(status == 1){
            return true;
        }
        return false;
    }
}