From 0eacf47294055d7c292999b3167cbaf6938e50cc Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期三, 12 六月 2024 16:56:26 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java | 695 ++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 459 insertions(+), 236 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 9e0b818..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
@@ -3,34 +3,35 @@
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.entity.DeviceType;
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.service.DeviceTypeService;
+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;
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
@@ -46,21 +47,22 @@
private ShuttleDispatcher shuttleDispatcher;
@Autowired
private LiftDispatcher liftDispatcher;
- // @Autowired
-// private ConveyorDispatcher conveyorDispatcher;
+ @Autowired
+ private ConveyorDispatcher conveyorDispatcher;
@Autowired
private DeviceService deviceService;
@Autowired
- private DeviceTypeService deviceTypeService;
+ 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;
}
@@ -718,164 +720,189 @@
*/
public List<Motion> generateChargeMotion(Task task) {
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());
-// }))
-// ));
+ 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;
}
@@ -885,40 +912,47 @@
*/
public List<Motion> generateShuttleChargeWrkComplete(Task task) {
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
-// ));
-//
-// }
+ 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;
}
@@ -934,24 +968,16 @@
// locNo
String locNo = task.getDestLoc();
- //鑾峰彇绌挎杞︾被鍨�
- DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
- .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))
- .eq(DeviceType::getStatus, 1));
- if (deviceType == null) {
- return motionList;
- }
-
- Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
+ Device shuttleDevice = deviceService.getOne(new LambdaQueryWrapper<Device>()
.eq(Device::getDeviceNo, task.getShuttleNo())
- .eq(Device::getDeviceType, deviceType.getId())
+ .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;
}
@@ -966,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(shuttleProtocol.getShuttleNo().intValue());
+ dto.setShuttleNo(shuttleDevice.getId().intValue());
dto.setLocNo(shuttleLocNo);
})),
MotionDto.build((dto -> {
- dto.setShuttleNo(shuttleProtocol.getShuttleNo().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
@@ -992,20 +1120,13 @@
return motionList;
}
+ String sourceLoc = task.getOriginLoc();//婧愬簱浣�
String targetLoc = task.getDestLoc();//浠诲姟鐩爣(鍊熺敤瀛楁)
String targetSite = task.getDestSite();//浠诲姟绫诲瀷(鍊熺敤瀛楁)
- //鑾峰彇绌挎杞︾被鍨�
- DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
- .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))
- .eq(DeviceType::getStatus, 1));
- if (deviceType == null) {
- return motionList;
- }
-
Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
.eq(Device::getDeviceNo, task.getShuttleNo())
- .eq(Device::getDeviceType, deviceType.getId())
+ .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
.eq(Device::getHostId, task.getHostId())
.eq(Device::getStatus, 1));
if (device == null) {
@@ -1031,11 +1152,11 @@
// 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅
motionList.addAll(kernelService.shuttleMove(
MotionDto.build((dto -> {
- dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+ dto.setShuttleNo(device.getId().intValue());
dto.setLocNo(shuttleLocNo);
})),
MotionDto.build((dto -> {
- dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+ dto.setShuttleNo(device.getId().intValue());
dto.setLocNo(targetLoc);
})),
MotionCtgType.SHUTTLE_MOVE
@@ -1046,32 +1167,134 @@
//鎵樼洏椤跺崌
motionList.add(Motion.build(motion -> {
motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
- motion.setDevice(String.valueOf(task.getShuttleNo()));
+ 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(task.getShuttleNo()));
+ 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(task.getShuttleNo()));
+ 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(task.getShuttleNo()));
+ 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)) {
+
+ 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 -> {
+ 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;
+ }
+
+ /**
+ * 鐢熸垚鎻愬崌鏈烘墜鍔ㄥ姩浣�
+ */
+ 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