From 9641d9ebc7b32b7e2cee898c8e9250e798c97e1b Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 16 八月 2025 15:17:32 +0800 Subject: [PATCH] 修改bug --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java | 158 +++++++++++++++++++++++----------------------------- 1 files changed, 71 insertions(+), 87 deletions(-) diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java index 385dd99..594229a 100644 --- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java +++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java @@ -1,28 +1,26 @@ package com.stylefeng.guns.modular.system.util; +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClient; 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 com.stylefeng.guns.modular.system.model.TOrderCrossCity; +import com.stylefeng.guns.modular.system.model.TOrderPrivateCar; +import com.stylefeng.guns.modular.system.model.TOrderTaxi; +import com.stylefeng.guns.modular.system.service.ITDriverService; +import com.stylefeng.guns.modular.system.service.ITOrderCrossCityService; +import com.stylefeng.guns.modular.system.service.ITOrderPrivateCarService; +import com.stylefeng.guns.modular.system.service.ITOrderTaxiService; 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.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Date; import java.util.List; @@ -33,9 +31,6 @@ public class TaskUtil { @Autowired - private ITLocationService locationService; - - @Autowired private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; @Value("${pushMinistryOfTransport}") @@ -44,78 +39,16 @@ @Autowired private ITDriverService driverService; - @Resource - private ITCompanyService companyMapper; - + @Autowired + private ITOrderPrivateCarService orderPrivateCarService; @Autowired - private ITEnterpriseWithdrawalService tEnterpriseWithdrawalService; + private ITOrderTaxiService orderTaxiService; - /** - * 每隔一分钟去处理的定时任务 - */ - @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(); - } - } + @Autowired + private ITOrderCrossCityService orderCrossCityService; + + /** * 每月第一天的1点执行的任务 */ @@ -132,4 +65,55 @@ e.printStackTrace(); } } + + + /** + * 每分钟执行 + */ + @Scheduled(cron = "0 0/1 * * * ?") + public void taskMinute(){ + // 15天后的时间 + long time = System.currentTimeMillis() + 15 * 24 * 60 * 60 * 1000; + Date date = new Date(time); + // 查出录音 + List<TOrderPrivateCar> list = orderPrivateCarService.selectList(new EntityWrapper<TOrderPrivateCar>().isNotNull("voiceTime").gt("voiceTime", date)); + List<TOrderTaxi> tOrderTaxis = orderTaxiService.selectList(new EntityWrapper<TOrderTaxi>().isNotNull("voiceTime").gt("voiceTime", date)); + List<TOrderCrossCity> tOrderCrossCities = orderCrossCityService.selectList(new EntityWrapper<TOrderCrossCity>().isNotNull("voiceTime").gt("voiceTime", date)); + ArrayList<String> strings = new ArrayList<>(); + for (TOrderPrivateCar tOrderPrivateCar : list) { + strings.add(tOrderPrivateCar.getVoice()); + } + for (TOrderTaxi tOrderTaxi : tOrderTaxis) { + strings.add(tOrderTaxi.getVoice()); + } + for (TOrderCrossCity tOrderCrossCity : tOrderCrossCities) { + strings.add(tOrderCrossCity.getVoice()); + } + if(strings.size()>0){ + deleteFile(strings); + } + + } + + public static String oss_domain = "https://cdxy-jiaotong-20250725.oss-cn-chengdu.aliyuncs.com/"; + public static String accessKeyId = "LTAI5t8obxz88oV8MgFMr4Bd"; + public static String accessKeySecret = "Y17SxRCVYGePCkr82FSCk9jqCBljRP"; + public static String bucketName="cdxy-jiaotong-20250725"; + public static String endpoint = "oss-cn-chengdu.aliyuncs.com"; + public static OSSClient ossClient = new OSSClient(endpoint, accessKeyId,accessKeySecret); + private static boolean deleteFile(List<String> fileNames) { + try { + for (String fileName : fileNames) { + // 删除文件 + ossClient.deleteObject(bucketName, "img/"+fileName); + } + // 关闭OSSClient + ossClient.shutdown(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + } -- Gitblit v1.7.1