From 2acc93755ddc56beb46e08b655ec9d94968d829f Mon Sep 17 00:00:00 2001
From: 杨张扬 <634643841@qq.com>
Date: 星期二, 03 六月 2025 17:21:43 +0800
Subject: [PATCH] 满托下线PDA呼叫,容器ID需转换成ASCII字符串

---
 wms/WMSHelper.cs |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/wms/WMSHelper.cs b/wms/WMSHelper.cs
index 18535e1..a067039 100644
--- a/wms/WMSHelper.cs
+++ b/wms/WMSHelper.cs
@@ -2,6 +2,7 @@
 using HH.WCS.Mobox3.DoubleCoin.models;
 using HH.WCS.Mobox3.DoubleCoin.util;
 using System;
+using System.Text;
 using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel;
 
 namespace HH.WCS.Mobox3.DoubleCoin.wms
@@ -122,6 +123,32 @@
             }
         }
 
-       
+        /// <summary>
+        /// 灏�6杩涘埗瀛楃涓茶浆鎹负ASCII瀛楃涓�+        /// </summary>
+        /// <param name="hexString"></param>
+        /// <returns></returns>
+        public static string ConvertHexToAscii(string hexString)
+        {
+            LogHelper.Info($"灏�6杩涘埗瀛楃涓茶浆鎹负ASCII瀛楃涓诧紝杞崲鍓嶏細{hexString}");
+
+            // 楠岃瘉杈撳叆鏄惁涓�6浣�6杩涘埗瀛楃涓�+            if (hexString.Length != 16 || !System.Text.RegularExpressions.Regex.IsMatch(hexString, @"^[0-9A-Fa-f]+$"))
+            {
+                throw new ArgumentException("杈撳叆蹇呴』鏄�6浣嶇殑16杩涘埗瀛楃涓�);
+            }
+
+            // 姣忎袱浣嶈浆鎹竴涓狝SCII瀛楃
+            StringBuilder asciiString = new StringBuilder();
+            for (int i = 0; i < 16; i += 2)
+            {
+                string hexPair = hexString.Substring(i, 2);
+                byte asciiChar = Convert.ToByte(hexPair, 16);
+                asciiString.Append((char)asciiChar);
+            }
+
+            LogHelper.Info($"灏�6杩涘埗瀛楃涓茶浆鎹负ASCII瀛楃涓诧紝杞崲鍚庯細{asciiString.ToString()}");
+            return asciiString.ToString();
+        }
     }
 }

--
Gitblit v1.9.1