WlnSyncTask.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.sd.wln.scheduled;
  2. import com.sd.wln.service.WlnOrderService;
  3. import com.sd.wln.service.WlnOutboundOrderService;
  4. import com.sd.wln.service.WlnSkuService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.context.annotation.Profile;
  7. import org.springframework.scheduling.annotation.Scheduled;
  8. import org.springframework.stereotype.Component;
  9. /**
  10. * 同步万里牛数据(本地环境不执行同步逻辑)
  11. */
  12. @Profile({"test", "prod"})
  13. @Component
  14. public class WlnSyncTask {
  15. @Autowired
  16. private WlnSkuService wlnSkuService;
  17. @Autowired
  18. private WlnOrderService wlnOrderService;
  19. @Autowired
  20. private WlnOutboundOrderService wlnOutboundOrderService;
  21. /**
  22. * 每天凌晨1点同步一次sku信息
  23. */
  24. @Scheduled(cron = "0 0 1 * * ?")
  25. // @Scheduled(fixedDelay = 60 * 1000)
  26. public void syncSku() {
  27. for (int i = 0; i < 3; i++) {
  28. boolean flag = wlnSkuService.syncSkuClassify();
  29. if (flag) {
  30. break;
  31. }
  32. }
  33. for (int i = 0; i < 3; i++) {
  34. boolean flag = wlnSkuService.syncSku();
  35. if (flag) {
  36. break;
  37. }
  38. }
  39. }
  40. /**
  41. * 每分钟同步一次订单数据
  42. */
  43. @Scheduled(fixedDelay = 3 * 60 * 1000)
  44. private void syncOrder() {
  45. wlnOrderService.syncOrder();
  46. }
  47. /**
  48. * 每5分钟同步一次出库单数据
  49. */
  50. @Scheduled(fixedDelay = 10 * 60 * 1000)
  51. private void syncOutboundOrder() {
  52. wlnOutboundOrderService.syncOutboundOrder();
  53. }
  54. }