package com.kmall.admin.task; import com.kmall.admin.service.GoodsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * 同步oms数据定时器 * * @author 小问号 * @email 1076650290@qq.com * @date 2020年11月30日15:33:57 */ @Component("syncOmsTask") @EnableScheduling @EnableAsync public class SyncOmsTask { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private GoodsService goodsService; /** * 同步oms海关备案编码 * 每天凌晨三点执行一次 */ @Scheduled(cron = "0 0 3 * * ?") public void syncOmsHsCode() { logger.info("同步所有商品表海关备案编码数据开始-----------------"); try { goodsService.syncOmsHsCode(); } catch (Exception e) { e.printStackTrace(); logger.info("同步所有商品表海关备案编码数据异常-----------------原因:" + e.getMessage()); } logger.info("同步所有商品表海关备案编码数据结束-----------"); } /** * 同步oms海关备案编码对应税率 * 每天凌晨四点执行一次 */ // @Scheduled(cron = "0 0 4 * * ?") public void syncOmsGoodsRate() { logger.info("同步所有商品表海关备案编码对应税率数据开始-----------------"); try { goodsService.syncOmsGoodsRate(); } catch (Exception e) { e.printStackTrace(); logger.info("同步所有商品表海关备案编码对应税率数据异常-----------------原因:" + e.getMessage()); } logger.info("同步所有商品表海关备案编码数据对应税率结束-----------"); } /** * 每日同步税率 * 每天凌晨四点执行一次 */ @Scheduled(cron = "0 0 4 * * ?") public void syncGoodsRate() { logger.info("同步所有商品表当前售价海关备案编码对应税率数据开始-----------------"); try { goodsService.syncGoodsRate(); } catch (Exception e) { e.printStackTrace(); logger.info("同步所有商品表当前售价海关备案编码对应税率数据异常-----------------原因:" + e.getMessage()); } logger.info("同步所有商品表当前售价海关备案编码数据对应税率结束-----------"); } }