mitao
2025-11-20 5ac328adc442d47b6039ed924e6de1162c90cbe0
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package com.stylefeng.guns.modular.system.util;
 
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.example.BalanceAcctExample;
import com.stylefeng.guns.modular.cloudPayment.example.MchApplicationExample;
import com.stylefeng.guns.modular.cloudPayment.example.WithdrawalExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.system.dao.TCompanyMapper;
import com.stylefeng.guns.modular.system.model.TDriver;
import com.stylefeng.guns.modular.system.model.TEnterpriseWithdrawal;
import com.stylefeng.guns.modular.system.service.*;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.AllocationResp;
import com.unionpay.upyzt.resp.BalanceAcctResp;
import com.unionpay.upyzt.resp.MchApplicationResp;
import com.unionpay.upyzt.resp.WithdrawalResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.List;
 
 
/**
 * 定时任务工具类
 */
@Component
public class TaskUtil {
 
    @Autowired
    private ITLocationService locationService;
 
    @Autowired
    private PushMinistryOfTransportUtil pushMinistryOfTransportUtil;
 
    @Value("${pushMinistryOfTransport}")
    private boolean pushMinistryOfTransport;
 
    @Autowired
    private ITDriverService driverService;
 
    @Resource
    private ITCompanyService companyMapper;
 
    @Autowired
    private ITEnterpriseWithdrawalService tEnterpriseWithdrawalService;
 
    @Autowired
    private IDictService dictService;
 
    @Autowired
    private MapDispatchUtil mapDispatchUtil;
 
    /**
     * 每隔一分钟去处理的定时任务
     */
    @Scheduled(fixedRate = 1000 * 60)
    public void taskMinute() {
        try {
            List<TEnterpriseWithdrawal> isAudit = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("isAudit", 1));
            for (TEnterpriseWithdrawal enterpriseWithdrawal : isAudit) {
                String mchApplicationId = enterpriseWithdrawal.getMchApplicationId();
                MchApplicationResp mchApplicationResp = MchApplicationExample.retrieveById(mchApplicationId);
                enterpriseWithdrawal.setApplicationStatus(mchApplicationResp.getApplicationStatus());
                if ("succeeded".equals(mchApplicationResp.getApplicationStatus())) {
                    enterpriseWithdrawal.setMchId(mchApplicationResp.getMchId());
                    enterpriseWithdrawal.setBalanceAcctId(mchApplicationResp.getBalanceAcctId());
                    enterpriseWithdrawal.setSettleAcctId(mchApplicationResp.getSettleAcctId());
                    enterpriseWithdrawal.setRelAcctNo(mchApplicationResp.getRelAcctNo());
                    enterpriseWithdrawal.setIsAudit(2);
                }
                tEnterpriseWithdrawalService.updateById(enterpriseWithdrawal);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    /**
     * 每天的凌晨执行的任务
     */
    @Scheduled(cron = "0 0 0 * * *")
//    @Scheduled(fixedRate = 1000 * 60)
    public void taskDay() {
        try {
//            companyMapper.aaa();
            companyMapper.updateMoney(); // 分账业务
            locationService.updateFence();//更新线上电子围栏
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 重置【输入提示】Key池
     */
    @Scheduled(cron = "0 0 0 * * *")
    public void resetInputtips() {
        try {
            dictService.updateByCode("gaode_inputtips_switch", "1");//重置【输入提示】Key池
            System.out.println("重置【输入提示】Key池成功!");
        } catch (Exception e) {
            System.out.println("重置【输入提示】Key池失败!Exception:" + e);
        }
    }
 
    /**
     * 更新地图使用量
     */
    @Scheduled(cron = "0 0/10 * * * *")
    public void updateDayBaseQuotaUsage() {
        System.out.println("updateDayBaseQuotaUsageBegin...");
 
        try {
            System.out.println("开始更新高德地图接口使用量...");
            mapDispatchUtil.updateGaoDeDayBaseQuotaUsageBatch();
            System.out.println("开始更新腾讯地图接口使用量...");
            mapDispatchUtil.updateTencentMapDayBaseQuotaUsageBatch();
        } catch (Exception e) {
            System.out.println("updateDayBaseQuotaUsageException");
            e.printStackTrace();
        }
 
        System.out.println("updateDayBaseQuotaUsageEnd");
    }
 
    @Scheduled(fixedRate = 1000 * 60)
    public void taskDayFenzhang() {
        try {
            companyMapper.taskDayFenzhang(); // 分账业务
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    @Scheduled(fixedRate = 1000 * 60)
    public void taskTixian() {
        try {
          /*  WithdrawalResp withdrawalResp = WithdrawalExample.retrieveById("3708467427201980978");
            System.out.println(withdrawalResp);*/
            companyMapper.taskTixian();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 每月第一天的1点执行的任务
     */
    @Scheduled(cron = "0 0 1 1 * *")
    public void taskMonth() {
        try {
            if (pushMinistryOfTransport) {
                List<TDriver> tDrivers = driverService.selectList(new EntityWrapper<TDriver>().eq("authState", 2).ne("flag", 3));
                for (TDriver driver : tDrivers) {
                    pushMinistryOfTransportUtil.baseInfoDriverStat(driver.getId());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}