From c4355edf683197a67e127c796e8f93650cc2a302 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期一, 19 六月 2023 19:02:38 +0800 Subject: [PATCH] 充电任务优化 --- src/main/java/com/zy/core/thread/ShuttleThread.java | 71 +++++++++++++++++------------------ 1 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/zy/core/thread/ShuttleThread.java b/src/main/java/com/zy/core/thread/ShuttleThread.java index 77dfe69..f8e571e 100644 --- a/src/main/java/com/zy/core/thread/ShuttleThread.java +++ b/src/main/java/com/zy/core/thread/ShuttleThread.java @@ -12,6 +12,7 @@ import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; import com.zy.common.model.NavigateNode; +import com.zy.common.model.enums.NavigationMapType; import com.zy.common.utils.*; import com.zy.core.News; import com.zy.core.ThreadHandler; @@ -365,6 +366,11 @@ OperateResult result = modbusTcpNet.Write("0", array);; if (result != null && result.IsSuccess) { + try { + Thread.sleep(3000);//鍛戒护涓嬪彂鍚庝紤鐪�1s + } catch (InterruptedException e) { + throw new RuntimeException(e); + } News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); return true; @@ -414,7 +420,7 @@ //灏忚溅绉诲姩鍒版彁鍗囨満鍙o紝璁$畻璺緞 //璁$畻灏忚溅璧风偣鍒颁腑鐐规墍闇�鍛戒护 LocMast currentLocMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString()); - List<NavigateNode> firstMastResult = NavigateUtils.calc(currentLocMast.getLocNo(), assignCommand.getSourceLocNo(), ShuttleTaskModeType.PAK_IN.id); + List<NavigateNode> firstMastResult = NavigateUtils.calc(currentLocMast.getLocNo(), assignCommand.getSourceLocNo(), NavigationMapType.NORMAL.id);//灏忚溅鍒颁腑鐐癸紝澶勪簬鏃犺揣鐘舵�侊紝浣跨敤姝e父閫氶亾鍦板浘 if (firstMastResult != null) { allNode.addAll(firstMastResult);//灏嗚妭鐐硅繘琛屼繚瀛� @@ -450,7 +456,7 @@ } //璁$畻涓偣鍒扮粓鐐硅矾寰� - List<NavigateNode> secMastResult = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getLocNo(), ShuttleTaskModeType.PAK_IN.id); + List<NavigateNode> secMastResult = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getLocNo(), NavigationMapType.DFX.id);//灏忚溅浠庝腑鐐瑰埌缁堢偣锛屽浜庢湁璐х姸鎬侊紝浣跨敤DFX鍦板浘 if (secMastResult != null) { allNode.addAll(secMastResult);//灏嗚妭鐐硅繘琛屼繚瀛� @@ -478,15 +484,14 @@ commands.add(getPalletCommand((short) 2)); } - navigateMapData = new NavigateMapData(Utils.getLev(currentLocMast.getLocNo())); - if (firstMastResult != null) { - //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� - navigateMapData.writeNavigateNodeToRedisMap(firstMastResult, true);////鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� + if (firstMastResult == null || secMastResult == null) { + throw new CoolException(MessageFormat.format( "鍥涘悜绌挎杞﹀嚭鍏ュ簱璺緞鎼滅储澶辫触 ===>> [id:{0}] [ip:{1}] [port:{2}]", slave.getId(), slave.getIp(), slave.getPort())); } - if (secMastResult != null) { - navigateMapData.writeNavigateNodeToRedisMap(secMastResult, true);////鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� - } + navigateMapData = new NavigateMapData(Utils.getLev(currentLocMast.getLocNo())); + //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� + navigateMapData.writeNavigateNodeToRedisMap(firstMastResult, true);////鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� + navigateMapData.writeNavigateNodeToRedisMap(secMastResult, true);////鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� break; case 3://鎵樼洏椤跺崌 case 4://鎵樼洏涓嬮檷 @@ -536,7 +541,7 @@ } LocMast locMast = locMastService.queryByQrCode(startQr); - List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), assignCommand.getLocNo(), ShuttleTaskModeType.PAK_IN.id); + List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), assignCommand.getLocNo(), NavigationMapType.NONE.id);//鎵嬪姩鍛戒护-绉诲姩鍛戒护锛屼娇鐢ㄦ棤杩囨护鍦板浘 if (result != null) { //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� @@ -572,7 +577,7 @@ int lev = Utils.getLev(locMast1.getLocNo());//绌挎杞﹀綋鍓嶉珮搴� String liftSiteLocNo = Utils.levToOutInStaLocNo(lev);//褰撳墠妤煎眰绔欑偣搴撲綅鍙� LocMast liftSitelocMast = locMastService.selectById(liftSiteLocNo); - List<NavigateNode> result1 = NavigateUtils.calc(locMast1.getLocNo(), liftSiteLocNo, ShuttleTaskModeType.PAK_IN.id); + List<NavigateNode> result1 = NavigateUtils.calc(locMast1.getLocNo(), liftSiteLocNo, NavigationMapType.NONE.id);//绉诲姩鍒版彁鍗囨満锛屼娇鐢ㄦ棤杩囨护鍦板浘 Short endStartCode = null; if (result1 != null) { @@ -675,7 +680,7 @@ shuttleProtocol.setPakMk(true); return true; }else { - List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), distLocMast.getLocNo(), ShuttleTaskModeType.PAK_IN.id); + List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), distLocMast.getLocNo(), NavigationMapType.DFX.id);//閿欒鎭㈠锛屼娇鐢―FX鍦板浘 if (result != null) { //鑾峰彇鍒嗘璺緞 ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(result); @@ -781,7 +786,6 @@ } } - //涓嬪彂鍛戒护 if (!write(command)) { News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); @@ -789,10 +793,22 @@ } else { News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙戞垚鍔燂紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); - try { - Thread.sleep(1000);//鍛戒护涓嬪彂瀹屽悗浼戠湢1s - } catch (InterruptedException e) { - throw new RuntimeException(e); + //淇濆瓨鏁版嵁鍒版暟鎹簱鍋氭祦姘� + BasShuttleOptService shuttleOptService = SpringUtils.getBean(BasShuttleOptService.class); + if (shuttleOptService != null) { + BasShuttleOpt opt = new BasShuttleOpt( + assignCommand.getTaskNo().intValue(), + assignCommand.getShuttleNo().intValue(), + new Date(), + ShuttleTaskModeType.get(assignCommand.getTaskMode()).desc, + assignCommand.getSourceLocNo(), + assignCommand.getLocNo(), + null, + null, + null, + JSON.toJSONString(command) + ); + shuttleOptService.insert(opt); } //鍒ゆ柇鏁版嵁鏄惁鎵ц瀹屾垚 @@ -805,23 +821,6 @@ redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); }else { //宸叉墽琛屽畬鎴� - //淇濆瓨鏁版嵁鍒版暟鎹簱鍋氭祦姘� - BasShuttleOptService shuttleOptService = SpringUtils.getBean(BasShuttleOptService.class); - if (shuttleOptService != null) { - BasShuttleOpt opt = new BasShuttleOpt( - assignCommand.getTaskNo().intValue(), - assignCommand.getShuttleNo().intValue(), - new Date(), - ShuttleTaskModeType.get(assignCommand.getTaskMode()).desc, - assignCommand.getSourceLocNo(), - assignCommand.getLocNo(), - null, - null, - null, - JSON.toJSONString(assignCommand) - ); - shuttleOptService.insert(opt); - } if (redisCommand.getLiftSecurityMk()) { //鏇鹃攣瀹氳繃鎻愬崌鏈猴紝闇�瑕佽繘琛岃В閿� @@ -856,7 +855,7 @@ }else { shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); } - News.info("鍥涘悜绌挎杞︿换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛岀┛姊溅鍙�={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); + News.info("鍥涘悜绌挎杞︿换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); } } @@ -1088,7 +1087,7 @@ * 姝e父绉诲姩鍛戒护,榛樿绉诲姩閫熷害1000 */ public ShuttleCommand getMoveCommand(Short startCodeNum, Short distCodeNum, Integer startToDistDistance, Short runDirection, Short middleCodeNum, Integer middleToDistDistance) { - return getMoveCommand(startCodeNum, distCodeNum, startToDistDistance, runDirection, middleCodeNum, middleToDistDistance, 1000); + return getMoveCommand(startCodeNum, distCodeNum, startToDistDistance, runDirection, middleCodeNum, middleToDistDistance, 500); } /** -- Gitblit v1.9.1