From f23549bc50ae4d489c37d68c0f3b1456b7156ea8 Mon Sep 17 00:00:00 2001
From: gtsxc <3272660260@qq.com>
Date: 星期二, 10 十二月 2024 16:06:31 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java |  103 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
index 3ff5556..d484864 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.SpringUtils;
 import com.zy.asrs.framework.exception.CoolException;
 import com.zy.asrs.wcs.common.ExecuteSupport;
 import com.zy.asrs.wcs.core.action.LiftAction;
@@ -24,6 +25,8 @@
 import com.zy.asrs.wcs.rcs.thread.DevpThread;
 import com.zy.asrs.wcs.rcs.thread.LiftThread;
 import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
+import com.zy.asrs.wcs.system.entity.Dict;
+import com.zy.asrs.wcs.system.service.DictService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -63,6 +66,10 @@
     private BasConveyorStaService basConveyorStaService;
     @Autowired
     private ShuttleDispatcher shuttleDispatcher;
+    @Autowired
+    private NavigateUtils navigateUtils;
+    @Autowired
+    private DictService dictService;
 
     // 璁$畻
     public Boolean accept(Motion motion) {
@@ -102,6 +109,14 @@
             return false;
         }
 
+        Double similarityRef = 0.9D;
+        Dict similarityRefDict = dictService.getOne(new LambdaQueryWrapper<Dict>()
+                .eq(Dict::getFlag, "similarityRef")
+                .eq(Dict::getStatus, 1));
+        if (similarityRefDict != null) {
+            similarityRef = Double.parseDouble(similarityRefDict.getValue());
+        }
+
         ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
         assignCommand.setShuttleNo(deviceNo);
         assignCommand.setTaskNo(motion.getTaskNo());
@@ -115,6 +130,10 @@
 
         LiftThread liftThread = null;
         LiftProtocol liftProtocol = null;
+        String movePath = null;
+        List<NavigateNode> originPath = null;
+        List<NavigateNode> finalPath = null;
+        Double similarity = null;
 
         switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
             case SHUTTLE_MOVE:
@@ -126,6 +145,18 @@
                 }
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE;
+
+                movePath = motion.getMovePath();
+                if (!Cools.isEmpty(movePath)) {
+                    originPath = JSON.parseArray(movePath, NavigateNode.class);
+                    finalPath = assignCommand.getNodes();
+                    similarity = navigateUtils.similarityPath(originPath, finalPath);
+                    if(similarity <= similarityRef) {
+                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
+                        return false;
+                    }
+                }
+
                 break;
             case SHUTTLE_TRANSPORT://绌挎杞﹁浇璐ц璧�
                 // 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护
@@ -136,6 +167,17 @@
                 }
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT;
+
+                movePath = motion.getMovePath();
+                if (!Cools.isEmpty(movePath)) {
+                    originPath = JSON.parseArray(movePath, NavigateNode.class);
+                    finalPath = assignCommand.getNodes();
+                    similarity = navigateUtils.similarityPath(originPath, finalPath);
+                    if(similarity <= similarityRef) {
+                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
+                        return false;
+                    }
+                }
 
                 if (motion.getReleaseLift() == 2) {//鎵ц涓噴鏀炬彁鍗囨満
                     task.setLiftNo(0);
@@ -175,17 +217,53 @@
                         .eq(Loc::getHostId, motion.getHostId())).getCode())) {
                     return true;
                 }
