From 1319a98367d2dd98bac4872afc9dfc117614b590 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 05 三月 2026 15:23:12 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java | 156 +++++++++++++++++++++++++++++++++-------------------
1 files changed, 99 insertions(+), 57 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java b/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
index d3e3504..245446b 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
@@ -143,6 +143,7 @@
stationProtocol.setRunBlock(statusEntity.isRunBlock());
stationProtocol.setEnableIn(statusEntity.isEnableIn());
stationProtocol.setWeight(statusEntity.getWeight());
+ stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx());
}
if (!Cools.isEmpty(stationProtocol.getSystemWarning())) {
@@ -213,8 +214,25 @@
if (commandType == StationCommandType.MOVE) {
if (!stationId.equals(targetStationId)) {
- List<Integer> path = calcPathStationIds(stationId, targetStationId);
+ List<NavigateNode> nodes = calcPathNavigateNodes(stationId, targetStationId);
+ List<Integer> path = new ArrayList<>();
+ List<Integer> liftTransferPath = new ArrayList<>();
+ for (NavigateNode n : nodes) {
+ JSONObject v = JSONObject.parseObject(n.getNodeValue());
+ if (v == null) {
+ continue;
+ }
+ Integer stationNo = v.getInteger("stationId");
+ if (stationNo == null) {
+ continue;
+ }
+ path.add(stationNo);
+ if (Boolean.TRUE.equals(n.getIsLiftTransferPoint())) {
+ liftTransferPath.add(stationNo);
+ }
+ }
stationCommand.setNavigatePath(path);
+ stationCommand.setLiftTransferPath(liftTransferPath);
}
}
return stationCommand;
@@ -271,65 +289,100 @@
return zyStationConnectDriver.readOriginCommand(address, length);
}
- private List<Integer> calcPathStationIds(Integer startStationId, Integer targetStationId) {
+ private List<NavigateNode> calcPathNavigateNodes(Integer startStationId, Integer targetStationId) {
NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
if (navigateUtils == null) {
return new ArrayList<>();
}
- List<NavigateNode> nodes = navigateUtils.calcByStationId(startStationId, targetStationId);
- List<Integer> ids = new ArrayList<>();
- for (NavigateNode n : nodes) {
- JSONObject v = JSONObject.parseObject(n.getNodeValue());
- if (v != null) {
- ids.add(v.getInteger("stationId"));
- }
- }
- return ids;
+ return navigateUtils.calcByStationId(startStationId, targetStationId);
}
private void executeMoveWithSeg(StationCommand original) {
- int stationCommandSendLength = 20;
- Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
- if (systemConfigMapObj != null) {
- try {
- HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
- String stationCommandSendLengthStr = systemConfigMap.get("stationCommandSendLength");
- if(stationCommandSendLengthStr != null){
- stationCommandSendLength = Integer.parseInt(stationCommandSendLengthStr);
- }
- } catch (Exception ignore) {}
- }
-
if(original.getCommandType() == StationCommandType.MOVE){
List<Integer> path = JSON.parseArray(JSON.toJSONString(original.getNavigatePath(), SerializerFeature.DisableCircularReferenceDetect), Integer.class);
+ List<Integer> liftTransferPath = JSON.parseArray(JSON.toJSONString(original.getLiftTransferPath(), SerializerFeature.DisableCircularReferenceDetect), Integer.class);
if (path == null || path.isEmpty()) {
+ // 鍚岀珯鐐逛换鍔′笉浼氱敓鎴愯矾寰勶紝浣嗕粛闇�涓嬪彂鍛戒护鍐欏叆浠诲姟鏁版嵁
+ if (Objects.equals(original.getStationId(), original.getTargetStaNo())) {
+ while (true) {
+ CommandResponse commandResponse = sendCommand(original);
+ if (commandResponse != null && commandResponse.getResult()) {
+ break;
+ }
+ try {
+ Thread.sleep(200);
+ } catch (Exception ignore) {}
+ }
+ }
return;
}
int total = path.size();
- List<Integer> segmentTargets = new ArrayList<>();
List<Integer> segmentEndIndices = new ArrayList<>();
- int idx = 0;
- while (idx < total) {
- int end = Math.min(idx + stationCommandSendLength, total) - 1;
- segmentTargets.add(path.get(end));
- segmentEndIndices.add(end);
- idx = end + 1;
+ if (liftTransferPath != null) {
+ for (Integer liftTransferStationId : liftTransferPath) {
+ int endIndex = path.indexOf(liftTransferStationId);
+ // 閬垮厤浠ヨ捣鐐逛綔涓哄垏鐐瑰鑷寸┖鍒嗘
+ if (endIndex <= 0) {
+ continue;
+ }
+ if (segmentEndIndices.isEmpty() || endIndex > segmentEndIndices.get(segmentEndIndices.size() - 1)) {
+ segmentEndIndices.add(endIndex);
+ }
+ }
+ }
+ if (segmentEndIndices.isEmpty() || segmentEndIndices.get(segmentEndIndices.size() - 1) != total - 1) {
+ segmentEndIndices.add(total - 1);
+ }
+
+ List<StationCommand> segmentCommands = new ArrayList<>();
+ int buildStartIdx = 0;
+ for (Integer endIdx : segmentEndIndices) {
+ if (endIdx == null || endIdx < buildStartIdx) {
+ continue;
+ }
+ List<Integer> segmentPath = new ArrayList<>(path.subList(buildStartIdx, endIdx + 1));
+ if (segmentPath.isEmpty()) {
+ buildStartIdx = endIdx + 1;
+ continue;
+ }
+
+ StationCommand segmentCommand = new StationCommand();
+ segmentCommand.setTaskNo(original.getTaskNo());
+ segmentCommand.setCommandType(original.getCommandType());
+ segmentCommand.setPalletSize(original.getPalletSize());
+ segmentCommand.setBarcode(original.getBarcode());
+ segmentCommand.setOriginalNavigatePath(path);
+ segmentCommand.setNavigatePath(segmentPath);
+ // 姣忔鍛戒护锛氳捣鐐�=褰撳墠娈甸绔欑偣锛岀粓鐐�=褰撳墠娈垫湯绔欑偣
+ segmentCommand.setStationId(segmentPath.get(0));
+ segmentCommand.setTargetStaNo(segmentPath.get(segmentPath.size() - 1));
+ segmentCommands.add(segmentCommand);
+
+ // 鍒嗘杈圭晫鐐归渶瑕佸悓鏃朵綔涓轰笅涓�娈电殑璧风偣锛堜緥濡� [221,220,219] + [219,213,212]锛�
+ buildStartIdx = endIdx;
+ }
+
+ if (segmentCommands.isEmpty()) {
+ return;
}
int segCursor = 0;
- Integer currentTarget = segmentTargets.get(segCursor);
- Integer currentEndIdx = segmentEndIndices.get(segCursor);
- Integer currentStartIdx = 0;
-
- StationCommand segCmd = new StationCommand();
- segCmd.setTaskNo(original.getTaskNo());
- segCmd.setStationId(original.getStationId());
- segCmd.setTargetStaNo(original.getTargetStaNo());
- segCmd.setCommandType(original.getCommandType());
- segCmd.setPalletSize(original.getPalletSize());
- segCmd.setNavigatePath(new ArrayList<>(path.subList(0, currentEndIdx + 1)));
- sendCommand(segCmd);
+ while (true) {
+ CommandResponse commandResponse = sendCommand(segmentCommands.get(segCursor));
+ if (commandResponse == null) {
+ try {
+ Thread.sleep(200);
+ } catch (Exception ignore) {}
+ continue;
+ }
+ if (commandResponse.getResult()) {
+ break;
+ }
+ try {
+ Thread.sleep(200);
+ } catch (Exception ignore) {}
+ }
long runTime = System.currentTimeMillis();
boolean firstRun = true;
@@ -362,26 +415,15 @@
if (remaining <= 0) {
break;
}
- int currentSegEndIndex = path.indexOf(segmentTargets.get(segCursor));
- int currentSegStartIndex = segCursor == 0 ? 0 : path.indexOf(segmentTargets.get(segCursor - 1)) + 1;
+ int currentSegEndIndex = segmentEndIndices.get(segCursor);
+ int currentSegStartIndex = segCursor == 0 ? 0 : segmentEndIndices.get(segCursor - 1);
int segLen = currentSegEndIndex - currentSegStartIndex + 1;
int remainingSegment = Math.max(0, currentSegEndIndex - currentIndex);
int thresholdSegment = (int) Math.ceil(segLen * 0.3);
- if (remainingSegment <= thresholdSegment && segCursor < segmentTargets.size() - 1) {
+ if (remainingSegment <= thresholdSegment && segCursor < segmentCommands.size() - 1) {
segCursor++;
- currentEndIdx = segmentEndIndices.get(segCursor);
- currentStartIdx = segmentEndIndices.get(segCursor - 1) + 1;
-
- StationCommand nextCmd = new StationCommand();
- nextCmd.setTaskNo(original.getTaskNo());
- nextCmd.setStationId(original.getStationId());
- nextCmd.setTargetStaNo(original.getTargetStaNo());
- nextCmd.setCommandType(original.getCommandType());
- nextCmd.setPalletSize(original.getPalletSize());
- nextCmd.setNavigatePath(new ArrayList<>(path.subList(currentStartIdx, currentEndIdx + 1)));
- nextCmd.setOriginalNavigatePath(path);
while (true) {
- CommandResponse commandResponse = sendCommand(nextCmd);
+ CommandResponse commandResponse = sendCommand(segmentCommands.get(segCursor));
if (commandResponse == null) {
Thread.sleep(200);
continue;
--
Gitblit v1.9.1