shikeying
2022-09-27 fb66d5ed24e716e536543364f746a9db5aeb20a9
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
65
66
67
68
69
70
71
72
73
74
75
76
package com.iplatform.recvideo.support;
 
import com.iplatform.model.po.Rc_task_status;
import com.iplatform.model.po.Rc_video_batch;
import com.iplatform.reccommon.TaskType;
import com.iplatform.recvideo.VideoLoadInfo;
import com.iplatform.recvideo.VideoLoader;
import com.iplatform.recvideo.service.VideoLoaderServiceImpl;
import com.walker.infrastructure.utils.DateUtils;
import com.walker.infrastructure.utils.NumberGenerator;
 
import java.util.ArrayList;
import java.util.List;
 
public class DefaultVideoLoader extends VideoLoader {
 
    private VideoLoaderServiceImpl videoLoaderService;
 
    public void setVideoLoaderService(VideoLoaderServiceImpl videoLoaderService) {
        this.videoLoaderService = videoLoaderService;
    }
 
    @Override
    protected long acquireNextBatchId() {
        return this.videoLoaderService.queryNextBatchValue();
    }
 
    @Override
    protected long acquireInitBatchId() {
        return 0;
    }
 
    @Override
    protected List<VideoLoadInfo> acquireLoadVideoFromDatabase(long nextBatchId) {
        return null;
    }
 
    @Override
    protected long copyRemoteVideoFiles(List<VideoLoadInfo> readyLoadList, long nextBatchId) throws Exception {
        return 0;
    }
 
    @Override
    protected int saveDataAndStatus(List<VideoLoadInfo> readyLoadList, long savedBatchId) {
        List<Rc_video_batch> videoBatchList = this.toVideoBatchList(readyLoadList, savedBatchId);
        Rc_task_status taskStatus = this.createNewTaskStatus(savedBatchId);
        return this.videoLoaderService.execSaveBatchAndStatus(videoBatchList, taskStatus);
    }
 
    private Rc_task_status createNewTaskStatus(long savedBatchId){
        Rc_task_status status = new Rc_task_status();
        status.setCreate_time(Long.parseLong(DateUtils.getDateTimeSecondForShow()));
        status.setStatus("0");
        status.setId(NumberGenerator.getLongSequenceNumber());
        status.setTask_type(TaskType.INDEX_VIDEO_LOAD);
        status.setLast_value(savedBatchId);
        status.setName("整理获取短视频任务");
        return status;
    }
 
    private List<Rc_video_batch> toVideoBatchList(List<VideoLoadInfo> readyLoadList, long savedBatchId){
        List<Rc_video_batch> resultList = new ArrayList<>(readyLoadList.size());
        Rc_video_batch e = null;
        String batchId = String.valueOf(savedBatchId);
        for(VideoLoadInfo v : readyLoadList){
            e = new Rc_video_batch();
            e.setBatch_id(batchId);
            e.setSrc_video_id(v.getSrcVideoId());
            e.setUser_id(v.getUserId());
            e.setSrc_video_path(v.getVideoDestPath());
            e.setId(NumberGenerator.getLongSequenceNumber());
            resultList.add(e);
        }
        return resultList;
    }
}