/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.workregularapply.service;

import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.workcalendar.entity.WorkCalendar;
import com.jeeplus.modules.workcalendar.service.WorkCalendarService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Calendar;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 * @author ssrh
 * @version 2018-07-17
 */
@Service
@Lazy(false)
@Transactional(readOnly = true)
public class WorkRegularApplyTaskService {
    @Autowired
    private WorkRegularApplyService workRegularApplyService;
    private Logger logger = LoggerFactory.getLogger(WorkRegularApplyTaskService.class);
    private static final ExecutorService threadPool = Executors.newFixedThreadPool(10);

//
   /* @Scheduled(cron= "0 0/1 * * * ?")
    public void notifyTask() {
        logger.info("-----------定时发起转正申请开始------------------");

        threadPool.execute(new Runnable() {
            @Override
            public void run() {
                workRegularApplyService.saveTask();
            }
        });
        logger.info("------------转正申请定时任务结束------------------");
    }*/


    @Scheduled(cron= "0 0 1 * * ?")
    public void notifyTask2() {
        logger.info("-----------凌晨发送转正申请任务开始------------------");
        threadPool.execute(new Runnable() {
            @Override
            public void run() {
                workRegularApplyService.saveTask();
            }
        });
        logger.info("-----------凌晨发送转正申请任务开始------------------");
    }
}