From 708422d37c02c225aa4fd793bff06de5fcb821dc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 04 五月 2026 19:17:44 +0800
Subject: [PATCH] #堵塞后重新分配库位增加日志显示到控制台V3.0.1.4

---
 src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java b/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java
index 83cce40..45f4e22 100644
--- a/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java
+++ b/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java
@@ -57,6 +57,9 @@
     private static final int RUN_BLOCK_DIRECT_REASSIGN_NEAREST_CACHE_SECONDS = 60 * 60 * 24;
     private static final long CHECK_STATION_OUT_ORDER_SLOW_THRESHOLD_MS = 200L;
     private static final long EXECUTE_REROUTE_PLAN_SLOW_THRESHOLD_MS = 200L;
+    private static final String RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING_PREFIX = "鍫靛閲嶅垎閰嶈姹俉MS澶辫触";
+    private static final String RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING =
+            RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING_PREFIX + "锛岃妫�鏌MS閲嶆柊鍒嗛厤搴撲綅鎺ュ彛";
 
     @Autowired
     private WrkMastService wrkMastService;
@@ -684,16 +687,31 @@
         }
         String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId());
         if (Cools.isEmpty(response)) {
+            appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING);
             News.taskError(wrkMast.getWrkNo(), "璇锋眰WMS閲嶆柊鍒嗛厤搴撲綅鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乺esponse锛歿}", response);
             return;
         }
-        JSONObject jsonObject = JSON.parseObject(response);
-        if (!jsonObject.getInteger("code").equals(200)) {
-            News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乺esponse锛歿}", response);
+        JSONObject jsonObject;
+        try {
+            jsonObject = JSON.parseObject(response);
+        } catch (Exception e) {
+            appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING);
+            News.taskError(wrkMast.getWrkNo(), "璇锋眰WMS閲嶆柊鍒嗛厤搴撲綅鎺ュ彛鍝嶅簲瑙f瀽寮傚父锛侊紒锛乺esponse锛歿}", response, e);
+            return;
+        }
+        if (jsonObject == null || !Integer.valueOf(200).equals(jsonObject.getInteger("code"))) {
+            appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING);
+            News.taskError(wrkMast.getWrkNo(), "璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乺esponse锛歿}", response);
             return;
         }
 
         StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+        if (dto == null || Cools.isEmpty(dto.getLocNo())) {
+            appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING);
+            News.taskError(wrkMast.getWrkNo(), "璇锋眰WMS閲嶆柊鍒嗛厤搴撲綅鎺ュ彛澶辫触锛學MS鏈繑鍥炵洰鏍囧簱浣嶏紒锛侊紒response锛歿}", response);
+            return;
+        }
+        clearStationSystemWarningByPrefix(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING_PREFIX);
         String sourceLocNo = wrkMast.getLocNo();
         String locNo = dto.getLocNo();
 
@@ -780,6 +798,36 @@
         }
     }
 
+    private void appendStationSystemWarning(StationProtocol stationProtocol, String warning) {
+        if (stationProtocol == null || Cools.isEmpty(warning)) {
+            return;
+        }
+        String currentWarning = stationProtocol.getSystemWarning();
+        if (Cools.isEmpty(currentWarning)) {
+            stationProtocol.setSystemWarning(warning);
+            return;
+        }
+        if (currentWarning.contains(warning)) {
+            return;
+        }
+        stationProtocol.setSystemWarning(currentWarning + ";" + warning);
+    }
+
+    private void clearStationSystemWarningByPrefix(StationProtocol stationProtocol, String warningPrefix) {
+        if (stationProtocol == null || Cools.isEmpty(warningPrefix) || Cools.isEmpty(stationProtocol.getSystemWarning())) {
+            return;
+        }
+        String[] warningParts = stationProtocol.getSystemWarning().split(";");
+        List<String> keepWarningList = new ArrayList<>();
+        for (String warningPart : warningParts) {
+            if (Cools.isEmpty(warningPart) || warningPart.startsWith(warningPrefix)) {
+                continue;
+            }
+            keepWarningList.add(warningPart);
+        }
+        stationProtocol.setSystemWarning(String.join(";", keepWarningList));
+    }
+
     private int countCurrentTaskBufferCommands(List<StationTaskBufferItem> taskBufferItems, Integer currentTaskNo) {
         if (taskBufferItems == null || taskBufferItems.isEmpty() || currentTaskNo == null || currentTaskNo <= 0) {
             return 0;

--
Gitblit v1.9.1