111
k94314517
2023-10-24 60b3a617617ae46ba72bc04cee50c67ddf30a76c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package doumeemes.task;
 
 
import doumeemes.biz.system.SystemDictDataBiz;
import doumeemes.core.utils.DateUtil;
import doumeemes.service.business.PlansService;
import doumeemes.service.ext.*;
import doumeemes.service.system.SystemDictService;
import doumeemes.service.system.impl.SystemDictServiceImpl;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
/**
 * 定时任务
 * @author jiangping
 * @date 2021-10-10 14:40:35
 * https://www.bejson.com/othertools/cron/  cron 表达式生成地址
 */
@Component
public class ScheduleTool {
    @Autowired
    public RabbitTemplate rabbitTemplate;
    @Autowired
    DepartmentExtService departmentExtService;
    @Autowired
    BarcodeParamExtService barcodeParamExtService;
    @Autowired
    CategoryExtService categoryExtService;
    @Autowired
    ProceduresExtService proceduresExtService;
    @Autowired
    PlansExtService plansExtService;
    @Autowired
    SystemDictDataBiz systemDictDataBiz;
    @Autowired
    WorkorderExtService workorderExtService;
 
    /**
     * 初始化全部企业部门数据
     * @throws Exception
     */
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 24)
    public void syncDepartment() throws Exception {
        System.out.println("定时加载企业部门缓存信息--------Begin------");
        departmentExtService.loadAllDepart();
        System.out.println("定时加载企业部门缓存信息--------end------");
    }
 
    /**
     * 初始化全部企业二维码数据
     * @throws Exception
     */
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 24)
    public void syncBarcode() throws Exception {
        System.out.println("定时加载企业二维码缓存信息--------Begin------");
        barcodeParamExtService.loadAll();
        System.out.println("定时加载企业二维码缓存信息--------end------");
    }
    /**
     * 初始化全部企业全部分类
     * @throws Exception
     */
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 24)
    public void syncCategory() throws Exception {
        System.out.println("定时加载企业分类信息缓存信息--------Begin------");
        categoryExtService.loadAll();
        System.out.println("定时加载企业分类信息缓存信息--------end------");
    }
    /**
     * 初始化全部企业工序数据
     * @throws Exception
     */
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 24)
    public void syncProcedures() throws Exception {
        System.out.println("定时加载企业工序缓存信息--------Begin------");
        proceduresExtService.loadAll();
        System.out.println("定时加载企业工序缓存信息--------end------");
    }
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 1)
    public void updatEdgpAccessToken() throws Exception {
        System.out.println("定时更新edgp平台访问授权码--------Begin------");
        systemDictDataBiz.updatEdgpAccessToken();
        System.out.println("定时更新edgp平台访问授权码--------end------");
    }
 
    /**
     * 每天凌晨重置所有企业的出入库、计划、工单code初始值
     * @throws Exception
     */
    @Scheduled(cron="0 0 0 * * ?")
    public void initCompnayCodes() throws Exception {
        System.out.println("定时加载数据code缓存信息--------Begin------");
        departmentExtService.initCompnayCodes();
        System.out.println("定时加载数据code缓存信息--------end------");
    }
 
    /**
     * 每天凌晨定点关闭不能关闭的计划
     * @throws Exception
     */
    @Scheduled(cron="0 0 1 * * ?")
    public void closePlans() throws Exception {
        System.out.println("定点关闭不能关闭的计划--------Begin------");
        plansExtService.autoClose();
        System.out.println("定点关闭不能关闭的计划--------end------");
    }
 
}