package com.gk.firework.Scheduls.ReportTask;
|
|
import com.gk.firework.Service.HistoryStockService;
|
import com.gk.firework.Service.StockService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
/**
|
* @author : jingjy
|
* @date : 2022/1/29 15:39
|
*/
|
@Configuration
|
@EnableScheduling
|
@ConditionalOnProperty(prefix = "scheduling",name = "enabled",havingValue = "true")
|
public class AsyncGetStockTask {
|
|
@Autowired
|
private StockService stockService;
|
|
@Scheduled(cron = "0 0/10 * * * ?") //每隔十分钟执行一次
|
// @Scheduled(cron = "0/10 * * * * ?") //每隔十秒执行一次
|
public void AsyncGetStock(){
|
//1.查询当前库存并插入staticStock
|
stockService.saveOrUpdateCurrentStock("系统更新");
|
}
|
|
|
}
|