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 |  130 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 102 insertions(+), 28 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 e1b9bf6..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;
@@ -117,13 +115,6 @@
                 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())
@@ -165,6 +156,7 @@
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(Utils.getLev(task.getDestLoc()));
                             dto.setStaNo(0);//鎻愬崌鏈哄唴渚�
+                            dto.setSync(0);//寮傛鎵ц
                         }))
                 ));
 
@@ -176,7 +168,6 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
-                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(standbyLocNoTo);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
@@ -232,6 +223,7 @@
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -381,6 +373,7 @@
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -453,13 +446,6 @@
             //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹�
             boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
             if (shuttleResult) {
-                //瀛樺湪浠诲姟锛岀姝㈣В鏋�
-                return motionList;
-            }
-
-            //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹�
-            boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
-            if (liftResult) {
                 //瀛樺湪浠诲姟锛岀姝㈣В鏋�
                 return motionList;
             }
@@ -635,6 +621,7 @@
                             dto.setLev(5);//绱㈢墝椤圭洰5灞傛槸杈撻�佺嚎灞�
                             dto.setStaNo(1);//鎻愬崌鏈哄乏渚�
                             dto.setSync(0);//寮傛鎵ц
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -780,6 +767,7 @@
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -982,13 +970,6 @@
             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())
@@ -1150,16 +1131,15 @@
                     MotionCtgType.SHUTTLE_MOVE
             ));
 
-            task.setLiftNo(Integer.parseInt(transferLiftDevice.getDeviceNo()));
-            taskService.updateById(task);
         }
 
         // 绌挎杞﹀紑濮嬪厖鐢�
-        motionList.addAll(kernelService.shuttleCharge(
+        motionList.addAll(kernelService.shuttleAction(
                 null,
                 MotionDto.build((dto -> {
                     dto.setShuttleNo(shuttleDevice.getId().intValue());
-                }))
+                })),
+                MotionCtgType.SHUTTLE_CHARGE_ON
         ));
 
         return motionList;
@@ -1196,6 +1176,15 @@
 
         // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞�
         if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) {
+
+            // 绌挎杞﹀叧闂厖鐢�
+            motionList.addAll(kernelService.shuttleAction(
+                    null,
+                    MotionDto.build((dto -> {
+                        dto.setShuttleNo(shuttleDevice.getId().intValue());
+                    })),
+                    MotionCtgType.SHUTTLE_CHARGE_OFF
+            ));
 
             // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅
             motionList.addAll(kernelService.shuttleMove(
@@ -1417,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