From c8ff461116306749ed4135fbb1e32a7d6777d5f0 Mon Sep 17 00:00:00 2001
From: cjs <2216046164@qq.com>
Date: 星期二, 03 六月 2025 17:13:53 +0800
Subject: [PATCH] ERP

---
 ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs
index b6de37b..cced9a5 100644
--- a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs
+++ b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs
@@ -128,7 +128,8 @@
                                                     if (trayCode.errCode == 0 && trayCode.result.Length == 80)
                                                     {
                                                         //鑾峰彇鎵樼洏鐮佺瓑淇℃伅  璇诲彇閫氶亾 10銆�1銆�2鐨勬暟鎹綔涓烘墭鐩樼爜   璇诲彇鍏跺畠閫氶亾 閲嶉噺 鍙犲寘绛変俊鎭�鎵�湁鏁版嵁瀛樺叆MachineInfo琛�-                                                        GetMachineData(pmInfo, trayCode.result);
+                                                        string location = "";
+                                                        GetMachineData(pmInfo,ref location, trayCode.result);
                                                         var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                         if (tray != null && tray.addState == 0)
                                                         {
@@ -182,7 +183,16 @@
                                                 if (trayCode.errCode == 0 && trayCode.result.Length == 95)
                                                 {
                                                     //鑾峰彇鎵樼洏鐮佺瓑淇℃伅  璇诲彇閫氶亾 11銆�2銆�3鐨勬暟鎹綔涓烘墭鐩樼爜   璇诲彇鍏跺畠閫氶亾 閲嶉噺 鍙犲寘绛変俊鎭�鎵�湁鏁版嵁瀛樺叆MachineInfo琛�-                                                    GetMachineData(pmInfo, trayCode.result, false, "1");
+
+                                                    string flLoc = "";
+                                                    string location = "";
+                                                    GetMachineData(pmInfo,ref location, trayCode.result, false, "1");
+                                                    if (pmInfo.location.Contains("FLZT"))
+                                                    {
+                                                        flLoc = pmInfo.location;
+                                                        pmInfo.location = location;
+                                                    }
+
                                                     var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                     if (tray != null)
                                                     {
@@ -219,6 +229,7 @@
                                                             {
                                                                 CMMLog.Info($"鐗╂枡缂栫爜锛歿tray.materialCode}锛屾壒娆″彿锛歿tray.lotNo}");
                                                                 string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1);
+                                                                pmInfo.location = !string.IsNullOrEmpty(flLoc) ? flLoc : pmInfo.location;
                                                                 HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3妤煎寘瑁呭彇鏂�, 0, tray.trayCode, timeStamp);
                                                                 ProcessHelper.deleteInfo(pmInfo.location + "-鍖呰涓嬬嚎");
                                                                 //鍖呰鍙栨枡鍗歌揣瀹屾垚锛岃澶囩敓浜ф暟閲忓姞涓�@@ -378,7 +389,8 @@
                                                     if (trayCode.errCode == 0 && trayCode.result.Length == 80)
                                                     {
                                                         //鑾峰彇鎵樼洏鐮佺瓑淇℃伅  璇诲彇閫氶亾 10銆�1銆�2鐨勬暟鎹綔涓烘墭鐩樼爜   璇诲彇鍏跺畠閫氶亾 閲嶉噺 鍙犲寘绛変俊鎭�鎵�湁鏁版嵁瀛樺叆MachineInfo琛�-                                                        GetMachineData(pmInfo, trayCode.result);
+                                                        string location = "";
+                                                        GetMachineData(pmInfo,ref location, trayCode.result);
                                                         var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                         if (tray != null && tray.addState == 0)
                                                         {
@@ -432,7 +444,14 @@
                                                 if (trayCode.errCode == 0 && trayCode.result.Length == 95)
                                                 {
                                                     //鑾峰彇鎵樼洏鐮佺瓑淇℃伅  璇诲彇閫氶亾 11銆�2銆�3鐨勬暟鎹綔涓烘墭鐩樼爜   璇诲彇鍏跺畠閫氶亾 閲嶉噺 鍙犲寘绛変俊鎭�鎵�湁鏁版嵁瀛樺叆MachineInfo琛�-                                                    GetMachineData(pmInfo, trayCode.result, false, "2");
+                                                    string flLoc = "";
+                                                    string location = "";
+                                                    GetMachineData(pmInfo,ref location, trayCode.result, false, "2");
+                                                    if (pmInfo.location.Contains("FLZT"))
+                                                    {
+                                                        flLoc = pmInfo.location;
+                                                        pmInfo.location = location;
+                                                    }
                                                     var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                     if (tray != null)
                                                     {
@@ -468,6 +487,7 @@
                                                             {
                                                                 CMMLog.Info($"鐗╂枡缂栫爜锛歿tray.materialCode}锛屾壒娆″彿锛歿tray.lotNo}");
                                                                 string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1);
+                                                                pmInfo.location = !string.IsNullOrEmpty(flLoc) ? flLoc : pmInfo.location;
                                                                 HHAmsExecuteResult req;
                                                                 if (pmInfo.deviceType == "22")
                                                                 {
@@ -2747,7 +2767,7 @@
         /// <param name="info"></param>
         /// <param name="result"></param>
         /// <param name="noPack">true : MES浜や簰鏂瑰紡  false : 鏃燤ES浜や簰鏂瑰紡</param>
-        private static void GetMachineData(Settings.PlcInfo pmInfo,int[] result ,bool noPack = true,string isOne = "")
+        private static void GetMachineData(Settings.PlcInfo pmInfo, ref string loc, int[] result ,bool noPack = true,string isOne = "")
         {
             //Console.WriteLine($"杩涘叆鏁版嵁澶勭悊娴佺▼锛�);
             CMMLog.Info($"杩涘叆鏁版嵁澶勭悊娴佺▼锛�);
@@ -2755,6 +2775,7 @@
             string empCode = RemoveNull(GetTrayCode(result.Take(5).ToArray()));//鍛樺伐缂栫爜
             string trayCode = RemoveNull(GetTrayCode(result.Skip(5).Take(3).ToArray()));//鎵樼洏鐮�             string location = RemoveNull(GetTrayCode(result.Skip(8).Take(1).ToArray()));//璁惧璐т綅缂栫爜
+            loc = location;
             #region 2024-12-30 鍙樻洿 鍔犲叆mes鐢熶骇璁㈠崟缂栧彿 鍒嗗綍ID   鍙樻洿娉ㄩ噴
             string orderCode = ""; //鐢熶骇璁㈠崟缂栧彿
             int fEntryID = 0; //鍒嗗綍ID

--
Gitblit v1.9.1