admin
2022-04-16 04f09e52ffd4681bdfd85e51acd3da0d1280c3d3
src/main/java/com/yeshi/buwan/job/video/VideoUpdateJob.java
@@ -2,16 +2,31 @@
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;
    /**
     * 同步所有专辑
@@ -25,4 +40,51 @@
        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;
    }
}