From f6326d8e85b55a290ca88c9f14a0f2a9ecbf6971 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期六, 07 三月 2026 14:03:31 +0800
Subject: [PATCH] 修改S6_MES上传条码逻辑

---
 src/Bro.M141_AOI1.Process/AOI1Process.cs |  415 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 240 insertions(+), 175 deletions(-)

diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index 7b7e435..cf95a04 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -271,6 +271,8 @@
             return msg;
         }
 
+        string barcodeNow;
+
         [ProcessMethod("ImageCheck", "ReadBarcode2", "璇绘爮鍏风爜", InvokeType.TestInvoke)]
         public ResponseMessage ReadBarcode2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
         {
@@ -315,61 +317,74 @@
 
                     if (ConfigAOI1.ISupMES)
                     {
-                        //string zword = mqtt.MESForBasketAsync("2", "DS02217", barcode, "1", num.ToString()).Result;
-                        string zwordstr = Task.Run(() => mqtt.MESForBasketAsync("2", "DS02217", barcode, "1", ConfigAOI1.mesnum2.ToString())).Result;
-
-                        ConfigAOI1.mesnum2++;
-                        if (ConfigAOI1.ISokMes)
+                        if (barcode == barcodeNow)
                         {
                             Plc1.WriteSingleAddress(1524, 1, out _);
                             Plc1.WriteSingleAddress(1514, 1, out _);
-                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插己鍒惰鏍忓叿鐮佽繍琛岃澶�");
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"閲嶅璇荤爜锛屽凡寮哄埗璇绘爮鍏风爜杩愯璁惧");
                         }
                         else
                         {
-                            try
+                            string zwordstr = Task.Run(() => mqtt.MESForBasketAsync("2", "DS02217", barcode, "1", ConfigAOI1.mesnum2.ToString())).Result;
+
+                            ConfigAOI1.mesnum2++;
+                            if (ConfigAOI1.ISokMes)
                             {
-                                var obj = JsonConvert.DeserializeObject<AutoLineMacQueueBak>(zwordstr);
-                                ConfigAOI1.zwoid = obj.zwoid;
-                                if (!string.IsNullOrEmpty(obj.zwoid) && obj.zstatus == "200")
+                                Plc1.WriteSingleAddress(1524, 1, out _);
+                                Plc1.WriteSingleAddress(1514, 1, out _);
+                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插己鍒惰鏍忓叿鐮佽繍琛岃澶�");
+                            }
+                            else
+                            {
+                                try
                                 {
-                                    Plc1.WriteSingleAddress(1524, 1, out _);
-                                    Plc1.WriteSingleAddress(1514, 1, out _);
-                                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid鑾峰彇鎴愬姛 {obj.zstatus} {obj.zwoid} ");
-                                }
-                                else
-                                {
-                                    try
+                                    var obj = JsonConvert.DeserializeObject<AutoLineMacQueueBak>(zwordstr);
+                                    if (!string.IsNullOrEmpty(obj.zwoid) && obj.zstatus == "200")
                                     {
-                                        if (zwordstr.Contains("version閿欒"))
+                                        ConfigAOI1.zwoid = obj.zwoid;
+                                        Plc1.WriteSingleAddress(1524, 1, out _);
+                                        Plc1.WriteSingleAddress(1514, 1, out _);
+                                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid鑾峰彇鎴愬姛 {obj.zstatus} {obj.zwoid} ");
+
+                                        barcodeNow = barcode;
+                                    }
+                                    else
+                                    {
+                                        try
                                         {
-                                            Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
-                                            MatchCollection matches = reg.Matches(obj.zerrmsg);
-                                            if (matches[0] != null && matches.Count == 3)
+                                            if (zwordstr.Contains("version閿欒"))
                                             {
-                                                ConfigAOI1.mesnum2 = int.Parse(matches[0].Value)+1;
-                                            }
-                                            else
-                                            {
-                                                ConfigAOI1.mesnum2 = 0;
+                                                Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                                MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                                if (matches[0] != null && matches.Count == 3)
+                                                {
+                                                    ConfigAOI1.mesnum2 = int.Parse(matches[0].Value) + 1;
+                                                }
+                                                else
+                                                {
+                                                    ConfigAOI1.mesnum2 = 0;
+                                                }
                                             }
                                         }
+                                        catch (Exception ex)
+                                        {
+                                        }
+                                        Plc1.WriteSingleAddress(1524, 2, out _);
+                                        Plc1.WriteSingleAddress(1514, 1, out _);
+                                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid鑾峰彇澶辫触 {zwordstr} ");
                                     }
-                                    catch (Exception ex) 
-                                    {
-                                    }                                 
+                                }
+                                catch (Exception ex)
+                                {
                                     Plc1.WriteSingleAddress(1524, 2, out _);
                                     Plc1.WriteSingleAddress(1514, 1, out _);
-                                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid鑾峰彇澶辫触 {zwordstr} ");
+                                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ zwoid鑾峰彇寮傚父  杩斿洖鏁版嵁涓� {zwordstr},寮傚父閿欒{ex.GetExceptionMessage()}");
                                 }
                             }
-                            catch(Exception ex)
-                            {
-                                Plc1.WriteSingleAddress(1524, 2, out _);
-                                Plc1.WriteSingleAddress(1514, 1, out _);
-                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ zwoid鑾峰彇寮傚父  杩斿洖鏁版嵁涓� {zwordstr},寮傚父閿欒{ex.GetExceptionMessage()}");
-                            }
-                        }                       
+                        }
+
+
+                  
                     }
                     else
                     {
@@ -747,8 +762,8 @@
         {
             ResponseMessage msg = new ResponseMessage();
 
-            var plcnum11 = Plc3.Read(1542, 1, out _);
-            var plcnum12 = Plc3.Read(1544, 1, out _);
+            var plcnum11 = Plc1.Read(1542, 1, out _);
+            var plcnum12 = Plc1.Read(1544, 1, out _);
 
             LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PLC淇℃伅璁板綍淇濆瓨瑙﹀彂 鑾峰彇PLC搴忓彿{plcnum11[0]}鍜寋plcnum12[0]}");
 
@@ -763,6 +778,11 @@
                 M141Config.numpro = 0;
             }
             M141Config.numpro++;
