12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package com.sd.wln.scheduled;
- import com.sd.wln.service.WlnOrderService;
- import com.sd.wln.service.WlnSkuService;
- import com.sd.wln.service.WlnStatementOfAccount;
- 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 WlnStatementOfAccount wlnStatementOfAccount;
- /**
- * 每天凌晨1点同步一次sku信息
- */
- @Scheduled(cron = "0 0 1 * * ?")
- public void syncSku() {
- if (WlnSkuService.syncSkuLock.tryLock()) {
- try {
- wlnSkuService.syncSkuClassify();
- wlnSkuService.syncSku();
- } finally {
- WlnSkuService.syncSkuLock.unlock();
- }
- }
- }
- /**
- * 每分钟同步一次订单数据
- */
- @Scheduled(fixedDelay = 2 * 60 * 1000)
- private void syncOrder() {
- wlnOrderService.syncOrder();
- }
- /**
- * 生成对账单
- */
- @Scheduled(cron = "0 0 19-23 * * ?")
- private void createStatementOfAccount() {
- wlnStatementOfAccount.createStatementOfAccount();
- }
- }
|