package com.zy.asrs.task;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.zy.asrs.service.PlannerService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
@Component
|
public class PlannerScheduler {
|
|
@Autowired
|
private PlannerService plannerService;
|
|
// 每3秒触发一次求解
|
@Scheduled(fixedDelay = 3000)
|
public void schedulePlanner() {
|
try {
|
JSONObject result = plannerService.calculateAndSaveSchedule();
|
// 日志记录可以根据需要添加,避免过于频繁
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|