From 0dab5a05ed6e734a83c43f8e6e5ef1b07115f48d Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 10 十二月 2024 10:50:54 +0800
Subject: [PATCH] #path similarity

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java                 |   20 +++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java                |   31 +++++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateUtils.java                  |   59 ++++++++++++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Motion.java                        |    6 +
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java |   75 ++++++++++++++++++
 zy-asrs-wcs/src/main/resources/application.yml                                           |    3 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java                 |    3 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/NavigationMapType.java        |    1 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapData.java                |   24 ++++-
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/PythonSimilarityResult.java         |   16 ++++
 10 files changed, 227 insertions(+), 11 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java
index 54c919e..6f02b7b 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java
@@ -1,6 +1,7 @@
 package com.zy.asrs.wcs.core.domain.dto;
 
 import com.zy.asrs.wcs.core.BuildSupport;
+import com.zy.asrs.wcs.rcs.entity.Device;
 import lombok.Data;
 
 /**
@@ -38,6 +39,8 @@
     //鎵ц瀹屾垚鍚庢槸鍚﹂噴鏀剧┛姊溅锛岄粯璁や笉閲婃斁  1: 閲婃斁  0: 涓嶉噴鏀�
     private Integer releaseShuttle;
 
+    private Device shuttleDevice;
+
     public static MotionDto build(BuildSupport<MotionDto> support) {
         MotionDto dto = new MotionDto();
 
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Motion.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Motion.java
index 0344879..a252e80 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Motion.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Motion.java
@@ -237,6 +237,12 @@
     @ApiModelProperty(value= "鎵�灞炴満鏋�")
     private Long hostId;
 
+    /**
+     * 绉诲姩璺緞
+     */
+    @ApiModelProperty(value= "绉诲姩璺緞")
+    private String movePath;
+
     public Motion() {}
 
     public Motion(String uuid,Integer taskNo,String serialNo,String title,Integer priority,Integer sync,Long motionCtg,Long motionSts,Long deviceCtg,String device,String origin,Integer oriDrt,String target,Integer tarDrt,String dockNo,Date ioTime,Date startTime,Date endTime,Date errTime,Long errCode,String errDesc,String temp,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo,Integer deleted,Long hostId) {
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 6660003..22a654f 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
@@ -182,6 +182,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(standbyLocNoTo);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
@@ -204,6 +205,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(destLoc);
 //                            dto.setReleaseLift(2);//鎵ц涓噴鏀炬彁鍗囨満
@@ -249,6 +251,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(standbyLocNoTo);
                         })),
@@ -289,6 +292,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(liftLocNoTo);
                         })),
@@ -341,6 +345,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(standbyLocNoFrom);
                         })),
                         MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -381,6 +386,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(destLoc);
                         })),
@@ -521,6 +527,7 @@
                             })),
                             MotionDto.build((dto -> {
                                 dto.setShuttleNo(shuttleDevice.getId().intValue());
+                                dto.setShuttleDevice(shuttleDevice);
                                 dto.setLocNo(originLoc);
                             })),
                             MotionCtgType.SHUTTLE_MOVE
@@ -545,6 +552,7 @@
                             })),
                             MotionDto.build((dto -> {
                                 dto.setShuttleNo(shuttleDevice.getId().intValue());
+                                dto.setShuttleDevice(shuttleDevice);
                                 dto.setLocNo(lastPathStartLoc);
                             })),
                             MotionCtgType.SHUTTLE_TRANSPORT
@@ -559,6 +567,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(standbyLocNoTo);
                             dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//杈撻�佺珯
@@ -583,6 +592,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(standbyLocs);
                             dto.setSync(0);//寮傛鎵ц
                             dto.setReleaseShuttle(1);//鎵ц瀹屾垚鍚庨噴鏀惧皬杞�
@@ -632,6 +642,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(standbyLocNoTo);
                         })),
@@ -672,6 +683,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(liftLocNoTo);
                         })),
@@ -724,6 +736,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(standbyLocNoFrom);
                         })),
                         MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -756,6 +769,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(originLoc);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
@@ -779,6 +793,7 @@
                             })),
                             MotionDto.build((dto -> {
                                 dto.setShuttleNo(shuttleDevice.getId().intValue());
+                                dto.setShuttleDevice(shuttleDevice);
                                 dto.setLocNo(lastPathStartLoc);
                             })),
                             MotionCtgType.SHUTTLE_TRANSPORT
