From 745d1ce73a3b27d2a3507843c8060755a0c95765 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期二, 21 十月 2025 19:06:36 +0800
Subject: [PATCH] 打印机条码格式修改,增添一个点检功能方法

---
 src/Bro.M141.Process/MyMQTT.cs                 |   12 +
 src/Bro.M141.Process/UI/UIPrinter.cs           |   12 +-
 src/Bro.M141_AOI1.Process/AOI1Process.cs       |  219 +++++++++++++++++++++++++++++++++++-
 src/Bro.M141.Process/M141Config.cs             |   18 +-
 src/Bro.M141.Process/M141Models.cs             |    3 
 src/Bro.M141.Process/M141Process.cs            |   33 +---
 src/Bro.M141.Process/M141Process_ImageCheck.cs |   10 +
 7 files changed, 253 insertions(+), 54 deletions(-)

diff --git a/src/Bro.M141.Process/M141Config.cs b/src/Bro.M141.Process/M141Config.cs
index b583595..bba1b8b 100644
--- a/src/Bro.M141.Process/M141Config.cs
+++ b/src/Bro.M141.Process/M141Config.cs
@@ -66,6 +66,14 @@
         public List<MeasureBind> MeasureBindCollection { get; set; } = new List<MeasureBind>();
 
 
+        [Category("鐐规閰嶇疆")]
+        [Description("鐐规閰嶇疆闆嗗悎锛岄厤缃娴嬬殑宸ヤ綅锛屽浘鐗囩储寮曪紝鐩告満鍜屾娴嬭皟鐢ㄩ」鍏崇郴")]
+        [DisplayName("鐐规閰嶇疆闆嗗悎")]
+        [TypeConverter(typeof(CollectionCountConvert))]
+        [Editor(typeof(ComplexCollectionEditor<MeasureBind>), typeof(UITypeEditor))]
+        public List<MeasureBind> MeasureBindCollection_Check { get; set; } = new List<MeasureBind>();
+
+
 
         [Category("妫�娴嬭秴鏃惰缃�")]
         [Description("妫�娴嬭秴鏃惰缃紝鑾峰彇妫�娴嬬粨鏋滄椂鐨勫厑璁告渶澶х瓑寰呮椂闂达紝鍗曚綅ms")]
@@ -527,12 +535,6 @@
         public string code { get; set; }
 
     }
-
-
-
-
-
-
     public class MeasureBind : IComplexDisplay, IHalconToolPath
     {
         [Category("绱㈠紩閰嶇疆")]
@@ -1111,14 +1113,10 @@
         [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
         public string ImageFolder { get; set; }
 
-
-
         [Category("妫�娴嬪姛鑳�")]
         [Description("鍥剧墖鍦ㄦ壒閲忔祴璇曡繃绋嬩腑鏈�缁堝浘鐗囩粨鏋滀細瀛樺偍杈冩參闇�瑕佽缃欢鏃剁‘淇濆浘鐗囦笉琚祫婧愯嚜鍔ㄩ噴鏀�")]
         [DisplayName("鍥剧墖瀛樺浘寤舵椂")]
         public int SaveImageTime { get; set; } = 0;
-
-
 
         [Category("妫�娴嬪姛鑳�")]
         [Description("true锛氬惎鍔∣K娴嬭瘯 false锛氬惎鍔∟G娴嬭瘯")]
diff --git a/src/Bro.M141.Process/M141Models.cs b/src/Bro.M141.Process/M141Models.cs
index 930c91b..43b83bf 100644
--- a/src/Bro.M141.Process/M141Models.cs
+++ b/src/Bro.M141.Process/M141Models.cs
@@ -203,9 +203,6 @@
         [Description("璇ユ娴嬮」鎵�娑夊強鐨勬墍鏈夋娴嬬偣浣嶉泦鍚�")]
         [TypeConverter(typeof(ComplexObjectConvert))]
         [Editor(typeof(ComplexCollectionEditor<MeasurePointSelector>), typeof(UITypeEditor))]
-
-
-
         public List<MeasurePointSelector> MeasurePointNameCollection { get; set; } = new List<MeasurePointSelector>();
 
 
diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs
index 44a3c5a..fdec168 100644
--- a/src/Bro.M141.Process/M141Process.cs
+++ b/src/Bro.M141.Process/M141Process.cs
@@ -103,6 +103,7 @@
         public PLCBase Plc1;
         bool devicestate = false;
         PLCBase Plc2;
+        public PLCBase Plc3;
         public Thread ThHeartPlc;
 
         public RabbitMQHelper mqtt;
@@ -322,7 +323,7 @@
 
                                             AlarmTypeList.Add(item2.alarmtype);
 
-                                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{item2.alarmtype}鍔犲叆闃熷垪,闃熷垪涓暟涓簕AlarmTypeList.Count}");
+                                       
                                         }
                                     }
                                 }
