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字符串

---
 device/TcpServer.cs |    1 -
 core/Monitor.cs     |    6 ++++++
 wms/WMSHelper.cs    |   29 ++++++++++++++++++++++++++++-
 api/ApiHelper.cs    |   12 +++++++++++-
 4 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/api/ApiHelper.cs b/api/ApiHelper.cs
index 3780833..e8a32c6 100644
--- a/api/ApiHelper.cs
+++ b/api/ApiHelper.cs
@@ -638,6 +638,16 @@
             LogHelper.Info("瑙﹀彂API锛歅DA婊℃墭涓嬬嚎鍏ュ簱" + JsonConvert.SerializeObject(model), "API");
             try
             {
+                if( model.RfId.Length < 16)
+                {
+                    result.resultCode = 1;
+                    result.resultMsg = $"杈撳叆鐨凴FID锛岄暱搴︿笉澶燂紝瑕佸ぇ浜�6浣�;
+                    LogHelper.Info(result.resultMsg);
+                    return result;
+                }
+
+                model.RfId = WMSHelper.ConvertHexToAscii(model.RfId);
+
                 //璇ヤ骇绾跨殑婊℃墭涓嬬嚎浣嶇疆锛岃捣鐐�                 var startPoint = Settings.ProductionLines.FirstOrDefault(a => a.PointOut == model.StartLoc);
                 if (startPoint != null)//璧风偣瀛樺湪
@@ -822,7 +832,7 @@
                     }
                     else
                     {
-                        result.resultCode = 9;
+                        result.resultCode = 12;
                         result.resultMsg = $"姝や綅缃細{startPoint.PointOut}宸查攣浣�;
                         LogHelper.Info(result.resultMsg);
                         return result;
diff --git a/core/Monitor.cs b/core/Monitor.cs
index ac0b0fb..af58528 100644
--- a/core/Monitor.cs
+++ b/core/Monitor.cs
@@ -552,6 +552,12 @@
                     db.Updateable<TN_InventoryM>(targetInM).UpdateColumns(it => new { it.EXPIRATION_DAY }).ExecuteCommand();
                 }
 
+                targetInM = db.Queryable<TN_InventoryM>().First(a => a.EXPIRATION_DAY > 0 && a.ITEMSTATE == "杩囨湡");//宸茶繃鏈熺殑璐у搧锛屽墿浣欏ぉ鏁版敼涓�
+                if (targetInM != null)
+                {
+                    targetInM.EXPIRATION_DAY = 0;
+                    db.Updateable<TN_InventoryM>(targetInM).UpdateColumns(it => new { it.EXPIRATION_DAY }).ExecuteCommand();
+                }
 
                 //  鍚屾 TN_DayProDetail
                 var curDay = System.DateTime.Now.Date;
diff --git a/device/TcpServer.cs b/device/TcpServer.cs
index bea90aa..2f79907 100644
--- a/device/TcpServer.cs
+++ b/device/TcpServer.cs
@@ -113,7 +113,6 @@
                     if (!buffers.Keys.Contains(remote_ip))
                     {
                         buffers.Add(remote_ip, new byte[1024]);
-                       
                     }
                     if (!isSend.Keys.Contains(remote_ip))
                     {
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