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

import com.cnlive.shenhe.entity.ShyChannel;
import com.cnlive.shenhe.entity.ShyComments;
import com.cnlive.shenhe.serviceImpl.ChannelServiceImpl;
import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl;
import com.cnlive.shenhe.serviceImpl.SitesServiceImpl;
import com.cnlive.shenhe.serviceImpl.UsersServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
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;

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

    @Autowired
    UsersServiceImpl usersService;


    @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");
         }
    	
    }
    
   
}