@@ -338,8 +339,7 @@
                                     {
 
                                         StateDIC[StateDICKey] = new List<int>();
-
-                                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{StateDICKey}鍔犲叆瀛楀吀锛歋tateDIC");
+                                       
 
                                     }
 
@@ -362,7 +362,7 @@
                                             CSVdata = csvdata,
                                         };
                                         AlarmType.Add(item.alarmtype, alarmData);
-                                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ{item.alarmname}绫诲埆{key}浣滀负key鍔犲叆AlarmType瀛楀吀");
+
                                     }
 
                                     alarmData.CSVhead += $",{item.alarmname}";
@@ -642,6 +642,9 @@
 
                         if (measureBind.WorkPosition == "P1" && M141Config.StationCode == "S5" && detectResults.GetDefectDescList().Count == 0)
                         {
+                            var defecttem1 = detectResults.SelectMany(u => u.AllNetResults).SelectMany(m => m.DetectDetails).Select(detail => detail.ClassName).ToList();
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN}  S3S5妫�娴� 缂洪櫡鍚嶇О闆嗗悎涓簕string.Join(",", defecttem1)}");
+
                             var defecttem = detectResults.SelectMany(u => u.AllNetResults.SelectMany(m => m.DetectDetails)).Where(u => u.ClassName == M141Config.defectname).ToList();
 
                             List<Netdefectdetail> Netdefectdetails = mysqlhelper.GetNetdefectdetails(products[0].SEQUENCE);
@@ -893,7 +896,6 @@
             });
         }
 
-
         public async Task RunImageCheckAsync(List<ProductModel> products, string triggerText, string triggerSource, MeasureBind measureBind)
         {
             await Task.Run(() =>
@@ -972,7 +974,6 @@
             });
         }
 
-
         private void RunCustomizedMethod(List<ProductModel> products, string triggerText, string triggerSource, IImageSet imgSet, string methodId, List<DetectResult> resultList)
         {
             try
@@ -1019,10 +1020,6 @@
                 LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鑷畾涔夋娴嬭繃绋嬪紓甯革紝{ex.GetExceptionMessage()}");
             }
         }
-
-
-
-
 
         #region plc
         public ResponseMessage RunImageCheck_plc(IOperationConfig config)
@@ -1101,7 +1098,6 @@
 
             CheckPositionDoneAsync_plc(measureBinds[0].WorkPosition, inputSequence, config, cameraIds);
 
-
             return msg;
 
         }
@@ -1152,8 +1148,6 @@
                     LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐩告満{camera.Name}妫�娴嬪墠娓呯悊缂撳瓨瀹屾垚");
                 }
             });
-
-
 
             inputSequence = triggerDatas[triggerDatas.Length - 1];
 
@@ -1245,7 +1239,6 @@
             {
                 try
                 {
-
                     string index = config.TriggerStr.Split(',')[1];
                     var positionSet = M141Config.WorkPositionCollection.FirstOrDefault(u => u.PositionName == positionName);
 
@@ -1897,10 +1890,6 @@
         }
 
 
-
-
-
-
         #region  鎵撳嵃鏈虹浉鍏�
         PrintDocument printDocument1 = new PrintDocument();
         string Printmessage = "";
@@ -1909,8 +1898,8 @@
         {
             try
             {
-                int ttwith = 320;
-                int ttheigh = 160;
+                int ttwith = 240;
+                int ttheigh = 80;
                 Printmessage = str;
 
                 this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)";
@@ -1950,7 +1939,7 @@
 
                 writer.Options = options;
                 Bitmap map = writer.Write(Printmessage);
-                e.Graphics.DrawImage(map, new System.Drawing.Point(90, 10));
+                e.Graphics.DrawImage(map, new System.Drawing.Point(90, 4));
 
                 // 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
                 using (Font font = new Font("Arial", 10))
@@ -1959,7 +1948,7 @@
                     // 璁╂枃瀛楀眳涓埌浜岀淮鐮佷笅鏂�
                     SizeF textSize = e.Graphics.MeasureString(Printmessage, font);
                     float textX = 90 + (map.Width - textSize.Width) / 2;
-                    float textY = 10 + map.Height;
+                    float textY = 1 + map.Height;
 
                     e.Graphics.DrawString(Printmessage, font, brush3, textX, textY);
                 }
diff --git a/src/Bro.M141.Process/M141Process_ImageCheck.cs b/src/Bro.M141.Process/M141Process_ImageCheck.cs
index 46108d4..f054fd9 100644
--- a/src/Bro.M141.Process/M141Process_ImageCheck.cs
+++ b/src/Bro.M141.Process/M141Process_ImageCheck.cs
@@ -496,7 +496,6 @@
                 Plc1.WriteSingleAddress(1526, mysqlhelper.GetS2Result(productList[0].SEQUENCE) ? 1 : 2, out _);
 
                 LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{string.Join(",", productList.Select(u => u.PID))}妫�娴嬪弽棣坽mysqlhelper.GetS2Result(productList[0].SEQUENCE)}");