+            if (M141Config.mesnum2 >= 50)
+            {
+                M141Config.mesnum2 = 0;
+            }
+            M141Config.mesnum2++;
             var tems = Task.Run(() => mqtt.MESForProduceAsync(pro, M141Config.mesnum2.ToString(), M141Config.numpro, endtray)).Result;
             if (tems == null)
             {
@@ -784,7 +804,7 @@
                     else
                     {
                         LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pro.PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
-                        result = "obj.zerrmsg";
+                        result = string.Empty;
                         if (obj.zerrmsg.Contains("閲嶅鏁版嵁"))
                         {
                             return true;
@@ -808,17 +828,13 @@
 
             Plc3 = invokeDevice as PLCBase;
 
-            bool Issuccess = false;
-
+            bool Issuccess = false;            
             bool Issuccess1 = false;
-
-            //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅璁板綍淇濆瓨瑙﹀彂");
-
-            var plcnum = Plc3.Read(2100, 1, out _);
-           
-            Issuccess = GetProImformation(plcnum[0]);
-
+        
+            var plcnum = Plc3.Read(2100, 1, out _);                    
             var plcnum1 = Plc3.Read(2102, 1, out _);
+            //涓婁紶MES
+            Issuccess = GetProImformation(plcnum[0]);
             Issuccess1 = GetProImformation(plcnum1[0]);
 
             LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅璁板綍淇濆瓨瑙﹀彂 鑾峰彇PLC搴忓彿{plcnum[0]}鍜寋plcnum1[0]}");
@@ -836,6 +852,7 @@
 
         private bool GetProImformation(int PLC_order)
         {
+            bool reasult = false;
             if (PLC_order == 0)
             {
                 LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PLC鍙嶉鏈烘鎵嬪惛鐩樻棤浜у搧");
@@ -846,27 +863,47 @@
                 var plist = mysqlhelper.GetProductList(PLC_order + "_1");
                 if (plist != null)
                 {
-                    if (!M141Config.Productioncode.Any(u => u.PID == plist[0].PID))
+                    ProductModel newp = new ProductModel();
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
+                    newp.Result = "OK";
+                    newp.SN = plist[0].SN;
+                    string tary_ID = string.Empty;
+                    //姝e父涓婁紶
+                    reasult = UptoMES(newp, "N", out tary_ID);
+                    if (!string.IsNullOrEmpty(tary_ID))
                     {
-                        int num = M141Config.Productioncode.Count + 1;
-                        M141Config.Productioncode.Add(new ProductionID
+                        M141Config.MES_codes.Add(new MES_code
                         {
-                            Uptomesid = num,
-                            PID = plist[0].PID,
-                            SEQUENCE = plist[0].SEQUENCE,
-                            BasketCode = plist[0].BasketCode,
-                            Zword = plist[0].Zword,
-                            //newp.Result = "OK";
-                            SN = plist[0].SN
+                            Printers_code = tary_ID                           
                         });
-                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁璁板綍鎴愬姛");
-                        return true;                       
-                    }
-                    else
-                    {
-                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"浜у搧{plist[0].PID}鏁版嵁閲嶅锛岃褰曞け璐�");
-                        return false;                      
-                    }
+                        //isStartclear = true;
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"MES涓婁紶浜у搧{plist[0].PID}鏃惰幏鍙栧埌鏉$爜{tary_ID}");
+                    }                 
+                    return reasult;
+                    //if (!M141Config.Productioncode.Any(u => u.PID == plist[0].PID))
+                    //{
+                    //    int num = M141Config.Productioncode.Count + 1;
+                    //    M141Config.Productioncode.Add(new ProductionID
+                    //    {
+                    //        Uptomesid = num,
+                    //        PID = plist[0].PID,
+                    //        SEQUENCE = plist[0].SEQUENCE,
+                    //        BasketCode = plist[0].BasketCode,
+                    //        Zword = plist[0].Zword,
+                    //        //newp.Result = "OK";
+                    //        SN = plist[0].SN
+                    //    });
+                    //    LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁璁板綍鎴愬姛");
+                    //    return true;                       
+                    //}
+                    //else
+                    //{
+                    //    LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"浜у搧{plist[0].PID}鏁版嵁閲嶅锛岃褰曞け璐�");
+                    //    return false;                      
+                    //}
                 }
                 else
                 {
@@ -877,6 +914,11 @@
            
         }
 
+        ///// <summary>
+        ///// 浜у搧闆剁洏涓婁紶鍚姩鏍囪瘑
+        ///// </summary>
+        //private bool isStartclear =false;
+
         [ProcessMethod("", "MEStogetcode", "MES涓婁紶鏁存壒鏁版嵁骞惰幏鍙栨潯鐮�", InvokeType.TestInvoke)]
         public ResponseMessage MEStogetcode(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
         {
@@ -885,154 +927,177 @@
             bool Issuccess = false;
             bool Issuccess1 = false;
 
-           // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶mes瑙﹀彂");
-            var plcnum = Plc3.Read(2100, 1, out _);
-            Issuccess = GetProImformation(plcnum[0]);
-
+            var plcnum = Plc3.Read(2100, 1, out _);          
             var plcnum1 = Plc3.Read(2102, 1, out _);
-            Issuccess1 = GetProImformation(plcnum1[0]);
-
+           
             LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶mes瑙﹀彂锛岃幏鍙朠LC搴忓彿{plcnum[0]}鍜寋plcnum1[0]}");
 
-            string saveTary_ID=string.Empty;
-
-            if (!Issuccess && !Issuccess1)
+            if (plcnum[0] != 0 && plcnum1[0] != 0)
             {
-                Plc3.WriteSingleAddress(2120, 2, out _);
-                return msg;
-            }
-                      
-            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶MES瑙﹀彂锛屼骇鍝佷俊鎭暟閲忎负锛歿M141Config.Productioncode.Count}");
-
-            if (M141Config.Productioncode.Count == 50)
-            {               
-                //浜у搧姝e父涓婁紶
-                while (M141Config.Productioncode.Count>0)
+                //姝e父涓婁紶涓�鐗囦骇鍝�
+                Issuccess = GetProImformation(plcnum[0]);
+                //鏈�鍚庝竴鐗囦骇鍝佸垽鏂槸鍚﹂渶瑕佷笂浼犲熬鐩橀浂鏁�
+                if (M141Config.MES_codes.Count>0)
                 {
+                    //闇�瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum1[0] + "_1");
                     ProductModel newp = new ProductModel();
-                    newp.SEQUENCE = M141Config.Productioncode[0].SEQUENCE;
-                    newp.PID = M141Config.Productioncode[0].PID;
-                    newp.BasketCode = M141Config.Productioncode[0].BasketCode;
-                    newp.Zword = M141Config.Productioncode[0].Zword;
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
                     newp.Result = "OK";
-                    newp.SN = M141Config.Productioncode[0].SN;
+                    newp.SN = plist[0].SN;
                     string tary_ID = string.Empty;
-                    bool isok = UptoMES(newp, "N", out tary_ID);
-                    if (!isok)
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "Y", out tary_ID);
+
+                    if (!string.IsNullOrEmpty(tary_ID))
                     {
-                        Plc3.WriteSingleAddress(2120, 2, out _);
-                        return msg;
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}闆剁洏灏炬暟宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
+                        M141Config.mesnum2 = 0;
                     }
-                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
-                    {
-                        saveTary_ID = tary_ID;
-                        StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");                      
-                        M141Config.MES_codes.Add(new MES_code
-                        {
-                            Printers_code = tary_ID
-                        });
-                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
-                    }                
-                    M141Config.Productioncode.RemoveAt(0);
+
                 }
-                M141Config.Productioncode.Clear();
-            }
-            else if (M141Config.Productioncode.Count > 50)
-            {
-                //涓�旀湁浜у搧琚彇璧�
-                for (int i = 0; i < 50; i++)
+                else
                 {
+                    //涓嶉渶瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum1[0] + "_1");
                     ProductModel newp = new ProductModel();
-                    int count = M141Config.Productioncode.Count;
-                    newp.SEQUENCE = M141Config.Productioncode[count - 1].SEQUENCE;
-                    newp.PID = M141Config.Productioncode[count - 1].PID;
-                    newp.BasketCode = M141Config.Productioncode[count - 1].BasketCode;
-                    newp.Zword = M141Config.Productioncode[count - 1].Zword;
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
                     newp.Result = "OK";
-                    newp.SN = M141Config.Productioncode[count - 1].SN;
+                    newp.SN = plist[0].SN;
                     string tary_ID = string.Empty;
-                    bool isok = UptoMES(newp, "N", out tary_ID);
-                    if (!isok)
-                    {
-                        Plc3.WriteSingleAddress(2120, 2, out _);
-                        return msg;
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "N", out tary_ID);
 
-                    }
-                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
+                    if (!string.IsNullOrEmpty(tary_ID))
                     {
-                        saveTary_ID = tary_ID;
-                        StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");
-                        M141Config.MES_codes.Add(new MES_code
-                        {
-                            Printers_code = tary_ID
-                        });
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
                         LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
-                    }
-                    M141Config.Productioncode.RemoveAt(count - 1);
-                }
-                M141Config.Productioncode.Clear();
-            }
-            else if (M141Config.Productioncode.Count > 0 && M141Config.Productioncode.Count < 50)
-            {
-                //浜у搧缂哄皯闇�瑕侀澶栫殑鏉$爜琛ユ晳
-                while (M141Config.Productioncode.Count > 0)
-                {
-                    ProductModel newp = new ProductModel();
-                    newp.SEQUENCE = M141Config.Productioncode[0].SEQUENCE;
-                    newp.PID = M141Config.Productioncode[0].PID;
-                    newp.BasketCode = M141Config.Productioncode[0].BasketCode;
-                    newp.Zword = M141Config.Productioncode[0].Zword;
-                    newp.Result = "OK";
-                    newp.SN = M141Config.Productioncode[0].SN;
-                    string tary_ID = string.Empty;
-                    bool isok = false;
-                                                        
-                    if (M141Config.Productioncode.Count==1)
-                    {
-                        isok = UptoMES(newp, "Y", out tary_ID);
-                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}瑙﹀彂闆舵暟灏剧洏");
                     }
                     else
                     {
-                        isok = UptoMES(newp, "N", out tary_ID);
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
                     }
-                    if (!isok)
+                }
+            }
+            else if (plcnum1[0] == 0 && plcnum[0] != 0)
+            {
+                Issuccess =true;
+                if (M141Config.MES_codes.Count > 0)
+                {
+                    //闇�瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum[0] + "_1");
+                    ProductModel newp = new ProductModel();
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
+                    newp.Result = "OK";
+                    newp.SN = plist[0].SN;
+                    string tary_ID = string.Empty;
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "Y", out tary_ID);
+
+                    if (!string.IsNullOrEmpty(tary_ID))
                     {
-                        Plc3.WriteSingleAddress(2120, 2, out _);
-                        return msg;
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}闆剁洏灏炬暟宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
+                        M141Config.mesnum2 = 0;
                     }
