From d2fd7cfc1a426baabe4fac47f88b4db03432e22b Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 31 十月 2023 12:32:32 +0800 Subject: [PATCH] #websocket --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 140 +++++++++++++++++++++++++++++++--------------- 1 files changed, 94 insertions(+), 46 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 e70ce0f..bcdd0f3 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -863,6 +863,12 @@ return false;//鍑哄簱绔欑偣涓嶅彲鍑� } + Integer liftNo = basDevp.getLiftNo();//鎼滅储鍑哄簱鎻愬崌鏈烘槸鍚﹀瓨鍦ㄥ叆搴撲换鍔★紝濡傚瓨鍦ㄧ姝㈠嚭搴� + List<WrkMast> liftWrkMasts = wrkMastMapper.selectInWrkMastByLiftNo(liftNo); + if (!liftWrkMasts.isEmpty()) { + return false;//瀛樺湪鍏ュ簱浠诲姟锛岀姝㈠嚭搴� + } + //鑾峰彇婧愮珯 LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo())); if (liftStaProtocol == null) { @@ -1107,6 +1113,18 @@ if (!sourceBasDevp.getInEnable().equals("Y")) { return false;//绔欑偣涓嶅彲鍏� + } + + //鍒ゆ柇鎻愬崌鏈烘暣涓笁妤兼槸鍚﹂兘澶勪簬鍏ュ簱妯″紡 + Integer outInModel1 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 1); + Integer outInModel2 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 5); + Integer outInModel3 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 8); + if (outInModel1 == null || outInModel2 == null || outInModel3 == null) { + return false;//涓嶅瓨鍦ㄥ嚭鍏ュ簱妯″紡 + } + + if (outInModel1 == 2 || outInModel2 == 2 && outInModel3 == 2) { + return false;//鍙鏈変竴涓浜庡嚭搴撴ā寮忥紝绂佹鍏ュ簱 } LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo()); @@ -2015,10 +2033,10 @@ } /** - * AGV琛ヨ揣 => 鏈烘鑷傛嫞鏂� + * AGV琛ヨ揣 => 鐢熸垚鍏ュ簱閫氱煡妗� */ - public void agvRestockByRobot() { - //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 + public void robotGenerateAgvTask() { +//妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 for (DevpSlave devp : slaveProperties.getDevp()) { // 鑾峰彇鍏ュ簱绔欎俊鎭� DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); @@ -2048,7 +2066,7 @@ } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) { //鑷姩銆佹棤鐗� targetSta = (short) 317; - }else { + } else { continue;//娌℃湁绌洪棽绔欑偣 } @@ -2107,9 +2125,23 @@ } } } + } + } + /** + * AGV琛ヨ揣 => 鏈烘鑷傛嫞鏂� + */ + public void agvRestockByRobot() { + //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 + for (DevpSlave devp : slaveProperties.getDevp()) { + // 鑾峰彇鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol303 = devpThread.getStation().get(303); StaProtocol staProtocol317 = devpThread.getStation().get(317); + if (staProtocol303 == null || staProtocol317 == null) { + continue; + } + if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) { //璋冨害鏈烘鑷� //鏌ヨ鏄惁鏈夊伐浣滄。 @@ -2172,7 +2204,7 @@ String barcode = barcodeThread.getBarcode(); if(!Cools.isEmpty(barcode)) { //閫氱煡AGV鍙栬揣 - agvRestockCall("CS-301-001-01@3", barcode); + agvRestockCall("301-1", barcode); log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); } } @@ -2186,7 +2218,7 @@ String barcode = barcodeThread.getBarcode(); if(!Cools.isEmpty(barcode)) { //閫氱煡AGV鍙栬揣 - agvRestockCall("CS-302-001-01@3", barcode); + agvRestockCall("302-1", barcode); log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); } } @@ -2694,6 +2726,18 @@ return false; } + //鑾峰彇婧愯緭閫佺珯 + LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); + if (liftSta == null) { + return false;//鎵句笉鍒扮珯鐐� + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) + WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftSta.getLiftNo()); + if (liftWrkMast != null) { + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�*************** List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(wrkMast.getStaNo()); if (targetNodes == null) { @@ -2709,18 +2753,6 @@ return false;//璺緞閿佸畾澶辫触 } //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�*************** - - //鑾峰彇婧愯緭閫佺珯 - LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); - if (liftSta == null) { - return false;//鎵句笉鍒扮珯鐐� - } - - //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) - WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftSta.getLiftNo()); - if (liftWrkMast != null) { - return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� - } //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id); @@ -3078,18 +3110,6 @@ return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍� } - //*************灏濊瘯瑙i攣鐩爣绔欒矾寰�*************** - List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo()); - if (targetNodes == null) { - return false;//鏈幏鍙栧埌鑺傜偣 - } - //灏濊瘯瑙i攣鐩爣绔欒矾寰� - boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//鎵�浣跨敤鐨勮矾寰勮繘琛岃В閿� - if (!result) { - return false;//璺緞瑙i攣澶辫触 - } - //*************灏濊瘯瑙i攣鐩爣绔欒矾寰�*************** - NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY()); liftNode.setZ(liftSta.getLev()); @@ -3154,22 +3174,26 @@ return false; } -// //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐� -// BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo()); -// if (targetBasDevp == null) { -// return false;//缂哄皯绔欑偣淇℃伅 -// } +// //璺ㄦゼ灞傜Щ鍔ㄤ换鍔� +// if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) { +// //鑾峰彇鐩爣绔� +// LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); +// if (liftSta == null) { +// return false;//鎵句笉鍒扮珯鐐� +// } // -// //鑾峰彇鎻愬崌鏈烘暟鎹� -// BasLift basLift = basLiftService.selectById(targetBasDevp.getLiftNo()); -// if (basLift == null) { -// return false;//娌℃湁鎻愬崌鏈烘暟鎹� +// //*************灏濊瘯瑙i攣鐩爣绔欒矾寰�*************** +// List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo()); +// if (targetNodes == null) { +// return false;//鏈幏鍙栧埌鑺傜偣 +// } +// //灏濊瘯瑙i攣鐩爣绔欒矾寰� +// boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//鎵�浣跨敤鐨勮矾寰勮繘琛岃В閿� +// if (!result) { +// return false;//璺緞瑙i攣澶辫触 +// } +// //*************灏濊瘯瑙i攣鐩爣绔欒矾寰�*************** // } -// if (basLift.getPoint() == null) { -// return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍� -// } -// NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY()); -// liftNode.setZ(basLift.getPoint$().getZ()); //灏忚溅宸茬粡鍦ㄧ洰鏍囧簱浣嶏紝鐩存帴璁ゅ畾灏忚溅绉诲姩浠诲姟瀹屾垚 if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) { @@ -3198,8 +3222,32 @@ return false; } - //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠� - NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id); + NyShuttleOperaResult result = null; + //璺ㄦゼ灞傜Щ鍔ㄤ换鍔� + if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) { + //闇�瑕佸皢鍓嶄袱涓妭鐐逛綔涓虹櫧鍚嶅崟鑺傜偣浼犲叆 + //鑾峰彇鐩爣绔� + LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); + if (liftSta == null) { + return false;//鎵句笉鍒扮珯鐐� + } + + List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo()); + if (targetNodes == null) { + return false;//鏈幏鍙栧埌鑺傜偣 + } + + //璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟 + ArrayList<int[]> whiteList = new ArrayList<>();//璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟 + for (NavigateNode node : targetNodes) { + whiteList.add(new int[]{node.getX(), node.getY()}); + } + result = NyShuttleOperaUtils.getStartToTargetCommandsByWhites(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, whiteList); + }else { + //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠� + result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id); + } + if (result == null) { return false;//璺緞璁$畻澶辫触 } -- Gitblit v1.9.1