-
             }
             else
             {
@@ -988,5 +987,14 @@
 
             public object data { get; set; }
         }
+
+
+
+
+      
+
+
+
+
     }
 }
diff --git a/src/Bro.M141.Process/MyMQTT.cs b/src/Bro.M141.Process/MyMQTT.cs
index f1e6d1a..da6a495 100644
--- a/src/Bro.M141.Process/MyMQTT.cs
+++ b/src/Bro.M141.Process/MyMQTT.cs
@@ -148,6 +148,7 @@
                 CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 鐗╂枡 瑙f瀽寮傚父锛歿ex.Message}");
             }
         }
+
         //Dictionary<string, Task> dic_ispass = new Dictionary<string, Task>();///value涓烘敹鍒版暟鎹�
 
         public async Task<string> MESForBasketAsync(string ztype, string zlsn, string zlpn, string zstatus, string zversion, int timeoutMes = 30000)
@@ -166,13 +167,18 @@
                     {
 
                         CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ {keystr}浜屾鎺ユ敹 杩斿洖鍊兼甯� {tem.receive}");
-                        
+                    
                         return tem.receive;
                     }
                     Thread.Sleep(1000);
                 }
-                MSGClasses.RemoveAll(u => u.key == keystr);
-                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ {keystr}浜屾鎺ユ敹 杩斿洖鍊间负绌�");
+                if (MSGClasses.Count > 10)
+                {
+                    MSGClasses.RemoveAt(0);
+                    CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ浜屾鎺ユ敹鏁版嵁瓒呰繃鍗佹潯 娓呴櫎绗竴鏉¤秴鏃舵暟鎹�");
+                }
+                //MSGClasses.RemoveAll(u => u.key == keystr);
+               
 
                 return null;
             }
diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index 842d7ed..59b576c 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -51,16 +51,16 @@
 
 
         PrintDocument printDocument1 = new PrintDocument();
-        int ttwith = (int)(80 * 4);
-        int ttheigh = (int)(40 * 4);
+        int ttwith = (int)(60 * 4);
+        int ttheigh = (int)(20 * 4);
         string message = "";
 
         public void StartPrint(string str)
         {
             try
             {
-                ttwith = 320;
-                ttheigh = 160;
+                ttwith = 240;
+                ttheigh = 80;
                 message = str;
 
                 if (string.IsNullOrEmpty(message))
@@ -135,7 +135,7 @@
 
                 writer.Options = options;
                 Bitmap map = writer.Write(numvalue);
-                e.Graphics.DrawImage(map, new System.Drawing.Point(90,10));
+                e.Graphics.DrawImage(map, new System.Drawing.Point(90,4));
 
 
                 // 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
@@ -145,7 +145,7 @@
                     // 璁╂枃瀛楀眳涓埌浜岀淮鐮佷笅鏂�
                     SizeF textSize = e.Graphics.MeasureString(numvalue, font);
                     float textX = 90 + (map.Width - textSize.Width) / 2;
-                    float textY = 10 + map.Height;
+                    float textY = 1 + map.Height;
 
                     e.Graphics.DrawString(numvalue, font, brush3, textX, textY);
                 }
diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index 8f105c1..8d82bef 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -9,10 +9,12 @@
 using HalconDotNet;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using NPOI.OpenXmlFormats.Vml;
 using NPOI.POIFS.Crypt.Dsig;
 using NPOI.SS.Formula.Functions;
 using NPOI.XSSF.Streaming.Values;
 using System.Collections.Concurrent;
+using System.Collections.Generic;
 using System.Net.Sockets;
 using System.Text.RegularExpressions;
 using static Bro.Common.Helper.EnumHelper;
@@ -105,6 +107,75 @@
         }
 
 
