package com.zy.asrs.task;
|
|
import com.zy.asrs.task.core.ReturnT;
|
import com.zy.asrs.task.handler.InventoryReserveExpireHandler;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* 预留库存过期定时任务调度器
|
* 定期检查并处理过期的预留库存
|
*/
|
@Slf4j
|
@Component
|
public class InventoryReserveScheduler {
|
|
@Autowired
|
private InventoryReserveExpireHandler inventoryReserveExpireHandler;
|
|
/**
|
* 每分钟执行一次,检查过期的预留库存
|
*/
|
@Scheduled(cron = "0 * * * * ?")
|
public void checkExpiredReserve() {
|
try {
|
ReturnT<String> result = inventoryReserveExpireHandler.start();
|
if (!result.isSuccess()) {
|
log.error("预留库存过期处理失败: {}", result.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("预留库存过期定时任务异常", e);
|
}
|
}
|
|
}
|