#
luxiaotao1123
2024-11-04 7f70cb15d035f0c233b9e62b9e43aa985317c908
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java
@@ -14,6 +14,7 @@
import com.zy.acs.manager.manager.service.BusService;
import com.zy.acs.manager.manager.service.SegmentService;
import com.zy.acs.manager.manager.service.TaskService;
import com.zy.acs.manager.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -48,13 +49,16 @@
    private SegmentService segmentService;
    @Autowired
    private TrafficService trafficService;
    @Autowired
    private ConfigService configService;
    @Scheduled(cron = "0/3 * * * * ? ")
    private void startupBus() throws InterruptedException {
        if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; }
        if (!this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS)) { return; }
        List<Bus> busList = busService.selectBySts(BusStsType.RECEIVE);
        for (Bus bus : busList) {
            mainService.infuseAgvForTask(bus);
            mainService.allocateTask(bus);
        }
        this.lock.unlock();
    }
@@ -77,7 +81,7 @@
        }
        for (AgvTaskDto dto : taskDtoList) {
            mainService.mergeMajorTask(dto.getAgvId(), dto.getTaskList());
            mainService.buildMajorTask(dto.getAgvId(), dto.getTaskList());
        }
        this.lock.unlock();
    }
@@ -116,6 +120,15 @@
            }
            if (finish) {
                bus.setBusSts(BusStsType.FINISH.val());
                bus.setEndTime(new Date());
                bus.setUpdateTime(new Date());
                if (!busService.updateById(bus)) {
                    log.error("Bus [{}] 更新失败 !!!", bus.getUuid());
                }
            }
            long cancelNum = taskList.stream().filter(task -> TaskStsType.CANCEL.val() == task.getTaskSts()).count();
            if (cancelNum == taskList.size()) {
                bus.setBusSts(BusStsType.CANCEL.val());
                bus.setUpdateTime(new Date());
                if (!busService.updateById(bus)) {
                    log.error("Bus [{}] 更新失败 !!!", bus.getUuid());