From c13fe87d70e81d7dcb604f8f1227de8f313cbefc Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 10 七月 2024 09:26:51 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java |   89 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 85 insertions(+), 4 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 126fd3d..d017869 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,8 +1,6 @@
 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.framework.common.R;
 import com.zy.asrs.wcs.core.domain.dto.MotionDto;
 import com.zy.asrs.wcs.core.entity.*;
 import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
@@ -1133,8 +1131,6 @@
                     MotionCtgType.SHUTTLE_MOVE
             ));
 
-            task.setLiftNo(Integer.parseInt(transferLiftDevice.getDeviceNo()));
-            taskService.updateById(task);
         }
 
         // 绌挎杞﹀紑濮嬪厖鐢�
@@ -1410,6 +1406,91 @@
         }
         return motionList;
     }
+    /**
+     * 鐢熸垚灏忚溅杞借揣杩佺Щ鍔ㄤ綔
+     */
+    public List<Motion> generateShuttleLadenMoveMotion(Task task) {
+        List<Motion> motionList = new ArrayList<>();
+        if (task.getTaskSts() != TaskStsType.NEW_LADEN_MOVE.sts) {
+            return motionList;
+        }
+        //originLoc 婧愬簱浣�
+        String originLoc =  task.getOriginLoc();
+        // locNo 鐩爣搴撲綅
+        String locNo = task.getDestLoc();
+
+        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());
+        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)) {
+
+            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(originLoc);
+                        })),
+                        MotionCtgType.SHUTTLE_MOVE
+                ));
+
+                // 绌挎杞﹂《鍗�
+                motionList.add(Motion.build(motion -> {
+                    motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
+                    motion.setDevice(String.valueOf(shuttleDevice.getId()));
+                    motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val());
+                }));
+
+                // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅
+                motionList.addAll(kernelService.shuttleMove(
+                        MotionDto.build((dto -> {
+                            dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setLocNo(originLoc);
+                        })),
+                        MotionDto.build((dto -> {
+                            dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setLocNo(locNo);
+                        })),
+                        MotionCtgType.SHUTTLE_MOVE
+                ));
+
+                //绌挎杞︽墭鐩樹笅闄�
+                motionList.add(Motion.build(motion -> {
+                    motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
+                    motion.setDevice(String.valueOf(shuttleDevice.getId()));
+                    motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val());
+                }));
+
+            }
+
+        } else {
+            //灏忚溅璺ㄥ眰
+        }
+        return motionList;
+    }
 
     /**
      * 鐢熸垚灏忚溅鎵嬪姩鍔ㄤ綔

--
Gitblit v1.9.1