From 86f899fa91e811415614dff1a699141144bfc802 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期五, 12 十二月 2025 13:25:37 +0800
Subject: [PATCH] S5上传mes逻辑修改及打印机逻辑修改和数据库存储数据增加

---
 src/Bro.M141_AOI1.Process/AOI1Process.cs |  482 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 469 insertions(+), 13 deletions(-)

diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index 8f105c1..f4c2e15 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -9,12 +9,18 @@
 using HalconDotNet;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using NPOI.OpenXmlFormats.Vml;
 using NPOI.POIFS.Crypt.Dsig;
+using NPOI.POIFS.FileSystem;
 using NPOI.SS.Formula.Functions;
 using NPOI.XSSF.Streaming.Values;
+using ScottPlot.Drawing.Colormaps;
+using System;
 using System.Collections.Concurrent;
+using System.Collections.Generic;
 using System.Net.Sockets;
 using System.Text.RegularExpressions;
+using Windows.Media.AppBroadcasting;
 using static Bro.Common.Helper.EnumHelper;
 using static NPOI.HSSF.Util.HSSFColor;
 using static Org.BouncyCastle.Crypto.Engines.SM2Engine;
@@ -105,6 +111,93 @@
         }
 
 
+        [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 (results1 != null&& results1.Count== b.Count())
+                    {
+
+                        var itemDict = results1.ToDictionary(u => u.OutputIndex);
+
+                        for (int i = 0; i < itemDict.Count(); i++)
+                        {
+                            double CValue;
+                            if (itemDict[i].CompensationValue != null)
+                            {
+                                CValue = itemDict[i].CompensationValue[0];
+                            }
+                            else
+                            {
+                                CValue = 0;
+                            }
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐐规缁撴灉{itemDict[i].Code}绠楁硶杈撳嚭鍊间负{b[i]}");
+                            double diff = b[i] + CValue;
+                            double Upvalue = itemDict[i].StandardValue + itemDict[i].Tolrenance_Positive;
+                            double Downvalue = itemDict[i].StandardValue - itemDict[i].Tolrenance_Negative;
+                            bool isInTolerance = false;
+
+                            if (diff >= Downvalue && diff <= Upvalue)
+                            {
+                                isInTolerance = true;
+                            }
+                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐐规缁撴灉{itemDict[i].Code}涓簕isInTolerance}");
+                            text.AddText($"{itemDict[i].Code} {diff}", isInTolerance == true ? Color.Lime : Color.Red, Color.Transparent);
+                            Head += $"{itemDict[i].Code},";
+                            data += $"{diff},";
+                        }                       
+                    }                   
+                    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 +233,6 @@
                             {
                                 codestr = "10";
                             }
-
                             if (codestr.Equals(mh.ToString()))
                             {
                                 ret.Add(1);
@@ -158,7 +250,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 +270,6 @@
             }
             return msg;
         }
-
 
         [ProcessMethod("ImageCheck", "ReadBarcode2", "璇绘爮鍏风爜", InvokeType.TestInvoke)]
         public ResponseMessage ReadBarcode2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -273,11 +363,11 @@
                                     LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid鑾峰彇澶辫触 {zwordstr} ");
                                 }
                             }
-                            catch
+                            catch(Exception ex)
                             {
                                 Plc1.WriteSingleAddress(1524, 2, out _);
                                 Plc1.WriteSingleAddress(1514, 1, out _);
-                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ zwoid鑾峰彇寮傚父  杩斿洖鏁版嵁涓� {zwordstr} ");
+                                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ zwoid鑾峰彇寮傚父  杩斿洖鏁版嵁涓� {zwordstr},寮傚父閿欒{ex.GetExceptionMessage()}");
                             }
                         }                       
                     }
@@ -294,7 +384,6 @@
 
             return msg;
         }
-
 
         private string BarcodeScannerCommunicate(TcpClientWrapBase client)
         {
@@ -326,7 +415,6 @@
             return "NOREAD";
         }
 
-
         private bool CheckBarcodeValid(string barcode)
         {
             bool isBarcodeValid = true;
@@ -336,7 +424,6 @@
             }
             return isBarcodeValid;
         }
-
 
         [ProcessMethod("ImageCheck", "CheckLineProfile", "妫�娴嬩骇鍝佺嚎杞粨搴�", InvokeType.TestInvoke)]
         public ResponseMessage CheckLineProfile(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -500,7 +587,6 @@
             return msg;
         }
 
