From 73ce8bebcc5d14f3fb62a19ee677abfcdfc776b4 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期六, 19 七月 2025 16:17:51 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java | 40 ++++++ src/main/java/com/zy/common/utils/NavigateMapUtils.java | 5 src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 2 src/main/java/com/zy/common/utils/ShuttleOperaUtils.java | 13 +- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 16 +- src/main/java/com/zy/common/utils/NavigateUtils.java | 24 ++-- src/main/java/com/zy/asrs/controller/ConsoleController.java | 3 src/main/java/com/zy/asrs/utils/Utils.java | 2 src/main/java/com/zy/asrs/controller/ShuttleController.java | 8 src/main/java/com/zy/core/task/ShuttleDemoScheduler.java | 5 src/main/java/com/zy/core/action/ShuttleAction.java | 96 +++++++++++++++ src/main/java/com/zy/common/utils/NavigateMapData.java | 60 ++++++---- src/main/java/com/zy/common/utils/NavigateSolution.java | 5 src/main/java/com/zy/common/model/enums/NavigationMapType.java | 25 +++ 14 files changed, 233 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java index c3e061d..186f708 100644 --- a/src/main/java/com/zy/asrs/controller/ConsoleController.java +++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java @@ -90,7 +90,8 @@ BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); //瑙f瀽json鍦板浘鏁版嵁 ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); - List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//杩囨护鍦板浘鏁版嵁 + + List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE), arrayList, lev, null, null);//杩囨护鍦板浘鏁版嵁 return R.ok().add(lists); } diff --git a/src/main/java/com/zy/asrs/controller/ShuttleController.java b/src/main/java/com/zy/asrs/controller/ShuttleController.java index 3a25e74..1f9b30c 100644 --- a/src/main/java/com/zy/asrs/controller/ShuttleController.java +++ b/src/main/java/com/zy/asrs/controller/ShuttleController.java @@ -310,11 +310,11 @@ if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) { //绉诲姩鍒扮洰鏍囧簱浣� - Integer mapType = NavigationMapType.NORMAL.id; + List<NavigationMapType> mapTypes = NavigationMapType.getMapTypes(NavigationMapType.NORMAL); if (shuttleProtocol.getHasLift()) { - mapType = NavigationMapType.DFX.id; + mapTypes = NavigationMapType.getMapTypes(NavigationMapType.DFX); } - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapType, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapTypes, assignCommand, shuttleThread); if (commands == null) { throw new CoolException("璺緞璁$畻澶辫触"); } @@ -354,7 +354,7 @@ return R.ok(); } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO_TASK) { //绉诲姩鍒扮洰鏍囧簱浣�(鐢熸垚绉诲姩浠诲姟) - shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(WrkIoType.LOC_MOVE.id), param.getDistLocNo(), param.getShuttleNo()); + shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(WrkIoType.SHUTTLE_MOVE.id), param.getDistLocNo(), param.getShuttleNo()); return R.ok(); } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_DEMO_OPEN) { //婕旂ず妯″紡-寮� 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 67ccf13..c5287f2 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -196,7 +196,7 @@ assignCommand.setAuto(true);//鑷姩妯″紡 //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false; @@ -334,7 +334,7 @@ //寮哄埗棰勭暀涓�鍙板皬杞︾粰鍏ュ簱浠诲姟 int lev = Utils.getLev(wrkMast.getSourceLocNo()); //鑾峰彇褰撳墠妤煎眰鏈夊嚑鍙板彲鐢ㄥ皬杞� - int shuttleCount = shuttleDispatchUtils.getShuttleCountByLev(lev); + int shuttleCount = shuttleDispatchUtils.getShuttleEnableUseCountByLev(lev); if (shuttleCount >= 2) {//鍙湁鍙敤灏忚溅鏁伴噺澶т簬2锛屾墠杩涜鍏ュ簱浠诲姟棰勭暀灏忚溅 int shuttleWrkInObligateCount = 1;//棰勭暀灏忚溅鏁伴噺 Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleWrkInObligateCount").eq("status", 1)); @@ -393,7 +393,7 @@ assignCommand.setAuto(true);//鑷姩妯″紡 //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false; @@ -601,7 +601,7 @@ assignCommand.setAuto(true);//鑷姩妯″紡 //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false; @@ -1585,7 +1585,7 @@ assignCommand.setAuto(true);//鑷姩妯″紡 //璁$畻杩戠偣浣嶇疆 - String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, null, null, 1); + String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 1); if (endLocation == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹁繎鐐逛綅缃绠楀け璐�", wrkMast.getWrkNo()); return false; @@ -1601,7 +1601,7 @@ } //鑾峰彇灏忚溅鍒拌繎鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.SHUTTLE), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞瑙i攣澶辫触 @@ -1716,7 +1716,7 @@ assignCommand.setAuto(true);//鑷姩妯″紡 //鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护 - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞瑙i攣澶辫触 @@ -1900,7 +1900,7 @@ assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅 //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞璁$畻澶辫触 diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java index 454a799..9be9d30 100644 --- a/src/main/java/com/zy/asrs/utils/Utils.java +++ b/src/main/java/com/zy/asrs/utils/Utils.java @@ -252,7 +252,7 @@ String recentLocNo = null; for (LocMast locMast : locMasts) { //寰呮満浣嶅埌鐩爣鐐硅窛绂� - List<NavigateNode> currentShuttlePath = navigateUtils.calc(locNo, locMast.getLocNo(), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(0, Utils.getLev(locNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘 + List<NavigateNode> currentShuttlePath = navigateUtils.calc(locNo, locMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), Utils.getShuttlePoints(0, Utils.getLev(locNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘 if (currentShuttlePath == null) { continue; } diff --git a/src/main/java/com/zy/common/model/enums/NavigationMapType.java b/src/main/java/com/zy/common/model/enums/NavigationMapType.java index 99cc6ac..e73b771 100644 --- a/src/main/java/com/zy/common/model/enums/NavigationMapType.java +++ b/src/main/java/com/zy/common/model/enums/NavigationMapType.java @@ -1,10 +1,15 @@ package com.zy.common.model.enums; +import java.util.ArrayList; +import java.util.List; + public enum NavigationMapType { NONE(-1, "鏃犺繃婊�"), - DFX(1, "杩囨护搴撲綅鐘舵�丏FX"), - NORMAL(2, "杩囨护搴撲綅鐘舵�乆"), + DFX(1, "鍦板浘鎼哄甫搴撲綅鐘舵�丏FX"), + NORMAL(2, "鍦板浘鎼哄甫搴撲綅鐘舵�乆"), + SHUTTLE(3, "鍦板浘鎼哄甫灏忚溅"), + LIFT(4, "鍦板浘鎼哄甫鎻愬崌鏈�"), ; public Integer id; @@ -39,4 +44,20 @@ return null; } + public static List<NavigationMapType> getDfxWithDevice() { + return getMapTypes(DFX, SHUTTLE, LIFT); + } + + public static List<NavigationMapType> getNormalWithDevice() { + return getMapTypes(NORMAL, SHUTTLE, LIFT); + } + + public static List<NavigationMapType> getMapTypes(NavigationMapType... types) { + List<NavigationMapType> mapTypes = new ArrayList<>(); + for (NavigationMapType type : types) { + mapTypes.add(type); + } + return mapTypes; + } + } diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java index f0b5cb9..8518def 100644 --- a/src/main/java/com/zy/common/utils/NavigateMapData.java +++ b/src/main/java/com/zy/common/utils/NavigateMapData.java @@ -35,14 +35,14 @@ @Autowired private BasMapService basMapService; - public int[][] getData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { + public int[][] getData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { try { BasMap basMap = basMapService.selectLatestMap(lev); String originData = basMap.getOriginData(); //瑙f瀽json鍦板浘鏁版嵁 ArrayList arrayList = JSON.parseObject(originData, ArrayList.class); - List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁 + List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁 int[][] map = new int[lists.size()][]; int j = 0; for (List<MapNode> list : lists) { @@ -66,7 +66,7 @@ /** * 灏濊瘯浠巖edis鑾峰彇鏁版嵁 */ - public int[][] getDataFromRedis(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { + public int[][] getDataFromRedis(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); Object o = redisUtil.get(RedisKeyType.MAP.key + lev); if (o == null) { @@ -74,15 +74,15 @@ } BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); - return this.getDataFormString(lev, basMap.getData(), mapType, whitePoints, shuttlePoints); + return this.getDataFormString(lev, basMap.getData(), mapTypes, whitePoints, shuttlePoints); } /** * 浠嶭ist鏁版嵁涓幏鍙栧湴鍥� */ - public int[][] getDataFormString(Integer lev, String data, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { + public int[][] getDataFormString(Integer lev, String data, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { ArrayList arrayList = JSON.parseObject(data, ArrayList.class); - List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁 + List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁 int[][] map = new int[lists.size()][]; int j = 0; for (List<MapNode> list : lists) { @@ -139,18 +139,30 @@ * @param whitePoints 鐧藉悕鍗曡妭鐐癸紝涓嶉渶瑕佽杩囨护 * @param shuttlePoints 绌挎杞﹁妭鐐癸紝闇�瑕佸姞杞借繘鍦板浘 */ - public List<List<MapNode>> filterMap(Integer mapType, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { + public List<List<MapNode>> filterMap(List<NavigationMapType> mapTypes, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { //閲嶅缓鏁版嵁鏍煎紡 List<List<MapNode>> lists = rebuildData(arrayList); - //杞藉叆搴撲綅淇℃伅 - lists = loadLocMast(mapType, lists, lev, whitePoints); + List<NavigationMapType> locMapType = new ArrayList<>(); + locMapType.add(NavigationMapType.NONE); + locMapType.add(NavigationMapType.DFX); + locMapType.add(NavigationMapType.NORMAL); + for (NavigationMapType mapType : mapTypes) { + if(locMapType.contains(mapType)) { + //杞藉叆搴撲綅淇℃伅 + lists = loadLocMast(mapType.id, lists, lev, whitePoints); + } - //鍔犺浇杞﹁締 - lists = loadShuttle(lists, shuttlePoints); + if (mapType.equals(NavigationMapType.SHUTTLE)) { + //鍔犺浇杞﹁締 + lists = loadShuttle(lists, shuttlePoints); + } - //鍔犺浇璐у弶鎻愬崌鏈虹偣浣� - lists = loadForkLift(lists, mapType, lev); + if (mapType.equals(NavigationMapType.SHUTTLE)) { + //鍔犺浇璐у弶鎻愬崌鏈虹偣浣� + lists = loadForkLift(lists, lev); + } + } //鍔犺浇鐧藉悕鍗曡妭鐐� lists = loadWhite(lists, lev, whitePoints); @@ -283,7 +295,7 @@ } //鍔犺浇璐у弶鎻愬崌鏈虹偣浣� - public List<List<MapNode>> loadForkLift(List<List<MapNode>> lists, Integer mapType, Integer lev) { + public List<List<MapNode>> loadForkLift(List<List<MapNode>> lists, Integer lev) { try { //鍔犺浇璐у弶鎻愬崌鏈烘斁璐х偣浣嶆暟鎹� List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() @@ -304,16 +316,16 @@ List<MapNode> list = lists.get(row); MapNode mapNode = list.get(bay); - if (mapType == NavigationMapType.DFX.id) { - //杞﹁締鏈夎揣 - if (staProtocol.getHasTray() != null && staProtocol.getHasTray()) { - mapNode.setValue(MapNodeType.DISABLE.id); - } - } else { - if (staProtocol.getHasCar() != null && staProtocol.getHasCar()) { - mapNode.setValue(MapNodeType.CAR.id); - } - } +// if (mapType == NavigationMapType.DFX.id) { +// //杞﹁締鏈夎揣 +// if (staProtocol.getHasTray() != null && staProtocol.getHasTray()) { +// mapNode.setValue(MapNodeType.DISABLE.id); +// } +// } else { +// if (staProtocol.getHasCar() != null && staProtocol.getHasCar()) { +// mapNode.setValue(MapNodeType.CAR.id); +// } +// } //鏇存柊list list.set(bay, mapNode); diff --git a/src/main/java/com/zy/common/utils/NavigateMapUtils.java b/src/main/java/com/zy/common/utils/NavigateMapUtils.java index 59fbc88..6a43158 100644 --- a/src/main/java/com/zy/common/utils/NavigateMapUtils.java +++ b/src/main/java/com/zy/common/utils/NavigateMapUtils.java @@ -48,7 +48,10 @@ BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); //甯﹀皬杞﹀湴鍥� - List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, shuttlePoints);//鑾峰彇甯﹀皬杞﹀湴鍥炬暟鎹� + List<NavigationMapType> mapTypes = new ArrayList<>(); + mapTypes.add(NavigationMapType.NONE); + mapTypes.add(NavigationMapType.SHUTTLE); + List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(mapTypes, arrayList, lev, null, shuttlePoints);//鑾峰彇甯﹀皬杞﹀湴鍥炬暟鎹� //鑾峰彇鍏ㄩ儴鍦板浘鏁版嵁 List<List<MapNode>> lists = navigateMapData.rebuildData(arrayList); diff --git a/src/main/java/com/zy/common/utils/NavigateSolution.java b/src/main/java/com/zy/common/utils/NavigateSolution.java index 1967be1..3fc56ed 100644 --- a/src/main/java/com/zy/common/utils/NavigateSolution.java +++ b/src/main/java/com/zy/common/utils/NavigateSolution.java @@ -5,6 +5,7 @@ import com.core.common.SpringUtils; import com.core.exception.CoolException; import com.zy.common.model.NavigateNode; +import com.zy.common.model.enums.NavigationMapType; import com.zy.core.enums.MapNodeType; import com.zy.core.model.PythonResult; import com.zy.system.entity.Config; @@ -25,10 +26,10 @@ int[][] map = {{}}; - public NavigateSolution(Integer mapType, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { + public NavigateSolution(List<NavigationMapType> mapTypes, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { //杞藉叆鍦板浘鎸囧畾灞傞珮鍦板浘 NavigateMapData mapData = SpringUtils.getBean(NavigateMapData.class); - int[][] data = mapData.getDataFromRedis(lev, mapType, whitePoints, shuttlePoints); + int[][] data = mapData.getDataFromRedis(lev, mapTypes, whitePoints, shuttlePoints); if (data == null) { throw new CoolException("鍦板浘鏈浇鍏ワ紒"); } diff --git a/src/main/java/com/zy/common/utils/NavigateUtils.java b/src/main/java/com/zy/common/utils/NavigateUtils.java index 3fa02a9..13888cf 100644 --- a/src/main/java/com/zy/common/utils/NavigateUtils.java +++ b/src/main/java/com/zy/common/utils/NavigateUtils.java @@ -32,11 +32,11 @@ @Autowired private NavigateMapData navigateMapData; - public List<NavigateNode> calc(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) { - return calcJava(startPoint, endPoint, mapType, shuttlePoints, whites); + public List<NavigateNode> calc(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites) { + return calcJava(startPoint, endPoint, mapTypes, shuttlePoints, whites); } - public List<NavigateNode> calcJava(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) { + public List<NavigateNode> calcJava(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites) { //閫氳繃寮�濮嬬紪鍙峰拰缁撴潫缂栧彿鑾峰彇瀵瑰簲鐨剎y杞村潗鏍� int[] startArr = NavigatePositionConvert.positionToXY(startPoint);//寮�濮嬭妭鐐� int[] endArr = NavigatePositionConvert.positionToXY(endPoint);//缁撴潫鑺傜偣 @@ -49,7 +49,7 @@ //鑾峰彇褰撳墠鑺傜偣璁$畻鐨勫眰楂橈紝骞惰祴鍊煎埌姣忎竴涓妭鐐逛腑 int lev = Utils.getLev(startPoint); - NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints); + NavigateSolution solution = new NavigateSolution(mapTypes, lev, whiteList, shuttlePoints); int[][] map = solution.map; //鍒濆鍖栧紑濮嬭妭鐐� @@ -109,7 +109,7 @@ return list; } - public List<NavigateNode> calcPython(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) { + public List<NavigateNode> calcPython(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites) { //閫氳繃寮�濮嬬紪鍙峰拰缁撴潫缂栧彿鑾峰彇瀵瑰簲鐨剎y杞村潗鏍� int[] startArr = NavigatePositionConvert.positionToXY(startPoint);//寮�濮嬭妭鐐� int[] endArr = NavigatePositionConvert.positionToXY(endPoint);//缁撴潫鑺傜偣 @@ -122,7 +122,7 @@ //鑾峰彇褰撳墠鑺傜偣璁$畻鐨勫眰楂橈紝骞惰祴鍊煎埌姣忎竴涓妭鐐逛腑 int lev = Utils.getLev(startPoint); - NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints); + NavigateSolution solution = new NavigateSolution(mapTypes, lev, whiteList, shuttlePoints); int[][] map = solution.map; //鍒濆鍖栧紑濮嬭妭鐐� @@ -189,9 +189,9 @@ } //璁$畻甯︽湯绔钀借矾寰� - public ArrayList<ArrayList<NavigateNode>> calcEndPath(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { + public ArrayList<ArrayList<NavigateNode>> calcEndPath(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { //璁$畻璺緞 - List<NavigateNode> navigateNodes = calc(startPoint, endPoint, mapType, shuttlePoints, whites); + List<NavigateNode> navigateNodes = calc(startPoint, endPoint, mapTypes, shuttlePoints, whites); if (navigateNodes == null) { News.error("{} dash {} can't find navigate path!", startPoint, endPoint); return null; @@ -215,8 +215,8 @@ } //璁$畻鏈娈佃惤鍦板潃 - public String calcEndLocation(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { - ArrayList<ArrayList<NavigateNode>> endPath = calcEndPath(startPoint, endPoint, mapType, shuttlePoints, whites, lastPathPart); + public String calcEndLocation(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { + ArrayList<ArrayList<NavigateNode>> endPath = calcEndPath(startPoint, endPoint, mapTypes, shuttlePoints, whites, lastPathPart); if (endPath == null) { return null; } @@ -403,7 +403,7 @@ * 妫�娴嬭矾寰勬槸鍚﹀彲鐢�(鍙蛋) */ public boolean checkPathIsAvailable(List<NavigateNode> path, Integer shuttleNo, Integer lev) { - int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.DFX.id, null, Utils.getShuttlePoints(shuttleNo, lev)); + int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.getDfxWithDevice(), null, Utils.getShuttlePoints(shuttleNo, lev)); for (NavigateNode node : path) { int value = map[node.getX()][node.getY()]; if (value != MapNodeType.NORMAL_PATH.id && value != MapNodeType.MAIN_PATH.id && value != MapNodeType.CHARGE.id && value != MapNodeType.CONVEYOR_CAR_GO.id) {//姣嶈建閬�3銆佸瓙杞ㄩ亾0銆佸厖鐢垫々5銆佸皬杞﹀彲璧拌緭閫佺珯 @@ -479,7 +479,7 @@ public boolean checkLocPathIsAvailable(String startLocNo, String endLocNo) { List<int[]> shuttlePoints = Utils.getShuttlePoints(0, Utils.getLev(startLocNo)); //璁$畻搴撲綅鍒版彁鍗囨満搴撲綅锛岃矾寰勬槸鍚﹀彲鐢� - List<NavigateNode> nodeList = this.calc(startLocNo, endLocNo, NavigationMapType.DFX.id, shuttlePoints, null); + List<NavigateNode> nodeList = this.calc(startLocNo, endLocNo, NavigationMapType.getMapTypes(NavigationMapType.DFX), shuttlePoints, null); if (nodeList == null) { return false; } diff --git a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java index b9d252e..6869199 100644 --- a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java +++ b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java @@ -10,6 +10,7 @@ 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; @@ -50,11 +51,11 @@ @Autowired private DeviceConfigService deviceConfigService; - public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { - return getStartToTargetCommands(startLocNo, endLocNo, mapType, null, assignCommand, shuttleThread); + public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { + return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread); } - public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, Integer mapType, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { + public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); if (shuttleProtocol == null) { return null; @@ -62,7 +63,7 @@ Integer shuttleNo = shuttleProtocol.getShuttleNo(); //鑾峰彇灏忚溅绉诲姩閫熷害 Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000); - List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites); + List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites); if (nodeList == null) { News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo); shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo); @@ -122,7 +123,7 @@ return commands; } - public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { + public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo); NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo); List<NavigateNode> unlockPath = new ArrayList<>(); @@ -145,7 +146,7 @@ //鑾峰彇灏忚溅绉诲姩閫熷害 Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000); - List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null); + List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null); if (nodeList == null) { News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo); shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo); diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java index f9fffa0..1bfe527 100644 --- a/src/main/java/com/zy/core/action/ShuttleAction.java +++ b/src/main/java/com/zy/core/action/ShuttleAction.java @@ -5,19 +5,19 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.zy.asrs.domain.param.CreateLocMoveTaskParam; import com.zy.asrs.entity.BasShuttleOpt; import com.zy.asrs.entity.LocMast; import com.zy.asrs.entity.WrkMast; import com.zy.asrs.service.BasShuttleOptService; -import com.zy.asrs.service.BasShuttleService; import com.zy.asrs.service.LocMastService; import com.zy.asrs.service.WrkMastService; import com.zy.asrs.utils.Utils; import com.zy.common.ExecuteSupport; import com.zy.common.model.NavigateNode; +import com.zy.common.service.CommonService; import com.zy.common.utils.NavigateMapUtils; import com.zy.common.utils.RedisUtil; -import com.zy.common.utils.ShuttleOperaUtils; import com.zy.core.News; import com.zy.core.cache.SlaveConnection; import com.zy.core.dispatcher.ShuttleDispatchUtils; @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Random; @Component public class ShuttleAction { @@ -45,8 +46,6 @@ private RedisUtil redisUtil; @Autowired private NavigateMapUtils navigateMapUtils; - @Autowired - private BasShuttleService basShuttleService; @Autowired private LocMastService locMastService; @Autowired @@ -59,6 +58,8 @@ private WrkMastService wrkMastService; @Autowired private ShuttleDispatchUtils shuttleDispatchUtils; + @Autowired + private CommonService commonService; public synchronized boolean assignWork(Integer shuttleNo, ShuttleAssignCommand assignCommand) { ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); @@ -365,7 +366,92 @@ return; } - shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleNo); + shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleProtocol.getShuttleNo()); + } + + public synchronized void demoModeCargoMove() { + Config demoCargoMoveConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoCargoMove")); + if (demoCargoMoveConfig == null) { + return; + } + + if (!demoCargoMoveConfig.getValue().equals("Y")) { + return; + } + + + Config demoRunLevConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoRunLev")); + if (demoRunLevConfig == null) { + return; + } + List<Integer> levList = JSON.parseArray(demoRunLevConfig.getValue(), Integer.class); + Random random = new Random(); + int index = random.nextInt(levList.size()); + Integer lev = levList.get(index); + + //鑾峰彇妤煎眰灏忚溅鏁伴噺 + int shuttleCountByLev = shuttleDispatchUtils.getShuttleCountByLev(lev); + //鑾峰彇妤煎眰璐х墿鎼繍浠诲姟 + int currentLevTask = 0; + for (WrkMast wrkMast : wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("io_type", WrkIoType.LOC_MOVE.id))) { + if (Utils.getLev(wrkMast.getLocNo()) == lev) { + currentLevTask += 1; + } + } + + //鎼繍浠诲姟鏁伴噺瓒呰繃灏忚溅鏁伴噺锛屾殏鏃朵笉鐢熸垚鏂颁换鍔� + if (currentLevTask > shuttleCountByLev) { + return; + } + + LocMast sourceLoc = null; + EntityWrapper<LocMast> wrapper = new EntityWrapper<>(); + wrapper.eq("lev1", lev); + wrapper.eq("loc_sts", "F"); + wrapper.last("ORDER BY RAND() LIMIT 1"); + for (int i = 0; i < 3; i++) { + LocMast locMast = locMastService.selectOne(wrapper); + if(locMast == null) { + continue; + } + + sourceLoc = locMast; + break; + } + + if(sourceLoc == null) { + return; + } + + LocMast targetLoc = null; + EntityWrapper<LocMast> targetWrapper = new EntityWrapper<>(); + targetWrapper.eq("lev1", lev); + targetWrapper.eq("loc_sts", "O"); + targetWrapper.last("ORDER BY RAND() LIMIT 1"); + for (int i = 0; i < 3; i++) { + LocMast locMast = locMastService.selectOne(targetWrapper); + if(locMast == null) { + continue; + } + + targetLoc = locMast; + break; + } + + if(targetLoc == null) { + return; + } + + try { + CreateLocMoveTaskParam param = new CreateLocMoveTaskParam(); + param.setSourceLocNo(sourceLoc.getLocNo()); + param.setLocNo(targetLoc.getLocNo()); + param.setTaskPri(13); + + boolean result = commonService.createLocMoveTask(param); + } catch (Exception e) { + e.printStackTrace(); + } } // //璺戝簱绋嬪簭 diff --git a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java index 9062069..38e09c4 100644 --- a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java +++ b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java @@ -129,7 +129,7 @@ //褰撳墠绌挎杞﹀簱浣嶅彿 String currentLocNo = shuttleProtocol.getCurrentLocNo(); //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈 - List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘 + List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, new ArrayList<NavigationMapType>(){{add(NavigationMapType.NORMAL);}}, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘 if (currentShuttlePath == null) { continue; } @@ -174,7 +174,7 @@ int currentLev = Utils.getLev(currentLocNo); //鍒ゆ柇褰撳墠妤煎眰鏄惁鏈変换鍔★紝濡傛灉鏈夊垯涓嶅垎閰嶈繖杈嗚溅 List<WrkMast> wrkMasts1 = wrkMastService.selectWrkByLev(currentLev); - int shuttleCount = this.getShuttleCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲� + int shuttleCount = this.getShuttleEnableUseCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲� if (!wrkMasts1.isEmpty() && shuttleCount <= 1) { //瀛樺湪鍏朵粬浠诲姟涓斿彲鐢ㄥ皬杞︽暟閲忓皬浜庣瓑浜�1锛岃烦杩囪繖杈嗚溅 continue; @@ -498,7 +498,7 @@ String locNo = forkLiftStaProtocol.getLocNo();//绔欑偣搴撲綅鍙� //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈 - List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//浣跨敤姝e父閫氶亾鍦板浘 + List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.getMapTypes(NavigationMapType.NORMAL), Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//浣跨敤姝e父閫氶亾鍦板浘 if (currentShuttlePath == null) { continue; } @@ -528,7 +528,7 @@ /** * 鑾峰彇妤煎眰鍙敤灏忚溅鏁伴噺 */ - public int getShuttleCountByLev(int lev) { + public int getShuttleEnableUseCountByLev(int lev) { List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() .eq("device_type", String.valueOf(SlaveType.Shuttle))); int count = 0; @@ -561,4 +561,36 @@ return count; } + /** + * 鑾峰彇妤煎眰灏忚溅鏁伴噺 + */ + public int getShuttleCountByLev(int lev) { + List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() + .eq("device_type", String.valueOf(SlaveType.Shuttle))); + int count = 0; + for (DeviceConfig device : shuttleList) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); + if (shuttleThread == null) { + continue; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + continue; + } + + if (shuttleProtocol.getCurrentLocNo() == null) { + continue; + } + + if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) == lev) { + //鍚屼竴妤煎眰鍙敤灏忚溅 + count++; + continue; + } + } + return count; + } + } diff --git a/src/main/java/com/zy/core/task/ShuttleDemoScheduler.java b/src/main/java/com/zy/core/task/ShuttleDemoScheduler.java index 6e02c01..1ca4fdf 100644 --- a/src/main/java/com/zy/core/task/ShuttleDemoScheduler.java +++ b/src/main/java/com/zy/core/task/ShuttleDemoScheduler.java @@ -30,4 +30,9 @@ } } + @Scheduled(cron = "0/3 * * * * ? ") + public synchronized void executeCargoMove() { + shuttleAction.demoModeCargoMove(); + } + } 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 bb2eaf3..ad23b1c 100644 --- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java @@ -732,7 +732,7 @@ //灏嗚矾寰勯攣涓庡皬杞﹁矾寰勮繘琛屽尮閰� ArrayList<NavigateNode> tmp = new ArrayList<>(); //妫�娴嬭矾寰勬槸鍚﹁閿佸畾 - int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.DFX.id, null, null); + int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.getDfxWithDevice(), null, null); for (NavigateNode node : path) { if(map[node.getX()][node.getY()] == -999) { tmp.add(node); -- Gitblit v1.9.1