From 6daf900a09adcca981f620744bf89851654d88e0 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 05 八月 2025 09:58:08 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 559 ++++++++++++++++++++----------------------------------- 1 files changed, 207 insertions(+), 352 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 6811d6d..09cefc6 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -12,7 +12,7 @@ import com.zy.common.service.CommonService; import com.zy.common.utils.*; import com.zy.core.News; -import com.zy.core.action.ForkLiftAction; +import com.zy.core.action.LiftAction; import com.zy.core.action.ShuttleAction; import com.zy.core.cache.SlaveConnection; import com.zy.core.dispatcher.ShuttleDispatchUtils; @@ -67,7 +67,7 @@ @Autowired private ShuttleAction shuttleAction; @Autowired - private ForkLiftAction forkLiftAction; + private LiftAction liftAction; @Autowired private NotifyUtils notifyUtils; @Autowired @@ -87,7 +87,7 @@ Object data = redisUtil.get(RedisKeyType.MAP.key + lev); if (data == null) {//redis鍦板浘鏁版嵁涓虹┖ //杞藉叆鍦板浘 - List<List<MapNode>> lists = navigateMapData.getJsonData(lev, -1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱) + List<List<MapNode>> lists = navigateMapData.getJsonOriginData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱) //瀛樺叆鏁版嵁搴� basMap.setData(JSON.toJSONString(lists)); @@ -183,7 +183,7 @@ //妫�娴嬮殰纰嶇墿杞� boolean checkObstacle = shuttleOperaUtils.checkObstacle(wrkMast.getLocNo(), new ArrayList<Integer>() {{ add(shuttleProtocol.getShuttleNo()); - }}); + }}, new ArrayList<>()); if (checkObstacle) { News.info("{}浠诲姟锛岄伩闅滆寖鍥存湁灏忚溅锛岀瓑寰呴殰纰嶅皬杞﹁皟绂讳腑", wrkMast.getWrkNo()); return false; @@ -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)); @@ -374,7 +374,7 @@ //妫�娴嬮殰纰嶇墿杞� boolean checkObstacle = shuttleOperaUtils.checkObstacle(wrkMast.getSourceLocNo(), new ArrayList<Integer>() {{ add(shuttleProtocol.getShuttleNo()); - }}); + }}, new ArrayList<>()); if (checkObstacle) { News.info("{}浠诲姟锛岄伩闅滆寖鍥存湁灏忚溅锛岀瓑寰呴殰纰嶅皬杞﹁皟绂讳腑", wrkMast.getWrkNo()); return false; @@ -386,6 +386,13 @@ return false; } + //妫�娴嬫槸鍚﹀瓨鍦ㄧЩ鍔ㄤ换鍔� + WrkMast moveWorking = wrkMastService.selectShuttleHasMoveWorking(wrkMast.getShuttleNo()); + if (moveWorking != null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀瓨鍦ㄧЩ鍔ㄤ换鍔�", wrkMast.getWrkNo()); + return false; + } + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� assignCommand.setTaskMode(ShuttleTaskModeType.TRANSPORT.id);//灏忚溅绉诲簱浠诲姟 @@ -393,7 +400,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; @@ -429,99 +436,6 @@ return false; } return true; - } - - /** - * 鍥涘悜绌挎杞︿换鍔″畬鎴� - */ - public synchronized void shuttleFinished() { - try { - List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() - .eq("device_type", String.valueOf(SlaveType.Shuttle))); - for (DeviceConfig device : shuttleList) { - //鑾峰彇鍥涘悜绌挎杞︿俊鎭� - ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); - ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); - if (shuttleProtocol == null) { - continue; - } - - //鍥涘悜绌挎杞︾姸鎬佷负绛夊緟纭銆佸皬杞﹀浜庣┖闂茬姸鎬� - if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id //浠诲姟瀹屾垚绛夊緟纭 - && shuttleProtocol.getTaskNo() != 0 - ) { - //灏嗕换鍔℃。鏍囪涓哄畬鎴� - WrkMast wrkMast = wrkMastService.selectByWorkNo(shuttleProtocol.getTaskNo()); - if (wrkMast != null) { - if (wrkMast.getWrkSts() == WrkStsType.INBOUND_SHUTTLE_RUN.sts) { - //5.灏忚溅鎼繍涓� ==> 9.鍏ュ簱瀹屾垚 - wrkMast.setWrkSts(WrkStsType.COMPLETE_INBOUND.sts); - shuttleThread.setSyncTaskNo(0); - } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_SHUTTLE_RUN.sts) { - //102.灏忚溅鎼繍涓� ==> 103.灏忚溅鎼繍瀹屾垚 - wrkMast.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts); - shuttleThread.setSyncTaskNo(0); - } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_NEARBY.sts) { - //302.灏忚溅绉诲姩鑷宠繎鐐逛腑 ==> 303.灏忚溅绉诲姩鑷宠繎鐐瑰畬鎴� - wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY_COMPLETE.sts); - shuttleThread.setSyncTaskNo(0); - } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT.sts) { - //304.灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� - wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT_COMPLETE.sts); - shuttleThread.setSyncTaskNo(0); - } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT.sts) { - //308.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� - if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { - continue;//灏忚溅鏈埌杈剧洰鏍囧眰 - } - wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_COMPLETE.sts); - shuttleThread.setSyncTaskNo(0); - } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SHUTTLE.sts) { - //310.灏忚溅绉诲姩涓� ==> 311.灏忚溅绉诲姩瀹屾垚 - wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE.sts); - shuttleThread.setSyncTaskNo(0); - notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVE_COMPLETE);//瑙﹀彂閫氱煡 - } else if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_WORKING.sts) { - //204.灏忚溅鍏呯數涓� ==> 205.灏忚溅鍏呯數瀹屾垚 - wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_COMPLETE.sts); - shuttleThread.setSyncTaskNo(0); - notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//瑙﹀彂閫氱煡 - } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_SHUTTLE_RUN.sts) { - //502.灏忚溅鎼繍涓� ==> 509.绉诲簱瀹屾垚 - wrkMast.setWrkSts(WrkStsType.COMPLETE_LOC_MOVE.sts); - shuttleThread.setSyncTaskNo(0); - notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_DELIVERY);//瑙﹀彂閫氱煡 - } else { - continue; - } - - if (wrkMastService.updateById(wrkMast)) { - //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� - shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); - News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); - } else { - News.error("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傚洓鍚戠┛姊溅鍙�={}锛屽伐浣滃彿={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); - } - } else { - Object object = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + shuttleProtocol.getTaskNo()); - if(object != null){ - ShuttleAssignCommand assignCommand = JSON.parseObject(object.toString(), ShuttleAssignCommand.class); - if (!assignCommand.getAuto()) { - //鎵嬪姩妯″紡 - //宸ヤ綔鍙锋竻闆� - shuttleThread.setTaskNo(0); - //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� - shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); - News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); - } - } - } - } - - } - } catch (Exception e) { - e.printStackTrace(); - } } /** @@ -580,15 +494,29 @@ return false; } + if (shuttleProtocol.getCurrentLocNo() == null) { + return false; + } + + //鍒ゆ柇灏忚溅鏄惁鍒拌揪璐х墿搴撲綅 if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { + //灏忚溅鏈埌杈惧彇璐т綅缃� + shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄥ簱浣嶈繘琛屽彇璐� News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞︽湭鍒拌揪鍙栬揣浣嶇疆", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); + return false; + } + + //妫�娴嬫槸鍚﹀瓨鍦ㄧЩ鍔ㄤ换鍔� + WrkMast moveWorking = wrkMastService.selectShuttleHasMoveWorking(wrkMast.getShuttleNo()); + if (moveWorking != null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀瓨鍦ㄧЩ鍔ㄤ换鍔�", wrkMast.getWrkNo()); return false; } //妫�娴嬮殰纰嶇墿杞� boolean checkObstacle = shuttleOperaUtils.checkObstacle(wrkMast.getLocNo(), new ArrayList<Integer>() {{ add(shuttleProtocol.getShuttleNo()); - }}); + }}, new ArrayList<>()); if (checkObstacle) { News.info("{}浠诲姟锛岄伩闅滆寖鍥存湁灏忚溅锛岀瓑寰呴殰纰嶅皬杞﹁皟绂讳腑", wrkMast.getWrkNo()); return false; @@ -599,9 +527,10 @@ assignCommand.setTaskMode(ShuttleTaskModeType.TRANSPORT.id);//灏忚溅绉诲簱浠诲姟 assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� assignCommand.setAuto(true);//鑷姩妯″紡 + assignCommand.setLocNo(wrkMast.getLocNo()); //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.DFX), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false; @@ -720,65 +649,65 @@ if (liftNo == null) { //鏈垎閰嶆彁鍗囨満 Integer staNo = wrkMast.getSourceStaNo(); - liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo); + liftNo = LiftUtils.getConveyorBindLiftNo(staNo); if(liftNo == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); return false; } //鐢宠鎻愬崌鏈鸿祫婧� - boolean applyForkLift = forkLiftAction.applyForkLift(liftNo, wrkMast.getWrkNo()); - if(!applyForkLift) { + boolean applyLift = liftAction.applyLift(liftNo, wrkMast.getWrkNo()); + if(!applyLift) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈠叆搴�", wrkMast.getWrkNo()); return false; } return false; } - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { return false; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { return false; } - if (!forkLiftThread.isIdle()) { + if (!liftThread.isIdle()) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo()); return false; } //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡叆搴撴ā寮� - if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { + if (!liftProtocol.getIOModeType().equals(LiftIoModeType.IN)) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡叆搴撴ā寮忥紝绂佹鍏ュ簱", wrkMast.getWrkNo()); return false; } //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿叆搴� - boolean inMission = ForkLiftUtils.queryInMission(wrkMast.getSourceStaNo(), liftSta.getLiftNo(), wrkMast.getWmsWrkNo()); + boolean inMission = LiftUtils.queryInMission(wrkMast.getSourceStaNo(), liftSta.getLiftNo(), wrkMast.getWmsWrkNo()); if (!inMission) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屼笂绾х郴缁熶笉鍏佽鍏ュ簱", wrkMast.getWrkNo()); return false; } //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommands); + LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 LiftAssignCommand assignCommand = new LiftAssignCommand(); assignCommand.setCommands(commands); - assignCommand.setLiftNo(liftNo.shortValue()); - assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); + assignCommand.setLiftNo(liftNo); + assignCommand.setTaskNo(wrkMast.getWrkNo()); + assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id); wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑 wrkMast.setSystemMsg("");//娓呯┖娑堟伅 wrkMast.setModiTime(now); if (wrkMastService.updateById(wrkMast)) { //涓嬪彂浠诲姟 - forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); } return false; } @@ -795,7 +724,7 @@ //103.灏忚溅鎼繍瀹屾垚 ==> 104.鎻愬崌鏈烘惉杩愪腑 if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts) { //鑾峰彇婧愮珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); + LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); if (liftSta == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾壘涓嶅埌绔欑偣锛岀姝㈡淳鍙�", wrkMast.getWrkNo()); return false;//鎵句笉鍒扮珯鐐� @@ -855,51 +784,51 @@ return false; } //鐢宠鎻愬崌鏈鸿祫婧� - boolean applyForkLift = forkLiftAction.applyForkLift(liftSta.getLiftNo(), wrkMast.getWrkNo()); - if(!applyForkLift) { + boolean applyLift = liftAction.applyLift(liftSta.getLiftNo(), wrkMast.getWrkNo()); + if(!applyLift) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈡墽琛屽嚭搴�", wrkMast.getWrkNo()); return false; } return false; } - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { return false; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { return false; } - if (!forkLiftThread.isIdle()) { + if (!liftThread.isIdle()) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo()); return false; } //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡嚭搴撴ā寮� - if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { + if (!liftProtocol.getIOModeType().equals(LiftIoModeType.OUT)) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡嚭搴撴ā寮忥紝绂佹鍑哄簱", wrkMast.getWrkNo()); return false; } //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿嚭搴� - boolean outMission = ForkLiftUtils.queryOutMission(wrkMast.getStaNo()); + boolean outMission = LiftUtils.queryOutMission(wrkMast.getStaNo()); if (!outMission) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屼笂绾х郴缁熶笉鍏佽鍑哄簱", wrkMast.getWrkNo()); return false; } //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo()); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommands); + LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo()); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 LiftAssignCommand assignCommand = new LiftAssignCommand(); assignCommand.setCommands(commands); - assignCommand.setLiftNo(liftNo.shortValue()); - assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); + assignCommand.setLiftNo(liftNo); + assignCommand.setTaskNo(wrkMast.getWrkNo()); + assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id); wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 103.鐢熸垚鍏ュ簱浠诲姟 ==> 104.鎻愬崌鏈烘惉杩愪腑 wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 @@ -907,7 +836,7 @@ wrkMast.setModiTime(new Date()); if (wrkMastService.updateById(wrkMast)) { //涓嬪彂浠诲姟 - forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); } return false; } @@ -924,6 +853,9 @@ for (DeviceConfig device : forkliftList) { //鑾峰彇鎻愬崌鏈轰俊鎭� ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo()); + if(forkLiftThread == null) { + continue; + } ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); if (forkLiftProtocol == null) { continue; @@ -1163,6 +1095,16 @@ continue; } + WrkMast wrkMast1 = wrkMastService.selectShuttleWorking(shuttleProtocol.getShuttleNo()); + if (wrkMast1 != null) { + continue; + } + + WrkMast wrkMast2 = wrkMastService.selectShuttleHasMoveWorking(shuttleProtocol.getShuttleNo()); + if (wrkMast2 != null) { + continue; + } + WrkMast wrkMast = wrkMastService.selectChargeWorking(shuttleProtocol.getShuttleNo()); if (wrkMast != null) {//宸叉湁鍏呯數浠诲姟 continue; @@ -1298,7 +1240,7 @@ return false; } - if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) { + if (wrkMast.getLocNo().equals(shuttleProtocol.getCurrentLocNo())) { //灏忚溅鍦ㄥ厖鐢垫々浣嶇疆 wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_RUN_COMPLETE.sts); wrkMast.setModiTime(new Date()); @@ -1444,7 +1386,7 @@ //妫�娴嬮殰纰嶇墿杞� boolean checkObstacle = shuttleOperaUtils.checkObstacle(basShuttleCharge.getWaitLocNo(), new ArrayList<Integer>() {{ add(shuttleProtocol.getShuttleNo()); - }}); + }}, new ArrayList<>()); if (checkObstacle) { News.info("{}浠诲姟锛岄伩闅滆寖鍥存湁灏忚溅锛岀瓑寰呴殰纰嶅皬杞﹁皟绂讳腑", wrkMast.getWrkNo()); return false; @@ -1544,14 +1486,9 @@ } //鑾峰彇婧愯緭閫佺珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); + LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); if (liftSta == null) { return false;//鎵句笉鍒扮珯鐐� - } - - if (liftSta.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾簮绔欏瓨鍦ㄦ墭鐩�", wrkMast.getWrkNo()); - return false; } if (liftSta.getHasCar()) { @@ -1560,14 +1497,9 @@ } //鑾峰彇鐩爣杈撻�佺珯 - ForkLiftStaProtocol liftStaTarget = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); + LiftStaProtocol liftStaTarget = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (liftStaTarget == null) { return false;//鎵句笉鍒扮珯鐐� - } - - if (liftStaTarget.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo()); - return false; } if (liftStaTarget.getHasCar()) { @@ -1582,7 +1514,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; @@ -1598,7 +1530,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攣澶辫触 @@ -1649,14 +1581,9 @@ } //鑾峰彇婧愯緭閫佺珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); + LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); if (liftSta == null) { return false;//鎵句笉鍒扮珯鐐� - } - - if (liftSta.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾簮绔欏瓨鍦ㄦ墭鐩�", wrkMast.getWrkNo()); - return false; } if (liftSta.getHasCar()) { @@ -1665,14 +1592,9 @@ } //鑾峰彇鐩爣杈撻�佺珯 - ForkLiftStaProtocol liftStaTarget = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); + LiftStaProtocol liftStaTarget = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (liftStaTarget == null) { return false;//鎵句笉鍒扮珯鐐� - } - - if (liftStaTarget.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo()); - return false; } if (liftStaTarget.getHasCar()) { @@ -1680,29 +1602,47 @@ return false; } - List<WrkMast> outWrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .eq("io_type", 101) - .in("wrk_sts" - , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts - , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts - , WrkStsType.OUTBOUND_LIFT_RUN.sts - , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts - ) - ); - for (WrkMast outWrkMast : outWrkMastList) { - if(Utils.getLev(outWrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽瓨鍦ㄦ鍦ㄦ墽琛岀殑灏忚溅鍑哄簱浠诲姟锛岀姝㈢Щ鍔ㄨ嚦绔欑偣", wrkMast.getWrkNo()); + if (wrkMast.getLiftNo() == null) { + //鐢宠鎻愬崌鏈鸿祫婧� + boolean applyLift = liftAction.applyLift(liftSta.getLiftNo(), wrkMast.getWrkNo()); + if(!applyLift) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈢Щ鍔�", wrkMast.getWrkNo()); return false; } + return false; } - if (wrkMast.getLiftNo() == null) { - //鐢宠鎻愬崌鏈鸿祫婧�(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) - boolean applyForkLift = forkLiftAction.applyForkLift(liftSta.getLiftNo(), wrkMast.getWrkNo()); - if(!applyForkLift) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈢Щ鍔ㄨ嚦绔欑偣", wrkMast.getWrkNo()); - return false; - } + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + + if (!liftThread.isIdle()) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + int targetLev = Utils.getLev(wrkMast.getLocNo()); + if (liftProtocol.getLev() != targetLev) { + //鑾峰彇鎻愬崌鏈哄懡浠� + LiftCommand liftCommand = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), targetLev); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(wrkMast.getLiftNo()); + assignCommand.setTaskNo(wrkMast.getWrkNo()); + assignCommand.setTaskMode(ForkLiftTaskModeType.MOVE.id); + //涓嬪彂浠诲姟 + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満鍦▄}灞傦紝鎻愬崌鏈轰笉鍦ㄥ皬杞﹀眰锛岃皟搴︾Щ鍔ㄤ腑", wrkMast.getWrkNo(), liftProtocol.getLev(), wrkMast.getLiftNo()); return false; } @@ -1713,7 +1653,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(), liftThread.getCurrentLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞瑙i攣澶辫触 @@ -1747,23 +1687,23 @@ //鎻愬崌鏈烘惉杩愪腑 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑 if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_COMPLETE.sts) { - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, wrkMast.getLiftNo()); - if (forkLiftThread == null) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { return false; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { return false; } - if (!forkLiftThread.isIdle()) { + if (!liftThread.isIdle()) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); return false; } //鑾峰彇婧愮珯 - ForkLiftStaProtocol sourceLiftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); + LiftStaProtocol sourceLiftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); //鑾峰彇鐩爣绔� - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); + LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (sourceLiftSta == null || liftSta == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀己灏戠珯鐐逛俊鎭紝绂佹娲惧彂", wrkMast.getWrkNo()); return false;//缂哄皯绔欑偣淇℃伅 @@ -1775,23 +1715,23 @@ } //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommands = forkLiftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev()); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommands); + LiftCommand liftCommand = liftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev()); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 LiftAssignCommand assignCommand = new LiftAssignCommand(); assignCommand.setCommands(commands); - assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); - assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); - assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue()); + assignCommand.setLiftNo(wrkMast.getLiftNo()); + assignCommand.setTaskNo(wrkMast.getWrkNo()); + assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id); wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑 wrkMast.setSystemMsg("");//娓呯┖娑堟伅 wrkMast.setModiTime(now); if (wrkMastService.updateById(wrkMast)) { //涓嬪彂浠诲姟 - forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); } } return true; @@ -1897,7 +1837,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.getMapTypes(NavigationMapType.NORMAL), assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞璁$畻澶辫触 @@ -1919,158 +1859,73 @@ //鑷姩鍒囨崲鍑哄叆搴撴ā寮� public void autoSwitchForkLiftIOMode() { - List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() - .eq("device_type", String.valueOf(SlaveType.ForkLift))); - for (DeviceConfig device : forkliftList) { - Integer liftNo = device.getDeviceNo(); - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - - List<Integer> liftAllStaNo = ForkLiftUtils.getLiftAllStaNo(liftNo); - if (liftAllStaNo.isEmpty()) { - continue; - } - - List<Integer> conveyorBindLiftAllStaNo = ForkLiftUtils.getConveyorBindLiftAllStaNo(liftNo); - if (conveyorBindLiftAllStaNo.isEmpty()) { - continue; - } - - //鑾峰彇鍏ュ簱浠诲姟 - List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .in("sta_no", liftAllStaNo) - .in("wrk_sts" - , WrkStsType.NEW_INBOUND.sts - , WrkStsType.INBOUND_DEVICE_RUN.sts - , WrkStsType.INBOUND_LIFT_RUN.sts - , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts - , WrkStsType.INBOUND_SHUTTLE_RUN.sts - , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts - )); - - //鑾峰彇鍑哄簱浠诲姟 - List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .in("sta_no", conveyorBindLiftAllStaNo) - .in("wrk_sts" - , WrkStsType.NEW_OUTBOUND.sts - , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts - , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts - , WrkStsType.OUTBOUND_LIFT_RUN.sts - , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts - )); - - if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.NONE)) { - //鏈煡妯″紡 - if (!inWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); - } else if (!outWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); - }else { - forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); - } - } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { - //鍏ュ簱妯″紡 - if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); - } - } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { - //鍑哄簱妯″紡 - if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); - } - } - } - } - - //鍑哄簱浠诲姟棰勮皟搴︽彁鍗囨満 - public void outTaskPreviewDispatchForkLift() { - List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .in("wrk_sts" - , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts - )); - for (WrkMast wrkMast : wrkMasts) { - if(wrkMast.getShuttleNo() == null){ - continue; - } - - //鑾峰彇鍥涘悜绌挎杞︾嚎绋� - ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); - if (shuttleThread == null) { - continue; - } - - ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); - if (shuttleProtocol == null) { - continue; - } - - if(shuttleProtocol.getCurrentLocNo() == null){ - continue; - } - - //閫氳繃杈撻�佺嚎绔欏彿鑾峰彇鎻愬崌鏈哄彿 - Integer liftNo = ForkLiftUtils.getConveyorBindLiftNo(wrkMast.getStaNo()); - if (liftNo == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); - continue; - } - - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - continue; - } - - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - - //瀛樺湪璋冨害閿� - Object object = redisUtil.get(RedisKeyType.OUT_TASK_PREVIEW_DISPATCH_FORKLIFT.key + forkLiftProtocol.getLiftNo()); - if (object != null) { - continue; - } - - //鐢宠鎻愬崌鏈鸿祫婧� - boolean applyForkLift = forkLiftAction.applyForkLift(liftNo, null); - if(!applyForkLift) { - continue;//鎻愬崌鏈哄凡琚粦瀹氾紝涓嶅啀鎵ц棰勮皟搴︿换鍔� - } - - if (!forkLiftThread.isIdle()) { - continue; - } - - //鎻愬崌鏈轰笉鍦ㄥ嚭搴撳眰 - if (forkLiftProtocol.getLev().equals(Utils.getLev(wrkMast.getSourceLocNo()))) { - continue; - } - - //绉诲姩 - int workNo = commonService.getWorkNo(WrkIoType.FORKLIFT_MOVE.id);//鑾峰彇浠诲姟鍙� - - //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommand = forkLiftThread.getMoveCommand(workNo, forkLiftProtocol.getLev(), Utils.getLev(wrkMast.getSourceLocNo())); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommand); - - //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 - LiftAssignCommand assignCommand = new LiftAssignCommand(); - assignCommand.setCommands(commands); - assignCommand.setLiftNo(forkLiftProtocol.getLiftNo().shortValue()); - assignCommand.setTaskNo((short) workNo); - assignCommand.setTaskMode(ForkLiftTaskModeType.MOVE.id.shortValue()); - - forkLiftAction.assignWork(forkLiftProtocol.getLiftNo(), assignCommand); - - redisUtil.set(RedisKeyType.OUT_TASK_PREVIEW_DISPATCH_FORKLIFT.key + forkLiftProtocol.getLiftNo(), "lock", 30);//30绉掍笉鍐嶈皟搴� - } +// List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() +// .eq("device_type", String.valueOf(SlaveType.ForkLift))); +// for (DeviceConfig device : forkliftList) { +// Integer liftNo = device.getDeviceNo(); +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// +// List<Integer> liftAllStaNo = ForkLiftUtils.getLiftAllStaNo(liftNo); +// if (liftAllStaNo.isEmpty()) { +// continue; +// } +// +// List<Integer> conveyorBindLiftAllStaNo = ForkLiftUtils.getConveyorBindLiftAllStaNo(liftNo); +// if (conveyorBindLiftAllStaNo.isEmpty()) { +// continue; +// } +// +// //鑾峰彇鍏ュ簱浠诲姟 +// List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() +// .in("sta_no", liftAllStaNo) +// .in("wrk_sts" +// , WrkStsType.NEW_INBOUND.sts +// , WrkStsType.INBOUND_DEVICE_RUN.sts +// , WrkStsType.INBOUND_LIFT_RUN.sts +// , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts +// , WrkStsType.INBOUND_SHUTTLE_RUN.sts +// , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts +// )); +// +// //鑾峰彇鍑哄簱浠诲姟 +// List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() +// .in("sta_no", conveyorBindLiftAllStaNo) +// .in("wrk_sts" +// , WrkStsType.NEW_OUTBOUND.sts +// , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts +// , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts +// , WrkStsType.OUTBOUND_LIFT_RUN.sts +// , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts +// )); +// +// if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.NONE)) { +// //鏈煡妯″紡 +// if (!inWrkMasts.isEmpty()) { +// forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); +// } else if (!outWrkMasts.isEmpty()) { +// forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); +// }else { +// forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); +// } +// } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { +// //鍏ュ簱妯″紡 +// if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) { +// forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); +// } +// } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { +// //鍑哄簱妯″紡 +// if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) { +// forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); +// } +// } +// } } } -- Gitblit v1.9.1