From 8c7b4949dfcf875cc537304d34a7f6960cbb0c10 Mon Sep 17 00:00:00 2001
From: qlsxk <qlsxk@qq.com>
Date: 星期四, 16 十月 2025 14:57:12 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/ShuttleOperaUtils.java | 74 +++++++++++++++++++++++++++++--------
1 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
index a683e32..c4fe002 100644
--- a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
+++ b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
@@ -3,9 +3,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
-import com.zy.asrs.entity.BasShuttle;
import com.zy.asrs.entity.DeviceConfig;
-import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.DeviceConfigService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.MapNode;
@@ -15,6 +13,7 @@
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.MapNodeType;
+import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.ShuttleRunDirection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.command.ShuttleAssignCommand;
@@ -36,11 +35,7 @@
public class ShuttleOperaUtils {
@Autowired
- private BasShuttleService basShuttleService;
- @Autowired
private NavigateUtils navigateUtils;
- @Autowired
- private NavigateMapUtils navigateMapUtils;
@Autowired
private NavigateMapData navigateMapData;
@Autowired
@@ -49,6 +44,8 @@
private ShuttleDispatchUtils shuttleDispatchUtils;
@Autowired
private DeviceConfigService deviceConfigService;
+ @Autowired
+ private RedisUtil redisUtil;
public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread, "move");
@@ -65,7 +62,27 @@
}
Integer shuttleNo = shuttleProtocol.getShuttleNo();
//鑾峰彇灏忚溅绉诲姩閫熷害
- Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000);
+ Integer runSpeed = 1000;
+ Object speedObj = redisUtil.get(RedisKeyType.SHUTTLE_SPEED_MAP.key);
+ if (speedObj != null) {
+ HashMap<Integer, Integer> shuttleSpeedMap = (HashMap<Integer, Integer>) speedObj;
+ Integer speed = shuttleSpeedMap.get(shuttleNo);
+ if (speed != null) {
+ runSpeed = speed;
+ }
+ }
+
+ 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) {
@@ -102,43 +119,58 @@
List<List<NavigateNode>> data = navigateUtils.getSectionPath(nodeList);
long endTime = System.currentTimeMillis();
News.info("[RCS Debug] getSection path time:{}", (endTime - startTime));
+
+ long startGetSectionCommandTime = System.currentTimeMillis();
//灏嗘瘡涓�娈佃矾寰勫垎鎴恈ommand鎸囦护
for (int i = 0; i < data.size(); i++) {
+ long startGetStartAndEndPathTime = System.currentTimeMillis();
List<NavigateNode> nodes = data.get(i);
-
//寮�濮嬭矾寰�
NavigateNode startPath = nodes.get(0);
-
//鐩爣璺緞
NavigateNode endPath = nodes.get(nodes.size() - 1);
+ News.info("[RCS Debug] getStartAndEndPath idx:{} time:{}", i, (System.currentTimeMillis() - startGetStartAndEndPathTime));
+
+ long startAllDistanceTime = System.currentTimeMillis();
Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+ News.info("[RCS Debug] getAllDistance idx:{} time:{}", i, (System.currentTimeMillis() - startAllDistanceTime));
+
+ long startGetPosition = System.currentTimeMillis();
//閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
//閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
+ News.info("[RCS Debug] xyToPosition idx:{} time:{}", i, (System.currentTimeMillis() - startGetPosition));
+
+ 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));
}
command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑
commands.add(command);
}
+ News.info("[RCS Debug] getSectionCommand path time:{}", (System.currentTimeMillis() - startGetSectionCommandTime));
assignCommand.setNodes(allNode);//褰撳墠浠诲姟鎵�鍗犵敤鐨勮妭鐐筶ist
assignCommand.setMapTypes(mapTypes);
//灏忚溅绉诲姩杩炵画涓嬪彂鎸囦护
boolean shuttleMoveCommandsContinuously = false;
- Config shuttleMoveCommandsContinuouslyConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleMoveCommandsContinuously"));
- if (shuttleMoveCommandsContinuouslyConfig != null) {
- if (shuttleMoveCommandsContinuouslyConfig.getValue().equals("Y")) {
+ if (systemConfigMapObj != null) {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+ String shuttleMoveCommandsContinuouslyConfig = systemConfigMap.get("shuttleMoveCommandsContinuously");
+ if (shuttleMoveCommandsContinuouslyConfig != null && shuttleMoveCommandsContinuouslyConfig.equals("Y")) {
shuttleMoveCommandsContinuously = true;
}
}
@@ -349,7 +381,17 @@
int[] pointArr = NavigatePositionConvert.positionToXY(locNo);
NavigateNode currentNode = new NavigateNode(pointArr[0], pointArr[1]);
currentNode.setZ(lev);
- innerNodes.add(currentNode);
+
+ boolean addCurrentNode = true;
+ for (int[] shuttlePoint : whiteShuttlePointList) {
+ if(currentNode.getX() == shuttlePoint[0] && currentNode.getY() == shuttlePoint[1]) {
+ addCurrentNode = false;
+ break;
+ }
+ }
+ if (addCurrentNode) {
+ innerNodes.add(currentNode);
+ }
List<List<MapNode>> lists = navigateMapData.getJsonData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);//鑾峰彇瀹屾暣鍦板浘
int[][] map = navigateMapData.parseJsonDataArr(lists);
--
Gitblit v1.9.1