From ddeaa535350db85a54a041da6a4d74e50877d637 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 04 四月 2023 14:34:02 +0800 Subject: [PATCH] 修复寻路算法路线数据4(站点)无法移动问题 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 464 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 368 insertions(+), 96 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 538cced..0db902b 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -22,14 +22,8 @@ import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.*; import com.zy.core.model.*; -import com.zy.core.model.command.CrnCommand; -import com.zy.core.model.command.LedCommand; -import com.zy.core.model.command.ShuttleCommand; -import com.zy.core.model.command.SteCommand; -import com.zy.core.model.protocol.CrnProtocol; -import com.zy.core.model.protocol.ShuttleProtocol; -import com.zy.core.model.protocol.StaProtocol; -import com.zy.core.model.protocol.SteProtocol; +import com.zy.core.model.command.*; +import com.zy.core.model.protocol.*; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.*; import lombok.extern.slf4j.Slf4j; @@ -612,6 +606,195 @@ * 鍏ュ嚭搴� ===>> 鍥涘悜绌挎杞﹀叆鍑哄簱浣滀笟涓嬪彂 */ public synchronized void shuttleIoExecute() { + // 鏍规嵁杈撻�佺嚎plc閬嶅巻 + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻鍏ュ簱绔� + for (DevpSlave.StaRack rackInStn : devp.getRackInStn()) { + // 鑾峰彇鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + + StaProtocol staProtocol = devpThread.getStation().get(rackInStn.getStaNo()); + StaProtocol staProtocol105 = devpThread.getStation().get(105); + staProtocol105.setWorkNo((short) 752); + staProtocol105.setStaNo((short) 100); + + StaProtocol staProtocol106 = devpThread.getStation().get(106); + staProtocol106.setWorkNo((short) 753); + staProtocol106.setStaNo((short) 100); + + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + Short workNo = staProtocol.getWorkNo(); + + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 + if (true || staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()) { + WrkMast wrkMast = wrkMastMapper.selectRackInStep48(workNo, staProtocol.getSiteId()); + if (wrkMast != null) { + if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 8) { + ShuttleThread shuttleThread = null; + HashMap<String, Object> searchIdleShuttle = null; + if (wrkMast.getWrkSts() == 4) { + //瀵绘壘鏈�杩戜笖绌洪棽鐨勫洓鍚戠┛姊溅 + searchIdleShuttle = this.searchIdleShuttle(wrkMast); + shuttleThread = (ShuttleThread) searchIdleShuttle.get("result"); + }else { + //鐘舵��8锛屽洓鍚戠┛姊溅宸插湪鎻愬崌鏈哄彛锛岀瓑寰呭懡浠よ繘琛屽叆搴撴惉杩愬姩浣� + Integer shuttleNo = wrkMast.getShuttleNo();//鍥涘悜绌挎杞﹀彿 + shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); + } + + if (shuttleThread == null) { + continue; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (!shuttleProtocol.isIdle()) { + continue; + } + + wrkMast.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());//缁欏伐浣滄。鍒嗛厤鍥涘悜绌挎杞﹀彿 + + //鍒嗛厤浠诲姟鍙� + shuttleProtocol.setTaskNo(wrkMast.getWrkNo().shortValue()); + //鍒嗛厤婧愬簱浣� + shuttleProtocol.setSourceLocNo(wrkMast.getSourceLocNo()); + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + //鍥涘悜绌挎杞﹀彿 + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); + //浠诲姟鍙� + assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); + //鍏ュ嚭搴撴ā寮� + assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue()); + //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) + String currentLocNo = shuttleProtocol.getCurrentLocNo(); + assignCommand.setSourceLocNo(currentLocNo); + + if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { + //鍚屼竴灞� + //鍒嗛厤鐩爣搴撲綅 + shuttleProtocol.setLocNo(wrkMast.getLocNo()); + //鐩爣搴撲綅 + assignCommand.setLocNo(wrkMast.getLocNo()); + wrkMast.setWrkSts(9L);//灏忚溅鍏ュ簱涓� + }else { + //涓嶅悓灞傦紝灏嗙洰鏍囧簱浣嶅垎閰嶆垚鎻愬崌鏈哄簱浣嶅彿 + + //灏忚溅褰撳墠灞傞珮 + Integer currentLev = Integer.parseInt(currentLocNo.substring(currentLocNo.length() - 2, currentLocNo.length())); + + //鑾峰彇鎻愬崌鏈� + LiftSlave liftSlave = slaveProperties.getLift().get(0); + //鎻愬崌鏈哄簱浣嶅彿 + String liftLocNo = liftSlave.getLiftLocNo(currentLev); + shuttleProtocol.setLocNo(liftLocNo); + //鐩爣搴撲綅 + assignCommand.setLocNo(liftLocNo); + wrkMast.setWrkSts(5L);//灏忚溅杩佺Щ鐘舵�� + } + + if (wrkMastMapper.updateById(wrkMast) > 0) { + //涓嬪彂浠诲姟 + MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); + } + } + + } + } + + } + } + + } + + /** + * 鎼滅储绌洪棽涓旀渶杩戠殑鍥涘悜绌挎杞� + */ + public HashMap<String,Object> searchIdleShuttle(WrkMast wrkMast) { + HashMap<String, Object> map = new HashMap<>(); + String locNo = wrkMast.getWrkSts() < 10 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();//搴撲綅鍙� + LocMast locMast = locMastService.queryByLoc(locNo);//鎵惧埌搴撲綅璁板綍 + String lay = locNo.substring(locNo.length() - 2, locNo.length());//褰撳墠宸ヤ綔妗e簱浣嶅眰楂� + ShuttleThread recentShuttle = null;//褰撳墠璺濈鏈�杩戠殑鍥涘悜绌挎杞︾嚎绋� + + for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); + ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + continue; + } + if (!shuttleProtocol.isIdle()) { + continue; + } + + String shuttleLocNo = shuttleProtocol.getCurrentLocNo();//浜岀淮鐮佸搴斿簱浣嶅彿 + String shuttleLocNoLay = shuttleLocNo.substring(shuttleLocNo.length() - 2, shuttleLocNo.length());//搴撲綅鍙峰搴斿眰楂� + if (lay.equals(shuttleLocNoLay)) { + //褰撳墠鍥涘悜绌挎杞﹀拰宸ヤ綔妗d换鍔″湪鍚屼竴灞傦紝鍒欒皟閰嶈杞﹁締 + map.put("sameLay", true);//鍚屼竴灞� + map.put("result", shuttleThread); + return map; + } + + //鏇存柊褰撳墠鏈�杩戠殑鍥涘悜绌挎杞� + if (recentShuttle == null) { + recentShuttle = shuttleThread; + }else { + ShuttleProtocol recentShuttleProtocol = recentShuttle.getShuttleProtocol();//鐩墠鏈�杩戠┛姊溅 + String recentShuttleLocNo = recentShuttleProtocol.getCurrentLocNo();//浜岀淮鐮佸搴斿簱浣嶅彿 + String recentShuttleLocNoLay = recentShuttleLocNo.substring(recentShuttleLocNo.length() - 2, recentShuttleLocNo.length());//搴撲綅鍙峰搴斿眰楂� + + int recentShuttleLocNoLayInt = Integer.parseInt(recentShuttleLocNoLay); + int layInt = Integer.parseInt(lay); + int shuttleLocNoLayInt = Integer.parseInt(shuttleLocNoLay); + int i = Math.abs(layInt - recentShuttleLocNoLayInt);//宸ヤ綔妗fゼ灞傚噺鏈�杩戠┛姊溅妤煎眰锛屽彇缁濆鍊� + int j = Math.abs(layInt - shuttleLocNoLayInt);//宸ヤ綔妗fゼ灞傚噺褰撳墠绌挎杞︽ゼ灞傦紝鍙栫粷瀵瑰�� + if (i < j) { + //鏇存柊鏈�杩戠┛姊溅 + recentShuttle = shuttleThread; + } else if (i == j) { + //妤煎眰鐩稿悓鎯呭喌 + //鎵捐窛绂诲嚭搴撶偣鏈�杩戠殑杞� + + if (!(recentShuttleProtocol.isIdle() && shuttleProtocol.isIdle())) { + //鍙鏈変竴杈嗚溅涓嶆槸绌洪棽鍒欎笉杩涜璋冨害 + map.put("sameLay", false);//涓嶅悓灞� + map.put("result", null); + return map; + } + + //鑾峰彇鎻愬崌鏈� + LiftSlave liftSlave = slaveProperties.getLift().get(0); + //鎻愬崌鏈哄簱浣嶅彿 + String recentLiftLocNo = liftSlave.getLiftLocNo(recentShuttleLocNoLayInt); + String shuttleLiftLocNo = liftSlave.getLiftLocNo(shuttleLocNoLayInt); + + //褰撳墠鏈�杩戝洓鍚戠┛姊溅鍒版彁鍗囨満璺緞 + List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentShuttleLocNo, recentLiftLocNo, ShuttleTaskModeType.PAK_IN.id); + //褰撳墠妤煎眰鍥涘悜绌挎杞﹀埌鎻愬崌鏈鸿矾寰� + List<NavigateNode> shuttlePath = NavigateUtils.calc(shuttleLocNo, shuttleLiftLocNo, ShuttleTaskModeType.PAK_IN.id); + //鍒ゆ柇鍝竴涓矾寰勬渶鐭� + if (shuttlePath.size() < recentShuttlePath.size()) { + //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅 + recentShuttle = shuttleThread; + } + } + } + } + + map.put("sameLay", false);//涓嶅悓灞� + map.put("result", recentShuttle); + return map; + } + + /** + * 鍥涘悜绌挎杞︿换鍔″畬鎴� + */ + public synchronized void shuttleFinished() { for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { //鑾峰彇鍥涘悜绌挎杞︿俊鎭� ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); @@ -620,99 +803,188 @@ continue; } - // 鍙湁褰撳洓鍚戠┛姊溅绌洪棽 骞朵笖鏃犱换鍔℃椂鎵嶇户缁墽琛� - if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE && shuttleProtocol.getTaskNo() == 0) { - //鍏ュ嚭搴撻�昏緫 - for (WrkMast wrkSts : wrkMastMapper.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 2))) { - //鍒嗛厤浠诲姟鍙� - shuttleProtocol.setTaskNo(wrkSts.getWrkNo().shortValue()); - //鍒嗛厤婧愬簱浣� - shuttleProtocol.setSourceLocNo(wrkSts.getSourceLocNo()); - //鍒嗛厤鐩爣搴撲綅 - shuttleProtocol.setLocNo(wrkSts.getLocNo()); - - //璁$畻璺緞 - List<NavigateNode> calc = NavigateUtils.calc(wrkSts.getSourceLocNo(), wrkSts.getLocNo(), "in"); - //鑾峰彇鍒嗘璺緞 - ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(calc); - //灏嗘map瀛樺叆redis涓� - HashMap<String, Object> map = new HashMap<>(); - //鎵ц姝ュ簭 - map.put("step", 0); - //璺緞鏁版嵁 - map.put("path", data); - //宸ヤ綔鍙� - map.put("wrk_no", wrkSts.getWrkNo()); - //浠诲姟鏁版嵁淇濆瓨鍒皉edis - redisUtil.set("wrk_no_" + wrkSts.getWrkNo().shortValue(), JSON.toJSONString(map)); - } - - } else if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE && shuttleProtocol.getTaskNo() != 0) { - //鍥涘悜绌挎杞︾┖闂� 骞朵笖鏈変换鍔� - Object o = redisUtil.get("wrk_no_" + shuttleProtocol.getTaskNo()); - HashMap map = JSON.parseObject(o.toString(), HashMap.class); - //褰撳墠姝ュ簭 - int step = Integer.parseInt(map.get("step").toString()); - //褰撳墠璺緞鏁版嵁 - Object data = map.get("path"); - ArrayList pathList = JSON.parseObject(data.toString(), ArrayList.class); - //鍙栫涓�鏉¤矾寰� - Object o1 = pathList.get(step); - ArrayList path = JSON.parseObject(o1.toString(), ArrayList.class); - - int size = path.size(); - //寮�濮嬭矾寰� - JSONObject startPath = JSON.parseObject(path.get(0).toString()); - System.out.println(startPath); - //鐩爣璺緞 - JSONObject endPath = JSON.parseObject(path.get(size - 1).toString()); - System.out.println(endPath); - - //涓嬪彂鍛戒护 - ShuttleCommand command = new ShuttleCommand(); - command.setCommandWord((short) 1); - command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getIntValue("x"), startPath.getIntValue("y"))); - command.setMiddleCodeNum((short) 0); - command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getIntValue("x"), endPath.getIntValue("y"))); - command.setStartToDistDistance(1000); - command.setMiddleToDistDistance(1000); - command.setRunDirection(ShuttleRunDirection.get(startPath.get("direction").toString()).id); - command.setPalletLift((short) 1); - command.setForceMoveDistance(1000); - command.setChargeSwitch((short) 2); - command.setIOControl((short) 0); - command.setRunSpeed((short) 1000); - command.setRadarTmp((short) 0); - command.setCommandEnd((short) 1); - - if (!MessageQueue.offer(SlaveType.Shuttle, shuttleProtocol.getShuttleNo().intValue(), new Task(2, command))) { - News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); - } else { - News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙戞垚鍔燂紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); - - //鍒ゆ柇鏁版嵁鏄惁鎵ц瀹屾垚 - if (step < size) { - //鏇存柊redis鏁版嵁 - //姝ュ簭澧炲姞 - step++; - map.put("step", step); - //浠诲姟鏁版嵁淇濆瓨鍒皉edis - redisUtil.set("wrk_no_" + map.get("wrk_no").toString(), JSON.toJSONString(map)); - }else { - //宸叉墽琛屽畬鎴� - //淇濆瓨鏁版嵁鍒版暟鎹簱鍋氭祦姘� - //鍒犻櫎redis - redisUtil.del("wrk_no_" + map.get("wrk_no").toString()); - - //銆傘�傘�� - //1銆佸懡浠や笅鏂归渶瑕佸垽鏂皬杞︾┖闂茬姸鎬� - //2銆� + //鍥涘悜绌挎杞︾姸鎬佷负绛夊緟纭 + if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id && shuttleProtocol.getTaskNo() != 0) { + //灏嗕换鍔℃。鏍囪涓哄畬鎴� + WrkMast wrkMast = wrkMastMapper.selectByWorkNo59(shuttleProtocol.getTaskNo().intValue()); + if (wrkMast != null) { + switch (wrkMast.getWrkSts().intValue()) { + case 9: + wrkMast.setWrkSts(14L); + break; + case 5: + wrkMast.setWrkSts(6L); + break; + default: } + if (wrkMastMapper.updateById(wrkMast) > 0) { + //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� + shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); + //浠诲姟鍙锋竻闆� + shuttleProtocol.setTaskNo((short) 0); + //婧愬簱浣嶆竻闆� + shuttleProtocol.setSourceLocNo(null); + //鐩爣搴撲綅娓呴浂 + shuttleProtocol.setLocNo(null); + //鏍囪澶嶄綅 + shuttleProtocol.setPakMk(true); + //浠诲姟鎸囦护娓呴浂 + shuttleProtocol.setAssignCommand(null); + News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); + } else { + News.error("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傚洓鍚戠┛姊溅鍙�={}锛屽伐浣滃彿={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); + } + } + + } + } + } + + /** + * 鎻愬崌鏈轰换鍔� + */ + public synchronized void liftIoExecute() { + for (LiftSlave liftSlave : slaveProperties.getLift()) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getLiftProtocol(); + if (liftProtocol == null) { + continue; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庣┖闂茬姸鎬� + if (!liftProtocol.isIdle()) { + continue; + } + + //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔� + WrkMast wrkMast = wrkMastMapper.selectLiftStep6(); + if (wrkMast == null) { + continue; + } + + //缁欐彁鍗囨満鍒嗛厤浠诲姟 + liftProtocol.setLiftLock(true);//閿佸畾鎻愬崌鏈� + liftProtocol.setTaskNo(wrkMast.getWrkNo().shortValue());//璁剧疆浠诲姟鍙� + liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//璁剧疆鍥涘悜绌挎杞﹀彿 + liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);//璁剧疆鎻愬崌鏈虹姸鎬佷负宸ヤ綔涓� + + //鎵惧埌鍥涘悜绌挎杞︾殑绾跨▼ + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, liftProtocol.getShuttleNo().intValue()); + if (shuttleThread == null) { + continue; + } + ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + continue; + } + + //鍛戒护list + ArrayList<LiftCommand> commands = new ArrayList<>(); + + //褰撳墠绌挎杞﹀簱浣嶅彿 + String currentLocNo = shuttleProtocol.getCurrentLocNo(); + //褰撳墠绌挎杞︽ゼ灞� + int currentLocNoLey = Integer.parseInt(currentLocNo.substring(currentLocNo.length() - 2, currentLocNo.length())); + + //宸ヤ綔妗g洰鏍囧簱浣嶅彿 + String wrkMastLocNo = wrkMast.getLocNo(); + //宸ヤ綔妗g洰鏍囧簱浣嶆ゼ灞� + int wrkMastLocNoLey = Integer.parseInt(wrkMastLocNo.substring(wrkMastLocNo.length() - 2, wrkMastLocNo.length())); + + //鎻愬崌鏈哄綋鍓嶆ゼ灞� + int liftLev = liftProtocol.getLev().intValue(); + if (liftLev != currentLocNoLey) { + //涓嶅悓妤煎眰 + LiftCommand command1 = new LiftCommand(); + command1.setLiftNo(liftProtocol.getLiftNo());//鎻愬崌鏈哄彿 + command1.setTaskNo(liftProtocol.getTaskNo());//浠诲姟鍙� + command1.setRun((short) 1);//鍗囬檷 + command1.setDistPosition((short) currentLocNoLey);//鐩爣妤煎眰(绌挎杞︽墍鍦ㄦゼ灞�) + command1.setLiftLock(true);//閿佸畾鎻愬崌鏈� + + commands.add(command1);//灏嗗懡浠ゆ坊鍔犺繘list + } + + //杈撻�佺嚎灏嗗洓鍚戠┛姊溅绉诲姩杩涙潵 + LiftCommand command2 = new LiftCommand(); + command2.setLiftNo(liftProtocol.getLiftNo());//鎻愬崌鏈哄彿 + command2.setTaskNo(liftProtocol.getTaskNo());//浠诲姟鍙� + command2.setRun((short) 6);//杈撻�佺嚎杩愪綔 + command2.setLiftLock(true);//閿佸畾鎻愬崌鏈� + + commands.add(command2);//灏嗗懡浠ゆ坊鍔犺繘list + + //鎻愬崌鏈烘惉杩愬洓鍚戠┛姊溅 + LiftCommand command3 = new LiftCommand(); + command3.setLiftNo(liftProtocol.getLiftNo());//鎻愬崌鏈哄彿 + command3.setTaskNo(liftProtocol.getTaskNo());//浠诲姟鍙� + command3.setRun((short) 1);//鍗囬檷 + command3.setDistPosition((short) wrkMastLocNoLey);//宸ヤ綔妗g洰鏍囨ゼ灞� + command3.setLiftLock(true);//閿佸畾鎻愬崌鏈� + + commands.add(command3);//灏嗗懡浠ゆ坊鍔犺繘list + + //鎻愬崌鏈哄埌杈炬寚瀹氭ゼ灞傦紝杈撻�佺嚎灏嗗洓鍚戠┛姊溅绉诲嚭鍘� + //杈撻�佺嚎灏嗗洓鍚戠┛姊溅绉诲姩杩涙潵 + LiftCommand command4 = new LiftCommand(); + command4.setLiftNo(liftProtocol.getLiftNo());//鎻愬崌鏈哄彿 + command4.setTaskNo(liftProtocol.getTaskNo());//浠诲姟鍙� + command4.setRun((short) 3);//杈撻�佺嚎杩愪綔 + command4.setLiftLock(true);//閿佸畾鎻愬崌鏈� + + commands.add(command4);//灏嗗懡浠ゆ坊鍔犺繘list + + wrkMast.setWrkSts(7L);//绉诲姩浠诲姟 + //鎵�闇�鍛戒护缁勫悎瀹屾瘯锛屾洿鏂版暟鎹簱锛屾彁浜ゅ埌绾跨▼鍘诲伐浣� + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(liftProtocol.getLiftNo()); + assignCommand.setTaskNo(liftProtocol.getTaskNo()); + if (wrkMastMapper.updateById(wrkMast) > 0) { + //涓嬪彂浠诲姟 + MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); + } + } + } + + /** + * 鎻愬崌鏈轰换鍔″畬鎴� + */ + public synchronized void liftFinished() { + for (LiftSlave liftSlave : slaveProperties.getLift()) { + //鑾峰彇鎻愬崌鏈轰俊鎭� + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); + LiftProtocol liftProtocol = liftThread.getLiftProtocol(); + if (liftProtocol == null) { + continue; + } + + //鎻愬崌鏈轰负绛夊緟纭 + if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id && liftProtocol.getTaskNo() != 0) { + //灏嗕换鍔℃。鏍囪涓哄畬鎴� + WrkMast wrkMast = wrkMastMapper.selectByWorkNo7(liftProtocol.getTaskNo().intValue()); + if (wrkMast != null) { + wrkMast.setWrkSts(8L); + if (wrkMastMapper.updateById(wrkMast) > 0) { + //璁剧疆鎻愬崌鏈轰负绌洪棽鐘舵�� + liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); + //浠诲姟鍙锋竻闆� + liftProtocol.setTaskNo((short) 0); + //鏍囪澶嶄綅 + liftProtocol.setPakMk(true); + //浠诲姟鎸囦护娓呴浂 + liftProtocol.setAssignCommand(null); + News.info("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo()); + } else { + News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); + } } } } - } /** -- Gitblit v1.9.1