郑永安
2023-06-19 f65443d8abeaedc9d102324565e8368e7c9d90c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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("系统更新");
    }
 
 
}