From 3df03c486fde77ab36b9298a94bdbb0aa065a7e2 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期二, 08 四月 2025 09:07:40 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java | 1239 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 637 insertions(+), 602 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java index 0f11234..b0204ad 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java @@ -4,17 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.wcs.core.domain.dto.MotionDto; import com.zy.asrs.wcs.core.entity.*; -import com.zy.asrs.wcs.core.model.NavigateNode; import com.zy.asrs.wcs.core.model.enums.*; import com.zy.asrs.wcs.core.service.*; import com.zy.asrs.wcs.core.utils.*; -import com.zy.asrs.wcs.rcs.News; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.entity.Device; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; +import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; import com.zy.asrs.wcs.rcs.service.DeviceService; +import com.zy.asrs.wcs.rcs.thread.DevpThread; import com.zy.asrs.wcs.rcs.thread.LiftThread; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; import org.springframework.beans.factory.annotation.Autowired; @@ -67,7 +67,13 @@ public List<Motion> generateMotion(Task task) { List<Motion> motionList = new ArrayList<>(); - motionList = this.generateFirstZoneMotion(task); + int originSite = Integer.parseInt(task.getOriginSite()); + int destSite = Integer.parseInt(task.getDestSite()); + if (originSite == 1015 || originSite == 1026 || destSite == 1015 || destSite == 1026) { + motionList = generateSecondZoneMotion(task); + }else { + motionList = generateFirstZoneMotion(task); + } return motionList; } @@ -101,8 +107,8 @@ String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); - //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鍙崲灞傛彁鍗囨満 - LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true); + //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑鍙崲灞傛彁鍗囨満(鍙兘涓嶇┖闂�) + LiftThread liftThread = liftDispatcher.searchLift(shuttleLocNo, task.getHostId(), true); if (liftThread == null) { return motionList; } @@ -113,11 +119,6 @@ return motionList; } - BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite()); - if (basConveyorStaDest == null) { - return motionList; - } - //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); if (shuttleResult) { @@ -125,35 +126,19 @@ return motionList; } - //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 杩涙彁鍗囨満 + //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 鎻愬崌鏈� ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo)) .eq(ShuttleStandby::getStatus, 1)); - //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 鍑烘彁鍗囨満 - ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() - .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) - .eq(ShuttleStandby::getDeviceLev, Utils.getLev(destLoc)) - .eq(ShuttleStandby::getStatus, 1)); - if (shuttleStandbyTo == null || shuttleStandbyFrom == null) { - return motionList; - } - //绌挎杞﹁繘鎻愬崌鏈哄簱浣嶅彿 String liftLocNoTo = shuttleStandbyTo.getDeviceLoc(); - //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿 - String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc(); - - //绌挎杞﹁繘鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� + //绌挎杞﹁繘鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� 杈撻�佺嚎浣嶇疆 String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc(); - - //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� - String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc(); - - //鎹㈠眰闇�瑕侀攣瀹氱殑璺緞 - List<String> lockPath = shuttleStandbyFrom.getLockPath$(); + //绌挎杞︽崲灞傛椂寰呮満浣嶇疆 浣跨敤琛ㄥ垪 memo鏁版嵁 + String standbyLocNoMemo = shuttleStandbyTo.getMemo(); // 鍏ュ簱鐩爣灞傛湁绌挎杞� if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getDestLoc())) { @@ -162,19 +147,18 @@ motionList.addAll(kernelService.liftMoveGoods( MotionDto.build((dto -> { dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(1);//鍏夋嘲1灞傛槸杈撻�佺嚎灞� - dto.setStaNo(31004);//鍏ュ簱绔欑偣 + dto.setStaNo(Integer.parseInt(task.getOriginSite()));//鍏ュ簱绔欑偣 })) , MotionDto.build((dto -> { dto.setLiftNo(transferLiftDevice.getId().intValue()); dto.setLev(Utils.getLev(task.getDestLoc())); - dto.setStaNo(getStaByLev(Utils.getLev(task.getDestLoc()))); - dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue()); -// dto.setSync();//寮傛鎵ц - })) + dto.setStaNo(Integer.parseInt(task.getDestSite())); +// dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 + })), + MotionCtgType.LIFT_WITH_GOODS_IN )); - // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅 + // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣� motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); @@ -182,185 +166,10 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); - })), - MotionCtgType.SHUTTLE_MOVE - )); - - // 绌挎杞﹀叆搴撻《鍗� - motionList.addAll(kernelService.shuttleAction( - null, - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - })), - MotionCtgType.SHUTTLE_PALLET_LIFT - )); - - // 绌挎杞﹁浇璐ц蛋琛岃嚦鐩爣搴撲綅 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(destLoc); - dto.setReleaseLift(2);//鎵ц涓噴鏀炬彁鍗囨満 - })), - MotionCtgType.SHUTTLE_TRANSPORT - )); - - // 绌挎杞﹀叆搴撴墭鐩樹笅闄� - motionList.addAll(kernelService.shuttleAction( - null, - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - })), - MotionCtgType.SHUTTLE_PALLET_DOWN - )); - - /** - * 浜屻�佸叆搴撶洰鏍囧眰娌℃湁绌挎杞� - */ - } else { - - // 鎻愬崌鏈鸿浇璐хЩ鍔� - motionList.addAll(kernelService.liftMoveGoods( - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(1);//鍏夋嘲1灞傛槸杈撻�佺嚎灞� - dto.setStaNo(31004);//鍏ュ簱绔欑偣 - })) - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(task.getDestLoc())); - dto.setStaNo(getStaByLev(Utils.getLev(task.getDestLoc()))); - dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue()); - })) - )); - - // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(shuttleLocNo); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); - })), - MotionCtgType.SHUTTLE_MOVE - )); - - // 閿佸畾鎹㈠眰璺緞 - motionList.addAll(kernelService.mapLockPath( - null, - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(JSON.toJSONString(lockPath)); - })) - )); - - // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 - motionList.addAll(kernelService.liftMove( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(shuttleLocNo)); - })) - )); - - // 閿佸畾鎻愬崌鏈� - motionList.addAll(kernelService.liftLock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(liftLocNoTo); })), - MotionCtgType.SHUTTLE_MOVE_TO_LIFT - )); - - // 瑙i攣鎻愬崌鏈� - motionList.addAll(kernelService.liftUnlock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 鎻愬崌鏈烘惉杞� 鑷� 鐩爣浣嶇疆灞� - motionList.addAll(kernelService.liftMoveShuttle( - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(shuttleLocNo)); - })), - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(destLoc)); - })) - )); - - // 閿佸畾鎻愬崌鏈� - motionList.addAll(kernelService.liftLock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 鏇存柊灏忚溅鍧愭爣 - motionList.addAll(kernelService.shuttleUpdateLocation( - null - , MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(liftLocNoFrom); - })) - )); - - // 绌挎杞︾Щ鍔ㄨ嚦鎻愬崌鏈哄緟鏈轰綅 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(liftLocNoFrom); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); - })), - MotionCtgType.SHUTTLE_MOVE_FROM_LIFT - )); - - // 瑙i攣鎻愬崌鏈� - motionList.addAll(kernelService.liftUnlock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 - })) - )); - - // 瑙i攣鎹㈠眰璺緞 - motionList.addAll(kernelService.mapUnlockPath( - null, - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(JSON.toJSONString(lockPath)); - })) + MotionCtgType.SHUTTLE_MOVE )); // 绌挎杞﹀叆搴撻《鍗� @@ -372,14 +181,31 @@ MotionCtgType.SHUTTLE_PALLET_LIFT )); + // 绌挎杞﹁浇璐ц蛋琛岃嚦寰呮満搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(liftLocNoTo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLocNo(standbyLocNoTo); + dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 + })), + MotionCtgType.SHUTTLE_TRANSPORT + )); + // 绌挎杞﹁浇璐ц蛋琛岃嚦鐩爣搴撲綅 motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); + dto.setLocNo(standbyLocNoTo); })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLiftNo(transferLiftDevice.getId().intValue()); dto.setLocNo(destLoc); dto.setReleaseLift(2);//鎵ц涓噴鏀炬彁鍗囨満 @@ -395,7 +221,6 @@ })), MotionCtgType.SHUTTLE_PALLET_DOWN )); - } } @@ -439,11 +264,6 @@ return motionList; } - BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite()); - if (basConveyorStaOrigin == null) { - return motionList; - } - //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); if (shuttleResult) { @@ -457,46 +277,20 @@ .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo)) .eq(ShuttleStandby::getStatus, 1)); - //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 鍑烘彁鍗囨満 - ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() - .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) - .eq(ShuttleStandby::getDeviceLev, Utils.getLev(originLoc)) - .eq(ShuttleStandby::getStatus, 1)); - if (shuttleStandbyTo == null || shuttleStandbyFrom == null) { - return motionList; - } - //绌挎杞﹁繘鎻愬崌鏈哄簱浣嶅彿 String liftLocNoTo = shuttleStandbyTo.getDeviceLoc(); - //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿 - String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc(); - - //绌挎杞﹁繘鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� + //绌挎杞﹁繘鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� 杈撻�佺嚎浣嶇疆 String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc(); - //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� - String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc(); - - //绌挎杞﹀嚭鎻愬崌鏈哄悗鍏ㄩ儴寰呮満浣� - String standbyLocs = shuttleStandbyFrom.getStandbyLoc();//鑾峰彇鍏ㄩ儴寰呮満浣� - - //鎹㈠眰闇�瑕侀攣瀹氱殑璺緞 - List<String> lockPath = shuttleStandbyFrom.getLockPath$(); + //绌挎杞﹀緟鏈轰綅缃� 浣跨敤琛ㄥ垪 + String standbyLocNoList = shuttleStandbyTo.getStandbyLoc(); //鑾峰彇鍑哄簱浠诲姟绫诲瀷 TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.OUT)) .eq(TaskCtg::getStatus, 1)); if (taskCtg == null) { - return motionList; - } - //鑾峰彇杈撻�佺嚎璺緞 - BasConveyorPath basConveyorPath = basConveyorPathService.getOne(new LambdaQueryWrapper<BasConveyorPath>() - .eq(BasConveyorPath::getDeviceStn, task.getOriginSite()) - .eq(BasConveyorPath::getDeviceNo, liftProtocol.getLiftNo()) - .eq(BasConveyorPath::getTypeNo, taskCtg.getId())); - if (basConveyorPath == null) { return motionList; } @@ -521,6 +315,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(originLoc); })), MotionCtgType.SHUTTLE_MOVE @@ -536,18 +331,21 @@ MotionCtgType.SHUTTLE_PALLET_LIFT )); - // 绌挎杞﹁浇璐у嚭搴撹嚦鏈�鍚庝竴娈佃矾寰勭瓑寰� - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(originLoc); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(lastPathStartLoc); - })), - MotionCtgType.SHUTTLE_TRANSPORT - )); + if (!originLoc.equals(lastPathStartLoc)) { + // 绌挎杞﹁浇璐у嚭搴撹嚦鏈�鍚庝竴娈佃矾寰勭瓑寰� + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(originLoc); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(lastPathStartLoc); + })), + MotionCtgType.SHUTTLE_TRANSPORT + )); + } // 绌挎杞﹁浇璐ц嚦鎻愬崌鏈哄緟鏈轰綅 motionList.addAll(kernelService.shuttleMove( @@ -557,11 +355,36 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLiftNo(transferLiftDevice.getId().intValue()); dto.setLocNo(standbyLocNoTo); dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//杈撻�佺珯 })), - MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR + MotionCtgType.SHUTTLE_TRANSPORT + )); + + Integer liftLevLogic = liftDispatcher.getLiftLevOffset(transferLiftDevice.getId().intValue(), Utils.getLev(originLoc)); + // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌鍑哄簱灞� + motionList.addAll(kernelService.liftMove( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLev(liftLevLogic); + })) + )); + + // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣� + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(standbyLocNoTo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(liftLocNoTo); + })), + MotionCtgType.SHUTTLE_MOVE )); // 绌挎杞﹀嚭搴撴墭鐩樹笅闄� @@ -577,12 +400,13 @@ motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); + dto.setLocNo(liftLocNoTo); })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocs); - dto.setSync(0);//寮傛鎵ц + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(standbyLocNoList); +// dto.setSync(0);//寮傛鎵ц dto.setReleaseShuttle(1);//鎵ц瀹屾垚鍚庨噴鏀惧皬杞� })), MotionCtgType.SHUTTLE_MOVE_STANDBY @@ -593,36 +417,88 @@ MotionDto.build((dto -> { dto.setLiftNo(transferLiftDevice.getId().intValue()); dto.setLev(Utils.getLev(task.getOriginLoc())); - dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//璧峰绔欑偣 + dto.setStaNo(Integer.parseInt(task.getOriginSite()));//璧峰绔欑偣 })) , MotionDto.build((dto -> { dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(1);//鍏夋嘲1灞傛槸杈撻�佺嚎灞� - dto.setStaNo(31001);//鍑哄簱绔欑偣 - dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue()); + dto.setStaNo(Integer.parseInt(task.getDestSite()));//鍑哄簱绔欑偣 dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 - })) + })), + MotionCtgType.LIFT_WITH_GOODS_OUT )); - // 杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛 -// motionList.addAll(kernelService.conveyorOutbound( -// MotionDto.build((dto -> { -// dto.setDevpNo(basConveyorPath.getDeviceId().intValue()); -// dto.setStaNo(basConveyorPath.getDeviceStn()); -// })), -// MotionDto.build((dto -> { -// dto.setDevpNo(basConveyorPath.getDeviceId().intValue()); -// dto.setStaNo(basConveyorPath.getStnNo()); -// })), -// MotionCtgType.CONVEYOR_OUTBOUND -// )); + } - /** - * 浜屻�佸嚭搴撹捣濮嬪眰娌℃湁绌挎杞� - */ + } + + return motionList; + } + + public List<Motion> generateSecondZoneMotion(Task task) { + List<Motion> motionList = new ArrayList<>(); + int originSite = Integer.parseInt(task.getOriginSite()); + + String conveyLocNo; + if (originSite == 1015 || originSite == 1026) { + BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite()); + if (basConveyorStaOrigin == null) { + return motionList; + } + + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyorStaOrigin.getConveyorId().intValue()); + StaProtocol staProtocol = devpThread.getStation().get(originSite); + if (staProtocol == null) { + return motionList; } else { + staProtocol = staProtocol.clone(); + } + conveyLocNo = staProtocol.getLocNo(); + }else { + conveyLocNo = null; + } - // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅 + if(conveyLocNo == null) { + return motionList; + } + + /** + * 鍏ュ簱 + */ + if (task.getTaskSts() == TaskStsType.NEW_INBOUND.sts) { + // locNo + String destLoc = task.getDestLoc(); + + // shuttle + Device shuttleDevice = deviceService.getOne(new LambdaQueryWrapper<Device>() + .eq(Device::getDeviceNo, task.getShuttleNo()) + .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) + .eq(Device::getHostId, task.getHostId()) + .eq(Device::getStatus, 1)); + if (shuttleDevice == null) { + return motionList; + } + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue()); + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + return motionList; + } + if (!shuttleThread.isIdle()) { + return motionList; + } + + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� + boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); + if (shuttleResult) { + //瀛樺湪浠诲姟锛岀姝㈣В鏋� + return motionList; + } + + // 鍏ュ簱鐩爣灞傛湁绌挎杞� + if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getDestLoc())) { + + // 绌挎杞﹁蛋琛岃嚦鍙栬揣搴撲綅 motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); @@ -630,134 +506,125 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(conveyLocNo); })), MotionCtgType.SHUTTLE_MOVE )); - // 閿佸畾鎹㈠眰璺緞 - motionList.addAll(kernelService.mapLockPath( + // 绌挎杞﹀叆搴撻《鍗� + motionList.addAll(kernelService.shuttleAction( null, MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(JSON.toJSONString(lockPath)); - })) + })), + MotionCtgType.SHUTTLE_PALLET_LIFT )); - // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 - motionList.addAll(kernelService.liftMove( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(shuttleLocNo)); - })) - )); - - // 閿佸畾鎻愬崌鏈� - motionList.addAll(kernelService.liftLock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満 + // 绌挎杞﹁浇璐ц蛋琛岃嚦鐩爣搴撲綅 motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); + dto.setLocNo(conveyLocNo); })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(liftLocNoTo); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(destLoc); })), - MotionCtgType.SHUTTLE_MOVE_TO_LIFT + MotionCtgType.SHUTTLE_TRANSPORT )); - // 瑙i攣鎻愬崌鏈� - motionList.addAll(kernelService.liftUnlock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 鎻愬崌鏈烘惉杞� 鑷� 鐩爣浣嶇疆灞� - motionList.addAll(kernelService.liftMoveShuttle( - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(shuttleLocNo)); - })), - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(liftLocNoFrom)); - })) - )); - - // 閿佸畾鎻愬崌鏈� - motionList.addAll(kernelService.liftLock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 鏇存柊灏忚溅鍧愭爣 - motionList.addAll(kernelService.shuttleUpdateLocation( - null - , MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(liftLocNoFrom); - })) - )); - - // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(liftLocNoFrom); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); - })), - MotionCtgType.SHUTTLE_MOVE_FROM_LIFT - )); - - // 瑙i攣鎻愬崌鏈� - motionList.addAll(kernelService.liftUnlock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 - })) - )); - - // 瑙i攣鎹㈠眰璺緞 - motionList.addAll(kernelService.mapUnlockPath( + // 绌挎杞﹀叆搴撴墭鐩樹笅闄� + motionList.addAll(kernelService.shuttleAction( null, MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(JSON.toJSONString(lockPath)); - })) + })), + MotionCtgType.SHUTTLE_PALLET_DOWN )); + } - // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍑哄簱搴撲綅 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(originLoc); - })), - MotionCtgType.SHUTTLE_MOVE - )); + } + + /** + * 鍑哄簱 + */ + if (task.getTaskSts() == TaskStsType.NEW_OUTBOUND.sts) { + // locNo + String originLoc = task.getOriginLoc(); + + // shuttle + Device shuttleDevice = deviceService.getOne(new LambdaQueryWrapper<Device>() + .eq(Device::getDeviceNo, task.getShuttleNo()) + .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) + .eq(Device::getHostId, task.getHostId()) + .eq(Device::getStatus, 1)); + if (shuttleDevice == null) { + return motionList; + } + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue()); + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + return motionList; + } + if (!shuttleThread.isIdle()) { + return motionList; + } + + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� + boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); + if (shuttleResult) { + //瀛樺湪浠诲姟锛岀姝㈣В鏋� + return motionList; + } + + //鍒嗘瀽鍑哄簱璺緞鏀捐揣搴撲綅 + String lastPathStartLoc = shuttleDispatcher.analyzeOutPathWaitLoc(originLoc, conveyLocNo, shuttleDevice); + if (lastPathStartLoc == null) { + return motionList;//鏈垎鏋愭垚鍔� + } + + //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 杩涙彁鍗囨満 + ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() + .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo)) + .eq(ShuttleStandby::getStatus, 1)); + + //绌挎杞﹀緟鏈轰綅缃� 浣跨敤琛ㄥ垪 + String standbyLocNoList = shuttleStandbyTo.getStandbyLoc(); + + String standbyLocNo; + if (originSite == 1015) { + standbyLocNo = "1200101"; + } else if (originSite == 1026) { + standbyLocNo = "1200105"; + } else { + standbyLocNo = null; + } + + /** + * 鍑哄簱 + */ + if (Utils.getLev(shuttleLocNo) == Utils.getLev(originLoc)) { + + //绌挎杞︿笉鍦ㄥ嚭搴撳簱浣� + if (!shuttleLocNo.equals(task.getOriginLoc())) { + // 绌挎杞﹁蛋琛岃嚦鍑哄簱搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(shuttleLocNo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(originLoc); + })), + MotionCtgType.SHUTTLE_MOVE + )); + } // 绌挎杞﹀嚭搴撻《鍗� motionList.addAll(kernelService.shuttleAction( @@ -768,20 +635,23 @@ MotionCtgType.SHUTTLE_PALLET_LIFT )); - // 绌挎杞﹁浇璐у嚭搴撹嚦鏈�鍚庝竴娈佃矾寰勭瓑寰� - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(originLoc); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(lastPathStartLoc); - })), - MotionCtgType.SHUTTLE_TRANSPORT - )); + if (!originLoc.equals(lastPathStartLoc)) { + // 绌挎杞﹁浇璐у嚭搴撹嚦鏈�鍚庝竴娈佃矾寰勭瓑寰� + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(originLoc); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(lastPathStartLoc); + })), + MotionCtgType.SHUTTLE_TRANSPORT + )); + } - // 绌挎杞﹁浇璐ц嚦鎻愬崌鏈哄緟鏈轰綅 + // 绌挎杞﹁浇璐ц嚦杈撻�佺嚎浣� motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); @@ -789,8 +659,8 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(conveyLocNo); dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//杈撻�佺珯 })), MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR @@ -809,45 +679,17 @@ motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); + dto.setLocNo(conveyLocNo); })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocs); - dto.setSync(0);//寮傛鎵ц + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(standbyLocNoList); +// dto.setSync(0);//寮傛鎵ц dto.setReleaseShuttle(1);//鎵ц瀹屾垚鍚庨噴鏀惧皬杞� })), MotionCtgType.SHUTTLE_MOVE_STANDBY )); - - // 鎻愬崌鏈鸿浇璐хЩ鍔� - motionList.addAll(kernelService.liftMoveGoods( - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(task.getOriginLoc())); - dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//璧峰绔欑偣 - })) - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(1);//鍏夋嘲1灞傛槸杈撻�佺嚎灞� - dto.setStaNo(31001);//鍑哄簱绔欑偣 - dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue()); - dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 - })) - )); - - // 杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛 -// motionList.addAll(kernelService.conveyorOutbound( -// MotionDto.build((dto -> { -// dto.setDevpNo(basConveyorPath.getDeviceId().intValue()); -// dto.setStaNo(basConveyorPath.getDeviceStn()); -// })), -// MotionDto.build((dto -> { -// dto.setDevpNo(basConveyorPath.getDeviceId().intValue()); -// dto.setStaNo(basConveyorPath.getStnNo()); -// })), -// MotionCtgType.CONVEYOR_OUTBOUND -// )); } @@ -855,7 +697,6 @@ return motionList; } - /** * 鐢熸垚鍏呯數鍔ㄤ綔 @@ -889,51 +730,12 @@ String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); - //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鍙崲灞傛彁鍗囨満 - LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true); - if (liftThread == null) { - return motionList; - } - Device transferLiftDevice = liftThread.getDevice(); - - LiftProtocol liftProtocol = liftThread.getStatus(); - if (liftProtocol == null || liftProtocol.getLiftNo() == null) { - return motionList; - } - //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); if (shuttleResult) { //瀛樺湪浠诲姟锛岀姝㈣В鏋� return motionList; } - - //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 杩涙彁鍗囨満 - ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() - .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) - .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo)) - .eq(ShuttleStandby::getStatus, 1)); - - //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 鍑烘彁鍗囨満 - ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() - .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) - .eq(ShuttleStandby::getDeviceLev, Utils.getLev(chargeLocNo)) - .eq(ShuttleStandby::getStatus, 1)); - if (shuttleStandbyTo == null || shuttleStandbyFrom == null) { - return motionList; - } - - //绌挎杞﹁繘鎻愬崌鏈哄簱浣嶅彿 - String liftLocNoTo = shuttleStandbyTo.getDeviceLoc(); - - //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿 - String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc(); - - //绌挎杞﹁繘鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� - String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc(); - - //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� - String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc(); // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鍏呯數灞� if (Utils.getLev(shuttleLocNo) == Utils.getLev(chargeLocNo)) { @@ -946,124 +748,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(chargeLocNo); - })), - MotionCtgType.SHUTTLE_MOVE - )); - - } else { - - // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅 - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(shuttleLocNo); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); - })), - MotionCtgType.SHUTTLE_MOVE - )); - - // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 - motionList.addAll(kernelService.liftMove( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(shuttleLocNo)); - })) - )); - - // 閿佸畾鎻愬崌鏈� - motionList.addAll(kernelService.liftLock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鎻愬崌鏈� - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoTo); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(liftLocNoTo); - })), - MotionCtgType.SHUTTLE_MOVE_TO_LIFT - )); - - // 瑙i攣鎻愬崌鏈� - motionList.addAll(kernelService.liftUnlock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 鎻愬崌鏈烘惉杞� 鑷� 鍏呯數灞� - motionList.addAll(kernelService.liftMoveShuttle( - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(shuttleLocNo)); - })), - MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLev(Utils.getLev(chargeLocNo)); - })) - )); - - // 閿佸畾鎻愬崌鏈� - motionList.addAll(kernelService.liftLock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 鏇存柊灏忚溅鍧愭爣 - motionList.addAll(kernelService.shuttleUpdateLocation( - null - , MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(liftLocNoFrom); - })) - )); - - // 绌挎杞︽彁鍗囨満鑷虫彁鍗囨満寰呮満浣� - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLiftNo(transferLiftDevice.getId().intValue()); - dto.setLocNo(liftLocNoFrom); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); - })), - MotionCtgType.SHUTTLE_MOVE_FROM_LIFT - )); - - // 瑙i攣鎻愬崌鏈� - motionList.addAll(kernelService.liftUnlock( - null - , MotionDto.build((dto -> { - dto.setLiftNo(transferLiftDevice.getId().intValue()); - })) - )); - - // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍏呯數浣� - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); - dto.setLocNo(standbyLocNoFrom); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(chargeLocNo); })), MotionCtgType.SHUTTLE_MOVE @@ -1132,6 +817,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(locNo); })), MotionCtgType.SHUTTLE_MOVE @@ -1172,7 +858,7 @@ return motionList; } - String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + String shuttleLocNo = task.getOriginLoc(); // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) { @@ -1186,6 +872,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(locNo); })), MotionCtgType.SHUTTLE_MOVE @@ -1226,6 +913,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLiftNo(liftDevice.getId().intValue()); dto.setLocNo(standbyLocNoTo); })), @@ -1266,6 +954,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLiftNo(liftDevice.getId().intValue()); dto.setLocNo(liftLocNoTo); })), @@ -1318,6 +1007,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(standbyLocNoFrom); })), MotionCtgType.SHUTTLE_MOVE_FROM_LIFT @@ -1349,6 +1039,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); dto.setLocNo(locNo); })), MotionCtgType.SHUTTLE_MOVE @@ -1404,6 +1095,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(device.getId().intValue()); + dto.setShuttleDevice(device); dto.setLocNo(targetLoc); })), MotionCtgType.SHUTTLE_MOVE @@ -1456,6 +1148,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(device.getId().intValue()); + dto.setShuttleDevice(device); dto.setLocNo(sourceLoc); })), MotionCtgType.SHUTTLE_MOVE @@ -1477,6 +1170,7 @@ })), MotionDto.build((dto -> { dto.setShuttleNo(device.getId().intValue()); + dto.setShuttleDevice(device); dto.setLocNo(targetLoc); })), MotionCtgType.SHUTTLE_TRANSPORT @@ -1517,12 +1211,13 @@ if (destSite.equals("move")) { //鎻愬崌鏈哄崌闄嶆ゼ灞� + Integer liftLevLogic = liftDispatcher.getLiftLevOffset(device.getId().intValue(), Integer.parseInt(task.getDestLoc())); // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 motionList.addAll(kernelService.liftMove( null , MotionDto.build((dto -> { dto.setLiftNo(device.getId().intValue()); - dto.setLev(Integer.parseInt(task.getDestLoc())); + dto.setLev(liftLevLogic); })) )); @@ -1534,19 +1229,23 @@ return motionList; } + Integer originLev = liftDispatcher.getLiftLevOffset(device.getId().intValue(), Utils.getLev(basConveyorStaOrigin.getLocNo())); + Integer targetLev = liftDispatcher.getLiftLevOffset(device.getId().intValue(), Utils.getLev(basConveyorStaDest.getLocNo())); + // 鎻愬崌鏈虹Щ鍔ㄦ墭鐩� motionList.addAll(kernelService.liftMoveGoods( MotionDto.build((dto -> { dto.setLiftNo(device.getId().intValue()); - dto.setLev(Utils.getLev(basConveyorStaOrigin.getLocNo())); + dto.setLev(originLev); dto.setStaNo(Integer.parseInt(task.getOriginSite())); })) , MotionDto.build((dto -> { dto.setLiftNo(device.getId().intValue()); - dto.setLev(Utils.getLev(basConveyorStaDest.getLocNo())); + dto.setLev(targetLev); dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue()); dto.setStaNo(Integer.parseInt(task.getDestSite())); - })) + })), + MotionCtgType.LIFT_WITH_GOODS )); } else if (destSite.equals("lock")) { @@ -1570,4 +1269,340 @@ return motionList; } + /** + * 鐢熸垚灏忚溅杞借揣杩佺Щ鍔ㄤ綔 + */ + public List<Motion> generateShuttleLadenMoveMotion(Task task) { + List<Motion> motionList = new ArrayList<>(); + if (task.getTaskSts() != TaskStsType.NEW_LADEN_MOVE.sts) { + return motionList; + } + //originLoc 婧愬簱浣� + String originLoc = task.getOriginLoc(); + // locNo 鐩爣搴撲綅 + String locNo = task.getDestLoc(); + + // shuttle + Device shuttleDevice = deviceService.getOne(new LambdaQueryWrapper<Device>() + .eq(Device::getDeviceNo, task.getShuttleNo()) + .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) + .eq(Device::getHostId, task.getHostId()) + .eq(Device::getStatus, 1)); + if (shuttleDevice == null) { + return motionList; + } + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue()); + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + return motionList; + } + if (!shuttleThread.isIdle()) { + return motionList; + } + + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鍙崲灞傛彁鍗囨満 + LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true); + if (liftThread == null) { + return motionList; + } + Device transferLiftDevice = liftThread.getDevice(); + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null || liftProtocol.getLiftNo() == null) { + return motionList; + } + + //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� + boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); + if (shuttleResult) { + //瀛樺湪浠诲姟锛岀姝㈣В鏋� + return motionList; + } + + //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 杩涙彁鍗囨満 + ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() + .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) + .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo)) + .eq(ShuttleStandby::getStatus, 1)); + + //鑾峰彇灏忚溅寰呮満搴撲綅 ==> 鍑烘彁鍗囨満 + ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() + .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) + .eq(ShuttleStandby::getDeviceLev, Utils.getLev(originLoc)) + .eq(ShuttleStandby::getStatus, 1)); + if (shuttleStandbyTo == null || shuttleStandbyFrom == null) { + return motionList; + } + + //绌挎杞﹁繘鎻愬崌鏈哄簱浣嶅彿 + String liftLocNoTo = shuttleStandbyTo.getDeviceLoc(); + + //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿 + String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc(); + + //绌挎杞﹁繘鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� 杈撻�佺嚎浣嶇疆 + String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc(); + + //绌挎杞︽崲灞傛椂寰呮満浣嶇疆 浣跨敤琛ㄥ垪 memo鏁版嵁 + String standbyLocNoMemo = shuttleStandbyTo.getMemo(); + + //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� + String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc(); + + //绌挎杞﹀嚭鎻愬崌鏈哄悗鍏ㄩ儴寰呮満浣� + String standbyLocs = shuttleStandbyFrom.getStandbyLoc();//鑾峰彇鍏ㄩ儴寰呮満浣� + + //鎹㈠眰闇�瑕侀攣瀹氱殑璺緞 + List<String> lockPath = shuttleStandbyFrom.getLockPath$(); + + //鑾峰彇鍑哄簱浠诲姟绫诲瀷 + TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() + .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.MOVE)) + .eq(TaskCtg::getStatus, 1)); + if (taskCtg == null) { + return motionList; + } + + + + + /** + * 鍑哄簱 + */ + if (Utils.getLev(shuttleLocNo) == Utils.getLev(originLoc)) { + + //绌挎杞︿笉鍦ㄥ嚭搴撳簱浣� + if (!shuttleLocNo.equals(task.getOriginLoc())) { + // 绌挎杞﹁蛋琛岃嚦鍑哄簱搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(shuttleLocNo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(originLoc); + })), + MotionCtgType.SHUTTLE_MOVE + )); + } + + // 绌挎杞﹀嚭搴撻《鍗� + motionList.addAll(kernelService.shuttleAction( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + })), + MotionCtgType.SHUTTLE_PALLET_LIFT + )); + + // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(originLoc); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(locNo); + })), + MotionCtgType.SHUTTLE_TRANSPORT + )); + + // 绌挎杞﹀嚭搴撴墭鐩樹笅闄� + motionList.addAll(kernelService.shuttleAction( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + })), + MotionCtgType.SHUTTLE_PALLET_DOWN + )); + + + + /** + * 浜屻�佸嚭搴撹捣濮嬪眰娌℃湁绌挎杞� + */ + } else { + + // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(shuttleLocNo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLocNo(standbyLocNoMemo); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + // 閿佸畾鎹㈠眰璺緞 + motionList.addAll(kernelService.mapLockPath( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(JSON.toJSONString(lockPath)); + })) + )); + + // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 + motionList.addAll(kernelService.liftMove( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLev(Utils.getLev(shuttleLocNo)); + })) + )); + + // 閿佸畾鎻愬崌鏈� + motionList.addAll(kernelService.liftLock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + })) + )); + + // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(standbyLocNoMemo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLocNo(liftLocNoTo); + })), + MotionCtgType.SHUTTLE_MOVE_TO_LIFT + )); + + // 瑙i攣鎻愬崌鏈� + motionList.addAll(kernelService.liftUnlock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + })) + )); + + // 鎻愬崌鏈烘惉杞� 鑷� 鐩爣浣嶇疆灞� + motionList.addAll(kernelService.liftMoveShuttle( + MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLev(Utils.getLev(shuttleLocNo)); + })), + MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLev(Utils.getLev(liftLocNoFrom)); + })) + )); + + // 閿佸畾鎻愬崌鏈� + motionList.addAll(kernelService.liftLock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + })) + )); + + // 鏇存柊灏忚溅鍧愭爣 + motionList.addAll(kernelService.shuttleUpdateLocation( + null + , MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(liftLocNoFrom); + })) + )); + + // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLocNo(liftLocNoFrom); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(standbyLocNoFrom); + })), + MotionCtgType.SHUTTLE_MOVE_FROM_LIFT + )); + + // 瑙i攣鎻愬崌鏈� + motionList.addAll(kernelService.liftUnlock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満 + })) + )); + + // 瑙i攣鎹㈠眰璺緞 + motionList.addAll(kernelService.mapUnlockPath( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(JSON.toJSONString(lockPath)); + })) + )); + + // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍑哄簱搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLiftNo(transferLiftDevice.getId().intValue()); + dto.setLocNo(standbyLocNoFrom); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(originLoc); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + // 绌挎杞﹀嚭搴撻《鍗� + motionList.addAll(kernelService.shuttleAction( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + })), + MotionCtgType.SHUTTLE_PALLET_LIFT + )); + + // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(originLoc); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setShuttleDevice(shuttleDevice); + dto.setLocNo(locNo); + })), + MotionCtgType.SHUTTLE_TRANSPORT + )); + + // 绌挎杞﹀嚭搴撴墭鐩樹笅闄� + motionList.addAll(kernelService.shuttleAction( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + })), + MotionCtgType.SHUTTLE_PALLET_DOWN + )); + + } + return motionList; + } } -- Gitblit v1.9.1