From e028a49bb9047969de47ce3c6b005b332020249e Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期三, 12 六月 2024 15:29:21 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java | 72 ++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 0 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 b18cd73..85004c5 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 @@ -21,6 +21,8 @@ import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; import com.zy.asrs.wcs.rcs.service.DeviceService; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; +import com.zy.asrs.wcs.system.entity.Dict; +import com.zy.asrs.wcs.system.service.DictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -53,11 +55,16 @@ private TaskCtgService taskCtgService; @Autowired private ShuttleStandbyService shuttleStandbyService; + @Autowired + private DictService dictService; public synchronized ShuttleThread searchIdleShuttle(Task task) { String locNo = taskService.judgeInbound(task) ? task.getDestLoc() : task.getOriginLoc(); ShuttleThread resThread = null; Integer finalDistance = ShuttleDispatcher.INF; + + //妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲� + boolean checkDispatchMaxNum = checkDispatchMaxNum(Utils.getLev(locNo), task.getHostId()); List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) @@ -99,6 +106,11 @@ if (currentLev == Utils.getLev(locNo)) { targetLocNo = locNo; }else { + if (!checkDispatchMaxNum) { + News.info("{}浠诲姟锛寋}灞傦紝宸茬粡杈惧埌褰撳墠妤煎眰璋冨害杞﹁締鏈�澶у��", task.getTaskNo(), Utils.getLev(locNo)); + continue; + } + Device recentTransferLift = Utils.getRecentTransferLift(locNo, Integer.parseInt(device.getDeviceNo())); if (recentTransferLift == null) { continue; @@ -311,5 +323,65 @@ return recentLoc; } + /** + * 妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲� + * true: 灏忎簬鏈�澶ф暟閲� false: 澶т簬鎴栫瓑浜庢渶澶ф暟閲� + */ + public boolean checkDispatchMaxNum(Integer lev, Long hostId) { + Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "dispatchShuttleMaxNum")); + if (dict == null) { + return false; + } + + int levCount = 0;//鐩爣妤煎眰杞﹁締鏁伴噺 + List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() + .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) + .eq(Device::getHostId, hostId) + .eq(Device::getStatus, 1)); + + for (Device device : list) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); + if (shuttleThread == null) { + continue; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + continue; + } + + if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) == lev) { + if (shuttleProtocol.getHasCharge()) { + continue;//鍏呯數涓� + } + + levCount++;//鐩爣妤煎眰鏈夎溅锛屾暟閲忓鍔� + } + } + + //鎼滅储鏄惁瀛樺湪鍓嶅線鐩爣妤煎眰鐨勫皬杞︾Щ鍔ㄥ伐浣滄。 + for (Task task : taskService.list(new LambdaQueryWrapper<Task>() + .in(Task::getTaskSts, TaskStsType.NEW_MOVE.sts, TaskStsType.ANALYZE_MOVE.sts, TaskStsType.EXECUTE_MOVE.sts, TaskStsType.COMPLETE_MOVE.sts))) { + if (task.getOriginLoc() == null || task.getDestLoc() == null) { + continue; + } + + int sourceLev = Utils.getLev(task.getOriginLoc());//宸ヤ綔妗f簮妤煎眰 + int targetLev = Utils.getLev(task.getDestLoc());//宸ヤ綔妗g洰鏍囨ゼ灞� + if (sourceLev == targetLev) { + continue;//宸ヤ綔妗fゼ灞傚拰鐩爣妤煎眰鐩稿悓锛岃烦杩� + } + + if (targetLev == lev) { + levCount++;//宸ヤ綔妗g洰鏍囨ゼ灞傚拰瀹為檯妤煎眰鐩稿悓锛屾暟閲忓鍔� + continue; + } + + } + + return levCount < Integer.parseInt(dict.getValue()); + } + } -- Gitblit v1.9.1