package cc.mrbird.febs.server.hr.task; import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService; import cc.mrbird.febs.server.hr.service.IEmpContractInfoService; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.CommandLineRunner; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; /** * name: ScheduledTask * package: cc.mrbird.febs.server.hr.task * description: 定时任务 * date: 2021-04-27 20:38 * * @author luoyibo * @version 0.1 * @since JDK 1.8 */ @Slf4j @Component public class ScheduledTask implements CommandLineRunner { @Resource IEmpBaseInfoService empBaseInfoService; @Resource IEmpContractInfoService empContractInfoService; /** * * 每天凌晨1点计算一次工龄 *

* date 2021-04-27 20:44 * @author: luoyibo * @return void */ @Scheduled(cron = "0 0 1 * * ?") public void calculateSeniority(){ log.info("每天凌晨1点计算工龄"); empBaseInfoService.updateSeniority(); } @Scheduled(cron = "0 0 2 * * ?") public void updateDeptName(){ log.info("每天凌晨2点更新部门名称和全称"); // empBaseInfoService.updateDeptName(); } @Scheduled(cron = "0 0 3 * * ?") public void autoStopContract(){ log.info("每天凌晨3点检查到期合同"); empContractInfoService.autoStopContract("32"); log.info("设置合同间隔的天数"); empContractInfoService.updateContractRemindDay(); } @Scheduled(cron = "0 0 4 * * ?") public void autoCalculateAge(){ log.info("每天凌晨4点自动更新年龄和年假"); empBaseInfoService.updateEmpBaseKeyInfo(); } @Override public void run(String... args) throws Exception { //empBaseInfoService.updateEmpBaseKeyInfo(); //calculateSeniority(); // autoStopContract(); //autoCalculateAge(); // updateDeptName(); //autoStopContract(); } }