+        [ProcessMethod("ImageCheck", "CheckProduction", "浜у搧鐐规", InvokeType.TestInvoke)]
+        public ResponseMessage CheckProduction(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+        {
+            ResponseMessage msg = new ResponseMessage();
+
+            if (config is IImageCheckOperationConfig opConfig)
+            {
+                var results1 = GetSpecListFromConfigSelection(opConfig.SpecCollection);
+                IImageSet imageSet = null;
+                string Head = "鏃堕棿,";
+                string data = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}T,";               
+                try
+                {
+                    var messure = M141Config.MeasureBindCollection_Check.FirstOrDefault(u => u.CameraId == invokeDevice.Id);
+                    var camera = DeviceCollection.FirstOrDefault(u => u.Id == messure.CameraId) as CameraBase;          
+                    try
+                    {
+                        imageSet = CollectHImage(camera, messure.SnapshotOpConfig);
+                    }
+                    catch (Exception exx)
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鐐规鍔熻兘鑾峰彇鍥惧儚澶辫触{exx.ToString()}");
+                    }
+                    var tool = GetHalconTool(null, "", opConfig.AlgorithemPath);
+                    var ret = tool.RunProcedure(null, new Dictionary<string, HalconDotNet.HObject>() { { "INPUT_Image", imageSet.HImage } }, new List<string>() { "OUTPUT_Results" }, null);
+                    //var ret = tool.RunProcedure(null, null, new List<string>() { "OUTPUT_Results" }, null);
+                    List<IShapeElement> eleList = new List<IShapeElement>();
+                    TextDisplay text = new TextDisplay();
+                    text.LineLimit = M141Config.LineLimit_p;
+                    text.FontSize = M141Config.FontSize_p;
+                    eleList.Add(text);
+                    text.StartX = text.StartY = 0;
+                    text.AddText("鐐规杩愯鎴愬姛", Color.Lime, Color.Transparent);
+                    var b = ret.Item2["OUTPUT_Results"].HTupleToDouble();
+                    if (ret != null&& results1.Count== b.Count())
+                    {
+                        var itemDict = results1.ToDictionary(u => u.OutputIndex);
+                        b.ForEach(u =>
+                        {
+                            int index = b.IndexOf(u); // 鑾峰彇褰撳墠鍊肩殑绱㈠紩
+                            if (itemDict.TryGetValue(index, out var item))
+                            {
+                                double diff = u - item.StandardValue;
+                                bool isInTolerance = (diff - item.Tolrenance_Positive) *(diff - item.Tolrenance_Negative) <= 0;
+                                text.AddText($"{item.Code} {u}", isInTolerance == true ? Color.Lime: Color.Red, Color.Transparent);
+                                 Head += $"{item.Code},";
+                                 data += $"{u},";
+                            }
+                        });           
+                    }                   
+                    camera.SaveFitImage(eleList, imageSet);
+                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐐规鍔熻兘杩愯鎴愬姛");
+                }
+                catch (Exception ex)
+                {
+                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鐐规鍔熻兘澶辫触,{ex.ToString()}");
+                }
+                LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐐规鍥剧墖寮�濮嬮噴鏀�");
+                imageSet.HImage?.Dispose();
+                imageSet.HImage = null;
+                imageSet.Dispose();
+                imageSet = null;
+                LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鍥剧墖宸查噴鏀�");
+                //鎶ヨ〃杈撳嚭
+                CSVRecordAsync($"鐩告満{invokeDevice.Name}_鐐规鏁版嵁璁板綍.csv", data, Head);
+            }                             
+            return msg;
+        }
+
         [ProcessMethod("ImageCheck", "ReadBarcode", "璇荤爜", InvokeType.TestInvoke)]
         public ResponseMessage ReadBarcode(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
         {
@@ -140,7 +211,6 @@
                             {
                                 codestr = "10";
                             }
-
                             if (codestr.Equals(mh.ToString()))
                             {
                                 ret.Add(1);
@@ -158,7 +228,6 @@
                     }
 
                     FillSpecResults(results[0].PID, results[0].Specs, ret, opConfig.Products[0].SEQUENCE);
-
 
                     opConfig.Products[0].SN = barcode;
                     opConfig.Products[0].PID = barcode + "_1";
@@ -179,7 +248,6 @@
             }
             return msg;
         }
-
 
         [ProcessMethod("ImageCheck", "ReadBarcode2", "璇绘爮鍏风爜", InvokeType.TestInvoke)]
         public ResponseMessage ReadBarcode2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -295,7 +363,6 @@
             return msg;
         }
 
