SyncOmsTask.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.kmall.admin.task;
  2. import com.kmall.admin.service.GoodsService;
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.scheduling.annotation.EnableAsync;
  7. import org.springframework.scheduling.annotation.EnableScheduling;
  8. import org.springframework.scheduling.annotation.Scheduled;
  9. import org.springframework.stereotype.Component;
  10. /**
  11. * 同步oms数据定时器
  12. *
  13. * @author 小问号
  14. * @email 1076650290@qq.com
  15. * @date 2020年11月30日15:33:57
  16. */
  17. @Component("syncOmsTask")
  18. @EnableScheduling
  19. @EnableAsync
  20. public class SyncOmsTask {
  21. private Logger logger = LoggerFactory.getLogger(getClass());
  22. @Autowired
  23. private GoodsService goodsService;
  24. /**
  25. * 同步oms海关备案编码
  26. * 每天凌晨四点执行一次
  27. */
  28. @Scheduled(cron = "0 0 4 * * ?")
  29. public void syncOmsHsCode() {
  30. logger.info("同步所有商品表海关备案编码数据开始-----------------");
  31. try {
  32. goodsService.syncOmsHsCode();
  33. } catch (Exception e) {
  34. e.printStackTrace();
  35. logger.info("同步所有商品表海关备案编码数据异常-----------------原因:" + e.getMessage());
  36. }
  37. logger.info("同步所有商品表海关备案编码数据结束-----------");
  38. }
  39. }