1
zhang
5 天以前 259509a4598f0516f583a4529e87c521d6f99450
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java
@@ -73,7 +73,9 @@
    @Scheduled(cron = "0/1 * * * * ? ")
    private void startupBus() throws InterruptedException {
//        if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; }
        if (!this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS)) { return; }
        if (!this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS)) {
            return;
        }
        List<Bus> busList = busService.selectBySts(BusStsType.RECEIVE);
        for (Bus bus : busList) {
            mainService.allocateTask(bus);
@@ -83,7 +85,9 @@
    @Scheduled(cron = "0/1 * * * * ? ")
    private void calculateSeg() throws InterruptedException {
        if (!this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS)) { return; }
        if (!this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS)) {
            return;
        }
        List<Task> taskList = taskService.selectBySts(TaskStsType.WAITING);
        List<AgvTaskDto> taskDtoList = new ArrayList<>();
@@ -106,15 +110,15 @@
    @EventListener(ApplicationReadyEvent.class)
    public void init() {
        try { Thread.sleep(1200); } catch (InterruptedException ignore) {}
        try {
            Thread.sleep(1200);
        } catch (InterruptedException ignore) {
        }
        // traffic calculate
        this.trafficCalcThread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    Thread.sleep(CORE_SCAN_FREQUENCY_MILLISECOND);
                    if (configService.getVal("stopDownData", Boolean.class)) { return; }
                    List<Segment> segments = segmentService.list(new LambdaQueryWrapper<Segment>()
                            .eq(Segment::getState, SegmentStateType.WAITING.toString())
@@ -137,11 +141,11 @@
                try {
                    Thread.sleep(CORE_SCAN_FREQUENCY_MILLISECOND);
                    if (configService.getVal("stopDownData", Boolean.class)) { return; }
                    List<String> actionGroupIds = actionService.selectGroupNo(ActionStsType.PREPARE);
                    for (String actionGroupId : actionGroupIds) {
                        mainService.publishAction(actionGroupId);
                    if (!configService.getVal("stopDownData", Boolean.class)) {
                        List<String> actionGroupIds = actionService.selectGroupNo(ActionStsType.PREPARE);
                        for (String actionGroupId : actionGroupIds) {
                            mainService.publishAction(actionGroupId);
                        }
                    }
                } catch (Exception e) {
@@ -156,7 +160,7 @@
    // patch ----------------------------------------------------------------------------------------------
    @Scheduled(cron = "0/3 * * * * ? ")
    private void busFinishPatch(){
    private void busFinishPatch() {
        List<Bus> busList = busService.selectBySts(BusStsType.PROGRESS);
        for (Bus bus : busList) {
            boolean finish = true;
@@ -188,12 +192,12 @@
    @PreDestroy
    public void shutDown(){
    public void shutDown() {
        if (this.trafficCalcThread != null) {
            this.trafficCalcThread .interrupt();
            this.trafficCalcThread.interrupt();
        }
        if (this.actionPublicThread != null) {
            this.actionPublicThread .interrupt();
            this.actionPublicThread.interrupt();
        }
    }