@Component
@RequestMapping("/balanceWarningScheduler")
public class BalanceWarningScheduler {
@Autowired
BalanceWarningService balanceWarningService;
@Value("${cron.expression.balancewarn.execute:true}")
private String exe;
private final Logger logger = LoggerFactory.getLogger(OweDealBatchScheduler.class);
@RequestMapping(value = "recoverDealBatch")
@Scheduled(cron ="${cron.expression.balancewarn:0 */2 * * * ?}") // 每2分钟执行一次 0 0/2 * * * ?
public void balanceWarning() {//预警提醒
if(exe!=null && "true".equals(exe)) {
ServerResp<Object> resp = null;
try {
Map<String, Object> param = new HashMap<String, Object>();
// 执行定时任务
logger.info("执行定时器 预警提醒");
resp = balanceWarningService.balanceWarning(param);
if (resp==null || !resp.isSuccess()) {
logger.info("定时器执行失败 复机定时任务");
}
} catch (Exception e) {
logger.info("定时器执行失败 预警提醒");
e.printStackTrace();
}
}
}
}
spring boot 定时任务
最新推荐文章于 2023-04-05 19:13:43 发布