@@ -793,6 +808,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLiftNo(transferLiftDevice.getId().intValue());
                             dto.setLocNo(standbyLocNoFrom);
                             dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//杈撻�佺珯
@@ -817,6 +833,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(standbyLocs);
                             dto.setSync(0);//寮傛鎵ц
                             dto.setReleaseShuttle(1);//鎵ц瀹屾垚鍚庨噴鏀惧皬杞�
@@ -950,6 +967,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(chargeLocNo);
                     })),
                     MotionCtgType.SHUTTLE_MOVE
@@ -965,6 +983,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(standbyLocNoTo);
                     })),
                     MotionCtgType.SHUTTLE_MOVE
@@ -995,6 +1014,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLiftNo(transferLiftDevice.getId().intValue());
                         dto.setLocNo(liftLocNoTo);
                     })),
@@ -1047,6 +1067,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(standbyLocNoFrom);
                     })),
                     MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -1068,6 +1089,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(chargeLocNo);
                     })),
                     MotionCtgType.SHUTTLE_MOVE
@@ -1136,6 +1158,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(locNo);
                     })),
                     MotionCtgType.SHUTTLE_MOVE
@@ -1190,6 +1213,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(shuttleDevice.getId().intValue());
+                            dto.setShuttleDevice(shuttleDevice);
                             dto.setLocNo(locNo);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
@@ -1230,6 +1254,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLiftNo(liftDevice.getId().intValue());
                         dto.setLocNo(standbyLocNoTo);
                     })),
@@ -1270,6 +1295,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLiftNo(liftDevice.getId().intValue());
                         dto.setLocNo(liftLocNoTo);
                     })),
@@ -1322,6 +1348,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(standbyLocNoFrom);
                     })),
                     MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -1353,6 +1380,7 @@
                     })),
                     MotionDto.build((dto -> {
                         dto.setShuttleNo(shuttleDevice.getId().intValue());
+                        dto.setShuttleDevice(shuttleDevice);
                         dto.setLocNo(locNo);
                     })),
                     MotionCtgType.SHUTTLE_MOVE
@@ -1408,6 +1436,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(device.getId().intValue());
+                            dto.setShuttleDevice(device);
                             dto.setLocNo(targetLoc);
                         })),
                         MotionCtgType.SHUTTLE_MOVE
@@ -1460,6 +1489,7 @@
                             })),
                             MotionDto.build((dto -> {
                                 dto.setShuttleNo(device.getId().intValue());
+                                dto.setShuttleDevice(device);
                                 dto.setLocNo(sourceLoc);
                             })),
                             MotionCtgType.SHUTTLE_MOVE
@@ -1481,6 +1511,7 @@
                         })),
                         MotionDto.build((dto -> {
                             dto.setShuttleNo(device.getId().intValue());
+                            dto.setShuttleDevice(device);
                             dto.setLocNo(targetLoc);
                         })),
                         MotionCtgType.SHUTTLE_TRANSPORT
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java
index dd37a7e..e4f74df 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java
@@ -1,11 +1,21 @@
 package com.zy.asrs.wcs.core.kernel;
 
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.exception.CoolException;
 import com.zy.asrs.wcs.core.domain.dto.MotionDto;
+import com.zy.asrs.wcs.core.model.NavigateNode;
 import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
 import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
 import com.zy.asrs.wcs.core.entity.Motion;
+import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
 import com.zy.asrs.wcs.core.service.MotionService;
 import com.zy.asrs.wcs.core.utils.LiftDispatcher;
+import com.zy.asrs.wcs.core.utils.NavigateUtils;
+import com.zy.asrs.wcs.core.utils.Utils;
+import com.zy.asrs.wcs.rcs.News;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -22,6 +32,10 @@
     private MotionService motionService;
     @Autowired
     private LiftDispatcher liftDispatcher;
+    @Autowired
+    private NavigateUtils navigateUtils;
+    @Autowired
+    private DeviceService deviceService;
 
     // agv -----------------------------------------------------------------------------
     @Deprecated
@@ -321,6 +335,12 @@
                 motion.setReleaseLift(target.getReleaseLift());
             }
 
