From 39a729e911ca4e5fb1c629fabf71cc3cf02dade8 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期六, 12 十月 2024 16:37:19 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java |  126 +++++++++++++++++++++++++++++++-----------
 1 files changed, 93 insertions(+), 33 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 b433be8..d81b555 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;
@@ -26,7 +24,9 @@
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 1.鍏呯數浠诲姟锛�2.搴撲綅绉昏浆锛�3.灏忚溅杩佺Щ锛�4.鎵嬪姩浠诲姟
@@ -54,7 +54,20 @@
     @Autowired
     private BasConveyorPathService basConveyorPathService;
     @Autowired
+    private BasConveyorStaService basConveyorStaService;
+    @Autowired
+    private BasConveyorService basConveyorService;
+    @Autowired
     private TaskCtgService taskCtgService;
+
+    public Integer getStaByLev(Integer lev) {
+        HashMap<Integer, Integer> map = new HashMap<>();
+        map.put(1, 31006);
+        map.put(2, 31007);
+        map.put(3, 31008);
+
+        return map.get(lev);
+    }
 
     public List<Motion> generateMotion(Task task) {
         List<Motion> motionList = new ArrayList<>();
@@ -101,6 +114,11 @@
 
             LiftProtocol liftProtocol = liftThread.getStatus();
             if (liftProtocol == null || liftProtocol.getLiftNo() == null) {
+                return motionList;
+            }
+
+            BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite());
+            if (basConveyorStaDest == null) {
                 return motionList;
             }
 
@@ -151,8 +169,9 @@
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(Utils.getLev(task.getDestLoc()));
-                            dto.setStaNo(Integer.parseInt(task.getDestSite()));
-                            dto.setSync(0);//寮傛鎵ц
+                            dto.setStaNo(getStaByLev(Utils.getLev(task.getDestLoc())));
+                            dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
+//                            dto.setSync();//寮傛鎵ц
                         }))
                 ));
 
@@ -216,7 +235,8 @@
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(Utils.getLev(task.getDestLoc()));
-                            dto.setStaNo(Integer.parseInt(task.getDestSite()));
+                            dto.setStaNo(getStaByLev(Utils.getLev(task.getDestLoc())));
+                            dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
                         }))
                 ));
 
@@ -232,6 +252,15 @@
                             dto.setLocNo(standbyLocNoTo);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
+                ));
+
+                // 閿佸畾鐩爣妤煎眰绌挎杞﹀緟鏈轰綅璺緞
+                motionList.addAll(kernelService.mapLockPath(
+                        null,
+                        MotionDto.build((dto -> {
+                            dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setLocNo(standbyLocNoFrom);
+                        }))
                 ));
 
                 // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
@@ -400,6 +429,11 @@
                 return motionList;
             }
 
+            BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite());
+            if (basConveyorStaOrigin == null) {
+                return motionList;
+            }
+
             //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹�
             boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
             if (shuttleResult) {
@@ -511,12 +545,13 @@
                         MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(Utils.getLev(task.getOriginLoc()));
-                            dto.setStaNo(Integer.parseInt(task.getOriginSite()));//璧峰绔欑偣
+                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//璧峰绔欑偣
                         }))
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(1);//鍏夋嘲1灞傛槸杈撻�佺嚎灞�
-                            dto.setStaNo(31004);//鍑哄簱绔欑偣
+                            dto.setStaNo(31001);//鍑哄簱绔欑偣
+                            dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue());
                             dto.setSync(0);//寮傛鎵ц
                             dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
@@ -536,17 +571,17 @@
                 ));
 
                 // 杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛
-                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
-                ));
+//                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
+//                ));
 
             /**
              * 浜屻�佸嚭搴撹捣濮嬪眰娌℃湁绌挎杞�
@@ -565,6 +600,15 @@
                             dto.setLocNo(standbyLocNoTo);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
+                ));
+
+                // 閿佸畾鐩爣妤煎眰绌挎杞﹀緟鏈轰綅璺緞
+                motionList.addAll(kernelService.mapLockPath(
+                        null,
+                        MotionDto.build((dto -> {
+                            dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setLocNo(standbyLocNoFrom);
+                        }))
                 ));
 
                 // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
@@ -709,13 +753,14 @@
                         MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(Utils.getLev(task.getOriginLoc()));
-                            dto.setStaNo(Integer.parseInt(task.getOriginSite()));//璧峰绔欑偣
+                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//璧峰绔欑偣
                         }))
                         , MotionDto.build((dto -> {
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLev(1);//鍏夋嘲1灞傛槸杈撻�佺嚎灞�
-                            dto.setStaNo(31004);//鍑哄簱绔欑偣
+                            dto.setStaNo(31001);//鍑哄簱绔欑偣
                             dto.setSync(0);//寮傛鎵ц
+                            dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue());
                             dto.setReleaseLift(1);//鎵ц瀹屾垚鍚庨噴鏀炬彁鍗囨満
                         }))
                 ));
@@ -734,17 +779,17 @@
                 ));
 
                 // 杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛
-                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
-                ));
+//                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
+//                ));
 
             }
 
@@ -1126,6 +1171,15 @@
                     MotionCtgType.SHUTTLE_MOVE
             ));
 
+            // 閿佸畾鐩爣妤煎眰绌挎杞﹀緟鏈轰綅璺緞
+            motionList.addAll(kernelService.mapLockPath(
+                    null,
+                    MotionDto.build((dto -> {
+                        dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setLocNo(standbyLocNoFrom);
+                    }))
+            ));
+
             // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
             motionList.addAll(kernelService.liftMove(
                     null
@@ -1404,17 +1458,23 @@
 
         } else if (destSite.equals("movePallet")) {
             //绉诲姩鎵樼洏
+            BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite());
+            BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite());
+            if(basConveyorStaOrigin == null || basConveyorStaDest == null) {
+                return motionList;
+            }
 
             // 鎻愬崌鏈虹Щ鍔ㄦ墭鐩�
             motionList.addAll(kernelService.liftMoveGoods(
                     MotionDto.build((dto -> {
                         dto.setLiftNo(device.getId().intValue());
-                        dto.setLev(0);
+                        dto.setLev(Utils.getLev(basConveyorStaOrigin.getLocNo()));
                         dto.setStaNo(Integer.parseInt(task.getOriginSite()));
                     }))
                     , MotionDto.build((dto -> {
                         dto.setLiftNo(device.getId().intValue());
-                        dto.setLev(0);
+                        dto.setLev(Utils.getLev(basConveyorStaDest.getLocNo()));
+                        dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
                         dto.setStaNo(Integer.parseInt(task.getDestSite()));
                     }))
             ));

--
Gitblit v1.9.1