From bb929bd0809eefc1108dd779846ff07d997f7ef0 Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期五, 19 七月 2024 09:25:14 +0800
Subject: [PATCH] 反馈MES工单完成

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs"
index 4b6f78a..0dfc40e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs"
@@ -3,6 +3,7 @@
 using System.Net.NetworkInformation;
 using WIDESEA_Comm.DataHandle;
 using WIDESEA_Comm.LogInfo;
+using static FreeSql.Internal.GlobalFilter;
 
 namespace WIDESEA_WCS.WCSClient
 {
@@ -134,8 +135,11 @@
             }
             else if (typeof(DataType) == typeof(string))//瀛楃涓�
             {
-                var bytes = (byte[])GetContent(siemensPLCClient.Read(dbAddress, (ushort)len), dbAddress);
-                string str = DataParse.GetStr(bytes, 0);
+                //var bytes = (byte[])GetContent(siemensPLCClient.Read(dbAddress, (ushort)len), dbAddress);
+                //string str = DataParse.GetStr(bytes, 0);
+                //return (DataType)(str as object);
+                var str = GetContent(siemensPLCClient.ReadString(dbAddress, (ushort)len), dbAddress).ToString();
+                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "")?.Replace("\u000e\u000e", "")?.Replace("\n", "")?.Replace("?", "")?.Trim();
                 return (DataType)(str as object);
             }
             else
@@ -151,8 +155,17 @@
         /// <returns></returns>
         public override DataType ReadByOrder<DataType>(string orderName, string Method = null)
         {
-            var item = itemGroups.Where(t => t.name.Equals(orderName)).FirstOrDefault();
-            if (Method != null) { item = itemGroups.Where(t => t.name.Equals(orderName) && t.Methods.Equals(Method)).FirstOrDefault(); }
+            DBItemGroup item = null;
+            //var item = itemGroups.Where(t => t.name.Equals(orderName)).FirstOrDefault();
+            //if (Method != null) { item = itemGroups.Where(t => t.name.Equals(orderName) && t.Methods.Equals(Method)).FirstOrDefault(); }
+            var items = itemGroups.Where(t => t.name.Contains(orderName)).ToList();
+            if (items.Count > 0)
+            {
+                if (Method != null)
+                    item = items.Where(t => t.Methods.Contains(Method)).FirstOrDefault();
+                else
+                    item = items.Where(t => t.name.Contains(orderName)).FirstOrDefault();
+            }
             if (item == null)
             {
                 throw new Exception($"PLC{PLCName},鏈畾涔夋寚浠orderName}");

--
Gitblit v1.9.3