#
cpT
9 天以前 26517ad3a5dc4477adc12abc89afc9574082c5fa
src/main/java/com/zy/asrs/task/PlannerScheduler.java
@@ -1,7 +1,10 @@
package com.zy.asrs.task;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.service.PlannerService;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -11,11 +14,19 @@
    @Autowired
    private PlannerService plannerService;
    @Autowired
    private ConfigService configService;
    // 每3秒触发一次求解
    @Scheduled(fixedDelay = 3000)
    public void schedulePlanner() {
        try {
            Config crnRunMethodConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "crnRunMethod"));
            if(crnRunMethodConfig != null) {
                if (!crnRunMethodConfig.getValue().equals("solver")) {
                    return;
                }
            }
            JSONObject result = plannerService.calculateAndSaveSchedule();
            // 日志记录可以根据需要添加,避免过于频繁
        } catch (Exception e) {