package com.tld.config; import com.tld.service.AskGoodsService; import com.tld.util.SnowflakeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; /** * 定时任务 */ @Component @Configuration //1.主要用于标记配置类,兼备Component的效果。 @EnableScheduling // 2.开启定时任务 public class SaticScheduleTask { @Autowired private AskGoodsService askGoodsService; //雪花算法 private SnowflakeUtil snowflakeUtil = new SnowflakeUtil(1, 1, 1); /** * 定时任务线程自定义 * @return */ @Bean public TaskScheduler taskScheduler() { ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.setPoolSize(50); return taskScheduler; } /** * 批量回调 生产领料 */ @Scheduled(cron = "0 */60 * * * ?") public void callback() { askGoodsService.getCallback(); } /** * 批量回调 入库回传 */ @Scheduled(cron = "0 */10 * * * ?") public void callPlugOutWarehousing(){ askGoodsService.getCallPlugOutWarehousing(); } /** * 批量回调 生产收货接口文档/报工单 w */ @Scheduled(cron = "0 */10 * * * ?") public void callWorkOrder(){ askGoodsService.getCallWorkOrder(); } /** * 批量回调 销售出库 */ @Scheduled(cron = "0 */10 * * * ?") public void callDelivery(){ askGoodsService.callDelivery(); } }