From 4453cdecbc6e7a925ae76e3223418654f1cf0b18 Mon Sep 17 00:00:00 2001 From: taisheng <taisheng@qq.com> Date: 星期二, 22 四月 2025 16:01:15 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/ShuttleOperaUtils.java | 87 ++++++++++++++++++++++------ src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 22 +++--- src/main/java/com/zy/common/utils/NavigateMapData.java | 17 +++++ 3 files changed, 95 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index 4588883..c756228 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -542,6 +542,15 @@ return false; } + //妫�娴嬮殰纰嶇墿杞� + boolean checkObstacle = shuttleOperaUtils.checkObstacle(wrkMast.getLocNo(), new ArrayList<Integer>() {{ + add(shuttleProtocol.getShuttleNo()); + }}); + if (checkObstacle) { + News.info("{}浠诲姟锛岄伩闅滆寖鍥存湁灏忚溅锛岀瓑寰呴殰纰嶅皬杞﹁皟绂讳腑", wrkMast.getWrkNo()); + return false; + } + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� assignCommand.setTaskMode(ShuttleTaskModeType.TRANSPORT.id);//灏忚溅绉诲簱浠诲姟 @@ -567,8 +576,8 @@ return false; } - commands.add(0, liftCommand.get(0)); - commands.add(liftCommand2.get(0)); +// commands.add(0, liftCommand.get(0)); +// commands.add(liftCommand2.get(0)); assignCommand.setCommands(commands); wrkMast.setWrkSts(WrkStsType.LOC_MOVE_SHUTTLE_RUN.sts);//灏忚溅鎼繍涓� 501.鐢熸垚绉诲簱浠诲姟 ==> 502.灏忚溅鎼繍涓� @@ -1766,15 +1775,6 @@ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞璁$畻澶辫触 } - -// //妫�娴嬮殰纰嶇墿杞� -// boolean checkObstacle = shuttleOperaUtils.checkObstacle(wrkMast.getLocNo(), new ArrayList<Integer>() {{ -// add(shuttleProtocol.getShuttleNo()); -// }}); -// if (checkObstacle) { -// News.info("{}浠诲姟锛岄伩闅滆寖鍥存湁灏忚溅锛岀瓑寰呴殰纰嶅皬杞﹁皟绂讳腑", wrkMast.getWrkNo()); -// return false; -// } assignCommand.setCommands(commands); diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java index d19f34b..cf5a6c0 100644 --- a/src/main/java/com/zy/common/utils/NavigateMapData.java +++ b/src/main/java/com/zy/common/utils/NavigateMapData.java @@ -115,6 +115,23 @@ return null; } + public int[][] parseJsonDataArr(List<List<MapNode>> lists) { + int[][] map = new int[lists.size()][]; + int j = 0; + for (List<MapNode> list : lists) { + int[] tmp = new int[list.size()]; + int i = 0; + for (MapNode mapNode : list) { + //灏嗘暟鎹坊鍔犺繘浜岀淮鏁扮粍 + tmp[i++] = mapNode.getValue(); + } + //鏁版嵁娣诲姞杩涗竴缁存暟缁� + map[j++] = tmp; + } + + return map; + } + /** * 杩囨护鍦板浘鏁版嵁 * mapType -1=>鏃犺繃婊わ紝1=銆嬭繃婊ゅ簱浣嶇姸鎬丏FX锛�2=銆嬭繃婊ゅ簱浣嶇姸鎬乆 diff --git a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java index 9292a44..4c14010 100644 --- a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java +++ b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java @@ -6,8 +6,8 @@ import com.zy.asrs.entity.BasShuttle; import com.zy.asrs.service.BasShuttleService; import com.zy.asrs.utils.Utils; +import com.zy.common.model.MapNode; import com.zy.common.model.NavigateNode; -import com.zy.common.model.enums.NavigationMapType; import com.zy.core.News; import com.zy.core.cache.SlaveConnection; import com.zy.core.dispatcher.ShuttleDispatchUtils; @@ -260,19 +260,28 @@ continue; } - int nextInt = new Random().nextInt(outerNodes.size()); - NavigateNode randomNode = outerNodes.get(nextInt); - String randomLocNo = NavigatePositionConvert.nodeToLocNo(randomNode); - shuttleDispatchUtils.dispatchShuttle(null, randomLocNo, shuttleNo); + HashMap<String, Integer> carMap = findCarMap(); + + String targetLocNo = null; + for (NavigateNode node : outerNodes) { + String dispatchLocNo = NavigatePositionConvert.nodeToLocNo(node); + if (carMap.containsKey(dispatchLocNo)) { + continue; + } + targetLocNo = dispatchLocNo; + break; + } + + if(targetLocNo == null) { + continue; + } + shuttleDispatchUtils.dispatchShuttle(null, targetLocNo, shuttleNo); } return true;//鍐呭湀涓湁杞� } - //鎼滅储鑺傜偣鍐呯殑灏忚溅缂栧彿 - private List<Integer> findNodesCar(List<NavigateNode> nodes) { - List<Integer> list = new ArrayList<>(); - + private HashMap<String, Integer> findCarMap() { HashMap<String, Integer> carMap = new HashMap<>(); for (ShuttleSlave slave : slaveProperties.getShuttle()) { ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); @@ -290,7 +299,13 @@ carMap.put(currentLocNo, slave.getId()); } + return carMap; + } + //鎼滅储鑺傜偣鍐呯殑灏忚溅缂栧彿 + private List<Integer> findNodesCar(List<NavigateNode> nodes) { + List<Integer> list = new ArrayList<>(); + HashMap<String, Integer> carMap = findCarMap(); for (NavigateNode node : nodes) { String locNo = NavigatePositionConvert.nodeToLocNo(node); if (carMap.containsKey(locNo)) { @@ -307,8 +322,10 @@ int lev = Utils.getLev(locNo); int[] pointArr = NavigatePositionConvert.positionToXY(locNo); NavigateNode currentNode = new NavigateNode(pointArr[0], pointArr[1]); + currentNode.setZ(lev); - int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.NORMAL.id, null, whiteShuttlePointList); + List<List<MapNode>> lists = navigateMapData.getJsonData(lev, -1, null, null);//鑾峰彇瀹屾暣鍦板浘 + int[][] map = navigateMapData.parseJsonDataArr(lists); int nodeValue = map[pointArr[0]][pointArr[1]]; currentNode.setNodeValue(nodeValue); @@ -348,7 +365,8 @@ currentNode.setZ(lev); innerNodes.add(currentNode); - int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.NORMAL.id, null, whiteShuttlePointList); + List<List<MapNode>> lists = navigateMapData.getJsonData(lev, -1, null, null);//鑾峰彇瀹屾暣鍦板浘 + int[][] map = navigateMapData.parseJsonDataArr(lists); int nodeValue = map[pointArr[0]][pointArr[1]]; currentNode.setNodeValue(nodeValue); @@ -358,7 +376,20 @@ if (list.isEmpty()) { continue; } - innerNodes.addAll(list); + + for (NavigateNode node : list) { + boolean flag = false; + for (int[] shuttlePoint : whiteShuttlePointList) { + if(node.getX() == shuttlePoint[0] && node.getY() == shuttlePoint[1]) { + flag = true; + break; + } + } + if(flag) { + continue; + } + innerNodes.add(node); + } } return innerNodes; @@ -389,13 +420,17 @@ NavigateNode node = new NavigateNode(x + innerCircleIdx, y); node.setNodeValue(map[x + innerCircleIdx][y]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } if (is_valid(map, x - innerCircleIdx, y)) { NavigateNode node = new NavigateNode(x - innerCircleIdx, y); node.setNodeValue(map[x - innerCircleIdx][y]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } } @@ -405,14 +440,18 @@ NavigateNode node = new NavigateNode(x, y + innerCircleIdx); node.setNodeValue(map[x][y + innerCircleIdx]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } if (is_valid(map, x, y - innerCircleIdx)) { NavigateNode node = new NavigateNode(x, y - innerCircleIdx); node.setNodeValue(map[x][y - innerCircleIdx]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } } }else if (mapDirection.equals("y")) {//姣嶈建y鏂瑰悜 @@ -422,14 +461,18 @@ NavigateNode node = new NavigateNode(x, y + innerCircleIdx); node.setNodeValue(map[x][y + innerCircleIdx]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } if (is_valid(map, x, y - innerCircleIdx)) { NavigateNode node = new NavigateNode(x, y - innerCircleIdx); node.setNodeValue(map[x][y - innerCircleIdx]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } } @@ -439,13 +482,17 @@ NavigateNode node = new NavigateNode(x + innerCircleIdx, y); node.setNodeValue(map[x + innerCircleIdx][y]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } if (is_valid(map, x - innerCircleIdx, y)) { NavigateNode node = new NavigateNode(x - innerCircleIdx, y); node.setNodeValue(map[x - innerCircleIdx][y]); node.setZ(z); - nodes.add(node); + if (node.getNodeValue().equals(startNode.getNodeValue())) { + nodes.add(node); + } } } }else { -- Gitblit v1.9.1