| | |
| | | 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 { |
| | | // }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 1 1 * *") |
| | | // public void taskMonth(){ |
| | | // try { |
| | | // |
| | | // }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(); |
| | | } |
| | | } |
| | | } |