luoyb
2021-05-12 49a2f509d6a114c062b966a5bab83f45980e808f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cc.mrbird.febs.server.hr.task;
 
import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
 
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;
 
    /**
     *
     * 每天凌晨1点计算一次工龄
     *
     * date 2021-04-27 20:44
     * @author: luoyibo
     * @return void
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void calculateSeniority(){
        log.info("每天凌晨1点计算一次工龄");
        empBaseInfoService.updateSeniority();
    }
    @Override
    public void run(String... args) throws Exception {
        calculateSeniority();
    }
}