From 06a9757c727c6bc15595d5f56a0e309077025741 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 17 四月 2024 09:22:14 +0800 Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java | 664 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 448 insertions(+), 216 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 4f7ef93..c596e27 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 @@ -1,20 +1,29 @@ package com.zy.asrs.wcs.core.kernel; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.common.Cools; 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; import com.zy.asrs.wcs.core.utils.LiftDispatcher; import com.zy.asrs.wcs.core.utils.ShuttleDispatcher; import com.zy.asrs.wcs.core.utils.Utils; 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.SlaveType; +import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; import com.zy.asrs.wcs.core.service.MotionService; +import com.zy.asrs.wcs.rcs.service.DeviceService; +import com.zy.asrs.wcs.rcs.thread.LiftThread; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,17 +49,22 @@ private ShuttleDispatcher shuttleDispatcher; @Autowired private LiftDispatcher liftDispatcher; -// @Autowired -// private ConveyorDispatcher conveyorDispatcher; + @Autowired + private ConveyorDispatcher conveyorDispatcher; + @Autowired + private DeviceService deviceService; + @Autowired + private ShuttleStandbyService shuttleStandbyService; 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; } @@ -703,215 +717,433 @@ } -// /** -// * 鐢熸垚鍏呯數鍔ㄤ綔 -// */ -// public List<Motion> generateChargeMotion(WrkCharge wrkCharge) { -// List<Motion> motionList = new ArrayList<>(); -// if (wrkCharge.getWrkSts() != WrkMastStsType.NEW_CHARGE.sts || wrkCharge.getIoType() != WrkIoTypeType.CHARGE.sts) { -// return motionList; -// } -// -// // locNo -// String chargeLocNo = wrkCharge.getLocNo(); -// -// // lift -// Integer transferLiftNo = 2; -// SiemensLiftThread liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, transferLiftNo); -// LiftProtocol liftProtocol = liftThread.getLiftProtocol(); -// if (liftProtocol == null || liftProtocol.getLiftNo() == null) { -// return motionList; -// } -// -// // shuttle -// Integer shuttleNo = wrkCharge.getShuttleNo(); -// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); -// ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); -// if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { -// return motionList; -// } -// if (!shuttleProtocol.isIdle()) { -// return motionList; -// } -// -// //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹� -// boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleProtocol.getShuttleNo().intValue()); -// if (shuttleResult) { -// //瀛樺湪浠诲姟锛岀姝㈣В鏋� -// return motionList; -// } -// -// //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹� -// boolean liftResult = Utils.checkLiftHasBinding(transferLiftNo); -// if (liftResult) { -// //瀛樺湪浠诲姟锛岀姝㈣В鏋� -// return motionList; -// } -// -// String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); -// -// //绌挎杞﹀埌鎻愬崌鏈哄簱浣嶅彿 -// String liftLocNoTo = LiftCodeType.getLocNo(transferLiftNo, Utils.getLev(shuttleLocNo)); -// -// //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿 -// String liftLocNoFrom = LiftCodeType.getLocNo(transferLiftNo, Utils.getLev(wrkCharge.getLocNo())); -// -// //绌挎杞﹀埌鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� -// String standbyLocNoTo = LiftCodeType.getStandbyLocNo(transferLiftNo, Utils.getLev(shuttleLocNo)); -// -// //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙� -// String standbyLocNoFrom = LiftCodeType.getStandbyLocNo(transferLiftNo, Utils.getLev(wrkCharge.getLocNo())); -// -// // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鍏呯數灞� -// if (Utils.getLev(shuttleLocNo) == Utils.getLev(chargeLocNo)) { -// -// // 绌挎杞﹁蛋琛岃嚦鍏呯數妗╁簱浣� -// motionList.addAll(kernelService.shuttleMove( -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(shuttleLocNo); -// })), -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(chargeLocNo); -// })), -// MotionCtgType.SHUTTLE_MOVE -// )); -// -// } else { -// -// // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅 -// motionList.addAll(kernelService.shuttleMove( -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(shuttleLocNo); -// })), -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(standbyLocNoTo); -// })), -// MotionCtgType.SHUTTLE_MOVE -// )); -// -// // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰 -// motionList.addAll(kernelService.liftMove( -// null -// , MotionDto.build((dto -> { -// dto.setLiftNo(transferLiftNo); -// dto.setLev(Utils.getLev(shuttleLocNo)); -// })) -// )); -// -// // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鎻愬崌鏈哄簱浣� -// motionList.addAll(kernelService.shuttleMove( -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(standbyLocNoTo); -// })), -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLiftNo(transferLiftNo); -// dto.setLocNo(liftLocNoTo); -// })), -// MotionCtgType.SHUTTLE_MOVE_TO_LIFT -// )); -// -// // 鎻愬崌鏈烘惉杞� 鑷� 杈撻�佺嚎灞� -// motionList.addAll(kernelService.liftMoveShuttle( -// MotionDto.build((dto -> { -// dto.setLiftNo(transferLiftNo); -// dto.setLev(Utils.getLev(shuttleLocNo)); -// })), -// MotionDto.build((dto -> { -// dto.setLiftNo(transferLiftNo); -// dto.setLev(Utils.getLev(chargeLocNo)); -// })) -// )); -// -// // 绌挎杞︽彁鍗囨満鑷虫彁鍗囨満寰呮満浣� -// motionList.addAll(kernelService.shuttleMove( -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLiftNo(transferLiftNo); -// dto.setLocNo(liftLocNoFrom); -// })), -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(standbyLocNoFrom); -// })), -// MotionCtgType.SHUTTLE_MOVE_FROM_LIFT -// )); -// -// // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍏呯數浣� -// motionList.addAll(kernelService.shuttleMove( -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(standbyLocNoFrom); -// })), -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(chargeLocNo); -// })), -// MotionCtgType.SHUTTLE_MOVE -// )); -// -// wrkCharge.setLiftNo(transferLiftNo); -// wrkChargeMapper.updateById(wrkCharge); -// } -// -// // 绌挎杞﹀紑濮嬪厖鐢� -// motionList.addAll(kernelService.shuttleCharge( -// null, -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// })) -// )); -// -// return motionList; -// } -// -// /** -// * 鐢熸垚鍏呯數瀹屾垚鍔ㄤ綔 -// */ -// public List<Motion> generateShuttleChargeWrkComplete(WrkCharge wrkCharge) { -// List<Motion> motionList = new ArrayList<>(); -// if (wrkCharge.getWrkSts() != WrkMastStsType.NEW_MOVE.sts || wrkCharge.getIoType() != WrkIoTypeType.MOVE.sts) { -// return motionList; -// } -// -// // locNo -// String locNo = wrkCharge.getLocNo(); -// -// // shuttle -// Integer shuttleNo = wrkCharge.getShuttleNo(); -// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); -// ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); -// if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { -// return motionList; -// } -// -// String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); -// -// // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� -// if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) { -// -// // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 -// motionList.addAll(kernelService.shuttleMove( -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(shuttleLocNo); -// })), -// MotionDto.build((dto -> { -// dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); -// dto.setLocNo(locNo); -// })), -// MotionCtgType.SHUTTLE_MOVE -// )); -// -// } -// return motionList; -// } + /** + * 鐢熸垚鍏呯數鍔ㄤ綔 + */ + public List<Motion> generateChargeMotion(Task task) { + List<Motion> motionList = new ArrayList<>(); + if (task.getTaskSts() != TaskStsType.NEW_CHARGE.sts) { + return motionList; + } + // locNo + String chargeLocNo = 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(); + + // lift + Device transferLiftDevice = Utils.getRecentTransferLift(shuttleLocNo, shuttleProtocol.getShuttleNo()); + if (transferLiftDevice == null) { + return motionList; + } + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, transferLiftDevice.getId().intValue()); + 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(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)) { + + // 绌挎杞﹁蛋琛岃嚦鍏呯數妗╁簱浣� + 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(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.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 + )); + + // 鎻愬崌鏈烘惉杞� 鑷� 杈撻�佺嚎灞� + 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.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 + )); + + // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍏呯數浣� + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(standbyLocNoFrom); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + dto.setLocNo(chargeLocNo); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + task.setLiftNo(Integer.parseInt(transferLiftDevice.getDeviceNo())); + taskService.updateById(task); + } + + // 绌挎杞﹀紑濮嬪厖鐢� + motionList.addAll(kernelService.shuttleCharge( + null, + MotionDto.build((dto -> { + dto.setShuttleNo(shuttleDevice.getId().intValue()); + })) + )); + + return motionList; + } + + /** + * 鐢熸垚鍏呯數瀹屾垚鍔ㄤ綔 + */ + public List<Motion> generateShuttleChargeWrkComplete(Task task) { + List<Motion> motionList = new ArrayList<>(); + if (task.getTaskSts() != TaskStsType.NEW_MOVE.sts) { + return motionList; + } + + // 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; + } + + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� + 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 + )); + + } + return motionList; + } + + /** + * 鐢熸垚灏忚溅杩佺Щ鍔ㄤ綔 + */ + public List<Motion> generateShuttleMoveMotion(Task task) { + List<Motion> motionList = new ArrayList<>(); + if (task.getTaskSts() != TaskStsType.NEW_MOVE.sts) { + return motionList; + } + + // locNo + String locNo = task.getDestLoc(); + + Device device = 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) { + return motionList; + } + + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); + if (shuttleThread == null) { + return motionList; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + return motionList; + } + + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� + if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) { + + // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 + 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(locNo); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + } + return motionList; + } + + /** + * 鐢熸垚灏忚溅鎵嬪姩鍔ㄤ綔 + */ + public List<Motion> generateShuttleManualMotion(Task task) { + List<Motion> motionList = new ArrayList<>(); + if (task.getTaskSts() != TaskStsType.NEW_MANUAL.sts) { + return motionList; + } + + String sourceLoc = task.getOriginLoc();//婧愬簱浣� + String targetLoc = task.getDestLoc();//浠诲姟鐩爣(鍊熺敤瀛楁) + String targetSite = task.getDestSite();//浠诲姟绫诲瀷(鍊熺敤瀛楁) + + Device device = 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) { + return motionList; + } + + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); + if (shuttleThread == null) { + return motionList; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + return motionList; + } + + if (targetSite.equals("moveLoc")) {//绉诲姩 + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� + 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(targetLoc); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + } + } else if (targetSite.equals("palletLift")) { + //鎵樼洏椤跺崌 + motionList.add(Motion.build(motion -> { + motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); + motion.setDevice(String.valueOf(device.getId())); + motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val()); + })); + } else if (targetSite.equals("palletDown")) { + //鎵樼洏涓嬮檷 + motionList.add(Motion.build(motion -> { + motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); + motion.setDevice(String.valueOf(device.getId())); + motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val()); + })); + } else if (targetSite.equals("chargeOpen")) { + //鍏呯數寮� + motionList.add(Motion.build(motion -> { + motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); + motion.setDevice(String.valueOf(device.getId())); + motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_ON.val()); + })); + } else if (targetSite.equals("chargeClose")) { + //鍏呯數鍏� + motionList.add(Motion.build(motion -> { + motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); + motion.setDevice(String.valueOf(device.getId())); + motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_OFF.val()); + })); + } else if (targetSite.equals("reset")) { + //澶嶄綅 + } else if (targetSite.equals("takeMove")) { + //鍙栨斁璐� + String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); + + // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞� + 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 + )); + + //鎵樼洏椤跺崌 + motionList.add(Motion.build(motion -> { + motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); + motion.setDevice(String.valueOf(device.getId())); + motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val()); + })); + + // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅 + motionList.addAll(kernelService.shuttleMove( + MotionDto.build((dto -> { + dto.setShuttleNo(device.getId().intValue()); + dto.setLocNo(sourceLoc); + })), + MotionDto.build((dto -> { + dto.setShuttleNo(device.getId().intValue()); + dto.setLocNo(targetLoc); + })), + MotionCtgType.SHUTTLE_MOVE + )); + + //鎵樼洏涓嬮檷 + motionList.add(Motion.build(motion -> { + motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); + motion.setDevice(String.valueOf(device.getId())); + motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val()); + })); + + } + } + + return motionList; + } } -- Gitblit v1.9.1