From 5bf10c1dafe485d506ec534f98e5220a3b83dd17 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 16 四月 2026 23:16:46 +0800
Subject: [PATCH] feat(WCS&WMS): 机械手扫码NG处理与线体条码读取与添加批量MES绑定解绑接口

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotBarcodeGenerator.cs |   37 ++++++++++++++-----------------------
 1 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotBarcodeGenerator.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotBarcodeGenerator.cs
index 0e5474b..f40a882 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotBarcodeGenerator.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotBarcodeGenerator.cs
@@ -1,36 +1,27 @@
+using Masuit.Tools;
+using WIDESEAWCS_QuartzJob;
+
 namespace WIDESEAWCS_Tasks
 {
     /// <summary>
-    /// 鏈烘鎵嬫潯鐮佺敓鎴愬櫒 - 璐熻矗鐢熸垚鎵樼洏鏉$爜
+    /// 鏈烘鎵嬫潯鐮佽鍙栧櫒 - 璐熻矗璇诲彇鐢佃姱鏉$爜
     /// </summary>
-    /// <remarks>
-    /// 鏉$爜鏍煎紡锛氬墠缂�锛堝彲閫夛級+ 鏃ユ湡锛坹yyyMMdd锛�+ 鏃堕棿锛圚Hmmss锛�+ 闅忔満鏁帮紙100-999锛�
-    /// 渚嬪锛歍RAY20260326093045123
-    /// </remarks>
     public static class RobotBarcodeGenerator
     {
         /// <summary>
-        /// 鐢熸垚鎵樼洏鏉$爜
+        /// 璇诲彇绾夸綋鏉$爜
         /// </summary>
-        /// <param name="prefix">鏉$爜鍓嶇紑锛岄粯璁や负绌哄瓧绗︿覆锛屼緥濡� "TRAY"</param>
-        /// <returns>鐢熸垚鐨勬潯鐮佸瓧绗︿覆锛屾牸寮忥細鍓嶇紑+鏃ユ湡+鏃堕棿+闅忔満鏁�</returns>
+        /// <param name="prefix">DB鐐逛綅锛屼緥濡� "DB40.990"</param>
+        /// <returns>璇诲彇鍒扮殑鐢佃姱鏉$爜</returns>
         public static string GenerateTrayBarcode(string prefix = "")
         {
-            // 鑾峰彇褰撳墠鏃ユ湡锛屾牸寮忓寲涓� yyyyMMdd锛�8浣嶆暟瀛楋級
-            // 渚嬪锛�20260326
-            string datePart = DateTime.Now.ToString("yyyyMMdd");
-
-            // 鑾峰彇褰撳墠鏃堕棿锛堟椂鍒嗙锛夛紝鏍煎紡鍖栦负 HHmmss锛�6浣嶆暟瀛楋級
-            // 渚嬪锛�093045 琛ㄧず 09:30:45
-            string timePart = DateTime.Now.ToString("HHmmss");
-
-            // 鐢熸垚3浣嶉殢鏈烘暟锛岃寖鍥� 100-999锛岀‘淇濇潯鐮佸敮涓�鎬�
-            // 浣跨敤 Random.Shared 鑾峰彇绾跨▼瀹夊叏鐨勯殢鏈烘暟鐢熸垚鍣�
-            string randomPart = Random.Shared.Next(100, 1000).ToString();
-
-            // 缁勫悎鎵�鏈夐儴鍒嗭細鍓嶇紑 + 鏃ユ湡 + 鏃堕棿 + 闅忔満鏁�
-            // 濡傛灉鍓嶇紑涓虹┖锛屽垯鐩存帴杩斿洖鏃ユ湡+鏃堕棿+闅忔満鏁扮殑缁勫悎
-            return prefix + datePart + timePart + randomPart;
+            var device = Storage.Devices.Where(d => d.DeviceName == "A鍖篲涓�娉ㄨ緭閫佺嚎").FirstOrDefault();
+            if (!device.IsNullOrEmpty() && device != null && device.Communicator.IsConnected)
+            {
+                var trayBarcode = device.Communicator.Read<string>(prefix);
+                return trayBarcode;
+            }
+            return "";
         }
     }
 }

--
Gitblit v1.9.3