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
package com.tanpu.feo.feojob.jobs;
import com.tanpu.feo.feojob.dao.user.entity.CurriculumRes;
import com.tanpu.feo.feojob.dao.user.entity.CurriculumResExample;
import com.tanpu.feo.feojob.dao.user.entity.UserCsFileRecord;
import com.tanpu.feo.feojob.dao.user.mapper.CurriculumResMapper;
import com.tanpu.feo.feojob.dao.user.mapper.UserCsFileRecordMapper;
import com.tanpu.feo.feojob.service.CurriculumResService;
import com.tanpu.feo.feojob.utils.TxVodUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Component
@Slf4j
public class GetTxVodJob {
@Resource
private CurriculumResService curriculumResService;
@Resource
private UserCsFileRecordMapper userCsFileRecordMapper;
@Resource
private CurriculumResMapper resMapper;
@Scheduled(cron = "0 * * * * ? ")
public void execute() {
List<UserCsFileRecord> records = curriculumResService.selectShortVideoForUndoneVodTask();
for (UserCsFileRecord record : records) {
try {
executeTask(record);
} catch (Exception e) {
log.error("error in parse short video task. guid: {}, error: {}", record.getGuid(), e);
}
}
}
public void executeTask(UserCsFileRecord record) {
String taskId = record.getExt2();
if (StringUtils.isBlank(taskId)) {
return;
}
Map<String, String> resultMap = TxVodUtil.getTransUrlByFileId(taskId);
String videoUrl = resultMap.get("videoUrl");
String coverUrl = resultMap.get("coverUrl");
if (StringUtils.isNotBlank(videoUrl) && StringUtils.isNotBlank(coverUrl)) {
// 更新视频资源
CurriculumRes res = new CurriculumRes();
res.setId(record.getRefid());
res.setAudio(videoUrl);
res.setCover(coverUrl);
resMapper.updateByPrimaryKeySelective(res);
// 更新cs file record
record.setExt1("");
userCsFileRecordMapper.updateByPrimaryKeySelective(record);
}
}
}