-                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
+                }
+                else
+                {
+                    //涓嶉渶瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum[0] + "_1");
+                    ProductModel newp = new ProductModel();
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
+                    newp.Result = "OK";
+                    newp.SN = plist[0].SN;
+                    string tary_ID = string.Empty;
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "N", out tary_ID);
+
+                    if (!string.IsNullOrEmpty(tary_ID))
                     {
-                        saveTary_ID = tary_ID;
-                        StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");
-                        M141Config.MES_codes.Add(new MES_code
-                        {
-                            Printers_code = tary_ID
-                        });
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
                         LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
                     }
-                    M141Config.Productioncode.RemoveAt(0);
                 }
-                M141Config.Productioncode.Clear();
             }
-            else if (M141Config.Productioncode.Count == 0)
+            else if(plcnum[0] == 0 && plcnum1[0] != 0)
             {
-                if (M141Config.Isprint && !string.IsNullOrEmpty(saveTary_ID))
+                Issuccess = true;
+                if (M141Config.MES_codes.Count > 0)
                 {
-                    StartPrint(saveTary_ID, "Honeywell PX240S(300 dpi)");
-                }      
+                    //闇�瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum1[0] + "_1");
+                    ProductModel newp = new ProductModel();
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
+                    newp.Result = "OK";
+                    newp.SN = plist[0].SN;
+                    string tary_ID = string.Empty;
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "Y", out tary_ID);
+
+                    if (!string.IsNullOrEmpty(tary_ID))
+                    {
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}闆剁洏灏炬暟宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
+                        M141Config.mesnum2 = 0;
+                    }
+                }
+                else
+                {
+                    //涓嶉渶瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum1[0] + "_1");
+                    ProductModel newp = new ProductModel();
+                    newp.SEQUENCE = plist[0].SEQUENCE;
+                    newp.PID = plist[0].PID;
+                    newp.BasketCode = plist[0].BasketCode;
+                    newp.Zword = plist[0].Zword;
+                    newp.Result = "OK";
+                    newp.SN = plist[0].SN;
+                    string tary_ID = string.Empty;
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "N", out tary_ID);
+
+                    if (!string.IsNullOrEmpty(tary_ID))
+                    {
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
+
+                    }
+                }
             }
+
             if (Issuccess && Issuccess1)
             {
                 Plc3.WriteSingleAddress(2120, 1, out _);
-                return msg;
             }
             else
             {
                 Plc3.WriteSingleAddress(2120, 2, out _);
-                return msg;
             }
-            
+
+            return msg;       
         }
 
         [ProcessMethod("", "MESup1", "MES涓婁紶杩涙枡鍙g┖绡�", InvokeType.TestInvoke)]

--
Gitblit v1.8.0