From ebdfec3e9db0977bccca0527be7d2226fbbd0229 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期三, 12 六月 2024 11:02:16 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java | 214 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 185 insertions(+), 29 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 0e3e5f2..1bcdc9e 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 @@ -8,9 +8,9 @@ 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; import com.zy.asrs.wcs.core.utils.LiftDispatcher; import com.zy.asrs.wcs.core.utils.ShuttleDispatcher; import com.zy.asrs.wcs.core.utils.Utils; @@ -29,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 @@ -48,8 +47,8 @@ private ShuttleDispatcher shuttleDispatcher; @Autowired private LiftDispatcher liftDispatcher; -// @Autowired -// private ConveyorDispatcher conveyorDispatcher; + @Autowired + private ConveyorDispatcher conveyorDispatcher; @Autowired private DeviceService deviceService; @Autowired @@ -57,12 +56,13 @@ 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: - } +// 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; } @@ -968,16 +968,16 @@ // locNo String locNo = task.getDestLoc(); - Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() + 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 (device == null) { + if (shuttleDevice == null) { return motionList; } - ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue()); if (shuttleThread == null) { return motionList; } @@ -992,14 +992,116 @@ // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) { - // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 + 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()); + if (liftThread == null) { + return motionList; + } + Device liftDevice = liftThread.getDevice(); + + //绌挎杞﹀埌鎻愬崌鏈哄簱浣嶅彿 + String liftLocNoTo = liftDispatcher.getLiftLocNo(liftThread, Utils.getLev(shuttleLocNo)); + + //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿 + String liftLocNoFrom = liftDispatcher.getLiftLocNo(liftThread, Utils.getLev(task.getDestLoc())); + + //绌挎杞﹀埌鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� + String standbyLocNoTo = liftDispatcher.getLiftStandByLocNo(liftThread, Utils.getLev(shuttleLocNo)); + + //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� + String standbyLocNoFrom = liftDispatcher.getLiftStandByLocNo(liftThread, Utils.getLev(task.getDestLoc())); + + + // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅 motionList.addAll(kernelService.shuttleMove( MotionDto.build((dto -> { - dto.setShuttleNo(device.getId().intValue()); + dto.setShuttleNo(shuttleDevice.getId().intValue()); dto.setLocNo(shuttleLocNo); })), MotionDto.build((dto -> { - dto.setShuttleNo(device.getId().intValue()); + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLiftNo(liftDevice.getId().intValue()); + dto.setLocNo(standbyLocNoTo); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 + motionList.addAll(kernelService.liftMove( + null + , MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + dto.setLev(Utils.getLev(shuttleLocNo)); + })) + )); + + // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満搴撲綅 + 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(liftDevice.getId().intValue()); + dto.setLocNo(liftLocNoTo); + })), + MotionCtgType.SHUTTLE_MOVE_TO_LIFT + )); + + // 鎻愬崌鏈烘惉杞� 鑷� 鐩爣浣嶇疆灞� + motionList.addAll(kernelService.liftMoveShuttle( + MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + dto.setLev(Utils.getLev(shuttleLocNo)); + })), + MotionDto.build((dto -> { + dto.setLiftNo(liftDevice.getId().intValue()); + dto.setLev(Utils.getLev(locNo)); + })) + )); + + // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLiftNo(liftDevice.getId().intValue()); + dto.setLocNo(liftLocNoFrom); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(standbyLocNoFrom); + })), + MotionCtgType.SHUTTLE_MOVE_FROM_LIFT + )); + + // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鐩爣浣嶇疆 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLiftNo(liftDevice.getId().intValue()); + dto.setLocNo(standbyLocNoFrom); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); dto.setLocNo(locNo); })), MotionCtgType.SHUTTLE_MOVE @@ -1098,18 +1200,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 -> { @@ -1144,4 +1248,56 @@ return motionList; } + /** + * 鐢熸垚鎻愬崌鏈烘墜鍔ㄥ姩浣� + */ + public List<Motion> generateLiftManualMotion(Task task) { + List<Motion> motionList = new ArrayList<>(); + if (task.getTaskSts() != TaskStsType.NEW_MANUAL.sts) { + return motionList; + } + + Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() + .eq(Device::getDeviceNo, task.getLiftNo()) + .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()) + .eq(Device::getHostId, task.getHostId()) + .eq(Device::getStatus, 1)); + if (device == null) { + return motionList; + } + + if (task.getDestSite().equals("move")) { + //鎻愬崌鏈哄崌闄嶆ゼ灞� + + // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 + motionList.addAll(kernelService.liftMove( + null + , MotionDto.build((dto -> { + dto.setLiftNo(device.getId().intValue()); + dto.setLev(Integer.parseInt(task.getDestLoc())); + })) + )); + + } else if (task.getDestSite().equals("movePallet")) { + //绉诲姩鎵樼洏 + + // 鎻愬崌鏈虹Щ鍔ㄦ墭鐩� + motionList.addAll(kernelService.liftMoveGoods( + MotionDto.build((dto -> { + dto.setLiftNo(device.getId().intValue()); + dto.setLev(Integer.parseInt(task.getOriginLoc())); + dto.setStaNo(Integer.parseInt(task.getOriginSite())); + })) + , MotionDto.build((dto -> { + dto.setLiftNo(device.getId().intValue()); + dto.setLev(Integer.parseInt(task.getDestLoc())); + dto.setStaNo(Integer.parseInt(task.getDestSite())); + })) + )); + + } + + return motionList; + } + } -- Gitblit v1.9.1