From e9a4418c14ef68fb454300b092c413e8df259ec2 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期六, 13 四月 2024 11:50:56 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java |  150 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 136 insertions(+), 14 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 08280d0..2702cdc 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,6 +4,7 @@
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.wcs.core.domain.dto.MotionDto;
 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;
@@ -14,12 +15,10 @@
 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.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.ShuttleThread;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -45,12 +44,10 @@
     private ShuttleDispatcher shuttleDispatcher;
     @Autowired
     private LiftDispatcher liftDispatcher;
-    //    @Autowired
+//    @Autowired
 //    private ConveyorDispatcher conveyorDispatcher;
     @Autowired
     private DeviceService deviceService;
-    @Autowired
-    private DeviceTypeService deviceTypeService;
 
     public List<Motion> generateMotion(Task task) {
         List<Motion> motionList = new ArrayList<>();
@@ -933,17 +930,9 @@
         // 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>()
                 .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) {
@@ -982,6 +971,139 @@
         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