12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package com.sd.wln.scheduled;
- import com.sd.wln.service.WlnOrderService;
- import com.sd.wln.service.WlnOutboundOrderService;
- import com.sd.wln.service.WlnSkuService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Profile;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- /**
- * 同步万里牛数据(本地环境不执行同步逻辑)
- */
- @Profile({"test", "prod"})
- @Component
- public class WlnSyncTask {
- @Autowired
- private WlnSkuService wlnSkuService;
- @Autowired
- private WlnOrderService wlnOrderService;
- @Autowired
- private WlnOutboundOrderService wlnOutboundOrderService;
- /**
- * 每天凌晨1点同步一次sku信息
- */
- @Scheduled(cron = "0 0 1 * * ?")
- // @Scheduled(fixedDelay = 60 * 1000)
- public void syncSku() {
- for (int i = 0; i < 3; i++) {
- boolean flag = wlnSkuService.syncSkuClassify();
- if (flag) {
- break;
- }
- }
- for (int i = 0; i < 3; i++) {
- boolean flag = wlnSkuService.syncSku();
- if (flag) {
- break;
- }
- }
- }
- /**
- * 每分钟同步一次订单数据
- */
- @Scheduled(fixedDelay = 3 * 60 * 1000)
- private void syncOrder() {
- wlnOrderService.syncOrder();
- }
- /**
- * 每5分钟同步一次出库单数据
- */
- @Scheduled(fixedDelay = 10 * 60 * 1000)
- private void syncOutboundOrder() {
- wlnOutboundOrderService.syncOutboundOrder();
- }
- }
|