From 873941c1a6c4aefe7e172be973865957b0ae4378 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 19 三月 2026 15:21:44 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java |   44 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java b/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
index ccf3230..e6bd3be 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
@@ -128,6 +128,8 @@
             boolean initialized = false;
             // 涓婁竴姝ユ墽琛屾椂闂达紙鐢ㄤ簬鍫靛妫�娴嬶級
             long stepExecuteTime = System.currentTimeMillis();
+            // 浠呭湪姣忔鍒拌揪鐩爣鏃舵墽琛屼竴娆″埌浣嶅鐞嗭紝閬垮厤閲嶅鐢熸垚鏉$爜
+            boolean arrivalHandled = false;
 
             while (true) {
                 if (Thread.currentThread().isInterrupted()) {
@@ -148,6 +150,7 @@
                     Integer commandTargetStationId = command.getTargetStaNo();
                     if (commandTargetStationId != null) {
                         if (!commandTargetStationId.equals(finalTargetStationId)) {
+                            arrivalHandled = false;
                             News.info("[WCS Debug] 浠诲姟{}鍒囨崲鐩爣: {} -> {}", taskNo, finalTargetStationId,
                                     commandTargetStationId);
                         }
@@ -232,6 +235,7 @@
                             currentStationId = nextStationId;
                             pendingPathQueue.poll();
                             stepExecuteTime = System.currentTimeMillis();
+                            arrivalHandled = false;
                             News.info("[WCS Debug] 浠诲姟{}绉诲姩鍒扮珯鐐�: {}, 鍓╀綑闃熷垪: {}", taskNo, currentStationId,
                                     pendingPathQueue.size());
                             sleep(1000); // 妯℃嫙绉诲姩鑰楁椂
@@ -261,18 +265,17 @@
                     // 璺緞闃熷垪涓虹┖锛岀瓑寰呮柊鐨勫垎娈靛懡浠�
                     if (currentStationId != null && finalTargetStationId != null
                             && currentStationId.equals(finalTargetStationId)) {
-                        // 宸插埌杈剧洰鏍囷細绔嬪嵆娓呯┖褰撳墠闃熷垪骞剁粨鏉熸湰杞墽琛岋紝鍚庣画鏂板懡浠ら噸鏂板垱寤烘墽琛岀嚎绋�
-                        if (generateBarcode) {
-                            Integer targetDeviceNo = getDeviceNoByStationId(finalTargetStationId);
-                            if (targetDeviceNo != null) {
-                                generateStationBarcode(taskNo, finalTargetStationId, targetDeviceNo);
-                                News.info("[WCS Debug] 浠诲姟{}鍒拌揪鐩爣{}骞剁敓鎴愭潯鐮�", taskNo, finalTargetStationId);
+                        // 宸插埌杈惧綋鍓嶇洰鏍囧悗缁х画绛夊緟涓嬩竴鏉″垎娈靛懡浠わ紝閬垮厤鎺掑簭/缁曞湀鍦烘櫙鍚炴帀鍚庣画鍛戒护
+                        if (!arrivalHandled) {
+                            if (generateBarcode) {
+                                Integer targetDeviceNo = getDeviceNoByStationId(finalTargetStationId);
+                                if (targetDeviceNo != null) {
+                                    generateStationBarcode(taskNo, finalTargetStationId, targetDeviceNo);
+                                    News.info("[WCS Debug] 浠诲姟{}鍒拌揪鐩爣{}骞剁敓鎴愭潯鐮�", taskNo, finalTargetStationId);
+                                }
                             }
+                            arrivalHandled = true;
                         }
-                        commandQueue.clear();
-                        pendingPathQueue.clear();
-                        News.info("[WCS Debug] 浠诲姟{}鍒拌揪鐩爣鍚庢竻绌洪槦鍒楀苟缁撴潫锛岀瓑寰呭悗缁柊鍛戒护閲嶅惎", taskNo);
-                        break;
                     }
 
                     // 缁х画绛夊緟鏂扮殑鍒嗘鍛戒护
@@ -411,6 +414,10 @@
         }
 
         if (command.getCommandType() == StationCommandType.WRITE_INFO) {
+            if (command.getBarcode() != null) {
+                updateStationBarcode(deviceNo, stationId, command.getBarcode());
+                return;
+            }
             if (taskNo == 9998 && targetStationId == 0) {
                 // 鐢熸垚鍑哄簱绔欑偣浠跨湡鏁版嵁
                 generateFakeOutStationData(deviceNo, stationId);
@@ -466,6 +473,23 @@
         }
     }
 
+    private void updateStationBarcode(Integer deviceNo, Integer stationId, String barcode) {
+        List<ZyStationStatusEntity> statusList = deviceStatusMap.get(deviceNo);
+        if (statusList == null) {
+            return;
+        }
+
+        ZyStationStatusEntity status = statusList.stream()
+                .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null);
+        if (status == null) {
+            return;
+        }
+
+        synchronized (status) {
+            status.setBarcode(barcode);
+        }
+    }
+
     // segmentedPathCommand 鏂规硶宸插垹闄わ紝鍔熻兘宸叉暣鍚堝埌 runTaskLoop
 
     private Integer getDeviceNoByStationId(Integer stationId) {

--
Gitblit v1.9.1