From 2b4747decaee49c1b9bdd568b306118eaf4a41e6 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期三, 10 七月 2024 13:33:29 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java |  111 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 74 insertions(+), 37 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 13cf97a..46b9d35 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
@@ -2,25 +2,23 @@
 
 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.ShuttleStandby;
-import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.entity.*;
 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.TaskCtgType;
 import com.zy.asrs.wcs.core.model.enums.TaskStsType;
-import com.zy.asrs.wcs.core.service.ShuttleStandbyService;
-import com.zy.asrs.wcs.core.service.TaskService;
+import com.zy.asrs.wcs.core.service.*;
 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;
@@ -53,6 +51,10 @@
     private DeviceService deviceService;
     @Autowired
     private ShuttleStandbyService shuttleStandbyService;
+    @Autowired
+    private BasConveyorPathService basConveyorPathService;
+    @Autowired
+    private TaskCtgService taskCtgService;
 
     public List<Motion> generateMotion(Task task) {
         List<Motion> motionList = new ArrayList<>();
@@ -115,13 +117,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())
@@ -163,6 +158,7 @@
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(Utils.getLev(task.getDestLoc()));
                             dto.setStaNo(0);//鎻愬崌鏈哄唴渚�
+                            dto.setSync(0);//寮傛鎵ц
                         }))
                 ));
 
@@ -174,7 +170,6 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
-                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(standbyLocNoTo);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
@@ -230,6 +225,7 @@
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -379,6 +375,7 @@
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -455,13 +452,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())
@@ -491,6 +481,22 @@
 
             //绌挎杞﹀嚭鎻愬崌鏈哄悗灏忚溅寰呮満浣�
             String shuttleFromLiftStandbyLoc = shuttleStandbyFrom.getStandbyLoc();
+
+            //鑾峰彇鍑哄簱浠诲姟绫诲瀷
+            TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
+                    .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.OUT))
+                    .eq(TaskCtg::getStatus, 1));
+            if (taskCtg == null) {
+                return motionList;
+            }
+            //鑾峰彇杈撻�佺嚎璺緞
+            BasConveyorPath basConveyorPath = basConveyorPathService.getOne(new LambdaQueryWrapper<BasConveyorPath>()
+                    .eq(BasConveyorPath::getDeviceStn, task.getOriginSite())
+                    .eq(BasConveyorPath::getDeviceNo, liftProtocol.getLiftNo())
+                    .eq(BasConveyorPath::getTypeNo, taskCtg.getId()));
+            if (basConveyorPath == null) {
+                return motionList;
+            }
 
             /**
              * 鍑哄簱
@@ -616,6 +622,8 @@
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(5);//绱㈢墝椤圭洰5灞傛槸杈撻�佺嚎灞�
                             dto.setStaNo(1);//鎻愬崌鏈哄乏渚�
+                            dto.setSync(0);//寮傛鎵ц
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -630,6 +638,19 @@
                             dto.setLocNo(shuttleFromLiftStandbyLoc);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
+                ));
+
+                // 杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛
+                motionList.addAll(kernelService.conveyorOutbound(
+                        MotionDto.build((dto -> {
+                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
+                            dto.setStaNo(basConveyorPath.getDeviceStn());
+                        })),
+                        MotionDto.build((dto -> {
+                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
+                            dto.setStaNo(basConveyorPath.getStnNo());
+                        })),
+                        MotionCtgType.CONVEYOR_OUTBOUND
                 ));
 
             /**
@@ -748,6 +769,7 @@
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
+                            dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
 
@@ -783,17 +805,17 @@
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
-                            dto.setLocNo(standbyLocNoTo);
+                            dto.setLocNo(standbyLocNoFrom);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
                 ));
 
-                // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
+                // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌鐩爣灞�
                 motionList.addAll(kernelService.liftMove(
                         null
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
-                            dto.setLev(Utils.getLev(shuttleLocNo));
+                            dto.setLev(Utils.getLev(originLoc));
                         }))
                 ));
 
@@ -809,12 +831,12 @@
                 motionList.addAll(kernelService.shuttleMove(
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
-                            dto.setLocNo(standbyLocNoTo);
+                            dto.setLocNo(standbyLocNoFrom);
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
-                            dto.setLocNo(liftLocNoTo);
+                            dto.setLocNo(liftLocNoFrom);
                         })),
                         MotionCtgType.SHUTTLE_MOVE_TO_LIFT
                 ));
@@ -861,6 +883,7 @@
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(5);//绱㈢墝椤圭洰5灞傛槸杈撻�佺嚎灞�
                             dto.setStaNo(1);//鎻愬崌鏈哄乏渚�
+                            dto.setSync(0);//寮傛鎵ц
                         }))
                 ));
 
@@ -875,6 +898,19 @@
                             dto.setLocNo(shuttleFromLiftStandbyLoc);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
+                ));
+
+                // 杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛
+                motionList.addAll(kernelService.conveyorOutbound(
+                        MotionDto.build((dto -> {
+                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
+                            dto.setStaNo(basConveyorPath.getDeviceStn());
+                        })),
+                        MotionDto.build((dto -> {
+                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
+                            dto.setStaNo(basConveyorPath.getStnNo());
+                        })),
+                        MotionCtgType.CONVEYOR_OUTBOUND
                 ));
 
             }
@@ -932,13 +968,6 @@
         //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹�
         boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
         if (shuttleResult) {
-            //瀛樺湪浠诲姟锛岀姝㈣В鏋�
-            return motionList;
-        }
-
-        //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹�
-        boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
-        if (liftResult) {
             //瀛樺湪浠诲姟锛岀姝㈣В鏋�
             return motionList;
         }
@@ -1104,16 +1133,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;
@@ -1151,6 +1179,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(
                     MotionDto.build((dto -> {

--
Gitblit v1.9.1