From 13ea8b334572c2423abb8d156fd8428f8d074172 Mon Sep 17 00:00:00 2001 From: zhang <zc857179121@qq.com> Date: 星期四, 03 七月 2025 08:24:58 +0800 Subject: [PATCH] 1 --- zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java index 159635d..765fde1 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java @@ -2,9 +2,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.acs.manager.core.domain.AgvTaskDto; -import com.zy.acs.manager.core.service.MainLockWrapService; -import com.zy.acs.manager.core.service.MainService; -import com.zy.acs.manager.core.service.TrafficService; +import com.zy.acs.manager.core.service.*; import com.zy.acs.manager.manager.entity.Bus; import com.zy.acs.manager.manager.entity.Segment; import com.zy.acs.manager.manager.entity.Task; @@ -53,7 +51,9 @@ @Autowired private TaskService taskService; @Autowired - private MainService mainService; + private MainLxtService mainService; + @Autowired + private MainZkdService mainZkdService; @Autowired private MainLockWrapService mainLockWrapService; @Autowired @@ -61,7 +61,7 @@ @Autowired private SegmentService segmentService; @Autowired - private TrafficService trafficService; + private TrafficZkdService trafficZkdService; @Autowired private ConfigService configService; @Autowired @@ -72,17 +72,21 @@ @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); + mainZkdService.allocateTask(bus); } this.lock.unlock(); } - @Scheduled(cron = "0/1 * * * * ? ") + //@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<>(); @@ -105,7 +109,10 @@ @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()) { @@ -117,8 +124,8 @@ ); for (Segment segment : segments) { long startTime = System.currentTimeMillis(); - trafficService.trigger(segment); - log.info("traffic calculation spend {} ms", System.currentTimeMillis() - startTime); + trafficZkdService.trigger(segment); +// log.info("traffic calculation spend {} ms", System.currentTimeMillis() - startTime); } } catch (Exception e) { @@ -150,7 +157,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; @@ -182,12 +189,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(); } } -- Gitblit v1.9.1