From fae1a7742f0d847a47a0f8d3d1235e4826f5d4c6 Mon Sep 17 00:00:00 2001
From: cjs <2216046164@qq.com>
Date: 星期三, 02 七月 2025 17:37:13 +0800
Subject: [PATCH] 1

---
 ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs b/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs
index 0249cff..0555a24 100644
--- a/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs
+++ b/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs
@@ -1345,7 +1345,9 @@
             #endregion
 
             string pcHead = "";
+            string pcTail = "";
             string cpHead = "";
+            string cpTail = "";
             string mtHead = "";// 璁惧鐨勭湡瀹炵墿鏂欑紪鐮� 
             #region  35~54 => 41~60 浜у搧鎵规鍙�@@ -1354,12 +1356,17 @@
             CMMLog.Info($"41~60data1_1:{data}");
             if (data.Length % 2 != 0)
             {
-                data = "0" + machineInfoTwo.lotNo;
-                pcHead = "" + machineInfoTwo.lotNo.Substring(0, 1);
+                //data = "0" + machineInfoTwo.lotNo;
+                //pcHead = "" + machineInfoTwo.lotNo.Substring(0, 1);
+
+                pcTail = machineInfoTwo.lotNo.Substring(data.Length - 1, 1) + "";
+                CMMLog.Info($"pcTail:{pcTail}");
+                data = machineInfoTwo.lotNo + " ";
             }
             CMMLog.Info($"41~60data1_2:{data}");
             //瀛楃涓查暱搴�/ 2 = 鍐欏叆閫氶亾鏁伴噺(涓や綅涓�浆) 鍒楋細 3L0050 鍐欏叆涓変釜閫氶亾
             int maxLength = 34 + (data.Length / 2);// data.Length / 2 鑷冲皯涓�1
+            int maxLength2 = maxLength;
             int aa = 0;
             for (int i = 35; i <= maxLength; i++)
             {
@@ -1367,17 +1374,43 @@
                 aa = aa + 2;
             }
             for (int x = maxLength + 1; x <= 54; x++) num[x] = 0;//灏嗕骇鍝佹壒娆″彿鏃犳暟鎹殑閫氶亾鍏ㄩ儴缃负 0
+            CMMLog.Info($"num:{JsonConvert.SerializeObject(num)}");
             #endregion
 
             #region   55~64 => 61~70 浜у搧鍨嬪彿(鍥涢挻浜у搧鍨嬪彿鏈変腑鏂囧拰鑻辨枃)
 
+            int maxLength3 = 0;
             if (Regex.IsMatch(ErpItemInfo.item_spec, @"[\u4e00-\u9fff]"))
             {
                 ERPService.HandleItemInfoChina(ErpItemInfo.item_spec, 55, 64, num);// 涓枃澶勭悊 55~64 61~70
             }
             else
             {
-                ERPService.HandleItemInfo(ErpItemInfo.item_spec, 55, 64, num);
+                data = ErpItemInfo.item_spec;
+                CMMLog.Info($"61~70data1_1:{data}");
+                if (data.Length % 2 != 0)
+                {
+                    //data = "0" + machineInfoTwo.lotNo;
+                    //pcHead = "" + machineInfoTwo.lotNo.Substring(0, 1);
+
+                    cpTail = ErpItemInfo.item_spec.Substring(data.Length - 1, 1) + "";
+                    CMMLog.Info($"cpTail:{cpTail}");
+                    data = ErpItemInfo.item_spec + " ";
+                }
+                CMMLog.Info($"61~70data1_2:{data}");
+                //瀛楃涓查暱搴�/ 2 = 鍐欏叆閫氶亾鏁伴噺(涓や綅涓�浆) 鍒楋細 3L0050 鍐欏叆涓変釜閫氶亾
+                maxLength = 54 + (data.Length / 2);// data.Length / 2 鑷冲皯涓�1
+                maxLength3 = maxLength;
+                aa = 0;
+                for (int i = 55; i <= maxLength; i++)
+                {
+                    num[i] = int.Parse(AsciiToTen(data.Substring(aa, 2)));
+                    aa = aa + 2;
+                }
+                for (int x = maxLength3 + 1; x <= 64; x++) num[x] = 0;//灏嗕骇鍝佹壒娆″彿鏃犳暟鎹殑閫氶亾鍏ㄩ儴缃负 0
+                CMMLog.Info($"num:{JsonConvert.SerializeObject(num)}");
+
+                //ERPService.HandleItemInfo(ErpItemInfo.item_spec, 55, 64, num);
             }
             
 
@@ -1423,8 +1456,10 @@
             ERPService.HandleItemInfo(ErpItemInfo.item_uom, 100, 104, num);// 100~104 106~110
 
             // 濡傛灉 浜у搧鎵规鍙�鎴栬� 浜у搧鍨嬪彿 浣嶆暟 涓�濂囨暟锛屽垯灏嗘彁鍓嶅彇鍑虹殑 棣栧瓧绗�閲嶆柊杞爜 鍐欏叆 鍏舵墍瀵瑰簲閫氶亾鍖哄煙鐨�棣栭�閬�-            if (pcHead != "") num[35] = int.Parse(AsciiToTen(pcHead));
-            if (cpHead != "") num[55] = int.Parse(AsciiToTen(cpHead));
+            //if (pcHead != "") num[35] = int.Parse(AsciiToTen(pcHead));
+            if (pcTail != "") num[maxLength2] = tailToTen(pcTail);
+            //if (cpHead != "") num[55] = int.Parse(AsciiToTen(cpHead));
+            if (cpHead != "") num[maxLength3] = int.Parse(AsciiToTen(cpTail));
             if (mtHead != "") num[65] = int.Parse(AsciiToTen(mtHead));
             if (pcHead != "" || cpHead != "") CMMLog.Info($"浜у搧鍨嬪彿鎴栨壒娆″彿鏁伴噺涓哄鏁帮紝鐗瑰皢棣栦綅鍙栧嚭鍗曠嫭澶勭悊锛屼互涓嬩负鎵规鍙峰拰浜у搧鍨嬪彿鐨勫崄杩涘埗鏁板�{num[35]},{num[55]}");
 
@@ -1433,6 +1468,18 @@
             return num;
         }
 
+        private static int tailToTen(string Tail)
+        {
+            char inputChar = Tail[0]; // 鑾峰彇瀛楃涓茬殑绗竴涓瓧绗�+            int asciiValue = (int)inputChar; // 杞崲涓篈SCII鐮�+            string hexValue = asciiValue.ToString("X2"); // 杞崲涓�6杩涘埗
+            string binaryValue = Convert.ToString(asciiValue, 2).PadLeft(8, '0'); // 杞崲涓�浣嶄簩杩涘埗
+            string finalBinaryValue = binaryValue + "00000000"; // 琛�涓簩杩涘埗0
+            int finalDecimalValue = Convert.ToInt32(finalBinaryValue, 2); // 杞崲涓�0杩涘埗
+
+            return finalDecimalValue;
+        }
+
         /// <summary>
         /// 涓夋ゼ鍙犳墭鏈烘壂鐮�         /// </summary>

--
Gitblit v1.9.1