From 5a8af645c7e36595e218d8ffc36d4f74eab63a32 Mon Sep 17 00:00:00 2001
From: cjs <2216046164@qq.com>
Date: 星期五, 04 七月 2025 17:27:06 +0800
Subject: [PATCH] 111

---
 ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs |   69 +++++++++++++++++++++++++++++-----
 1 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs b/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs
index bf0202b..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,14 +1456,28 @@
             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]}");
 
             CMMLog.Info($"鍙犵洏鏈烘暟鎹鐞嗗畬姣曪細{JsonConvert.SerializeObject(num)}");
 
             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>
@@ -1829,7 +1876,7 @@
                     if (result.result[0] == 1)
                     {
                         //鍒ゆ柇3妤煎彔鐩樿捣鐐规槸鍚︽湁浠诲姟鍗犵敤锛屾病鏈夊垯鐢熸垚浠诲姟
-                        if (ProcessHelper.CheckStartFree(plc.location))
+                        if (ProcessHelper.CheckStartFree(plc.location)) 
                         {
                             string wmstaskno = "";
                             string traycode = "";
@@ -2875,11 +2922,11 @@
                         //info.productType = RemoveNull(GetTrayCode(result.Skip(50).Take(10).ToArray()).Trim().ToString());
                         //info.materialCode = RemoveNull(GetTrayCode(result.Skip(60).Take(20).ToArray()).Trim().ToString());
 
-                        info.lotNo = RemoveNull(GetTrayCode(result.Skip(35).Take(20).ToArray()).Trim().ToString());
-                        info.productType = RemoveNull(GetTrayCode(result.Skip(55).Take(10).ToArray()).Trim().ToString());
-                        info.materialCode = RemoveNull(GetTrayCode(result.Skip(65).Take(15).ToArray()).Trim().ToString());
-                        info.materialName = RemoveNull(GetTrayCode(result.Skip(80).Take(20).ToArray()).Trim().ToString());
-                        info.measurementUnit = RemoveNull(GetTrayCode(result.Skip(100).Take(5).ToArray()).Trim().ToString());
+                        info.lotNo =RemoveNull(GetTrayCode(result.Skip(35).Take(20).ToArray()).Trim().ToString()).TrimStart();
+                        info.productType = RemoveNull(GetTrayCode(result.Skip(55).Take(10).ToArray()).Trim().ToString()).TrimStart();
+                        info.materialCode = RemoveNull(GetTrayCode(result.Skip(65).Take(15).ToArray()).Trim().ToString()).TrimStart();
+                        info.materialName = RemoveNull(GetTrayCode(result.Skip(80).Take(20).ToArray()).Trim().ToString()).TrimStart();
+                        info.measurementUnit = RemoveNull(GetTrayCode(result.Skip(100).Take(5).ToArray()).Trim().ToString()).TrimStart();
 
                         CMMLog.Info($"鏁版嵁澶勭悊娴佺▼锛氬寘瑁呮満鏃燤ES鎯呭喌涓嬶紝鑾峰彇浠ュ線MES浼犺緭鐨勬暟鎹紝鏂拌幏寰楁暟鎹紝lotNo:{info.lotNo},productType:{info.productType},materialCode:{info.materialCode},materialName:{info.materialName},measurementUnit:{info.measurementUnit}");
                         

--
Gitblit v1.9.1