From 366ba040d2447bacd3455299425e3166f1f992bb Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期四, 20 十一月 2025 14:38:32 +0800
Subject: [PATCH] 添加大车、大理片笼以及多设备串行/并行执行写入基础逻辑

---
 mes-processes/mes-plcSend/src/main/java/com/mes/interaction/flow/GlassStorageInteraction.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/flow/GlassStorageInteraction.java b/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/flow/GlassStorageInteraction.java
index e4751e7..28b8569 100644
--- a/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/flow/GlassStorageInteraction.java
+++ b/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/flow/GlassStorageInteraction.java
@@ -24,15 +24,57 @@
 
     @Override
     public InteractionResult execute(InteractionContext context) {
-        List<String> processed = context.getProcessedGlassIds();
-        if (CollectionUtils.isEmpty(processed)) {
-            return InteractionResult.waitResult("娌℃湁鍙瓨鍌ㄧ殑鐜荤拑", null);
-        }
+        try {
+            // 鍓嶇疆鏉′欢楠岃瘉
+            if (context.getCurrentDevice() == null) {
+                return InteractionResult.fail("璁惧閰嶇疆涓嶅瓨鍦�");
+            }
 
-        Map<String, Object> data = new HashMap<>();
-        data.put("storedCount", processed.size());
-        data.put("storedGlasses", processed);
-        return InteractionResult.success(data);
+            // 浼樺厛浣跨敤澶勭悊鍚庣殑鐜荤拑ID锛屽鏋滄病鏈夊垯浣跨敤涓婂ぇ杞︾殑鐜荤拑ID
+            List<String> processed = context.getProcessedGlassIds();
+            if (CollectionUtils.isEmpty(processed)) {
+                processed = context.getLoadedGlassIds();
+                if (CollectionUtils.isEmpty(processed)) {
+                    // 灏濊瘯浠庡叡浜暟鎹幏鍙�
+                    Object processedGlasses = context.getSharedData().get("processedGlasses");
+                    if (processedGlasses instanceof List) {
+                        @SuppressWarnings("unchecked")
+                        List<String> list = (List<String>) processedGlasses;
+                        processed = list;
+                    }
+                }
+            }
+
+            if (CollectionUtils.isEmpty(processed)) {
+                return InteractionResult.waitResult("娌℃湁鍙瓨鍌ㄧ殑鐜荤拑", null);
+            }
+
+            // 楠岃瘉鐜荤拑ID
+            for (String glassId : processed) {
+                if (glassId == null || glassId.trim().isEmpty()) {
+                    return InteractionResult.fail("鐜荤拑ID涓嶈兘涓虹┖");
+                }
+            }
+
+            // 鎵ц瀛樺偍鎿嶄綔
+            context.getSharedData().put("storedGlasses", processed);
+            context.getSharedData().put("storageTime", System.currentTimeMillis());
+
+            // 鍚庣疆鏉′欢妫�鏌�
+            Object stored = context.getSharedData().get("storedGlasses");
+            if (stored == null) {
+                return InteractionResult.fail("鐜荤拑瀛樺偍澶辫触锛氬瓨鍌ㄦ暟鎹负绌�");
+            }
+
+            Map<String, Object> data = new HashMap<>();
+            data.put("storedCount", processed.size());
+            data.put("storedGlasses", processed);
+            data.put("deviceId", context.getCurrentDevice().getId());
+            data.put("deviceCode", context.getCurrentDevice().getDeviceCode());
+            return InteractionResult.success(data);
+        } catch (Exception e) {
+            return InteractionResult.fail("鐜荤拑瀛樺偍浜や簰鎵ц寮傚父: " + e.getMessage());
+        }
     }
 }
 

--
Gitblit v1.8.0