From 035c1e94569a2c043f232f3452d25ad2e51bcf23 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期四, 17 四月 2025 08:22:02 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java | 92 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 88 insertions(+), 4 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java index 9648ec7..c307a4d 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java @@ -9,14 +9,12 @@ import com.zy.asrs.wcs.core.entity.*; import com.zy.asrs.wcs.core.kernel.AnalyzeService; import com.zy.asrs.wcs.core.model.NavigateNode; -import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; -import com.zy.asrs.wcs.core.model.enums.NavigationMapType; -import com.zy.asrs.wcs.core.model.enums.TaskCtgType; -import com.zy.asrs.wcs.core.model.enums.TaskStsType; +import com.zy.asrs.wcs.core.model.enums.*; import com.zy.asrs.wcs.core.service.*; import com.zy.asrs.wcs.rcs.News; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.entity.Device; +import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; import com.zy.asrs.wcs.rcs.service.DeviceService; @@ -346,6 +344,51 @@ } /** + * 鎼滅储鍙敤搴撲綅锛岄�氳繃灏忚溅鍙峰拰鐩爣搴撲綅 + */ + public String searchAvailableLocNo(Integer shuttleNo, Long hostId, String currentLocNo, List<String> locNos) { + BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>() + .eq(BasShuttle::getShuttleNo, shuttleNo) + .eq(BasShuttle::getHostId, hostId)); + if (basShuttle == null) { + throw new CoolException("灏忚溅鍩虹鏁版嵁涓嶅瓨鍦�"); + } + + if (locNos.isEmpty()) { + throw new CoolException("褰撳墠灞傛棤閬胯浣嶇疆"); + } + + int lev = Utils.getLev(currentLocNo); + + Integer finalDistance = ShuttleDispatcher.INF; + String recentLoc = null; + for (String loc : locNos) { + //褰撳墠绌挎杞﹀埌閬胯浣嶈绠� + List<NavigateNode> currentShuttlePath = NavigateUtils.calc( + currentLocNo + , loc + , NavigationMapType.NORMAL.id + , Utils.getShuttlePoints(shuttleNo, lev) + );//浣跨敤姝e父閫氶亾鍦板浘 + if (currentShuttlePath == null) { + continue; + } + + Integer currDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� + if (currDistance < finalDistance) { + finalDistance = currDistance; + recentLoc = loc; + } + } + + if (recentLoc == null) { + throw new CoolException("鎼滅储閬胯浣嶇疆澶辫触"); + } + + return recentLoc; + } + + /** * 妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲� * true: 灏忎簬鏈�澶ф暟閲� false: 澶т簬鎴栫瓑浜庢渶澶ф暟閲� */ @@ -370,6 +413,9 @@ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); if (shuttleProtocol == null) { + continue; + } + if (shuttleProtocol.getProtocolStatusType() == ShuttleProtocolStatusType.OFFLINE){ continue; } @@ -402,6 +448,44 @@ } + //鎼滅储鏄惁瀛樺湪鍓嶅線鐩爣妤煎眰鐨勫皬杞﹀伐浣滄。 + for (Task task : taskService.list(new LambdaQueryWrapper<Task>() + .in(Task::getTaskSts, TaskStsType.NEW_INBOUND.sts, TaskStsType.ANALYZE_INBOUND.sts, TaskStsType.EXECUTE_INBOUND.sts, TaskStsType.COMPLETE_INBOUND.sts + , TaskStsType.NEW_OUTBOUND.sts, TaskStsType.ANALYZE_OUTBOUND.sts, TaskStsType.EXECUTE_OUTBOUND.sts, TaskStsType.COMPLETE_OUTBOUND.sts))) { + + List<Motion> motions = motionService.list(new LambdaQueryWrapper<Motion>() + .eq(Motion::getTaskNo, task.getTaskNo()) + .in(Motion::getMotionCtg, MotionCtgType.SHUTTLE_MOVE + , MotionCtgType.SHUTTLE_MOVE_LIFT_PALLET + , MotionCtgType.SHUTTLE_MOVE_DOWN_PALLET + , MotionCtgType.SHUTTLE_MOVE_FROM_LIFT + , MotionCtgType.SHUTTLE_MOVE_TO_LIFT + , MotionCtgType.SHUTTLE_MOVE_FROM_CONVEYOR + , MotionCtgType.SHUTTLE_MOVE_TO_CONVEYOR + , MotionCtgType.SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR + )); + + boolean isUpdateLev = false; + for (Motion motion : motions) { + if (motion.getOrigin() == null || motion.getTarget() == null) { + continue; + } + + int sourceLev = Utils.getLev(motion.getOrigin());//鍔ㄤ綔婧愭ゼ灞� + int targetLev = Utils.getLev(motion.getTarget());//鍔ㄤ綔鐩爣妤煎眰 + if (sourceLev != targetLev) { + isUpdateLev = true; + break; + } + } + + if(isUpdateLev) { + levCount++;//宸ヤ綔妗e睘浜庤法灞備换鍔★紝灏忚溅褰掑睘浜庣洰鏍囨ゼ灞� + continue; + } + + } + return levCount < Integer.parseInt(dict.getValue()); } -- Gitblit v1.9.1