ChannelJob.java 2.34 KB
package com.cnlive.shenhe.job;

import com.cnlive.shenhe.entity.ShyChannel;
import com.cnlive.shenhe.service.ChannelService;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.InfoUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Administrator
 */
@Component
public class ChannelJob {

    private static Logger logger = LoggerFactory.getLogger(ChannelJob.class);
    @Value("${spring.localhost.url}")
    //本机地址
    private String localhost_url;
    @Autowired
    InfoUtil infoUtil;
    @Autowired
    ChannelService channelService;

    @Scheduled(fixedRate = 60 * 1000)
    public void updateChannel() {
        //遍历免审的spid去更改状态值
        ShyChannel shyChannel = new ShyChannel();
        // 审核类型为免审
        shyChannel.setShenhe_type(CommonConst.AUDIT_TYPE_FREE);
        shyChannel.setShenhe_status(CommonConst.AUDIT_INTT);
        List<ShyChannel> channelList = channelService.findshyChannel(shyChannel);
        if (channelList.size() > 0) {
            for (ShyChannel channel : channelList) {
                channelService.updateState(channel.getId().toString(), CommonConst.AUDIT_SUCCESS, "", "白名单", "白名单通过");
            }
        }
    }

    /**
     * 频道审核通知
     */
//    @Scheduled(fixedRate = 60 * 1000)
    public void channelNotice() {
        ShyChannel shyChannel = new ShyChannel();
        // 审核类型为人工审
        shyChannel.setShenhe_type(CommonConst.AUDIT_TYPE_USER);
        shyChannel.setShenhe_status(CommonConst.AUDIT_INTT);
        List<ShyChannel> channelList = channelService.findshyChannel(shyChannel);
        if (channelList.size() > 0) {
            logger.info("您有" + channelList.size() + "条新的频道审核申请,请注意查看!");
            // 设置Headless模式,linux系统下
            System.setProperty("java.awt.headless", "false");
            infoUtil.show("新频道申请", "您有" + channelList.size() + "条新的频道审核申请,请注意查看!", localhost_url + "/channel/page?shenhe_status=0&receive=0");
        }

    }


}