package cn.com.countrygarden.bi.main.controller.dataMigration;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时调度nc数据
 * Created by ADMS on 2018/7/18.
 */
@Component
@PropertySource("classpath:/application.properties")
public class DataMigrationTask {
    //@Value("${schedule.start}")
    private Integer start;
    //@Value("${schedule.end}")
    private Integer end;
    //@Value("${schedule.pageSize}")
    private Integer pageSize = 100;
    //@Value("${schedule.nThreads}")
    private Integer nThreads = 10;

    protected final org.slf4j.Logger logger = LoggerFactory.getLogger(DataMigrationController.class);

    @Autowired
    private DataMigrationHandle dataMigrationHandle;
    /**
     * 人员数据调度
     */
    //@Scheduled(fixedDelayString = "${schedule.fixedDelayString.BdPsndoc}") //测试实现-每隔三十五秒
    @Scheduled(cron = "${schedule.cron.BdPsndoc}")//每天两点执行定时调度
    public void runBdPsndoc() {
        logger.info("调度*******************************train start*******************************");
        dataMigrationHandle.docHandle(pageSize, nThreads);
        logger.info("调度*******************************train end*******************************");
    }

    @Scheduled(cron = "${schedule.cron.hiPsndocWork}")//每天两点执行定时调度
    public void runHiPsndocWork() {
        logger.info("调度*******************************work start*******************************");
        dataMigrationHandle.workHandle(pageSize, nThreads);
        logger.info("调度*******************************work end*******************************");
    }

    @Scheduled(cron = "${schedule.cron.hiPsndocTrain}")//每天两点执行定时调度
    public void runHiPsndocTrain() {
        logger.info("调度*******************************train start*******************************");
        dataMigrationHandle.trainHandle(300, nThreads);
        logger.info("调度*******************************train end*******************************");
    }

    @Scheduled(cron = "${schedule.cron.hiPsnJob}")//每天两点执行定时调度
    public void runHiPsnJob() {
        logger.info("调度*******************************job start*******************************");
        dataMigrationHandle.jobHandle(pageSize, nThreads);
        logger.info("调度*******************************job end*******************************");
    }

    @Scheduled(cron = "${schedule.cron.bdType}")//每天两点执行定时调度
    public void runType() {
        logger.info("调度*******************************type start*******************************");
        dataMigrationHandle.typeHandle(pageSize, nThreads);
        logger.info("调度*******************************type end*******************************");
    }

}