+            List<NavigateNode> nodeList = navigateUtils.calc(motion.getOrigin(), motion.getTarget(), NavigationMapType.NONE_LOCK.id, Utils.getShuttlePoints(Integer.parseInt(target.getShuttleDevice().getDeviceNo()), Utils.getLev(motion.getTarget())));
+            if (nodeList == null) {
+                throw new CoolException(motion.getOrigin() + " dash " + motion.getTarget() + " can't find navigate path!");
+            }
+            motion.setMovePath(JSON.toJSONString(nodeList));
+
         }));
 
         return motionList;
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 b58abda..f595685 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;
@@ -65,6 +68,8 @@
     private ShuttleDispatcher shuttleDispatcher;
     @Autowired
     private NavigateUtils navigateUtils;
+    @Autowired
+    private DictService dictService;
 
     // 璁$畻
     public Boolean accept(Motion motion) {
@@ -104,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());
@@ -117,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:
@@ -128,6 +145,16 @@
                 }
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE;
+
+                movePath = motion.getMovePath();
+                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://绌挎杞﹁浇璐ц璧�
                 // 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护
@@ -138,6 +165,15 @@
                 }
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT;
+
+                movePath = motion.getMovePath();
+                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);
@@ -179,15 +215,45 @@
                 }
                 shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                 shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT_TO_CONVEYOR;
+
+                movePath = motion.getMovePath();
+                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();
+                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();
+                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://鍑烘彁鍗囨満
@@ -297,6 +363,15 @@
                 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();
