SpecialTopTask.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.ylcm.sys.task;
  2. import java.time.LocalDate;
  3. import java.time.format.DateTimeFormatter;
  4. import org.springframework.scheduling.annotation.Scheduled;
  5. import org.springframework.stereotype.Component;
  6. import com.ylcm.sys.service.SpecialAnalysisService;
  7. import lombok.extern.slf4j.Slf4j;
  8. @Component
  9. @Slf4j
  10. public class SpecialTopTask {
  11. private SpecialAnalysisService specialAnalysisService;
  12. /**
  13. * 一周的每天运行 产品专题广告投放排名
  14. */
  15. @Scheduled(cron = "0 0 0/2 * * ?")
  16. public void topTaskWeek(){
  17. log.info("产品专题广告投放排名---start");
  18. LocalDate now = LocalDate.now();
  19. LocalDate day7before = now.minusDays(7);
  20. specialAnalysisService.specialTop(0, now.format(DateTimeFormatter.ISO_DATE), day7before.format(DateTimeFormatter.ISO_DATE));
  21. specialAnalysisService.specialTop(1, now.format(DateTimeFormatter.ISO_DATE), day7before.format(DateTimeFormatter.ISO_DATE));
  22. log.info("产品专题广告投放排名---end");
  23. }
  24. /**
  25. * 月的每天运行一次
  26. */
  27. @Scheduled(cron = "0 0 1 * * ?")
  28. public void topTaskMonth(){
  29. log.info("产品专题广告投放排名---start");
  30. LocalDate now = LocalDate.now();
  31. LocalDate day7before = now.minusDays(30);
  32. specialAnalysisService.specialTop(0, now.format(DateTimeFormatter.ISO_DATE), day7before.format(DateTimeFormatter.ISO_DATE));
  33. specialAnalysisService.specialTop(1, now.format(DateTimeFormatter.ISO_DATE), day7before.format(DateTimeFormatter.ISO_DATE));
  34. LocalDate day365before = now.minusDays(365);
  35. specialAnalysisService.specialTop(0, now.format(DateTimeFormatter.ISO_DATE), day365before.format(DateTimeFormatter.ISO_DATE));
  36. specialAnalysisService.specialTop(1, now.format(DateTimeFormatter.ISO_DATE), day365before.format(DateTimeFormatter.ISO_DATE));
  37. log.info("产品专题广告投放排名---end");
  38. }
  39. }