From c5c290a0da0a73371f3890a41cc66e02cd6b24a6 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期一, 16 十月 2023 16:56:39 +0800 Subject: [PATCH] #检测目标楼层车数量是否小于允许的最大数量 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 251 ++++++++++++++++++++++--------------------------- 1 files changed, 113 insertions(+), 138 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 5b6cae4..ed89dab 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -102,6 +102,8 @@ private RedisUtil redisUtil; @Autowired private WrkMastLocMapper wrkMastLocMapper; + @Autowired + private BasLiftOptService basLiftOptService; /** @@ -846,6 +848,10 @@ return false;//鍑哄簱绔欑偣涓嶅瓨鍦� } + if (!basDevp.getAutoing().equals("Y")) { + return false;//涓嶆槸鑷姩鐘舵�� + } + if (!basDevp.getOutEnable().equals("Y")) { return false;//鍑哄簱绔欑偣涓嶅彲鍑� } @@ -1291,8 +1297,14 @@ && liftProtocol.getTaskNo() != 0 && !liftProtocol.getBusy() ) { + BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString()); + int taskNo = liftProtocol.getTaskNo().intValue(); + if (basLiftOpt != null) { + taskNo = basLiftOpt.getWrkNo(); + } + //灏嗕换鍔℃。鏍囪涓哄畬鎴� - WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(liftProtocol.getTaskNo().intValue()); + WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); if (wrkMast != null) { switch (wrkMast.getWrkSts().intValue()) { case 3://3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴� @@ -1307,15 +1319,16 @@ wrkMast.setWrkSts(25L); if (wrkMast.getIoType() == 11) {//搴撲綅绉昏浆 wrkMast.setWrkSts(4L);//4.鎻愬崌鏈烘惉杩愬畬鎴� + }else { + if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { + //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚 + wrkMast.setWrkSts(29L); + } } + if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { //閲婃斁鎻愬崌鏈轰护鐗� liftProtocol.setToken(0); - } - - if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { - //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚 - wrkMast.setWrkSts(29L); } break; @@ -1530,14 +1543,47 @@ private boolean locToLocExecuteStep3(WrkMast wrkMast) { Date now = new Date(); if (wrkMast.getWrkSts() == 23) {//23.灏忚溅鎼繍瀹屾垚 + //婧愮珯 + Integer sourceStaNo = wrkMast.getSourceStaNo(); + //鐩爣绔� + Integer staNo = wrkMast.getStaNo(); + if (sourceStaNo == null || staNo == null) { + return false;//婧愮珯鎴栫洰鏍囩珯涓虹┖ + } + + int liftNo = staNo / 100;//鑾峰彇鎻愬崌鏈哄彿 + //鑾峰彇鎻愬崌鏈虹嚎绋� - LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); if (liftThread == null) { return false; } LiftProtocol liftProtocol = liftThread.getLiftProtocol(); if (liftProtocol == null) { return false; + } + + //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐� + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo())); + if (liftStaProtocol == null) { + return false;//鎵句笉鍒扮珯鐐� + } + + if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { + return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹湁鎵樼洏 + } + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + return false; + } + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { + //灏忚溅杩樺湪杈撻�佺珯鐐� + //璋冨害灏忚溅閬胯 + boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread); + if (!result) { + return false; + } } if (!liftProtocol.isIdle()) { @@ -1548,14 +1594,6 @@ WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { return false; - } - - //婧愮珯 - Integer sourceStaNo = wrkMast.getSourceStaNo(); - //鐩爣绔� - Integer staNo = wrkMast.getStaNo(); - if (sourceStaNo == null || staNo == null) { - return false;//婧愮珯鎴栫洰鏍囩珯涓虹┖ } //鑾峰彇鎻愬崌鏈哄懡浠� @@ -1592,13 +1630,17 @@ private boolean locToLocExecuteStep4(WrkMast wrkMast) { if (wrkMast.getWrkSts() == 4) {//4.鎻愬崌鏈烘惉杩愬畬鎴� //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐� - BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo()); - if (targetBasDevp == null) { - return false;//缂哄皯绔欑偣淇℃伅 + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(wrkMast.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); + if (liftStaProtocol == null) { + return false;//鎵句笉鍒扮珯鐐� + } + + if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { + return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹湁鎵樼洏 } if (wrkMast.getShuttleNo() == null) { - shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐� + shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐� return false; } @@ -1616,14 +1658,14 @@ } //鍒ゆ柇灏忚溅鏄惁鍒拌揪鐩爣杈撻�佺珯鐐� - if (!shuttleProtocol.getCurrentLocNo().equals(targetBasDevp.getLocNo())) { + if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { //灏忚溅涓嶅湪鐩爣杈撻�佺珯鐐� - shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐� + shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐� return false; } //灏忚溅宸叉姷杈剧洰鏍囪緭閫佺珯鐐癸紝灏嗚揣鐗╂惉杩愬埌鐩爣搴撲綅 - NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo()); + NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getLocNo()); if (result == null) {//璺緞璁$畻澶辫触 return false; } @@ -2001,58 +2043,56 @@ continue;//娌℃湁绌洪棽绔欑偣 } - targetSta = (short) 317; - if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { //鍚慉GV鍙戣捣缁勬墭璇锋眰 -// try { -// HashMap<String, Object> param = new HashMap<>(); -// param.put("wrkNo", wrkMast.getWrkNo()); -// String response = new HttpHandler.Builder() -// .setUri(wmsUrl) -// .setPath("/openAGV") -// .setJson(JSON.toJSONString(param)) -// .build() -// .doPost(); -// JSONObject jsonObject = JSON.parseObject(response); -// Integer code = jsonObject.getInteger("code"); -// if (code.equals(200)) {//AGV缁勬墭鎴愬姛 -// //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 -// wrkMast.setStaNo(targetSta.intValue()); -// wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 -// if (wrkMastMapper.updateById(wrkMast) > 0) { -// //鍚�300绔欏啓鍏ョ洰鏍囩珯 -// staProtocol = staProtocol.clone(); -// staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯 -// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); -// try { -// Thread.sleep(500); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// continue; -// } -// } -// } catch (Exception e) { -// e.printStackTrace(); -// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); -// } - - //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 - wrkMast.setStaNo(targetSta.intValue()); - wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 - if (wrkMastMapper.updateById(wrkMast) > 0) { - //鍚�300绔欏啓鍏ョ洰鏍囩珯 - staProtocol = staProtocol.clone(); - staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯 - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - try { - Thread.sleep(500); - } catch (Exception e) { - e.printStackTrace(); + try { + HashMap<String, Object> param = new HashMap<>(); + param.put("wrkNo", wrkMast.getWrkNo()); + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/replenishment") + .setJson(JSON.toJSONString(param)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) {//AGV缁勬墭鎴愬姛 + //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 + wrkMast.setStaNo(targetSta.intValue()); + wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 + if (wrkMastMapper.updateById(wrkMast) > 0) { + //鍚�300绔欏啓鍏ョ洰鏍囩珯 + staProtocol = staProtocol.clone(); + staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯 + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + try { + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } + continue; + } } - continue; + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } + +// //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 +// wrkMast.setStaNo(targetSta.intValue()); +// wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 +// if (wrkMastMapper.updateById(wrkMast) > 0) { +// //鍚�300绔欏啓鍏ョ洰鏍囩珯 +// staProtocol = staProtocol.clone(); +// staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯 +// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); +// try { +// Thread.sleep(500); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// continue; +// } } } } @@ -2142,11 +2182,11 @@ private boolean agvRestockCall(String staNo, String barcode) { try { HashMap<String, Object> param = new HashMap<>(); - param.put("staNo", staNo); - param.put("barcode", barcode); + param.put("devNo", staNo); + param.put("containerCode", barcode); String response = new HttpHandler.Builder() .setUri(wmsUrl) - .setPath("/callAGV") + .setPath("/rpc/start") .setJson(JSON.toJSONString(param)) .build() .doPost(); @@ -2582,8 +2622,6 @@ if (!stepMoveLoc) { continue; } - -// this.shuttleMoveExecuteStepClearWrkMast(wrkMast);//娓呯悊111.灏忚溅绉诲姩瀹屾垚 } } @@ -3146,69 +3184,6 @@ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); } } - return true; - } - - /** - * 灏忚溅杩佺Щ-娓呯悊111.灏忚溅绉诲姩瀹屾垚 - */ - private boolean shuttleMoveExecuteStepClearWrkMast(WrkMast wrkMast) { - if (wrkMast.getWrkSts() == 111) { - //鑾峰彇鍥涘悜绌挎杞︾嚎绋� - NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); - if (shuttleThread == null) { - return false; - } - NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); - if (shuttleProtocol == null) { - return false; - } - - //灏忚溅澶勪簬绌洪棽鐘舵�� - if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) { - return false; - } - - Object o = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo()); - if (o != null) { - ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); - ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); - int size = assignCommand.getCommands().size(); - NyShuttleHttpCommand command = assignCommand.getCommands().get(size - 1);//鑾峰彇鏈�鍚庝竴娈靛懡浠� - if (!command.getComplete()) { - return false;//鏈�鍚庝竴娈靛懡浠よ繕鏈畬鎴愶紝涓嶅仛鎿嶄綔 - } - NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(shuttleProtocol.getCurrentLocNo())); - navigateMapData.writeNavigateNodeToRedisMap(assignCommand.getNodes(), false);//瑙i攣璺緞 - - //鍒犻櫎redis - redisUtil.del("shuttle_wrk_no_" + redisCommand.getWrkNo()); - } - - // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� - if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) { - log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={0}]澶辫触", wrkMast.getWrkNo()); - } - // 鍒犻櫎宸ヤ綔涓绘。 - if (!wrkMastService.deleteById(wrkMast)) { - log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={0}]澶辫触", wrkMast.getWrkNo()); - } - - //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� - shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); - //婧愬簱浣嶆竻闆� - shuttleProtocol.setSourceLocNo(null); - //鐩爣搴撲綅娓呴浂 - shuttleProtocol.setLocNo(null); - //浠诲姟鎸囦护娓呴浂 - shuttleProtocol.setAssignCommand(null); - //宸ヤ綔鍙锋竻闆� - shuttleProtocol.setTaskNo(0); - //娓呴櫎浠ょ墝 - shuttleProtocol.setToken(0); - News.info("鍥涘悜绌挎杞﹀凡纭涓旂Щ鍔ㄤ换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); - } - return true; } -- Gitblit v1.9.1