ScheduledService.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.szwl.controller;
  2. import com.szwl.service.TDepartmentService;
  3. import com.szwl.service.TShandeMchService;
  4. import com.szwl.service.es.EsTCoinOrderService;
  5. import com.szwl.service.es.EsTOrderService;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.scheduling.annotation.EnableScheduling;
  9. import org.springframework.scheduling.annotation.Scheduled;
  10. import org.springframework.stereotype.Component;
  11. import java.text.ParseException;
  12. import java.util.Calendar;
  13. @Configuration //1.主要用于标记配置类,兼备Component的效果。
  14. @Component
  15. @EnableScheduling // 2.开启定时任务
  16. public class ScheduledService {
  17. @Autowired
  18. private TShandeMchService tShandeMchService;
  19. @Autowired
  20. EsTCoinOrderService esTCoinOrderService;
  21. @Autowired
  22. EsTOrderService esTOrderService;
  23. //每天凌晨统计/核对杉德支付的金额表
  24. @Scheduled(cron = "30 05 0 * * ?")
  25. public void shandejiesuan(){
  26. tShandeMchService.jiesuan();
  27. }
  28. //在每小时的20分执行一次 es同步数据
  29. @Scheduled(cron = "0 20 * * * ?")
  30. public void tongbuEs() throws ParseException {
  31. esTOrderService.tongbuByHour();
  32. esTCoinOrderService.tongbuByHour();
  33. }
  34. }