郑永安
2023-06-19 451e341df739f387201914b67323efa1c4f4c8d3
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
package com.ruoyi.system.Schedules;
 
import com.ruoyi.common.annotation.Log;
import com.ruoyi.system.service.enterpriseManage.EnterpriseManageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.Date;
 
@Component
//@ConditionalOnProperty(prefix = "safeCheckScheduling", name = "enabled", havingValue = "true")
public class ValidityUpadeScheduleWork {
 
    private static SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss:sss");
 
    private final Logger logger = LoggerFactory.getLogger(ValidityUpadeScheduleWork.class);
 
    @Autowired
    private EnterpriseManageService enterpriseManageService;
 
    @Scheduled(cron = "0 0 0 * * ?") //每天的24点执行一次
    @PostConstruct
    public void updateValidityState() throws Exception{
        logger.info("【每日更新许可证状态】 " + dateFormat.format(new Date())+" 开始进行企业许可证更新任务调度");
        enterpriseManageService.ValidityStateUpdate();
        logger.info("【每日更新许可证状态】 " + dateFormat.format(new Date())+" 许可证任务调度执行结束");
    }
 
    @Scheduled(cron = "0 0 3 ? * SAT") //每周六凌晨3点执行一次
    public void createNewWorkTask() throws Exception{
        logger.info("【每周更新许可证状态】 " + dateFormat.format(new Date())+" 开始进行企业许可证更新任务调度");
        enterpriseManageService.ValidityStateUpdate();
        logger.info("【每周更新许可证状态】 " + dateFormat.format(new Date())+" 许可证任务调度执行结束");
    }
 
 
}