From 2f9849905dbb8d65faa28628a40084708a0386ef Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 25 十二月 2025 10:58:34 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java |   58 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
index faf66f7..419b417 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -3,7 +3,9 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.core.common.SpringUtils;
+import com.zy.asrs.entity.BasStation;
 import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.BasStationService;
 import com.zy.common.model.NavigateNode;
 import com.zy.common.utils.NavigateUtils;
 import com.zy.common.utils.RedisUtil;
@@ -18,6 +20,7 @@
 import java.util.HashMap;
 import java.util.List;
 
+import java.util.Random;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -96,6 +99,16 @@
             }
         });
         return new CommandResponse(true, "鍛戒护宸插彈鐞嗭紙寮傛鎵ц锛�");
+    }
+
+    @Override
+    public CommandResponse sendOriginCommand(String address, short[] data) {
+        return new CommandResponse(true, "鍘熷鍛戒护宸插彈鐞嗭紙寮傛鎵ц锛�");
+    }
+
+    @Override
+    public byte[] readOriginCommand(String address, int length) {
+        return new byte[0];
     }
 
     private void handleCommand(Integer deviceNo, StationCommand command) {
@@ -190,12 +203,9 @@
         Integer stationId = command.getStationId();
         Integer targetStationId = command.getTargetStaNo();
 
-        String startLev = String.valueOf(stationId).substring(0, 1);
-
         List<NavigateNode> navigateNodes = null;
-
         try {
-            navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationId, targetStationId);
+            navigateNodes = navigateUtils.calcByStationId(stationId, targetStationId);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -208,6 +218,10 @@
     }
 
     private void diffLevCommand(StationCommand command, boolean generateBarcode) {
+        BasStationService basStationService = SpringUtils.getBean(BasStationService.class);
+        if (basStationService == null) {
+            return;
+        }
         NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
         if (navigateUtils == null) {
             return;
@@ -217,20 +231,27 @@
         Integer stationId = command.getStationId();
         Integer targetStationId = command.getTargetStaNo();
 
-        String startLev = String.valueOf(stationId).substring(0, 1);
-        String endLev = String.valueOf(targetStationId).substring(0, 1);
-        
         List<NavigateNode> navigateNodes = null;
         List<NavigateNode> targetNavigateNodes = null;
 
         try {
-            List<NavigateNode> liftStationList = navigateUtils.findLiftStationList(Integer.parseInt(startLev));
+            BasStation startStation = basStationService.selectById(stationId);
+            if (startStation == null) {
+                return;
+            }
+
+            BasStation targetStation = basStationService.selectById(targetStationId);
+            if (targetStation == null) {
+                return;
+            }
+
+            List<NavigateNode> liftStationList = navigateUtils.findLiftStationList(startStation.getStationLev());
             if(liftStationList.isEmpty()){
                 //鏈壘鍒版彁鍗囨満鑺傜偣
                 return;
             }
 
-            List<NavigateNode> targetLiftStationList = navigateUtils.findLiftStationList(Integer.parseInt(endLev));
+            List<NavigateNode> targetLiftStationList = navigateUtils.findLiftStationList(targetStation.getStationLev());
             if(targetLiftStationList.isEmpty()){
                 //鏈壘鍒版彁鍗囨満鑺傜偣
                 return;
@@ -260,13 +281,13 @@
                     continue;
                 }
 
-                navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationId, liftStationId);
+                navigateNodes = navigateUtils.calcByStationId(stationId, liftStationId);
                 if(navigateNodes == null){
                     continue;
                 }
 
                 //璁$畻鎻愬崌鏈哄埌鐩爣绔欑殑璺緞
-                targetNavigateNodes = navigateUtils.calcByStationId(Integer.parseInt(endLev), targetLiftStationId, targetStationId);
+                targetNavigateNodes = navigateUtils.calcByStationId(targetLiftStationId, targetStationId);
                 if(targetNavigateNodes == null) {
                     continue;
                 }
@@ -305,8 +326,9 @@
 
             Integer nextStationId = null;
             Integer nextStationDeviceNo = null;
+            NavigateNode nextNode = null;
             try {
-                NavigateNode nextNode = navigateNodes.get(i + 1);
+                nextNode = navigateNodes.get(i + 1);
                 JSONObject nextValueObject = JSON.parseObject(nextNode.getNodeValue());
                 nextStationId = nextValueObject.getInteger("stationId");
                 nextStationDeviceNo = nextValueObject.getInteger("deviceNo");
@@ -351,6 +373,10 @@
                     continue;
                 }
                 lastStationId = currentStationId;
+
+                if (nextNode.getIsInflectionPoint()) {
+                    sleep(4000);
+                }
             }
 
             i++;
@@ -553,8 +579,10 @@
                 return false;
             }
 
+            Random random = new Random();
+
             String barcodeTime = String.valueOf(System.currentTimeMillis());
-            String barcode = barcodeTime.substring(5);
+            String barcode = String.valueOf(random.nextInt(10)) + String.valueOf(random.nextInt(10)) + barcodeTime.substring(7);
 
             boolean result = updateStationData(lockTaskNo, currentStationId, currentStationDeviceNo, null, null, null, barcode, null);
             if (!result) {
@@ -614,7 +642,7 @@
         return executeResult;
     }
 
-    public synchronized boolean lockExecute(Integer taskNo, Supplier<Boolean> function) {
+    public boolean lockExecute(Integer taskNo, Supplier<Boolean> function) {
         if (!setLockStation(taskNo)) {
             return false;
         }
@@ -624,7 +652,7 @@
         return result;
     }
 
-    private synchronized boolean checkTaskNoInArea(Integer taskNo) {
+    private boolean checkTaskNoInArea(Integer taskNo) {
         Object fakeTaskNoAreaObj = redisUtil.get(RedisKeyType.FAKE_TASK_NO_AREA.key);
         if (fakeTaskNoAreaObj == null) {
             return false;

--
Gitblit v1.9.1