From 8ef2bb5e46d84594e6ed632c07ea0b47a1bf6c4d Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期三, 11 十二月 2024 16:15:17 +0800 Subject: [PATCH] #path similarity --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 113 insertions(+), 4 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java index 928c2e7..af6aa85 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java @@ -1,12 +1,14 @@ package com.zy.asrs.wcs.core.utils; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zy.asrs.framework.common.Cools; +import com.zy.asrs.wcs.core.domain.dto.BasLiftLevOffsetDto; import com.zy.asrs.wcs.core.entity.BasLift; import com.zy.asrs.wcs.core.entity.ShuttleStandby; 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.WorkZoneType; import com.zy.asrs.wcs.core.service.BasLiftService; import com.zy.asrs.wcs.core.service.ShuttleStandbyService; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; @@ -32,11 +34,14 @@ private BasLiftService basLiftService; @Autowired private ShuttleStandbyService shuttleStandbyService; + @Autowired + private NavigateUtils navigateUtils; /** * 鏍规嵁鐩爣浣嶇疆鎼滅储绌洪棽鎻愬崌鏈� + * transfer: 鏄惁鍙崲灞� */ - public LiftThread searchIdleLift(String locNo, Long hostId) { + public LiftThread searchLift(String locNo, Long hostId, Boolean transfer) { LiftThread recentLiftThread = null; Integer finalDistance = Integer.MAX_VALUE; List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() @@ -58,6 +63,16 @@ continue; } + if (transfer) { + BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>().eq(BasLift::getLiftNo, device.getDeviceNo()).eq(BasLift::getHostId, hostId)); + if (basLift == null) { + continue; + } + if (basLift.getTransfer() != 1) { + continue;//鎻愬崌鏈鸿璁剧疆鎴愪笉鍙崲灞� + } + } + ShuttleStandby standby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() .eq(ShuttleStandby::getDeviceId, device.getId()) .eq(ShuttleStandby::getDeviceLev, Utils.getLev(locNo)) @@ -67,8 +82,70 @@ } String liftLocNo = Utils.getLocNo(Utils.getRow(standby.getDeviceStandbyLoc()), Utils.getBay(standby.getDeviceStandbyLoc()), Utils.getLev(locNo)); - List<NavigateNode> nodeList = NavigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, null); - Integer originPathAllDistance = NavigateUtils.getOriginPathAllDistance(nodeList);//鎬昏窛绂� + List<NavigateNode> nodeList = navigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, null); + if (nodeList == null) { + continue; + } + Integer originPathAllDistance = navigateUtils.getOriginPathAllDistance(nodeList);//鎬昏窛绂� + if (originPathAllDistance < finalDistance) { + finalDistance = originPathAllDistance; + recentLiftThread = liftThread; + } + } + + return recentLiftThread; + } + + /** + * 鏍规嵁鐩爣浣嶇疆鎼滅储绌洪棽鎻愬崌鏈� + * transfer: 鏄惁鍙崲灞� + */ + public LiftThread searchIdleLift(String locNo, Long hostId, Boolean transfer) { + LiftThread recentLiftThread = null; + Integer finalDistance = Integer.MAX_VALUE; + List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() + .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()) + .eq(Device::getHostId, hostId) + .eq(Device::getStatus, 1)); + for (Device device : list) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); + if (liftThread == null) { + continue; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + continue; + } + + if (!liftThread.isIdle()) { + continue; + } + + if (transfer) { + BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>().eq(BasLift::getLiftNo, device.getDeviceNo()).eq(BasLift::getHostId, hostId)); + if (basLift == null) { + continue; + } + if (basLift.getTransfer() != 1) { + continue;//鎻愬崌鏈鸿璁剧疆鎴愪笉鍙崲灞� + } + } + + ShuttleStandby standby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() + .eq(ShuttleStandby::getDeviceId, device.getId()) + .eq(ShuttleStandby::getDeviceLev, Utils.getLev(locNo)) + .eq(ShuttleStandby::getStatus, 1)); + if (standby == null) { + continue; + } + + String liftLocNo = Utils.getLocNo(Utils.getRow(standby.getDeviceStandbyLoc()), Utils.getBay(standby.getDeviceStandbyLoc()), Utils.getLev(locNo)); + List<NavigateNode> nodeList = navigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, null); + if (nodeList == null) { + continue; + } + Integer originPathAllDistance = navigateUtils.getOriginPathAllDistance(nodeList);//鎬昏窛绂� if (originPathAllDistance < finalDistance) { finalDistance = originPathAllDistance; recentLiftThread = liftThread; @@ -112,4 +189,36 @@ return liftLocNo; } + /** + * 鑾峰彇鎹㈠眰闇�瑕侀攣瀹氱殑璺緞 + */ + public List<String> getLockPathByLocNo(LiftThread liftThread, Integer lev) { + Device device = liftThread.getDevice(); + ShuttleStandby standby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() + .eq(ShuttleStandby::getDeviceId, device.getId()) + .eq(ShuttleStandby::getDeviceLev, lev) + .eq(ShuttleStandby::getStatus, 1)); + if (standby == null) { + return null; + } + + return standby.getLockPath$(); + } + + public Integer getLiftLevOffset(Integer deviceId,Integer lev) { + BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>().eq(BasLift::getDeviceId, deviceId)); + if (basLift != null) { + if(Cools.isEmpty(basLift.getLevOffset())) { + return lev; + } + List<BasLiftLevOffsetDto> levOffsetDtos = JSON.parseArray(basLift.getLevOffset(), BasLiftLevOffsetDto.class); + for (BasLiftLevOffsetDto offsetDto : levOffsetDtos) { + if(lev == offsetDto.getLogicLev()){ + return offsetDto.getRealLev(); + } + } + } + return lev; + } + } -- Gitblit v1.9.1