From 14cc8925be94a6c07e8e48278afc8f2d4aa284f1 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 19 三月 2026 20:45:42 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/WmsOperateUtils.java |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/WmsOperateUtils.java b/src/main/java/com/zy/core/utils/WmsOperateUtils.java
index 7bbcb33..a99d80a 100644
--- a/src/main/java/com/zy/core/utils/WmsOperateUtils.java
+++ b/src/main/java/com/zy/core/utils/WmsOperateUtils.java
@@ -82,6 +82,17 @@
 
     private final ConcurrentMap<String, Boolean> asyncInTaskInflight = new ConcurrentHashMap<>();
 
+    private String buildAsyncInTaskKey(String prefix, String barcode, Integer stationId, Integer taskNo) {
+        StringBuilder keyBuilder = new StringBuilder(prefix)
+                .append(barcode)
+                .append("_")
+                .append(stationId);
+        if (taskNo != null && taskNo > 0) {
+            keyBuilder.append("_").append(taskNo);
+        }
+        return keyBuilder.toString();
+    }
+
     // 鐢宠鍏ュ簱浠诲姟
     public String applyInTask(String barcode, Integer sourceStaNo, Integer locType1) {
         Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
@@ -169,8 +180,12 @@
      * @param locType1    鎵樼洏楂樺害
      */
     public void applyInTaskAsync(String barcode, Integer sourceStaNo, Integer locType1) {
-        String requestKey = RedisKeyType.ASYNC_WMS_IN_TASK_REQUEST.key + barcode + "_" + sourceStaNo;
-        String responseKey = RedisKeyType.ASYNC_WMS_IN_TASK_RESPONSE.key + barcode + "_" + sourceStaNo;
+        applyInTaskAsync(barcode, sourceStaNo, null, locType1);
+    }
+
+    public void applyInTaskAsync(String barcode, Integer sourceStaNo, Integer taskNo, Integer locType1) {
+        String requestKey = buildAsyncInTaskKey(RedisKeyType.ASYNC_WMS_IN_TASK_REQUEST.key, barcode, sourceStaNo, taskNo);
+        String responseKey = buildAsyncInTaskKey(RedisKeyType.ASYNC_WMS_IN_TASK_RESPONSE.key, barcode, sourceStaNo, taskNo);
 
         if (asyncInTaskInflight.putIfAbsent(requestKey, Boolean.TRUE) != null) {
             return;
@@ -192,13 +207,16 @@
                     String response = applyInTask(barcode, sourceStaNo, locType1);
                     if (response != null) {
                         redisUtil.set(responseKey, response, APPLY_IN_TASK_RESPONSE_TTL_SECONDS);
-                        News.info("寮傛WMS鍏ュ簱璇锋眰瀹屾垚锛宐arcode={}锛宻tationId={}锛宺esponse={}", barcode, sourceStaNo, response);
+                        News.info("寮傛WMS鍏ュ簱璇锋眰瀹屾垚锛宐arcode={}锛宻tationId={}锛宼askNo={}锛宺esponse={}",
+                                barcode, sourceStaNo, taskNo, response);
                     } else {
                         redisUtil.set(responseKey, "FAILED", 10);
-                        News.error("寮傛WMS鍏ュ簱璇锋眰澶辫触锛宐arcode={}锛宻tationId={}", barcode, sourceStaNo);
+                        News.error("寮傛WMS鍏ュ簱璇锋眰澶辫触锛宐arcode={}锛宻tationId={}锛宼askNo={}",
+                                barcode, sourceStaNo, taskNo);
                     }
                 } catch (Exception e) {
-                    News.error("寮傛WMS鍏ュ簱璇锋眰寮傚父锛宐arcode={}锛宻tationId={}锛宔rror={}", barcode, sourceStaNo, e.getMessage());
+                    News.error("寮傛WMS鍏ュ簱璇锋眰寮傚父锛宐arcode={}锛宻tationId={}锛宼askNo={}锛宔rror={}",
+                            barcode, sourceStaNo, taskNo, e.getMessage());
                     redisUtil.set(responseKey, "ERROR:" + e.getMessage(), 10);
                 } finally {
                     asyncInTaskInflight.remove(requestKey);
@@ -209,7 +227,8 @@
             asyncInTaskInflight.remove(requestKey);
             redisUtil.del(requestKey);
             redisUtil.set(responseKey, "ERROR:ASYNC_QUEUE_FULL", 10);
-            News.error("寮傛WMS鍏ュ簱璇锋眰琚嫆缁濓紝绾跨▼姹犲凡婊★紝barcode={}锛宻tationId={}", barcode, sourceStaNo);
+            News.error("寮傛WMS鍏ュ簱璇锋眰琚嫆缁濓紝绾跨▼姹犲凡婊★紝barcode={}锛宻tationId={}锛宼askNo={}",
+                    barcode, sourceStaNo, taskNo);
         }
     }
 
@@ -221,7 +240,11 @@
      * @return 鍝嶅簲缁撴灉锛宯ull琛ㄧず杩樻湭瀹屾垚鎴栨湭鎵惧埌
      */
     public String queryAsyncInTaskResponse(String barcode, Integer stationId) {
-        String responseKey = RedisKeyType.ASYNC_WMS_IN_TASK_RESPONSE.key + barcode + "_" + stationId;
+        return queryAsyncInTaskResponse(barcode, stationId, null);
+    }
+
+    public String queryAsyncInTaskResponse(String barcode, Integer stationId, Integer taskNo) {
+        String responseKey = buildAsyncInTaskKey(RedisKeyType.ASYNC_WMS_IN_TASK_RESPONSE.key, barcode, stationId, taskNo);
         Object response = redisUtil.get(responseKey);
         if (response != null) {
             // 鑾峰彇鍚庡垹闄わ紝閬垮厤閲嶅澶勭悊
@@ -239,7 +262,11 @@
      * @return true琛ㄧず姝e湪璇锋眰涓�
      */
     public boolean isAsyncRequestInProgress(String barcode, Integer stationId) {
-        String requestKey = RedisKeyType.ASYNC_WMS_IN_TASK_REQUEST.key + barcode + "_" + stationId;
+        return isAsyncRequestInProgress(barcode, stationId, null);
+    }
+
+    public boolean isAsyncRequestInProgress(String barcode, Integer stationId, Integer taskNo) {
+        String requestKey = buildAsyncInTaskKey(RedisKeyType.ASYNC_WMS_IN_TASK_REQUEST.key, barcode, stationId, taskNo);
         return asyncInTaskInflight.containsKey(requestKey) || redisUtil.get(requestKey) != null;
     }
 

--
Gitblit v1.9.1