VideosJob.java 3.5 KB
package com.cnlive.shenhe.job;

import com.cnlive.shenhe.entity.ShyVideos;
import com.cnlive.shenhe.service.VideosService;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonConstStates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Administrator
 */
@Component
@Async
public class VideosJob {

    private static Logger logger = LoggerFactory.getLogger(VideosJob.class);
    @Autowired
    VideosService videosService;

    /**
     * 白名单sp视频通过
     * 免审、未审核
     */
    @Scheduled(fixedRate = 60 * 1000)
    public void updateVideos() {
        ShyVideos shyVideos = new ShyVideos();
        // 审核类型为免审
        shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_FREE);
        // 审核状态为未审核
        shyVideos.setState(CommonConst.AUDIT_INTT);
        List<ShyVideos> shyVideosList = videosService.findShyVideo(shyVideos);
        if (shyVideosList.size() > 0) {
            for (ShyVideos video : shyVideosList) {
                logger.info("当前白名单通过的videos_id:" + video.getId());
                video.setUpdater("白名单");
                // 更新点播和审核的视频状态
                videosService.updateDianboAndShenhe(video, CommonConstStates.TONGGUO);
            }
        }
    }

    /**
     * 定时向易盾发送视频抽帧图片进行检测
     * 机审 、未审核 、抽帧完成 进行送审
     * 每天8点到23点执行,每三分钟一次
     */
    @Scheduled(cron = "0 0/3 8-23 * * ? ")
    public void videoFilter() {
        ShyVideos shyVideos = new ShyVideos();
        //审核类型为机审
        shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE);
        //待审核状态
        shyVideos.setState(CommonConst.AUDIT_INTT);
        //抽帧完成
        shyVideos.setAvsample(CommonConst.AVSAMPLE_SUCCESS);
        List<ShyVideos> shyVideosList = videosService.findShyVideo(shyVideos);
        if (shyVideosList != null && shyVideosList.size() > 0) {
            for (ShyVideos video : shyVideosList) {
                logger.info("定时向易盾发送检测视频的videos_id:{}", video.getId());
                //易盾图片过滤
                logger.info("审核云定时向易盾发送视频抽帧图片检测:{}", video.getVideo_id());
                videosService.videoFilter(video.getId());
            }
        }
    }


    /**
     * 自动退领
     * 每天0点执行
     */
    @Scheduled(cron = "0 0 0 * * ? ")
    public void autoRetReceive() {
        logger.info("点播自动退领的进入.....");
        ShyVideos shyVideos = new ShyVideos();
        //审核状态:未审核
        shyVideos.setState(CommonConst.AUDIT_INTT);
        //已领取
        shyVideos.setReceive(CommonConst.RECEIVE_AFTER);
        List<ShyVideos> shyVideosList = videosService.findShyVideo(shyVideos);
        if (shyVideosList.size() > 0) {
            for (ShyVideos shyVideos2 : shyVideosList) {
                logger.info("自动退领的videos_id:" + shyVideos2.getId());
                //未领取
                shyVideos2.setReceive(CommonConst.RECEIVE_BEFORE);
                shyVideos2.setReceive_user_id(null);
                videosService.updateShyVideos(shyVideos2);
            }
        }
    }

}