-                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
+                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT_TO_CONVEYOR;
+
+                movePath = motion.getMovePath();
+                if (!Cools.isEmpty(movePath)) {
+                    originPath = JSON.parseArray(movePath, NavigateNode.class);
+                    finalPath = assignCommand.getNodes();
+                    similarity = navigateUtils.similarityPath(originPath, finalPath);
+                    if(similarity <= similarityRef) {
+                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
+                        return false;
+                    }
+                }
+
                 break;
             case SHUTTLE_MOVE_LIFT_PALLET://绌挎杞﹂《鍗囧苟绉诲姩
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_LIFT;
+
+                movePath = motion.getMovePath();
+                if (!Cools.isEmpty(movePath)) {
+                    originPath = JSON.parseArray(movePath, NavigateNode.class);
+                    finalPath = assignCommand.getNodes();
+                    similarity = navigateUtils.similarityPath(originPath, finalPath);
+                    if(similarity <= similarityRef) {
+                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
+                        return false;
+                    }
+                }
+
                 shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getTaskNo(), true));
                 break;
             case SHUTTLE_MOVE_DOWN_PALLET://绌挎杞︾Щ鍔ㄥ苟鎵樼洏涓嬮檷
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_DOWN;
+
+                movePath = motion.getMovePath();
+                if (!Cools.isEmpty(movePath)) {
+                    originPath = JSON.parseArray(movePath, NavigateNode.class);
+                    finalPath = assignCommand.getNodes();
+                    similarity = navigateUtils.similarityPath(originPath, finalPath);
+                    if(similarity <= similarityRef) {
+                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
+                        return false;
+                    }
+                }
+
                 shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getTaskNo(), false));
                 break;
             case SHUTTLE_MOVE_FROM_LIFT://鍑烘彁鍗囨満
@@ -294,6 +372,17 @@
                 //鑾峰彇鍙敤寰呮満浣�
                 String shuttleFromLiftStandbyLoc = shuttleDispatcher.searchAvailableLocNo(Integer.valueOf(shuttleDevice.getDeviceNo()), shuttleDevice.getHostId(), shuttleThread.getStatus().getCurrentLocNo(), standbyLocs);
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), shuttleFromLiftStandbyLoc, NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
+
+                movePath = motion.getMovePath();
+                if (!Cools.isEmpty(movePath)) {
+                    originPath = JSON.parseArray(movePath, NavigateNode.class);
+                    finalPath = assignCommand.getNodes();
+                    similarity = navigateUtils.similarityPath(originPath, finalPath);
+                    if(similarity <= similarityRef) {
+                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
+                        return false;
+                    }
+                }
 
                 //鏇存柊鍔ㄤ綔鍙敤寰呮満浣�
                 motion.setTarget(shuttleFromLiftStandbyLoc);
@@ -519,7 +608,7 @@
         //鑾峰彇灏忚溅绉诲姩閫熷害
         Integer runSpeed = Optional.ofNullable(basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, assignCommand.getDeviceId())).getRunSpeed()).orElse(1000);
         Long hostId = shuttleThread.getDevice().getHostId();
-        List<NavigateNode> nodeList = NavigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo)));
+        List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo)));
         if (nodeList == null) {
             News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
             return null;
@@ -532,7 +621,7 @@
 
         List<ShuttleCommand> commands = new ArrayList<>();
         //鑾峰彇鍒嗘璺緞
-        ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodeList);
+        ArrayList<ArrayList<NavigateNode>> data = navigateUtils.getSectionPath(nodeList);
         //灏嗘瘡涓�娈佃矾寰勫垎鎴恈ommand鎸囦护
         for (ArrayList<NavigateNode> nodes : data) {
             //寮�濮嬭矾寰�
@@ -540,7 +629,7 @@
 
             //鐩爣璺緞
             NavigateNode endPath = nodes.get(nodes.size() - 1);
-            Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+            Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
             //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
             String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ(), hostId);
             //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
@@ -575,7 +664,7 @@
         //鑾峰彇灏忚溅绉诲姩閫熷害
         Integer runSpeed = Optional.ofNullable(basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, assignCommand.getDeviceId())).getRunSpeed()).orElse(1000);
         Long hostId = shuttleThread.getDevice().getHostId();
-        List<NavigateNode> nodeList = NavigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo)));
+        List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo)));
         if (nodeList == null) {
             News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
             return null;
@@ -588,7 +677,7 @@
 
         List<ShuttleCommand> commands = new ArrayList<>();
         //鑾峰彇鍒嗘璺緞
-        ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodeList);
+        ArrayList<ArrayList<NavigateNode>> data = navigateUtils.getSectionPath(nodeList);
         //灏嗘瘡涓�娈佃矾寰勫垎鎴恈ommand鎸囦护
         for (ArrayList<NavigateNode> nodes : data) {
             //寮�濮嬭矾寰�
@@ -596,7 +685,7 @@
 
             //鐩爣璺緞
             NavigateNode endPath = nodes.get(nodes.size() - 1);
-            Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+            Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
             //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
             String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ(), hostId);
             //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�

--
Gitblit v1.9.1