| | |
| | | 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.modular.system.model.TDriver; |
| | | 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 java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | |
| | | @Autowired |
| | | private ITOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | @Autowired |
| | | private ITOrderTaxiService orderTaxiService; |
| | | |
| | | @Autowired |
| | | private ITOrderCrossCityService orderCrossCityService; |
| | | |
| | | |
| | | /** |
| | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | } |