ContentJob.java 3.42 KB
package com.cnlive.shenhe.job;

import com.cnlive.shenhe.entity.ShyContent;
import com.cnlive.shenhe.entity.ShyYidun;
import com.cnlive.shenhe.serviceImpl.ContentServiceImpl;
import com.cnlive.shenhe.serviceImpl.YiDunServiceImpl;
import com.cnlive.shenhe.utils.CommonConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ContentJob {
    private static Logger logger = LoggerFactory.getLogger(ContentJob.class);
    @Autowired
    ContentServiceImpl contentService;
    @Autowired
    YiDunServiceImpl yiDunServiceImpl;


    /**
     * 白名单sp图文通过
     */
    @Scheduled(fixedRate = 60 * 1000)
    public void updateVideos() {
        ShyContent shyContent = new ShyContent();
        shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_FREE);// 审核类型为免审
        shyContent.setReceive_status(CommonConst.RECEIVE_BEFORE);// 领取状态为未领取
        List<ShyContent> shyContentList = contentService.findshyContent(shyContent);
        if (shyContentList.size() > 0) {
            for (ShyContent content : shyContentList) {
                logger.info("当前白名单通过的content_id:" + content.getId());
                content.setUpdater("白名单");
                // 更新点播和审核的视频状态
                contentService.callback(content.getId() + "", "白名单审核通过", 1, "", "白名单");
            }
        }
    }

    /**
     * 定时向易盾提交网站地址
     */
    @Scheduled(cron = "0 0/1 * * * ? ")//每分钟一次
    public void videofilter() {
        ShyContent shyContent = new ShyContent();
        //机审
        shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE);
        //待审
        shyContent.setReceive_status(CommonConst.RECEIVE_BEFORE);
        List<ShyContent> shyContentList = contentService.findshyContent(shyContent);
        if (shyContentList != null && shyContentList.size() > 0) {
            for (ShyContent content : shyContentList) {
                //易盾网站过滤
                ShyYidun shyYidun = new ShyYidun();
                shyYidun.setContent_id(content.getId().toString());
                ShyYidun shyYidun1 = yiDunServiceImpl.getidunMsgByContentId(shyYidun);
                if (shyYidun1 == null) {
                    logger.info("定时发送易盾检测的content_id:" + content.getId());
                    contentService.contentFilter(content);

                }
            }
        }
    }


    /**
     * 自动退领
     */
    @Scheduled(cron = "0 0 0 * * ? ")//每天0点执行
    public void autoRetReceive() {
        logger.info("图文自动退领的进入.....");
        ShyContent shyContent = new ShyContent();
        shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);//领取状态为,已领
        List<ShyContent> shyContentList = contentService.findshyContent(shyContent);
        if (shyContentList.size() > 0) {
            for (ShyContent shyContent2 : shyContentList) {
                logger.info("自动退领的content_id:" + shyContent2.getId());
                shyContent2.setReceive_status(CommonConst.RECEIVE_BEFORE);//未领取
                shyContent2.setAuditor_id(null);
                contentService.updateshyContent(shyContent2);
            }
        }
    }

}