+                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);
                 motion.setUpdateTime(new Date());
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/PythonSimilarityResult.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/PythonSimilarityResult.java
new file mode 100644
index 0000000..31c0e42
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/PythonSimilarityResult.java
@@ -0,0 +1,16 @@
+package com.zy.asrs.wcs.core.model;
+
+import lombok.Data;
+
+@Data
+public class PythonSimilarityResult {
+
+    private String firstPath;
+
+    private String secondPath;
+
+    private Double similarity;
+
+    private Integer calcResult;
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/NavigationMapType.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/NavigationMapType.java
index 352cb92..b1310e4 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/NavigationMapType.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/NavigationMapType.java
@@ -5,6 +5,7 @@
     NONE(-1, "鏃犺繃婊�"),
     DFX(1, "杩囨护搴撲綅鐘舵�丏FX"),    // 甯﹁揣璧拌
     NORMAL(2, "杩囨护搴撲綅鐘舵�乆"),   // 鏃犺揣璧拌
+    NONE_LOCK(3, "杩囨护搴撲綅鐘舵�乆锛屼笖鏃犺矾寰勯攣"),
     ;
 
     public Integer id;
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapData.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapData.java
index c3139be..445644e 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapData.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapData.java
@@ -31,6 +31,8 @@
     private LocService locService;
     @Autowired
     private DictService dictService;
+    @Autowired
+    private NavigateMapData navigateMapData;
 
     private Integer lev;//鍦板浘妤煎眰
 
@@ -54,14 +56,22 @@
      * 灏濊瘯浠巖edis鑾峰彇鏁版嵁
      */
     public int[][] getDataFromRedis(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
-        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
-        Object o = redisUtil.get(DeviceRedisConstant.MAP + lev);
-        if (o == null) {
-            return null;
+        String mapData = null;
+        if(mapType == NavigationMapType.NONE_LOCK.id){
+            List<List<MapNode>> realMap = navigateMapData.getJsonDataFromDict(-1, null, null);//鑾峰彇瀹屾暣鍦板浘
+            mapData = JSON.toJSONString(realMap);
+        }else {
+            RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+            Object o = redisUtil.get(DeviceRedisConstant.MAP + lev);
+            if (o == null) {
+                return null;
+            }
+
+            BasMapDto basMap = JSON.parseObject(o.toString(), BasMapDto.class);
+            mapData = basMap.getData();
         }
 
-        BasMapDto basMap = JSON.parseObject(o.toString(), BasMapDto.class);
-        return this.getDataFormString(basMap.getData(), mapType, whitePoints, shuttlePoints);
+        return this.getDataFormString(mapData, mapType, whitePoints, shuttlePoints);
     }
 
     /**
@@ -319,7 +329,7 @@
                 ) {
                     mapNode.setValue(MapNodeType.DISABLE.id);//绂佺敤鑺傜偣
                 }
-            } else if (mapType == NavigationMapType.NORMAL.id) {
+            } else if (mapType == NavigationMapType.NORMAL.id || mapType == NavigationMapType.NONE_LOCK.id) {
                 //杩囨护搴撲綅鐘舵�乆
                 if (loc.getLocStsFlag().equals("X")) {
                     mapNode.setValue(MapNodeType.DISABLE.id);//绂佺敤鑺傜偣
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateUtils.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateUtils.java
index 802c98d..c696b12 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateUtils.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateUtils.java
@@ -2,15 +2,23 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zy.asrs.framework.common.SpringUtils;
 import com.zy.asrs.wcs.core.model.MapNode;
 import com.zy.asrs.wcs.core.model.NavigateNode;
+import com.zy.asrs.wcs.core.model.PythonResult;
+import com.zy.asrs.wcs.core.model.PythonSimilarityResult;
 import com.zy.asrs.wcs.core.model.enums.MapNodeType;
 import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
 import com.zy.asrs.wcs.rcs.News;
+import com.zy.asrs.wcs.system.entity.Dict;
+import com.zy.asrs.wcs.system.service.DictService;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -24,6 +32,9 @@
 
     @Value("${pythonCalcPath}")
     private String pythonCalcPath;
+
+    @Value("${pythonCalcSimilarity}")
+    private String pythonCalcSimilarity;
 
     public List<NavigateNode> calc(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints) {
         //閫氳繃寮�濮嬬紪鍙峰拰缁撴潫缂栧彿鑾峰彇瀵瑰簲鐨剎y杞村潗鏍�
@@ -289,7 +300,47 @@
         return node;
     }
 
-//    public static void main(String[] args) {
+    public Double similarityPath(List<NavigateNode> firstPath, List<NavigateNode> secondPath) {
+        try {
+            ProcessBuilder processBuilder = new ProcessBuilder("python", pythonCalcSimilarity, JSON.toJSONString(firstPath), JSON.toJSONString(secondPath));
+            processBuilder.redirectErrorStream(true);
+
+            Process process = processBuilder.start();
+
+            // 璇诲彇Python鑴氭湰鐨勮緭鍑�
+            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+            String line;
+            StringBuilder builder = new StringBuilder();
+            while ((line = reader.readLine()) != null) {
+                builder.append(line);
+            }
+
+            // 绛夊緟Python鑴氭湰鎵ц瀹屾垚
+            int exitCode = process.waitFor();
+            if (exitCode != 0) {
+                System.out.println("Python script exited with error code: " + exitCode);
+                return null;
+            }
+            reader.close();
+
+            if (builder.length() <= 0) {
+                return null;
+            }
+
+            PythonSimilarityResult result = JSON.parseObject(builder.toString(), PythonSimilarityResult.class);
+            if (result.getCalcResult() != 200) {
+                return 0D;
+            }
+
+            Double similarity = result.getSimilarity();
+            return similarity;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return 0D;
+    }
+
+    public static void main(String[] args) {
 //        //璁$畻璺緞
 //        List<NavigateNode> calc = calc("1000901", "1800201", NavigationMapType.NONE.id, null);
 //        System.out.println(calc);
@@ -302,7 +353,9 @@
 //            System.out.println(currentPathAllDistance);
 //            System.out.println(list);
 //        }
-//
-//    }
+
+        System.loadLibrary("example");
+
+    }
 
 }
diff --git a/zy-asrs-wcs/src/main/resources/application.yml b/zy-asrs-wcs/src/main/resources/application.yml
index dca4d7d..c1b6fec 100644
--- a/zy-asrs-wcs/src/main/resources/application.yml
+++ b/zy-asrs-wcs/src/main/resources/application.yml
@@ -63,4 +63,5 @@
 config:
   token-key: KUHSMcYQ4lePt3r6bckz0P13cBJyoonYqInThvQlUnbsFCIcCcZZAbWZ6UNFztYNYPhGdy6eyb8WdIz8FU2Cz396TyTJk3NI2rtXMHBOehRb4WWJ4MdYVVg2oWPyqRQ2
 
-pythonCalcPath: D:\\path\\cpu.py
\ No newline at end of file
+pythonCalcPath: D:\\path\\cpu.py
+pythonCalcSimilarity: D:\\path\\similarity.py
\ No newline at end of file

--
Gitblit v1.9.1