From 9372f61dcb41eeb2e09871caefce0f764d6ab021 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期五, 21 六月 2024 15:17:04 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java | 258 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 204 insertions(+), 54 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 e3ef211..5791605 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 @@ -2,14 +2,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.common.Cools; -import com.zy.asrs.framework.common.R; import com.zy.asrs.wcs.core.domain.dto.MotionDto; import com.zy.asrs.wcs.core.entity.ShuttleStandby; import com.zy.asrs.wcs.core.entity.Task; import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; import com.zy.asrs.wcs.core.model.enums.MotionCtgType; import com.zy.asrs.wcs.core.model.enums.TaskStsType; -import com.zy.asrs.wcs.core.model.enums.WorkZoneType; import com.zy.asrs.wcs.core.service.ShuttleStandbyService; import com.zy.asrs.wcs.core.service.TaskService; import com.zy.asrs.wcs.core.utils.ConveyorDispatcher; @@ -19,7 +17,6 @@ import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.core.entity.Motion; import com.zy.asrs.wcs.rcs.entity.Device; -import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; 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; @@ -32,10 +29,9 @@ import java.util.ArrayList; import java.util.List; -import java.util.Objects; /** - * todo:luxiaotao 1.鍏呯數浠诲姟锛�2.搴撲綅绉昏浆锛�3.灏忚溅杩佺Щ + * 1.鍏呯數浠诲姟锛�2.搴撲綅绉昏浆锛�3.灏忚溅杩佺Щ锛�4.鎵嬪姩浠诲姟 * Created by vincent on 2023/10/11 */ @Service @@ -60,12 +56,6 @@ public List<Motion> generateMotion(Task task) { List<Motion> motionList = new ArrayList<>(); -// switch (Objects.requireNonNull(WorkZoneType.query(task.getTaskSts() == TaskStsType.NEW_INBOUND.sts ? task.getOriginSite() : task.getDestSite()))) { -// case FIRST_ZONE: -// motionList = this.generateFirstZoneMotion(task); -// break; -// default: -// } motionList = this.generateFirstZoneMotion(task); return motionList; } @@ -85,21 +75,86 @@ * 5.绌挎杞﹀叆搴撹嚦鐩爣搴撲綅 */ if (task.getTaskSts() == TaskStsType.NEW_INBOUND.sts) { -// // lift -// LiftThread liftThread = liftDispatcher.queryLiftForTransport(task.getOriginSite()); -// LiftProtocol liftProtocol = liftThread.getStatus(); -// if (liftProtocol == null) { -// return motionList; -// } + // 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(); + + //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鍙崲灞傛彁鍗囨満 + 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); + if (shuttleResult) { + //瀛樺湪浠诲姟锛岀姝㈣В鏋� + return motionList; + } + + //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹� + boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo())); + if (liftResult) { + //瀛樺湪浠诲姟锛岀姝㈣В鏋� + 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(); // shuttle // ShuttleThread shuttleThread = shuttleDispatcher.queryShuttleWhichConvenient(task, Integer.parseInt(liftThread.getStatus().getLiftNo())); // ShuttleThread shuttleThread = shuttleDispatcher.queryShuttleWhichConvenient(task, 1); - ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, 6); - if (Cools.isEmpty(shuttleThread)) { return motionList; } - ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); // String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); - String shuttleLocNo = "0100201"; // // conveyor // DevpSlave devpSlave = conveyorDispatcher.queryByInBound(task.getSourceStaNo()); @@ -751,12 +806,13 @@ String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); - // lift - Device transferLiftDevice = Utils.getRecentTransferLift(shuttleLocNo, shuttleProtocol.getShuttleNo()); - if (transferLiftDevice == null) { + //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鍙崲灞傛彁鍗囨満 + LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true); + if (liftThread == null) { return motionList; } - LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, transferLiftDevice.getId().intValue()); + Device transferLiftDevice = liftThread.getDevice(); + LiftProtocol liftProtocol = liftThread.getStatus(); if (liftProtocol == null || liftProtocol.getLiftNo() == null) { return motionList; @@ -843,7 +899,15 @@ })) )); - // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鎻愬崌鏈哄簱浣� + // 閿佸畾鎻愬崌鏈� + 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()); @@ -857,7 +921,15 @@ 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()); @@ -866,6 +938,23 @@ 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); })) )); @@ -881,6 +970,14 @@ dto.setLocNo(standbyLocNoFrom); })), MotionCtgType.SHUTTLE_MOVE_FROM_LIFT + )); + + // 瑙i攣鎻愬崌鏈� + motionList.addAll(kernelService.liftUnlock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(transferLiftDevice.getId().intValue()); + })) )); // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍏呯數浣� @@ -996,24 +1093,26 @@ // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) { - // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 - 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(locNo); - })), - MotionCtgType.SHUTTLE_MOVE - )); + if (!shuttleLocNo.equals(locNo)) {//灏忚溅涓嶅湪鐩爣搴撲綅 + // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 + 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(locNo); + })), + MotionCtgType.SHUTTLE_MOVE + )); + } } else { //灏忚溅璺ㄥ眰 - //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鎻愬崌鏈� - LiftThread liftThread = liftDispatcher.searchIdleLift(locNo, task.getHostId()); + //鑾峰彇璺濈鐩爣浣嶇疆鏈�杩戠殑绌洪棽鍙崲灞傛彁鍗囨満 + LiftThread liftThread = liftDispatcher.searchIdleLift(locNo, task.getHostId(), true); if (liftThread == null) { return motionList; } @@ -1055,7 +1154,15 @@ })) )); - // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満搴撲綅 + // 閿佸畾鎻愬崌鏈� + motionList.addAll(kernelService.liftLock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + })) + )); + + // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満 motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { dto.setShuttleNo(shuttleDevice.getId().intValue()); @@ -1069,6 +1176,22 @@ MotionCtgType.SHUTTLE_MOVE_TO_LIFT )); + // 鍚戞彁鍗囨満鍙戦�佸皬杞﹀凡鍒颁綅淇″彿 + motionList.addAll(kernelService.liftShuttleArrival( + null + , MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + })) + )); + + // 瑙i攣鎻愬崌鏈� + motionList.addAll(kernelService.liftUnlock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + })) + )); + // 鎻愬崌鏈烘惉杞� 鑷� 鐩爣浣嶇疆灞� motionList.addAll(kernelService.liftMoveShuttle( MotionDto.build((dto -> { @@ -1078,6 +1201,23 @@ MotionDto.build((dto -> { dto.setLiftNo(liftDevice.getId().intValue()); dto.setLev(Utils.getLev(locNo)); + })) + )); + + // 閿佸畾鎻愬崌鏈� + motionList.addAll(kernelService.liftLock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + })) + )); + + // 鏇存柊灏忚溅鍧愭爣 + motionList.addAll(kernelService.shuttleUpdateLocation( + null + , MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(liftLocNoFrom); })) )); @@ -1093,6 +1233,14 @@ dto.setLocNo(standbyLocNoFrom); })), MotionCtgType.SHUTTLE_MOVE_FROM_LIFT + )); + + // 瑙i攣鎻愬崌鏈� + motionList.addAll(kernelService.liftUnlock( + null + , MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + })) )); // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鐩爣浣嶇疆 @@ -1202,18 +1350,20 @@ // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� if (Utils.getLev(shuttleLocNo) == Utils.getLev(targetLoc)) { - // 绌挎杞﹁蛋琛岃嚦婧愬簱浣� - motionList.addAll(kernelService.shuttleMove( - MotionDto.build((dto -> { - dto.setShuttleNo(device.getId().intValue()); - dto.setLocNo(shuttleLocNo); - })), - MotionDto.build((dto -> { - dto.setShuttleNo(device.getId().intValue()); - dto.setLocNo(sourceLoc); - })), - MotionCtgType.SHUTTLE_MOVE - )); + if (!shuttleLocNo.equals(sourceLoc)) {//灏忚溅涓嶅湪鐩爣搴撲綅 + // 绌挎杞﹁蛋琛岃嚦婧愬簱浣� + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(device.getId().intValue()); + dto.setLocNo(shuttleLocNo); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(device.getId().intValue()); + dto.setLocNo(sourceLoc); + })), + MotionCtgType.SHUTTLE_MOVE + )); + } //鎵樼洏椤跺崌 motionList.add(Motion.build(motion -> { -- Gitblit v1.9.1