From 2d48eb3d32262cfbb21ec21debefa84d870fdff5 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 11 四月 2026 12:34:12 +0800
Subject: [PATCH] #入库异常

---
 src/main/java/com/zy/core/plugin/store/StoreInTaskPolicy.java |   69 +++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/zy/core/plugin/store/StoreInTaskPolicy.java b/src/main/java/com/zy/core/plugin/store/StoreInTaskPolicy.java
index 7549ec5..3b7fbc7 100644
--- a/src/main/java/com/zy/core/plugin/store/StoreInTaskPolicy.java
+++ b/src/main/java/com/zy/core/plugin/store/StoreInTaskPolicy.java
@@ -7,6 +7,7 @@
 import com.zy.common.model.StartupDto;
 import com.zy.core.enums.RedisKeyType;
 import com.zy.core.model.StationObjModel;
+import com.zy.core.model.protocol.StationProtocol;
 
 import java.util.List;
 
@@ -24,21 +25,11 @@
         return basDevp.getBarcodeStationList$();
     }
 
-    boolean matchCandidate(StoreInTaskContext context);
-
-    default boolean beforeApply(StoreInTaskContext context) {
-        return true;
-    }
-
     default void onRequestPermitGranted(StoreInTaskContext context) {
     }
 
     default String getGenerateLockKey(StoreInTaskContext context) {
         return RedisKeyType.GENERATE_IN_TASK_LIMIT.key + context.getStationObjModel().getStationId();
-    }
-
-    default int getSubmitLockSeconds(StoreInTaskContext context) {
-        return 2;
     }
 
     default int getRetryLockSeconds(StoreInTaskContext context) {
@@ -66,19 +57,53 @@
     default void afterTaskCreated(StoreInTaskContext context, WrkMast wrkMast) {
     }
 
-    default void onApplySubmitted(StoreInTaskContext context) {
-        context.getStationProtocol().setSystemWarning("璇锋眰鍏ュ簱涓�");
-    }
-
-    default void onApplyFailed(StoreInTaskContext context, AsyncInTaskResult result) {
-        context.getStationProtocol().setSystemWarning("璇锋眰鍏ュ簱澶辫触锛學MS杩斿洖=" + buildFailureMessage(result));
-    }
-
-    default String buildFailureMessage(AsyncInTaskResult result) {
-        if (!Cools.isEmpty(result.getResponse())) {
-            return result.getResponse();
+    default void setSystemWarning(StoreInTaskContext context, String warning) {
+        if (context == null || context.getStationProtocol() == null) {
+            return;
         }
-        return result.getMessage();
+        context.getStationProtocol().setSystemWarning(warning);
+        syncWarningToBackStation(context, warning);
+    }
+
+    default void clearSystemWarning(StoreInTaskContext context) {
+        setSystemWarning(context, "");
+    }
+
+    default void onApplyFailed(StoreInTaskContext context, InTaskApplyResult result) {
+        String warning = "璇锋眰鍏ュ簱澶辫触锛學MS杩斿洖=" + result.getResponse() + "锛學CS鍝嶅簲=" + result.getMessage();
+        setSystemWarning(context, warning);
+    }
+
+    default void syncWarningToBackStation(StoreInTaskContext context, String warning) {
+        if (context == null || context.getStationObjModel() == null || context.getStationThread() == null) {
+            return;
+        }
+        StationObjModel backStation = context.getStationObjModel().getBackStation();
+        if (backStation == null || backStation.getStationId() == null) {
+            return;
+        }
+        if (backStation.getStationId().equals(context.getStationProtocol().getStationId())) {
+            return;
+        }
+
+        List<StationProtocol> stations = context.getStationThread().getStatus();
+        if (stations != null) {
+            for (StationProtocol station : stations) {
+                if (station != null && backStation.getStationId().equals(station.getStationId())) {
+                    station.setSystemWarning(warning);
+                    return;
+                }
+            }
+        }
+
+        java.util.Map<Integer, StationProtocol> stationMap = context.getStationThread().getStatusMap();
+        if (stationMap == null) {
+            return;
+        }
+        StationProtocol backStationProtocol = stationMap.get(backStation.getStationId());
+        if (backStationProtocol != null) {
+            backStationProtocol.setSystemWarning(warning);
+        }
     }
 
 }

--
Gitblit v1.9.1