-
         [ProcessMethod("ImageCheck", "GetMatrix", "鑾峰彇鐭╅樀", InvokeType.TestInvoke)]
         public ResponseMessage GetMatrix(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
         {
@@ -529,11 +615,385 @@
             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;
+            //涓婁紶鍙嶉缁撴灉          
+            bool Issuccess = false;
+            bool Issuccess1 = false;
 
+            string tary_label = string.Empty;
 
+            string tary_label1 = string.Empty;
 
+            var plcnum = Plc3.Read(2100, 1, out _);
+            var plcnum1 = Plc3.Read(2102, 1, out _);
+            if (plcnum[0] == 0)
+            {
+                Issuccess = true;
+            }
+            else
+            {
+                Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label);
+                if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
+                {
+                    StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
+                }
+            }
+            if (plcnum1[0] == 0)
+            {
+                Issuccess1 = true;               
+            }
+            else
+            {
+                Issuccess1 = UpMES(plcnum1[0] + "_1", "N", out tary_label1);
 
+                if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
+                {
+                    StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
+                }
+            }                      
+            if (Issuccess && Issuccess1)
+            {
+                Plc3.WriteSingleAddress(2120, 1, out _);
+            }
+            else
+            {
+                Plc3.WriteSingleAddress(2120, 2, out _);
+            }
+            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;
+            //涓婁紶鍙嶉缁撴灉          
+            bool Issuccess = false;
+            bool Issuccess1 = false;
+
+            string tary_label = string.Empty;
+
+            string tary_label1 = string.Empty;
+
+            var plcnum = Plc3.Read(2100, 1, out _);
+            var plcnum1 = Plc3.Read(2102, 1, out _);
+            if (plcnum[0] != 0|| plcnum1[0] != 0)
+            {
+                if (plcnum[0] == 0)
+                {
+                    Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1);
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
+                    {
+                        StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
+                    }
+                }
+                else if(plcnum1[0] == 0)
+                {
+                    Issuccess = UpMES(plcnum[0] + "_1", "Y", out tary_label);
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
+                    {
+                        StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
+                    }
+                }
+                else if (plcnum[0] != 0 && plcnum1[0] != 0)
+                {
+                    Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label);                   
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
+                    {
+                        StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
+                    }
+                    Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1);
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
+                    {
+                        StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
+                    }
+                }
+            }
+           
+            if (Issuccess && Issuccess1)
+            {
+                Plc3.WriteSingleAddress(2120, 1, out _);
+            }
+            else
+            {
+                Plc3.WriteSingleAddress(2120, 2, out _);
+            }
+            return msg;
+        }
+
+        private bool UpMES(string PLCNum ,string endtray , out string result )
+        {
+            var plist = mysqlhelper.GetProductList(PLCNum);
+            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;
+            bool isok = UptoMES(newp, endtray, out result);
+            return isok;
+
+        }
+
+        private bool UptoMES( ProductModel pro, string endtray,  out string result)
+        {
+            if (M141Config.numpro >= 50)
+            {
+                M141Config.numpro = 0;
+            }
+            M141Config.numpro++;
+            var tems = Task.Run(() => mqtt.MESForProduceAsync(pro, M141Config.mesnum2.ToString(), M141Config.numpro, endtray)).Result;
+            if (tems == null)
+            {
+                LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pro.PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+                result = string.Empty;
+                return false;
+            }
+            else
+            {
+                try
+                {
+                    var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems);
+                    if (obj.zstatus == "200")
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pro.PID}鏁版嵁涓婁紶MES鎴愬姛 {tems}");
+                        result = obj.tary_label;
+                        return true;
+                    }
+                    else
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pro.PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                        result = "obj.zerrmsg";
+                        if (obj.zerrmsg.Contains("閲嶅鏁版嵁"))
+                        {
+                            return true;
+                        }
+                        return false;
+                    }
+                }
+                catch (Exception)
+                {
+                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pro.PID}鏁版嵁涓婁紶MES澶辫触  {tems}");
+                    result = string.Empty;
+                    return false;
+                }
+
+            }
+        }
+
+       [ProcessMethod("", "PLCtosaveproduction", "MES閫氳繃plc鑾峰彇浜у搧PID骞朵繚瀛�", InvokeType.TestInvoke)]
+        public ResponseMessage PLCtosaveproduction(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+        {
+            ResponseMessage msg = new ResponseMessage();
+
+            Plc3 = invokeDevice as PLCBase;
+
+            bool Issuccess = false;
+
+            bool Issuccess1 = false;
+
+            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅璁板綍淇濆瓨瑙﹀彂");
+
+            var plcnum = Plc3.Read(2100, 1, out _);
+            Issuccess = GetProImformation(plcnum[0]);
+
+            var plcnum1 = Plc3.Read(2102, 1, out _);
+            Issuccess1 = GetProImformation(plcnum1[0]);
+            
+            if (Issuccess && Issuccess1)
+            {
+                Plc3.WriteSingleAddress(2120, 1, out _);
+            }
+            else
+            {
+                Plc3.WriteSingleAddress(2120, 2, out _);
+            }
+            return msg;
+        }
+
+        private bool GetProImformation(int PLC_order)
+        {
+            if (PLC_order == 0)
+            {
+                LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PLC鍙嶉鏈烘鎵嬪惛鐩樻棤浜у搧");
+                return true;
+            }
+            else
+            {
+                var plist = mysqlhelper.GetProductList(PLC_order + "_1");
+                if (plist != null)
+                {
+                    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
+                {
+                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"PLC搴忓彿锛歿PLC_order}鏃犳硶浠庢暟鎹簱涓幏鍙栨暟鎹�");
+                    return false;
+                }
+            }
+           
+        }
+
+        [ProcessMethod("", "MEStogetcode", "MES涓婁紶鏁存壒鏁版嵁骞惰幏鍙栨潯鐮�", InvokeType.TestInvoke)]
+        public ResponseMessage MEStogetcode(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+        {
+            ResponseMessage msg = new ResponseMessage();
+            Plc3 = invokeDevice as PLCBase;
+            bool Issuccess = false;
+            bool Issuccess1 = false;
+
+            var plcnum = Plc3.Read(2100, 1, out _);
+            Issuccess = GetProImformation(plcnum[0]);
+
+            var plcnum1 = Plc3.Read(2102, 1, out _);
+            Issuccess1 = GetProImformation(plcnum1[0]);
+
+            if (!Issuccess && !Issuccess1)
+            {
+                Plc3.WriteSingleAddress(2120, 2, out _);
+                return msg;
+            }
+                      
+            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶MES瑙﹀彂");
+
+            if (M141Config.Productioncode.Count == 50)
+            {
+                //浜у搧姝e父涓婁紶
+                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 = UptoMES(newp, "N", out tary_ID);
+                    if (!isok)
+                    {
+                        Plc3.WriteSingleAddress(2120, 2, out _);
+                    }
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(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);
+                }
+            }
+            else if (M141Config.Productioncode.Count > 50)
+            {
+                //涓�旀湁浜у搧琚彇璧�
+                for (int i = 0; i < 50; i++)
+                {
+                    ProductModel newp = new ProductModel();
+                    newp.SEQUENCE = M141Config.Productioncode[-1].SEQUENCE;
+                    newp.PID = M141Config.Productioncode[-1].PID;
+                    newp.BasketCode = M141Config.Productioncode[-1].BasketCode;
+                    newp.Zword = M141Config.Productioncode[-1].Zword;
+                    newp.Result = "OK";
+                    newp.SN = M141Config.Productioncode[-1].SN;
+                    string tary_ID = string.Empty;
+                    bool isok = UptoMES(newp, "N", out tary_ID);
+                    if (!isok)
+                    {
+                        Plc3.WriteSingleAddress(2120, 2, out _);
+                    }
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(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(-1);
+                }
+                M141Config.Productioncode.Clear();
+            }
+            else if (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);
+                    }
+                    if (!isok)
+                    {
+                        Plc3.WriteSingleAddress(2120, 2, out _);
+                    }
+                    if (M141Config.Isprint && !string.IsNullOrEmpty(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);
+                }
+            }
+            if (Issuccess && Issuccess1)
+            {
+                Plc3.WriteSingleAddress(2120, 1, out _);
+            }
+            else
+            {
+                Plc3.WriteSingleAddress(2120, 2, out _);
+            }
+            return msg;
+        }
 
         [ProcessMethod("", "MESup1", "MES涓婁紶杩涙枡鍙g┖绡�", InvokeType.TestInvoke)]
         public ResponseMessage MESup1(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -670,7 +1130,6 @@
                                 }
                                 Plc1.WriteSingleAddress(1590, 2, out _);
                             }
-
                             LogAsync(DateTime.Now, obj?.zstatus == "200" ? EnumHelper.LogLevel.Information : EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  杩涙枡鍙f弧杞� 涓婁紶{(obj?.zstatus == "200" ? "鎴愬姛" : "澶辫触")}   {obj?.zstatus}");
                         }
                         catch
@@ -691,8 +1150,6 @@
                 LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴");
                 Plc1.WriteSingleAddress(1590, 1, out _);
             }
-
-
             return msg;
         }
 
@@ -708,7 +1165,6 @@
                 string Msg = Task.Run(() => mqtt.MESForBasketAsync("3", "DS02217", ConfigAOI1.PlcAndBasketcodes.Any(u => u.id == num) ? ConfigAOI1.PlcAndBasketcodes.FirstOrDefault(u => u.id == num).code : "NoRead", "0", ConfigAOI1.mesnum3.ToString())).Result;
                 if (Msg != null)
                 {
-
                     try
                     {
                         var obj = JsonConvert.DeserializeObject<AutoLineMacQueueBak>(Msg);

--
Gitblit v1.8.0