puzhibing
2023-07-26 709a4a10be56952ead6340e4822fce41a66e47cd
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
package com.supersavedriving.driver.modular.system.util;
 
 
import com.supersavedriving.driver.modular.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.util.Set;
 
 
/**
 * 定时任务工具类
 */
@Component
public class TaskUtil {
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private IAccountChangeDetailService accountChangeDetailService;
 
    @Autowired
    private IOrderService orderService;
 
    @Autowired
    private IYouTuiDriverService youTuiDriverService;
 
    @Autowired
    private RedisUtil redisUtil;
 
    @Autowired
    private IDriverWorkService driverWorkService;
 
 
    /**
     * 5秒推送
     */
    @Scheduled(fixedRate = 1000 * 5)
    public void task5Seconds(){
        try {
            Set<String> orderServices = redisUtil.getSetAllValue("orderService");
            for (String s : orderServices) {
                orderService.pushOrderInfo(Long.valueOf(s));//开始推送订单数据
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
 
    /**
     * 每隔一分钟去处理的定时任务
     */
    @Scheduled(fixedRate = 1000 * 60)
    public void taskMinute(){
        try {
            driverWorkService.taskDriverOffWork();
            youTuiDriverService.editState();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    /**
     * 每天的凌晨执行的任务
     */
    @Scheduled(cron = "0 0 0 * * *")
    public void taskDay(){
        try {
            orderService.completeCollection();
            accountChangeDetailService.deductionInsurance();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
 
    /**
     * 每月1日凌晨执行的任务
     */
    @Scheduled(cron = "0 0 0 1 * *")
    public void taskMonth1(){
        try {
            driverService.emptyIntegral();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
    /**
     * 每月16日凌晨执行的任务
     */
    @Scheduled(cron = "0 0 0 16 * *")
    public void taskMonth16(){
        try {
            driverService.emptyIntegral();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}