xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
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;
 
    /**
     * 每隔一分钟去处理的定时任务
     */
    @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();
        }
    }
 
    @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();
        }
    }
}