From 44fa920bbcf6cd94c81f3a6d2f3008925a8635ca Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期四, 11 五月 2023 09:40:39 +0800 Subject: [PATCH] 四向穿梭车命令封装 --- src/main/java/com/zy/common/utils/NavigateUtils.java | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zy/common/utils/NavigateUtils.java b/src/main/java/com/zy/common/utils/NavigateUtils.java index 38fbb15..306a049 100644 --- a/src/main/java/com/zy/common/utils/NavigateUtils.java +++ b/src/main/java/com/zy/common/utils/NavigateUtils.java @@ -1,6 +1,7 @@ package com.zy.common.utils; -import com.alibaba.fastjson.JSONObject; +import com.zy.asrs.utils.Utils; +import com.zy.common.model.MapNode; import com.zy.common.model.NavigateNode; import com.zy.core.enums.ShuttleTaskModeType; @@ -15,6 +16,9 @@ //閫氳繃寮�濮嬬紪鍙峰拰缁撴潫缂栧彿鑾峰彇瀵瑰簲鐨剎y杞村潗鏍� int[] startArr = NavigatePositionConvert.positionToXY(startPoint);//寮�濮嬭妭鐐� int[] endArr = NavigatePositionConvert.positionToXY(endPoint);//缁撴潫鑺傜偣 + + //鑾峰彇褰撳墠鑺傜偣璁$畻鐨勫眰楂橈紝骞惰祴鍊煎埌姣忎竴涓妭鐐逛腑 + int lev = Utils.getLev(startPoint); //鍒濆鍖栧紑濮嬭妭鐐� NavigateNode start = new NavigateNode(startArr[0], startArr[1]); @@ -35,6 +39,7 @@ while (res_node != null) { res_node.setDirection(null); res_node.setIsInflectionPoint(false); + res_node.setZ(lev);//璁剧疆灞傞珮 //瀵绘壘鎷愮偣 HashMap<String, Object> result = searchInflectionPoint(res_node, fatherNode, res_node.getFather());//鍒嗗埆浼犲叆褰撳墠鑺傜偣銆佺埗鑺傜偣銆佷笅涓�鑺傜偣 @@ -158,11 +163,20 @@ //鑾峰彇浠巟鐐瑰埌涓嬩竴鐐圭殑琛岃蛋璺濈 public static Integer getXToNextDistance(NavigateNode xNode) { NavigateMapData mapData = new NavigateMapData(); - ArrayList<ArrayList<JSONObject>> lists = mapData.getJsonData(1); + List<List<MapNode>> lists = mapData.getJsonData(1); if (lists != null) { - JSONObject jsonObject = lists.get(xNode.getX()).get(xNode.getY()); - if (jsonObject != null) { - return Integer.parseInt(jsonObject.getOrDefault(xNode.getDirection(), 0).toString()); + MapNode mapNode = lists.get(xNode.getX()).get(xNode.getY()); + if (mapNode != null) { + switch (xNode.getDirection()) { + case "top": + return mapNode.getTop(); + case "bottom": + return mapNode.getBottom(); + case "left": + return mapNode.getLeft(); + case "right": + return mapNode.getRight(); + } } return 0; } -- Gitblit v1.9.1