admin
2024-10-17 b30fb8afd3cd6228bda9b182dc412bb3c8daf69c
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
77
package com.yeshi.buwan.job.video;
 
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.buwan.dao.juhe.pptv.PPTVSeriesDao;
import com.yeshi.buwan.dao.juhe.pptv.VideoPPTVMapDao;
import com.yeshi.buwan.videos.pptv.PPTVApiUtil;
import com.yeshi.buwan.videos.pptv.entity.PPTVSeries;
import com.yeshi.buwan.videos.pptv.entity.VideoPPTVMap;
import com.yeshi.buwan.service.inter.juhe.PPTVService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.List;
 
@Component
public class PPTVVideoUpdate {
 
    private final static Logger logger = LoggerFactory.getLogger(PPTVVideoUpdate.class);
 
    @Resource
    private PPTVService pptvService;
 
    @Resource
    private PPTVSeriesDao pptvSeriesDao;
 
    @Resource
    private VideoPPTVMapDao videoPPTVMapDao;
 
 
    /**
     * 更新最近几天的视频
     *
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("video-update-pptv-updateLatestVideo")
    public ReturnT<String> updateLatestVideo(String param) throws Exception {
 
        List<PPTVSeries> list = PPTVApiUtil.getUpdateList();
 
        if (list != null) {
            pptvService.save(list);
        }
        return ReturnT.SUCCESS;
    }
 
 
    @XxlJob("video-update-pptv-syncVideo")
    public ReturnT<String> syncVideo(String param) throws Exception {
        List<PPTVSeries> list = pptvSeriesDao.list(0, 10000);
        for (PPTVSeries s : list) {
            if (s != null) {
                switch (s.getStatus()) {
                    case "add":
                    case "update":
                        List<VideoPPTVMap> mapList = videoPPTVMapDao.listByInfoId(s.getInfoID());
                        if (mapList == null || mapList.size() == 0) {
                            PPTVSeries series = PPTVApiUtil.getDetail(s.getSeriesCode());
                            pptvService.save(series);
                            Thread.sleep(1000);
                            System.out.println(s.getName());
                            series = pptvService.getSeriesDetail(s.getInfoID());
                            if (series != null)
                                pptvService.addToVideoInfo(series);
                        }
                        break;
                }
            }
        }
        return ReturnT.SUCCESS;
    }
 
}