admin
2022-04-16 04f09e52ffd4681bdfd85e51acd3da0d1280c3d3
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
78
79
80
81
82
83
84
85
86
87
88
89
90
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.domain.VideoType;
import com.yeshi.buwan.service.imp.ClearService;
import com.yeshi.buwan.service.imp.VideoTypeService;
import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
import com.yeshi.buwan.util.video.VideoConstant;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
@Component
public class VideoUpdateJob {
 
    @Resource
    private SolrAlbumVideoDataManager solrAlbumDataManager;
 
    @Resource
    private ClearService clearService;
 
    @Resource
    private VideoTypeService videoTypeService;
 
    /**
     * 同步所有专辑
     *
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("video-update-solr-syncAllAlbum")
    public ReturnT<String> syncAllAlbum(String param) throws Exception {
        solrAlbumDataManager.syncAllAlbum();
        return ReturnT.SUCCESS;
    }
 
 
    /**
     * @return com.xxl.job.core.biz.model.ReturnT<java.lang.String>
     * @author hxh
     * @description 删除过期的数据
     * 查询的数据冗余的分类的sql: SELECT GROUP_CONCAT(a.videotypeid) FROM (SELECT COUNT(*) c,cv.`videotypeid` FROM wk_category_video cv GROUP BY cv.`videotypeid` ORDER BY c DESC) a WHERE a.c>20000
     * @date 17:09 2022/3/18
     * @param: param
     **/
    //删除过期数据
    @XxlJob("video-update-delete-outofdate-video")
    public ReturnT<String> deleteOutOfDateVideo(String param) throws Exception {
        List<Long> typeList = new ArrayList<>();
        if (StringUtil.isNullOrEmpty(param)) {
            typeList = Arrays.asList(new Long[]{212L, 213L, 214L, 282L, 283L});
        } else {
            String[] sts = param.split(",");
            for (String st : sts) {
                typeList.add(Long.parseLong(st));
            }
        }
        for (Long type : typeList) {
            VideoType videoType = videoTypeService.getVideoType(type);
            while (videoType.getParent() != null) {
                videoType = videoType.getParent();
            }
 
            int leftNum = 2000;
            //主分类下面的小视频数量留10000
            if (VideoConstant.isMainCategory(videoType.getId())) {
                leftNum = 10000;
            }
            clearService.clearOldVideo(type, leftNum);
        }
        return ReturnT.SUCCESS;
    }
 
 
    //删除依赖
    @XxlJob("video-update-clear-depend-video")
    public ReturnT<String> clearDependVideo(String param) throws Exception {
        clearService.clearDependVideo();
        return ReturnT.SUCCESS;
    }
 
 
}