-
         private string BarcodeScannerCommunicate(TcpClientWrapBase client)
         {
             string barcode = "";
@@ -326,7 +393,6 @@
             return "NOREAD";
         }
 
-
         private bool CheckBarcodeValid(string barcode)
         {
             bool isBarcodeValid = true;
@@ -336,7 +402,6 @@
             }
             return isBarcodeValid;
         }
-
 
         [ProcessMethod("ImageCheck", "CheckLineProfile", "妫�娴嬩骇鍝佺嚎杞粨搴�", InvokeType.TestInvoke)]
         public ResponseMessage CheckLineProfile(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -500,7 +565,6 @@
             return msg;
         }
 
-
         [ProcessMethod("ImageCheck", "GetMatrix", "鑾峰彇鐭╅樀", InvokeType.TestInvoke)]
         public ResponseMessage GetMatrix(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
         {
@@ -529,10 +593,147 @@
             return msg;
         }
 
+        [ProcessMethod("", "MESupdata", "MES姝e父涓婁紶OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
+        public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+        {
+            ResponseMessage msg = new ResponseMessage();
+
+            Plc3 = invokeDevice as PLCBase;
+            ///浜у搧1涓婁紶
+            var plcnum = Plc3.Read(2100, 1, out _);
+            if (plcnum[0] != 0)
+            {
+                var plist = mysqlhelper.GetProductList(plcnum + "_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;
+
+                var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+                M141Config.mesnum2++;
+                if (tems == null)
+                {
+                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+                }
+                else
+                {
+                    try
+                    {
+                        var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems);
+                        if (obj.zstatus == "200")
+                        {
+                            Plc1.WriteSingleAddress(2120, 1, out _);
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES鎴愬姛  {tems}");
+                        }
+                        else
+                        {
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                        }
+                    }
+                    catch (Exception)
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                    }
+                }
+                ///浜у搧1涓婁紶
+                var plcnum1 = Plc3.Read(2102, 1, out _);
+                if (plcnum1[0] != 0)
+                {
+                    var plist1 = mysqlhelper.GetProductList(plcnum1 + "_1");
+                    ProductModel newp1 = new ProductModel();
+                    newp1.SEQUENCE = plist[0].SEQUENCE;
+                    newp1.PID = plist[0].PID;
+                    newp1.BasketCode = plist[0].BasketCode;
+                    newp1.Zword = plist[0].Zword;
+                    newp1.Result = "OK";
+                    newp1.SN = plist[0].SN;
+
+                    var tems1 = Task.Run(() => mqtt.MESForProduceAsync(newp1, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+                    M141Config.mesnum2++;
+                    if (tems1 == null)
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+                    }
+                    else
+                    {
+                        try
+                        {
+                            var obj1 = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems1);
+                            if (obj1.zstatus == "200")
+                            {
+                                Plc1.WriteSingleAddress(2120, 1, out _);
+                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES鎴愬姛  {tems}");
+                            }
+                            else
+                            {
+                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                            }
+                        }
+                        catch (Exception)
+                        {
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                        }
+                    }
+                }
+                
+            }
+            return msg;
+        }
+
+        [ProcessMethod("", "MESupFinallydata", "MES涓婁紶灏剧洏OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
+        public ResponseMessage MESupFinallydata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+        {
+            ResponseMessage msg = new ResponseMessage();
+
+            Plc3 = invokeDevice as PLCBase;
+            ///浜у搧1涓婁紶
+            var plcnum = Plc3.Read(2100, 1, out _);
+            var plist = mysqlhelper.GetProductList(plcnum+"_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;
+            //涓婁紶灏剧洏鏁版嵁
+            var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro,"Y")).Result;
+            M141Config.mesnum2 = 0;
+            if (tems == null)
+            {
+                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+            }
+            else
+            {
+                try
+                {
+                    var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems);
+                    if (obj.zstatus == "200")
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES鎴愬姛  {tems}");
 
 
-
-
+                        //鎵撳嵃鑾峰彇鐨勬潯鐮�
+                        if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label))
+                        {
+                            StartPrint(obj.tary_label);
+                        }
+                    }
+                    else
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                    }
+                }
+                catch (Exception)
+                {
+                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                }
+            }
+            return msg;
+        }
 
 
         [ProcessMethod("", "MESup1", "MES涓婁紶杩涙枡鍙g┖绡�", InvokeType.TestInvoke)]

--
Gitblit v1.8.0