From c8f5e604019bdbc4bd67113ffc0b2dbb1a79017a Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期五, 20 九月 2024 15:25:36 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java |   99 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 66 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..bfa0d2c 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());
                         }))
                 ));
 
@@ -400,6 +420,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 +536,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 +562,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
+//                ));
 
             /**
              * 浜屻�佸嚭搴撹捣濮嬪眰娌℃湁绌挎杞�
@@ -709,13 +735,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 +761,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
+//                ));
 
             }
 
@@ -1404,17 +1431,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