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/utils/LiftDispatcher.java | 99 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 97 insertions(+), 2 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 783237e..377f800 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,6 +1,9 @@
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;
@@ -31,6 +34,63 @@
private BasLiftService basLiftService;
@Autowired
private ShuttleStandbyService shuttleStandbyService;
+ @Autowired
+ private NavigateUtils navigateUtils;
+
+ /**
+ * 鏍规嵁鐩爣浣嶇疆鎼滅储鎻愬崌鏈�
+ * transfer: 鏄惁鍙崲灞�
+ */
+ 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>()
+ .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 (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;
+ }
+ }
+
+ return recentLiftThread;
+ }
/**
* 鏍规嵁鐩爣浣嶇疆鎼滅储绌洪棽鎻愬崌鏈�
@@ -77,8 +137,11 @@
}
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;
@@ -122,4 +185,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