From 54b4f53323d0833cbac86fd18932c5fa5a5447a8 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 17 二月 2025 14:19:17 +0800 Subject: [PATCH] #移库任务 --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 160 insertions(+), 12 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java index 7b1ce95..f7ac1cb 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java @@ -1,11 +1,9 @@ package com.zy.asrs.wcs.core.timer; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.exception.CoolException; import com.zy.asrs.wcs.core.entity.Task; -import com.zy.asrs.wcs.core.kernel.command.AgvCommandService; -import com.zy.asrs.wcs.core.kernel.command.CraneCommandService; -import com.zy.asrs.wcs.core.kernel.command.LiftCommandService; -import com.zy.asrs.wcs.core.kernel.command.ShuttleCommandService; +import com.zy.asrs.wcs.core.kernel.command.*; import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; import com.zy.asrs.wcs.core.model.enums.MotionCtgType; import com.zy.asrs.wcs.core.model.enums.MotionStsType; @@ -35,24 +33,38 @@ private MotionService motionService; @Autowired private AgvCommandService agvCommandService; -// @Autowired -// private ConveyorCommandService conveyorCommandService; + @Autowired + private ConveyorCommandService conveyorCommandService; @Autowired private CraneCommandService craneCommandService; @Autowired private LiftCommandService liftCommandService; @Autowired private ShuttleCommandService shuttleCommandService; + @Autowired + private MapCommandService mapCommandService; -// @Scheduled(cron = "0/1 * * * * ? ") + @Scheduled(cron = "0/1 * * * * ? ") public synchronized void executeTask() { Date now = new Date(); // ANALYZE_INBOUND for (Task task : taskService.selectByAnalyzeSts()) { Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()); if (executingMotion != null) {//瀛樺湪姝e湪鎵ц鐨刴otion - continue; + if (executingMotion.getSync() == 1) {//褰撳墠鎵ц涓殑鍔ㄤ綔鏄悓姝ュ姩浣滐紝绛夊緟鎵ц瀹屾垚鍚庡啀鎵ц涓嬩竴涓姩浣� + continue; + } + + //寮傛鍔ㄤ綔锛屽彧鍏佽涓嬩竴鏉″姩浣滆鎵ц + Motion nextMotion = motionService.getOne(new LambdaQueryWrapper<Motion>().eq(Motion::getUuid, executingMotion.getUuid()).eq(Motion::getPriority, executingMotion.getPriority() - 1)); + if (nextMotion != null) { + if (!(nextMotion.getMotionSts() == MotionStsType.INIT.val() || nextMotion.getMotionSts() == MotionStsType.WAITING.val())) { + continue;//涓嬩竴鏉″姩浣滃凡缁忚鎵ц锛屼笉鍏佽鍐嶆墽琛屽悗缁姩浣� + } + } } + + Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId()); if (null != motion) { @@ -115,7 +127,9 @@ for (Task taskCharge : taskService.selectChargeByAnalyzeSts()) { Motion executingMotion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.EXECUTING.val(), taskCharge.getHostId()); if (executingMotion != null) {//瀛樺湪姝e湪鎵ц鐨刴otion - continue; + if (executingMotion.getSync() == 1) {//褰撳墠鎵ц涓殑鍔ㄤ綔鏄悓姝ュ姩浣滐紝绛夊緟鎵ц瀹屾垚鍚庡啀鎵ц涓嬩竴涓姩浣� + continue; + } } Motion motion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.INIT.val(), taskCharge.getHostId()); @@ -178,7 +192,9 @@ for (Task task : taskService.selectManualByAnalyzeSts()) { Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()); if (executingMotion != null) {//瀛樺湪姝e湪鎵ц鐨刴otion - continue; + if (executingMotion.getSync() == 1) {//褰撳墠鎵ц涓殑鍔ㄤ綔鏄悓姝ュ姩浣滐紝绛夊緟鎵ц瀹屾垚鍚庡啀鎵ц涓嬩竴涓姩浣� + continue; + } } Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId()); @@ -229,6 +245,132 @@ } @Scheduled(cron = "0/1 * * * * ? ") + public synchronized void executeLadenMoveTask() { + Date now = new Date(); + // ANALYZE_CHARGE + for (Task taskCharge : taskService.selectLadenMoveByAnalyzeSts()) { + Motion executingMotion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.EXECUTING.val(), taskCharge.getHostId()); + if (executingMotion != null) {//瀛樺湪姝e湪鎵ц鐨刴otion + if (executingMotion.getSync() == 1) {//褰撳墠鎵ц涓殑鍔ㄤ綔鏄悓姝ュ姩浣滐紝绛夊緟鎵ц瀹屾垚鍚庡啀鎵ц涓嬩竴涓姩浣� + continue; + } + + //寮傛鍔ㄤ綔锛屽彧鍏佽涓嬩竴鏉″姩浣滆鎵ц + Motion nextMotion = motionService.getOne(new LambdaQueryWrapper<Motion>().eq(Motion::getUuid, executingMotion.getUuid()).eq(Motion::getPriority, executingMotion.getPriority() - 1)); + if (nextMotion != null) { + if (!(nextMotion.getMotionSts() == MotionStsType.INIT.val() || nextMotion.getMotionSts() == MotionStsType.WAITING.val())) { + continue;//涓嬩竴鏉″姩浣滃凡缁忚鎵ц锛屼笉鍏佽鍐嶆墽琛屽悗缁姩浣� + } + } + } + + Motion motion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.INIT.val(), taskCharge.getHostId()); + if (null != motion) { + boolean result = this.executeMotion(motion); + if (!result) { + continue; + } + // 鏇存柊Task + switch (TaskStsType.query(taskCharge.getTaskSts())) { + case ANALYZE_LADEN_MOVE: + taskCharge.setTaskSts(TaskStsType.EXECUTE_LADEN_MOVE.sts); + break; + } + taskCharge.setUpdateTime(now); + if (!taskService.updateById(taskCharge)) { + log.error("{}鍏朵粬宸ヤ綔妗f洿鏂扮姸鎬佸け璐ワ紒", taskCharge.getTaskNo()); + } + } + } + // EXECUTE_CHARGE + for (Task taskCharge : taskService.selectLadenMoveByExecuteSts()) { + if (!motionService.hasRunningMotion(taskCharge.getUuid(), taskCharge.getHostId())) { + Motion motion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.WAITING.val(), taskCharge.getHostId()); + if (null != motion) { + boolean result = this.executeMotion(motion); + if (!result) { + continue; + } + } else { + if (motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.EXECUTING.val(), taskCharge.getHostId()) != null) { + continue; + } + + // 鏇存柊Task + switch (TaskStsType.query(taskCharge.getTaskSts())) { + case EXECUTE_LADEN_MOVE: + taskCharge.setTaskSts(TaskStsType.COMPLETE_LADEN_MOVE.sts); + break; + } + taskCharge.setUpdateTime(now); + if (!taskService.updateById(taskCharge)) { + log.error("{}浠栧伐浣滄。鏇存柊鐘舵�佸け璐ワ紒", taskCharge.getTaskNo()); + } + } + } + } + } + + @Scheduled(cron = "0/1 * * * * ? ") + public synchronized void executeMoveTask() { + Date now = new Date(); + // ANALYZE_MOVE + for (Task task : taskService.selectMoveByAnalyzeSts()) { + Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()); + if (executingMotion != null) {//瀛樺湪姝e湪鎵ц鐨刴otion + if (executingMotion.getSync() == 1) {//褰撳墠鎵ц涓殑鍔ㄤ綔鏄悓姝ュ姩浣滐紝绛夊緟鎵ц瀹屾垚鍚庡啀鎵ц涓嬩竴涓姩浣� + continue; + } + } + + Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId()); + if (null != motion) { + boolean result = this.executeMotion(motion); + if (!result) { + continue; + } + // 鏇存柊Task + switch (TaskStsType.query(task.getTaskSts())) { + case ANALYZE_MOVE: + task.setTaskSts(TaskStsType.EXECUTE_MOVE.sts); + break; + } + task.setUpdateTime(now); + if (!taskService.updateById(task)) { + log.error("{}鍏朵粬宸ヤ綔妗f洿鏂扮姸鎬佸け璐ワ紒", task.getTaskNo()); + } + } + } + // EXECUTE_MOVE + for (Task task : taskService.selectMoveByExecuteSts()) { + if (!motionService.hasRunningMotion(task.getUuid(), task.getHostId())) { + Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.WAITING.val(), task.getHostId()); + if (null != motion) { + boolean result = this.executeMotion(motion); + if (!result) { + continue; + } + } else { + if (motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()) != null) { + continue; + } + + // 鏇存柊Task + switch (TaskStsType.query(task.getTaskSts())) { + case EXECUTE_MOVE: + task.setTaskSts(TaskStsType.COMPLETE_MOVE.sts); + break; + } + task.setUpdateTime(now); + if (!taskService.updateById(task)) { + log.error("{}浠栧伐浣滄。鏇存柊鐘舵�佸け璐ワ紒", task.getTaskNo()); + } + } + } + } + } + + @Scheduled(cron = "0/1 * * * * ? ") public void scanMotionByExecuting() { List<Motion> motionList = motionService.selectBySts(MotionStsType.EXECUTING.val()); for (Motion motion : motionList) { @@ -240,7 +382,7 @@ Boolean executeRes = Boolean.FALSE; switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl())).deviceCtg) { case CONVEYOR: -// executeRes = conveyorCommandService.accept(motion); + executeRes = conveyorCommandService.accept(motion); break; case CRANE: executeRes = craneCommandService.accept(motion); @@ -253,6 +395,9 @@ break; case AGV: executeRes = agvCommandService.accept(motion); + break; + case MAP: + executeRes = mapCommandService.accept(motion); break; default: break; @@ -287,7 +432,10 @@ executeRes = shuttleCommandService.finish(motion); break; case CONVEYOR: -// executeRes = conveyorCommandService.finish(motion); + executeRes = conveyorCommandService.finish(motion); + break; + case MAP: + executeRes = mapCommandService.finish(motion); break; default: break; -- Gitblit v1.9.1