From c9c80ecde06d151f4f2f3ccf46d3f4c0e65cd8a1 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 23 九月 2025 13:13:46 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 35 ++++++-----
src/main/java/com/zy/asrs/utils/MapExcelUtils.java | 107 +++++++++++++++++++++++------------
src/main/java/com/zy/common/utils/ShuttleOperaUtils.java | 22 +++++--
src/main/java/com/zy/core/thread/ShuttleThread.java | 4
src/main/webapp/views/admin/debugParam/debugParam.html | 7 ++
5 files changed, 114 insertions(+), 61 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/MapExcelUtils.java b/src/main/java/com/zy/asrs/utils/MapExcelUtils.java
index e3ffb96..ad41208 100644
--- a/src/main/java/com/zy/asrs/utils/MapExcelUtils.java
+++ b/src/main/java/com/zy/asrs/utils/MapExcelUtils.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.core.common.Cools;
+import com.core.exception.CoolException;
import com.zy.asrs.domain.enums.MapExcelNodeType;
import com.zy.common.model.MapNode;
import com.zy.core.enums.MapNodeType;
@@ -15,10 +16,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Component
public class MapExcelUtils {
@@ -72,6 +70,8 @@
for (int bay = 1; bay <= finalBay; bay++) {
MapNode node = new MapNode();
node.setId(row + "-" + bay);
+ node.setRow(row);
+ node.setBay(bay);
HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1);
String nodeType = nodeData.get("bgColor").toString();
@@ -102,6 +102,7 @@
mapList.add(rows);
}
+ MapNode baseMapNode = null;
//鐢熸垚灏忚溅鍦板浘鍧愭爣闂磋窛鏁版嵁
for (int row = 1; row <= finalRow; row++) {
for (int bay = 1; bay <= finalBay; bay++) {
@@ -114,6 +115,29 @@
Integer left = bayData.getInteger("left");
Integer right = bayData.getInteger("right");
+ HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1);
+ String nodeValue = nodeData.get("value").toString();
+ if (Utils.isJSON(nodeValue)) {
+ JSONObject jsonData = JSON.parseObject(nodeValue);
+ if (jsonData.containsKey("top")) {
+ top = jsonData.getInteger("top");
+ }
+ if (jsonData.containsKey("bottom")) {
+ bottom = jsonData.getInteger("bottom");
+ }
+ if (jsonData.containsKey("left")) {
+ left = jsonData.getInteger("left");
+ }
+ if (jsonData.containsKey("right")) {
+ right = jsonData.getInteger("right");
+ }
+
+ if (jsonData.containsKey("xBase")) {
+ //鍩虹偣
+ baseMapNode = mapNode;
+ }
+ }
+
mapNode.setTop(top);
mapNode.setBottom(bottom);
mapNode.setLeft(left);
@@ -121,51 +145,58 @@
}
}
- //鐢熸垚鐗涚溂Y鍧愭爣鍩哄噯鏁版嵁
+ if (baseMapNode == null) {
+ throw new CoolException("鏈缃熀鍑嗙偣");
+ }
+
+ List<Integer> rowList = new ArrayList<>();
+ List<Integer> bayList = new ArrayList<>();
+ for (int row = 1; row <= finalRow; row++) {
+ rowList.add(row);
+ }
for (int bay = 1; bay <= finalBay; bay++) {
+ bayList.add(bay);
+ }
+
+ if (baseMapNode.getRow() != 1) {
+ Collections.reverse(rowList);
+ }
+
+ if (baseMapNode.getBay() != 1) {
+ Collections.reverse(bayList);
+ }
+
+ //鐢熸垚鐗涚溂Y鍧愭爣鍩哄噯鏁版嵁
+ for (int i = 0; i < bayList.size(); i++) {
+ Integer bay = bayList.get(i);
int yBase = 10000;
- for (int row = 1; row <= finalRow; row++) {
+ for (int j = 0; j < rowList.size(); j++) {
+ Integer row = rowList.get(j);
MapNode mapNode = mapList.get(row - 1).get(bay - 1);
- HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1);
-
- JSONObject rowData = rowMap.get(row);
- Integer bottom = rowData.getInteger("bottom");
- String nodeValue = nodeData.get("value").toString();
- if (Utils.isJSON(nodeValue)) {
- JSONObject jsonData = JSON.parseObject(nodeValue);
- if (jsonData.containsKey("bottom")) {
- bottom = jsonData.getInteger("bottom");
- }
- }
-
- if (row != 1) {
- yBase += bottom;
- }
mapNode.setYBase(yBase);
+
+ if (baseMapNode.getRow() == 1) {
+ yBase += mapNode.getBottom();
+ }else {
+ yBase += mapNode.getTop();
+ }
}
}
//鐢熸垚鐗涚溂X鍧愭爣鍩哄噯鏁版嵁
- for (int row = 1; row <= finalRow; row++) {
+ for (int i = 0; i < rowList.size(); i++) {
+ Integer row = rowList.get(i);
int xBase = 10000;
- for (int bay = 1; bay <= finalBay; bay++) {
+ for (int j = 0; j < bayList.size(); j++) {
+ Integer bay = bayList.get(j);
MapNode mapNode = mapList.get(row - 1).get(bay - 1);
- HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1);
-
- JSONObject bayData = bayMap.get(bay);
- Integer right = bayData.getInteger("right");
- String nodeValue = nodeData.get("value").toString();
- if (Utils.isJSON(nodeValue)) {
- JSONObject jsonData = JSON.parseObject(nodeValue);
- if (jsonData.containsKey("right")) {
- right = jsonData.getInteger("right");
- }
- }
-
- if (bay != 1) {
- xBase += right;
- }
mapNode.setXBase(xBase);
+
+ if (baseMapNode.getBay() == 1) {
+ xBase += mapNode.getRight();
+ }else {
+ xBase += mapNode.getLeft();
+ }
}
}
diff --git a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
index 7cdbed3..c4fe002 100644
--- a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
+++ b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
@@ -72,6 +72,17 @@
}
}
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+
+ //灏忚溅(x,y)鍛戒护杩愯鏂瑰悜棰犲��
+ boolean shuttleDirectionReverse = false;
+ if (systemConfigMapObj != null) {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+ if (systemConfigMap.get("shuttleDirectionReverse").equals("Y")) {
+ shuttleDirectionReverse = true;
+ }
+ }
+
long calcStartTime = System.currentTimeMillis();
List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites);
if (nodeList == null) {
@@ -133,15 +144,15 @@
long startGetMoveCommandTime = System.currentTimeMillis();
//鑾峰彇绉诲姩鍛戒护
- ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes);
+ ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, shuttleDirectionReverse);
News.info("[RCS Debug] getMoveCommand idx:{} time:{}", i, (System.currentTimeMillis() - startGetMoveCommandTime));
if (i + 1 == data.size()) {
long startGetInOutLiftTime = System.currentTimeMillis();
if (moveType.equals("inLift")) {
- command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true);
+ command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true, shuttleDirectionReverse);
}else if (moveType.equals("outLift")) {
- command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false);
+ command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false, shuttleDirectionReverse);
}
News.info("[RCS Debug] getInOutLiftTime idx:{} time:{}", i, (System.currentTimeMillis() - startGetInOutLiftTime));
}
@@ -156,9 +167,8 @@
//灏忚溅绉诲姩杩炵画涓嬪彂鎸囦护
boolean shuttleMoveCommandsContinuously = false;
- Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
- if (object != null) {
- HashMap<String, String> systemConfigMap = (HashMap<String, String>) object;
+ if (systemConfigMapObj != null) {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
String shuttleMoveCommandsContinuouslyConfig = systemConfigMap.get("shuttleMoveCommandsContinuously");
if (shuttleMoveCommandsContinuouslyConfig != null && shuttleMoveCommandsContinuouslyConfig.equals("Y")) {
shuttleMoveCommandsContinuously = true;
diff --git a/src/main/java/com/zy/core/thread/ShuttleThread.java b/src/main/java/com/zy/core/thread/ShuttleThread.java
index 02d6120..861cbb1 100644
--- a/src/main/java/com/zy/core/thread/ShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -81,9 +81,9 @@
//***************鑾峰彇鍛戒护*****************
- ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes);//鑾峰彇绉诲姩鍛戒护
+ ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean shuttleDirectionReverse);//鑾峰彇绉诲姩鍛戒护
- ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn);//鑾峰彇绉诲姩鍛戒护
+ ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn, Boolean shuttleDirectionReverse);//鑾峰彇绉诲姩鍛戒护
ShuttleCommand getLiftCommand(Integer taskNo, Boolean lift);//椤跺崌鍛戒护 true=>椤跺崌 false=>涓嬮檷
diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
index 5e2e26c..44f6187 100644
--- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
@@ -989,7 +989,7 @@
}
@Override
- public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) {
+ public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean shuttleDirectionReverse) {
NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class);
NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
@@ -1009,8 +1009,14 @@
HashMap<String, Object> data = new HashMap<>();
String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ());
Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum));
- int xp = Integer.parseInt(String.valueOf(nyNode.get("y")));
- int yp = Integer.parseInt(String.valueOf(nyNode.get("x")));
+
+ int xp = Integer.parseInt(String.valueOf(nyNode.get("x")));
+ int yp = Integer.parseInt(String.valueOf(nyNode.get("y")));
+ if (shuttleDirectionReverse) {
+ xp = Integer.parseInt(String.valueOf(nyNode.get("y")));
+ yp = Integer.parseInt(String.valueOf(nyNode.get("x")));
+ }
+
int z = Integer.parseInt(String.valueOf(nyNode.get("z")));
List<MapNode> mapNodes = mapData.get(node.getX());
@@ -1040,7 +1046,7 @@
}
@Override
- public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn) {
+ public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn, Boolean shuttleDirectionReverse) {
NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class);
NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
@@ -1051,7 +1057,7 @@
HashMap<String, Object> body = new HashMap<>();
if (moveIn) {
body.put("requestType", "intoLift");//杩涙彁鍗囨満
- }else {
+ } else {
body.put("requestType", "outLift");//鍑烘彁鍗囨満
}
body.put("taskId", taskId);//TaskID闇�瑕侀殢鏈�
@@ -1064,8 +1070,14 @@
HashMap<String, Object> data = new HashMap<>();
String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ());
Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum));
- int xp = Integer.parseInt(String.valueOf(nyNode.get("y")));
- int yp = Integer.parseInt(String.valueOf(nyNode.get("x")));
+
+ int xp = Integer.parseInt(String.valueOf(nyNode.get("x")));
+ int yp = Integer.parseInt(String.valueOf(nyNode.get("y")));
+ if (shuttleDirectionReverse) {
+ xp = Integer.parseInt(String.valueOf(nyNode.get("y")));
+ yp = Integer.parseInt(String.valueOf(nyNode.get("x")));
+ }
+
int z = Integer.parseInt(String.valueOf(nyNode.get("z")));
List<MapNode> mapNodes = mapData.get(node.getX());
@@ -1330,13 +1342,6 @@
//WCS绯荤粺鍧愭爣杞墰鐪煎潗鏍�
private static int[] WCSXyzToNyXyz(int x, int y, int z) {
-// //WCS绯荤粺Y杞� => 鐗涚溂X杞磋浆鎹㈠叕寮�
-// int x1 = Math.abs(y - 61) + 11;
-// //WCS绯荤粺X杞� => 鐗涚溂Y杞磋浆鎹㈠叕寮�
-// int y1 = x + 10;
-
-// int x1 = x + 10;
-// int y1 = y + 10;
LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
.eq("row1", x)
@@ -1349,7 +1354,7 @@
String qrCodeValue = locMast.getQrCodeValue();
JSONObject data = JSON.parseObject(qrCodeValue);
- return new int[]{data.getInteger("y"), data.getInteger("x"), z};
+ return new int[]{data.getInteger("x"), data.getInteger("y"), z};
}
@Override
diff --git a/src/main/webapp/views/admin/debugParam/debugParam.html b/src/main/webapp/views/admin/debugParam/debugParam.html
index 2b7dee2..5a44cb7 100644
--- a/src/main/webapp/views/admin/debugParam/debugParam.html
+++ b/src/main/webapp/views/admin/debugParam/debugParam.html
@@ -54,6 +54,12 @@
<el-input v-model="codeMap.direction_map" style="width: 60%;"></el-input>
</div>
+ <div class="show-box">
+ <div>灏忚溅(x,y)鍛戒护杩愯鏂瑰悜棰犲��</div>
+ <el-radio border v-model="codeMap.shuttleDirectionReverse" label="Y">寮�</el-radio>
+ <el-radio border v-model="codeMap.shuttleDirectionReverse" label="N">鍏�</el-radio>
+ </div>
+
<div class="show-box">
<div>灏忚溅鍑烘彁鍗囨満杩戠偣璺濈</div>
<el-input v-model="codeMap.shuttleOutLiftLocationDistance" style="width: 60%;"></el-input>
@@ -257,6 +263,7 @@
data.push('avoidInnerCircle');
data.push('avoidOuterCircle');
data.push('direction_map');
+ data.push('shuttleDirectionReverse');
data.push('shuttleOutLiftLocationDistance');
data.push('shuttleMoveCommandsContinuously');
data.push('trafficControlRestartCalcPath');
--
Gitblit v1.9.1