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.Process/UI/UIPrinter.cs          |  160 ++++++----
 src/Bro.M141_AOI1.Process/AOI1Process.cs      |  482 +++++++++++++++++----------------
 src/Bro.M141.Process/M141Config.cs            |    2 
 src/Bro.M141.Process/M141Process.cs           |    9 
 src/Bro.M141.Process/UI/UIPrinter.Designer.cs |  165 ++++++++++-
 5 files changed, 492 insertions(+), 326 deletions(-)

diff --git a/src/Bro.M141.Process/M141Config.cs b/src/Bro.M141.Process/M141Config.cs
index a115d5e..fa91b92 100644
--- a/src/Bro.M141.Process/M141Config.cs
+++ b/src/Bro.M141.Process/M141Config.cs
@@ -516,8 +516,6 @@
             return alarmname;
         }
 
-
-
         public IImportFromFileInEditor GetImportObject(string data, out string msg)
         {
             msg = "";
diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs
index f5dc4c0..a2e5c79 100644
--- a/src/Bro.M141.Process/M141Process.cs
+++ b/src/Bro.M141.Process/M141Process.cs
@@ -962,15 +962,11 @@
                                 LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"浜у搧{p.PID}_{p.SEQUENCE}宸ヤ綅{measureBind.WorkPosition}鐨勭{measureBind.CheckIndex}妫�娴嬪畬鎴愶紝{msg}");
                             }
                         });
-
-
-
                     }
                     catch (Exception ex)
                     {
                         LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"{measureBind.WorkPosition}锛屼骇鍝亄string.Join(",", products.Select(u => u.PID))}鐨凬G鍥剧墖淇濆瓨寮傚父锛寋ex.GetExceptionMessage()}");
                     }
-
                 }
             });
         }
@@ -1626,7 +1622,6 @@
             });
         }
 
-
         public void ReplyPlcData(WorkPositionSet p, List<bool> result)
         {
             if (p.plcresult != 0)
@@ -1700,9 +1695,6 @@
             });
 
         }
-
-
-
 
         #endregion
 
@@ -1892,6 +1884,7 @@
         {
             try
             {
+                LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鎵撳嵃鏈烘墦鍗皗str}");
                 int ttwith = 240;
                 int ttheigh = 80;
                 Printmessage = str;
diff --git a/src/Bro.M141.Process/UI/UIPrinter.Designer.cs b/src/Bro.M141.Process/UI/UIPrinter.Designer.cs
index 7e3017f..fc615ba 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.Designer.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.Designer.cs
@@ -46,27 +46,38 @@
             label3 = new Label();
             textBox8 = new TextBox();
             button4 = new Button();
+            button7 = new Button();
+            textBox9 = new TextBox();
+            label4 = new Label();
+            label5 = new Label();
+            textBox10 = new TextBox();
+            label6 = new Label();
+            textBox11 = new TextBox();
+            label7 = new Label();
+            textBox12 = new TextBox();
+            label8 = new Label();
+            textBox13 = new TextBox();
             SuspendLayout();
             // 
             // button2
             // 
-            button2.Location = new Point(229, 51);
+            button2.Location = new Point(177, 51);
             button2.Margin = new Padding(3, 2, 3, 2);
             button2.Name = "button2";
             button2.Size = new Size(93, 46);
             button2.TabIndex = 1;
-            button2.Text = "棰勮";
+            button2.Text = "S6棰勮";
             button2.UseVisualStyleBackColor = true;
             button2.Click += button2_Click;
             // 
             // button1
             // 
-            button1.Location = new Point(27, 51);
+            button1.Location = new Point(51, 51);
             button1.Margin = new Padding(3, 2, 3, 2);
             button1.Name = "button1";
             button1.Size = new Size(93, 46);
             button1.TabIndex = 2;
-            button1.Text = "S5鎵撳嵃鏉$爜";
+            button1.Text = "S6鎵撳嵃鏉$爜";
             button1.UseVisualStyleBackColor = true;
             button1.Click += button1_Click;
             // 
@@ -89,7 +100,7 @@
             // 
             // button3
             // 
-            button3.Location = new Point(27, 101);
+            button3.Location = new Point(27, 178);
             button3.Margin = new Padding(2);
             button3.Name = "button3";
             button3.Size = new Size(69, 33);
@@ -100,7 +111,7 @@
             // 
             // textBox2
             // 
-            textBox2.Location = new Point(27, 138);
+            textBox2.Location = new Point(27, 215);
             textBox2.Margin = new Padding(3, 2, 3, 2);
             textBox2.Name = "textBox2";
             textBox2.Size = new Size(269, 21);
@@ -119,15 +130,15 @@
             // 
             // richTextBox1
             // 
-            richTextBox1.Location = new Point(328, 26);
+            richTextBox1.Location = new Point(444, 26);
             richTextBox1.Name = "richTextBox1";
-            richTextBox1.Size = new Size(270, 509);
+            richTextBox1.Size = new Size(203, 509);
             richTextBox1.TabIndex = 9;
             richTextBox1.Text = "";
             // 
             // textBox3
             // 
-            textBox3.Location = new Point(82, 195);
+            textBox3.Location = new Point(82, 256);
             textBox3.Margin = new Padding(3, 2, 3, 2);
             textBox3.Name = "textBox3";
             textBox3.Size = new Size(151, 21);
@@ -135,7 +146,7 @@
             // 
             // textBox4
             // 
-            textBox4.Location = new Point(82, 231);
+            textBox4.Location = new Point(82, 281);
             textBox4.Margin = new Padding(3, 2, 3, 2);
             textBox4.Name = "textBox4";
             textBox4.Size = new Size(151, 21);
@@ -143,7 +154,7 @@
             // 
             // textBox5
             // 
-            textBox5.Location = new Point(82, 267);
+            textBox5.Location = new Point(82, 306);
             textBox5.Margin = new Padding(3, 2, 3, 2);
             textBox5.Name = "textBox5";
             textBox5.Size = new Size(151, 21);
@@ -151,7 +162,7 @@
             // 
             // textBox6
             // 
-            textBox6.Location = new Point(82, 303);
+            textBox6.Location = new Point(82, 331);
             textBox6.Margin = new Padding(3, 2, 3, 2);
             textBox6.Name = "textBox6";
             textBox6.Size = new Size(151, 21);
@@ -159,7 +170,7 @@
             // 
             // textBox7
             // 
-            textBox7.Location = new Point(82, 339);
+            textBox7.Location = new Point(82, 356);
             textBox7.Margin = new Padding(3, 2, 3, 2);
             textBox7.Name = "textBox7";
             textBox7.Size = new Size(151, 21);
@@ -196,7 +207,7 @@
             // 
             // textBox8
             // 
-            textBox8.Location = new Point(82, 375);
+            textBox8.Location = new Point(82, 381);
             textBox8.Margin = new Padding(3, 2, 3, 2);
             textBox8.Name = "textBox8";
             textBox8.Size = new Size(151, 21);
@@ -204,7 +215,7 @@
             // 
             // button4
             // 
-            button4.Location = new Point(126, 51);
+            button4.Location = new Point(51, 116);
             button4.Margin = new Padding(3, 2, 3, 2);
             button4.Name = "button4";
             button4.Size = new Size(93, 46);
@@ -213,10 +224,123 @@
             button4.UseVisualStyleBackColor = true;
             button4.Click += button4_Click;
             // 
+            // button7
+            // 
+            button7.Location = new Point(177, 116);
+            button7.Margin = new Padding(3, 2, 3, 2);
+            button7.Name = "button7";
+            button7.Size = new Size(93, 46);
+            button7.TabIndex = 20;
+            button7.Text = "S9棰勮";
+            button7.UseVisualStyleBackColor = true;
+            button7.Click += button7_Click;
+            // 
+            // textBox9
+            // 
+            textBox9.Location = new Point(355, 29);
+            textBox9.Margin = new Padding(3, 2, 3, 2);
+            textBox9.Name = "textBox9";
+            textBox9.Size = new Size(70, 21);
+            textBox9.TabIndex = 21;
+            textBox9.Text = "320";
+            // 
+            // label4
+            // 
+            label4.AutoSize = true;
+            label4.Location = new Point(276, 29);
+            label4.Name = "label4";
+            label4.Size = new Size(67, 13);
+            label4.TabIndex = 22;
+            label4.Text = "S9鎵撳嵃闀垮害";
+            // 
+            // label5
+            // 
+            label5.AutoSize = true;
+            label5.Location = new Point(276, 65);
+            label5.Name = "label5";
+            label5.Size = new Size(67, 13);
+            label5.TabIndex = 24;
+            label5.Text = "S9鎵撳嵃瀹藉害";
+            // 
+            // textBox10
+            // 
+            textBox10.Location = new Point(355, 65);
+            textBox10.Margin = new Padding(3, 2, 3, 2);
+            textBox10.Name = "textBox10";
+            textBox10.Size = new Size(70, 21);
+            textBox10.TabIndex = 23;
+            textBox10.Text = "160";
+            // 
+            // label6
+            // 
+            label6.AutoSize = true;
+            label6.Location = new Point(276, 101);
+            label6.Name = "label6";
+            label6.Size = new Size(67, 13);
+            label6.TabIndex = 26;
+            label6.Text = "S9鎵撳嵃姣斾緥";
+            // 
+            // textBox11
+            // 
+            textBox11.Location = new Point(355, 101);
+            textBox11.Margin = new Padding(3, 2, 3, 2);
+            textBox11.Name = "textBox11";
+            textBox11.Size = new Size(70, 21);
+            textBox11.TabIndex = 25;
+            textBox11.Text = "0.85";
+            // 
+            // label7
+            // 
+            label7.AutoSize = true;
+            label7.Location = new Point(276, 133);
+            label7.Name = "label7";
+            label7.Size = new Size(73, 13);
+            label7.TabIndex = 28;
+            label7.Text = "S9鎵撳嵃璧峰X";
+            // 
+            // textBox12
+            // 
+            textBox12.Location = new Point(355, 133);
+            textBox12.Margin = new Padding(3, 2, 3, 2);
+            textBox12.Name = "textBox12";
+            textBox12.Size = new Size(70, 21);
+            textBox12.TabIndex = 27;
+            textBox12.Text = "10";
+            // 
+            // label8
+            // 
+            label8.AutoSize = true;
+            label8.Location = new Point(276, 167);
+            label8.Name = "label8";
+            label8.Size = new Size(73, 13);
+            label8.TabIndex = 30;
+            label8.Text = "S9鎵撳嵃璧峰Y";
+            // 
+            // textBox13
+            // 
+            textBox13.AccessibleName = "";
+            textBox13.Location = new Point(355, 167);
+            textBox13.Margin = new Padding(3, 2, 3, 2);
+            textBox13.Name = "textBox13";
+            textBox13.Size = new Size(70, 21);
+            textBox13.TabIndex = 29;
+            textBox13.Text = "-10";
+            // 
             // UIPrinter
             // 
             AutoScaleDimensions = new SizeF(6F, 13F);
             AutoScaleMode = AutoScaleMode.Font;
+            Controls.Add(label8);
+            Controls.Add(textBox13);
+            Controls.Add(label7);
+            Controls.Add(textBox12);
+            Controls.Add(label6);
+            Controls.Add(textBox11);
+            Controls.Add(label5);
+            Controls.Add(textBox10);
+            Controls.Add(label4);
+            Controls.Add(textBox9);
+            Controls.Add(button7);
             Controls.Add(button4);
             Controls.Add(textBox8);
             Controls.Add(label3);
@@ -262,5 +386,16 @@
         private Label label3;
         private TextBox textBox8;
         private Button button4;
+        private Button button7;
+        private TextBox textBox9;
+        private Label label4;
+        private Label label5;
+        private TextBox textBox10;
+        private Label label6;
+        private TextBox textBox11;
+        private Label label7;
+        private TextBox textBox12;
+        private Label label8;
+        private TextBox textBox13;
     }
 }
diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index ba876a4..6f7db62 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -45,6 +45,7 @@
         {
             base.OnProcessUpdated();
             printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print);
+            printDocument2.PrintPage += new PrintPageEventHandler(printDocument_Print1);
             textBox1.Text = "C229M2508250500002";
         }
 
@@ -53,6 +54,11 @@
         PrintDocument printDocument1 = new PrintDocument();
         int ttwith = (int)(60 * 4);
         int ttheigh = (int)(20 * 4);
+
+        PrintDocument printDocument2 = new PrintDocument();
+        int ttwith1 = (int)(80 * 4);
+        int ttheigh1 = (int)(40 * 4);
+
         string message = "";
 
         public void StartPrint(string str)
@@ -106,8 +112,8 @@
         {
             try
             {
-                ttwith = 240;
-                ttheigh = 80;
+                ttwith1 = textBox9.Text.ToInt();
+                ttheigh1 = textBox10.Text.ToInt();
                 message = str;
 
                 if (string.IsNullOrEmpty(message))
@@ -121,11 +127,11 @@
                 //this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
                 //this.printDocument1.Print();
 
-                this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)1";
-                this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+                this.printDocument2.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)1";
+                this.printDocument2.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
 
-                this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
-                this.printDocument1.Print();
+                this.printDocument2.PrintController = new System.Drawing.Printing.StandardPrintController();
+                this.printDocument2.Print();
 
 
 
@@ -264,77 +270,80 @@
         }
 
 
-        //private void printDocument_Print(object sender, PrintPageEventArgs e)
-        //{
-        //    Font fntTxt = new Font("榛戜綋", 15, System.Drawing.FontStyle.Bold);//姝f枃鏂囧瓧               
-        //    System.Drawing.Brush brush = new SolidBrush(System.Drawing.Color.Black);//鐢诲埛           
-        //    try
-        //    {
-        //        string numvalue = message;
+        private void printDocument_Print1(object sender, PrintPageEventArgs e)
+        {
+            Font fntTxt = new Font("榛戜綋", 15, System.Drawing.FontStyle.Bold);//姝f枃鏂囧瓧               
+            System.Drawing.Brush brush = new SolidBrush(System.Drawing.Color.Black);//鐢诲埛           
+            try
+            {
+                string numvalue = message;
 
-        //        float Scale = (float)0.95;
-        //        int startX = 10;
-        //        int startY = 25;
+                float Scale = textBox11.Text.ToFloat();
+                ///(float)0.85;
+                int startX = textBox12.Text.ToInt();
+                //10;
+                int startY = textBox13.Text.ToInt();
+                  //  -20;
 
-        //        //int length = 320 * Scale;
-        //        //int height = 160 * Scale;
-        //        var g = e.Graphics;
+                //int length = 320 * Scale;
+                //int height = 160 * Scale;
+                var g = e.Graphics;
 
-        //        Font font = new Font("Arial", 8 * Scale);//璁剧疆瀛椾綋棰滆壊
-        //        Font font2 = new Font("Arial", 11 * Scale);//璁剧疆瀛椾綋棰滆壊
-        //        Font font3 = new Font("Arial", 36 * Scale);//璁剧疆瀛椾綋棰滆壊
-        //        Font font4 = new Font("Arial", 12 * Scale);//璁剧疆瀛椾綋棰滆壊
+                Font font = new Font("Arial", 8 * Scale);//璁剧疆瀛椾綋棰滆壊
+                Font font2 = new Font("Arial", 11 * Scale);//璁剧疆瀛椾綋棰滆壊
+                Font font3 = new Font("Arial", 36 * Scale);//璁剧疆瀛椾綋棰滆壊
+                Font font4 = new Font("Arial", 12 * Scale);//璁剧疆瀛椾綋棰滆壊
 
 
-        //        Pen p = new Pen(Color.Black, Scale);//瀹氫箟浜嗕竴涓粦鑹�,瀹藉害涓�1鐨勭敾绗�
-        //        g.Clear(Color.White);
-        //        g.DrawRectangle(p, startX * Scale, startY * Scale, 70 * Scale, 20 * Scale);//鍦ㄧ敾鏉夸笂鐢荤煩褰�,璧峰鍧愭爣涓�(10,10),瀹戒负80,楂樹负20
-        //        g.DrawRectangle(p, startX * Scale, startY * Scale, 280 * Scale, 20 * Scale);//鍦ㄧ敾鏉夸笂鐢荤煩褰�,璧峰鍧愭爣涓�(90,10),瀹戒负80,楂樹负20
-        //        g.DrawString("鍘傚晢", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);//
-        //        g.DrawString("鍢夊桨绉戞妧", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale);
+                Pen p = new Pen(Color.Black, Scale);//瀹氫箟浜嗕竴涓粦鑹�,瀹藉害涓�1鐨勭敾绗�
+                g.Clear(Color.White);
+                g.DrawRectangle(p, startX * Scale, startY * Scale, 70 * Scale, 20 * Scale);//鍦ㄧ敾鏉夸笂鐢荤煩褰�,璧峰鍧愭爣涓�(10,10),瀹戒负80,楂樹负20
+                g.DrawRectangle(p, startX * Scale, startY * Scale, 280 * Scale, 20 * Scale);//鍦ㄧ敾鏉夸笂鐢荤煩褰�,璧峰鍧愭爣涓�(90,10),瀹戒负80,楂樹负20
+                g.DrawString("鍘傚晢", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);//
+                g.DrawString("鍢夊桨绉戞妧", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale);
 
 
-        //        //绗簩琛屾暟鎹�
-        //        g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale);
-        //        g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 280 * Scale, 20 * Scale);
-        //        g.DrawString("鍝佸悕", font, brush, (startX + 20) * Scale, (startY + 25) * Scale);
-        //        g.DrawString(@"COVER LG208H-RC100 #2", font4, brush, (startX + 71) * Scale, (startY + 22) * Scale);
+                //绗簩琛屾暟鎹�
+                g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale);
+                g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 280 * Scale, 20 * Scale);
+                g.DrawString("鍝佸悕", font, brush, (startX + 20) * Scale, (startY + 25) * Scale);
+                g.DrawString(@"COVER LG208I-RC100 #1", font4, brush, (startX + 71) * Scale, (startY + 22) * Scale);
 
-        //        //绗笁琛屾暟鎹�
-        //        g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 70 * Scale, 20 * Scale);
-        //        g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 280 * Scale, 20 * Scale);
-        //        g.DrawString("鏂欏彿", font, brush, (startX + 20) * Scale, (startY + 45) * Scale);
-        //        g.DrawString(@"436LG208I000", font2, brush, (startX + 130) * Scale, (startY + 43) * Scale);
+                //绗笁琛屾暟鎹�
+                g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 70 * Scale, 20 * Scale);
+                g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 280 * Scale, 20 * Scale);
+                g.DrawString("鏂欏彿", font, brush, (startX + 20) * Scale, (startY + 45) * Scale);
+                g.DrawString(@"436LG208J000", font2, brush, (startX + 130) * Scale, (startY + 43) * Scale);
 
-        //        //绗洓琛屾暟鎹�
-        //        g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 70 * Scale, 20 * Scale);
-        //        g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 210 * Scale, 20 * Scale);
-        //        g.DrawString("鏁伴噺", font, brush, (startX + 20) * Scale, (startY + 65) * Scale);
-        //        g.DrawString(@"50PCS", font2, brush, (startX + 120) * Scale, (startY + 62) * Scale);
+                //绗洓琛屾暟鎹�
+                g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 70 * Scale, 20 * Scale);
+                g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 210 * Scale, 20 * Scale);
+                g.DrawString("鏁伴噺", font, brush, (startX + 20) * Scale, (startY + 65) * Scale);
+                g.DrawString(@"50PCS", font2, brush, (startX + 120) * Scale, (startY + 62) * Scale);
 
-        //        //绗簲琛屾暟鎹�
-        //        g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 70 * Scale, 20 * Scale);
-        //        g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 210 * Scale, 20 * Scale);
-        //        g.DrawString("鐢熶骇鏃ユ湡", font, brush, (startX + 10) * Scale, (startY + 85) * Scale);
-        //        g.DrawString($"{DateTime.Now.ToString("yyyy.MM.dd")}", font2, brush, (startX + 105) * Scale, (startY + 82) * Scale);
+                //绗簲琛屾暟鎹�
+                g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 70 * Scale, 20 * Scale);
+                g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 210 * Scale, 20 * Scale);
+                g.DrawString("鐢熶骇鏃ユ湡", font, brush, (startX + 10) * Scale, (startY + 85) * Scale);
+                g.DrawString($"{DateTime.Now.ToString("yyyy.MM.dd")}", font2, brush, (startX + 105) * Scale, (startY + 82) * Scale);
 
-        //        //绗叚琛屾暟鎹�
-        //        g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 70 * Scale, 20 * Scale);
-        //        g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 140 * Scale, 20 * Scale);
-        //        g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 210 * Scale, 20 * Scale);
-        //        g.DrawString("MARK1", font, brush, (startX + 15) * Scale, (startY + 104) * Scale);
-        //        g.DrawString("MARK2", font, brush, (startX + 155) * Scale, (startY + 104) * Scale);
+                //绗叚琛屾暟鎹�
+                g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 70 * Scale, 20 * Scale);
+                g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 140 * Scale, 20 * Scale);
+                g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 210 * Scale, 20 * Scale);
+                g.DrawString("MARK1", font, brush, (startX + 15) * Scale, (startY + 104) * Scale);
+                g.DrawString("MARK2", font, brush, (startX + 155) * Scale, (startY + 104) * Scale);
 
 
-        //        //渚ч潰
-        //        g.DrawRectangle(p, (startX + 210) * Scale, (startY + 60) * Scale, 70 * Scale, 60 * Scale);
-        //        g.DrawString(@"#2", font3, brush, (startX + 210) * Scale, (startY + 62) * Scale);
-        //    }
-        //    catch (Exception ee)
-        //    {
-        //        MessageBox.Show(ee.Message);
-        //    }
-        //}
+                //渚ч潰
+                g.DrawRectangle(p, (startX + 210) * Scale, (startY + 60) * Scale, 70 * Scale, 60 * Scale);
+                g.DrawString(@"#1", font3, brush, (startX + 210) * Scale, (startY + 62) * Scale);
+            }
+            catch (Exception ee)
+            {
+                MessageBox.Show(ee.Message);
+            }
+        }
 
         private void printDocument_Print222(object sender, PrintPageEventArgs e)
         {
@@ -485,6 +494,27 @@
             DialogResult res = printPreviewDialog1.ShowDialog();
             printPreviewDialog1.Document.Dispose();
         }
+        private void button7_Click(object sender, EventArgs e)
+        {
+            ttwith1 = textBox9.Text.ToInt();
+
+            ttheigh1 = textBox10.Text.ToInt();
+
+            message = textBox1.Text;
+            if (string.IsNullOrEmpty(message))
+            {
+                MessageBox.Show("鎵撳嵃鍐呭涓嶅彲涓虹┖");
+                return;
+            }
+            PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
+            this.printDocument2.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)";
+            this.printDocument2.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith1, ttheigh1);
+            //this.printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument_Print);
+            printPreviewDialog1.Document = printDocument2;
+            DialogResult res = printPreviewDialog1.ShowDialog();
+            printPreviewDialog1.Document.Dispose();
+        }
+
 
 
 
@@ -856,7 +886,5 @@
                 CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 鐗╂枡 杩斿洖鏁版嵁涓� {Msg}");
             }
         }
-
-        
     }
 }
diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index d56ccac..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);                 
-                                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
                                 {
-                                    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} ");
-                                }
-                                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
                     {
@@ -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)
             {
@@ -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,10 +914,10 @@
            
         }
 
-        /// <summary>
-        /// 浜у搧闆剁洏涓婁紶鍚姩鏍囪瘑
-        /// </summary>
-        private bool isStartclear =false;
+        ///// <summary>
+        ///// 浜у搧闆剁洏涓婁紶鍚姩鏍囪瘑
+        ///// </summary>
+        //private bool isStartclear =false;
 
         [ProcessMethod("", "MEStogetcode", "MES涓婁紶鏁存壒鏁版嵁骞惰幏鍙栨潯鐮�", InvokeType.TestInvoke)]
         public ResponseMessage MEStogetcode(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -890,202 +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;
-  
-            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶MES瑙﹀彂锛屼骇鍝佷俊鎭暟閲忎负锛歿M141Config.Productioncode.Count}");
-
-            if (M141Config.Productioncode.Count == 50)
-            {               
-                //浜у搧姝e父涓婁紶
-                while (M141Config.Productioncode.Count>0)
+            if (plcnum[0] != 0 && plcnum1[0] != 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 = true;
-                    if (M141Config.Productioncode.Count==1)
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "Y", out tary_ID);
+
+                    if (!string.IsNullOrEmpty(tary_ID))
                     {
-                        if (isStartclear)
-                        {
-                           
-                            isok = UptoMES(newp, "Y", out tary_ID);
-                            isStartclear = false;
-                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩闆剁洏灏炬暟涓婁紶");
-                        }
-                        else
-                        {
-                            isok = UptoMES(newp, "N", out 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鎵撳嵃骞朵笖淇濆瓨");
                     }
                     else
                     {
-                        isok = UptoMES(newp, "N", out tary_ID);
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
                     }
-                       
-                    if (!isok)
-                    {
-                        Plc3.WriteSingleAddress(2120, 2, out _);
-                        return msg;
-                    }
-                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
-                    {
-                        if (M141Config.Productioncode.Count == 1)
-                        {
-                            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鎵撳嵃骞朵笖淇濆瓨");
-                        }
-                        else
-                        {
-                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏉$爜锛歿tary_ID}涓嶆槸鍦ㄦ渶鍚庝竴浠朵骇鍝佽幏鍙�,鍚姩闆剁洏娓呴櫎澶嶄綅浜у搧涓婁紶鍔ㄤ綔");
-                            isStartclear = true;
-                        }
-                        
-                    }                
-                    M141Config.Productioncode.RemoveAt(0);
                 }
-                M141Config.Productioncode.Clear();
             }
-            else if (M141Config.Productioncode.Count > 50)
+            else if (plcnum1[0] == 0 && plcnum[0] != 0)
             {
-                //涓�旀湁浜у搧琚彇璧板鑷存潯鐮佸ぇ浜庡疄闄呮暟閲�
-                for (int i = 0; i < 50; i++)
+                Issuccess =true;
+                if (M141Config.MES_codes.Count > 0)
                 {
+                    //闇�瑕佷笂浼犲熬鐩�
+                    var plist = mysqlhelper.GetProductList(plcnum[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 = true;
-                    if (i==49)
-                    {
-                        if (isStartclear)
-                        {
-                            isok = UptoMES(newp, "Y", out tary_ID);
-                            isStartclear = false;
-                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩闆剁洏灏炬暟涓婁紶");
-                        }
-                        else
-                        {
-                            isok = UptoMES(newp, "N", out tary_ID);
-                        }
-                    }
-                    else
-                    {
+                    //姝e父涓婁紶
+                    Issuccess1 = UptoMES(newp, "Y", out tary_ID);
 
-                        isok = UptoMES(newp, "N", out tary_ID);
-                    }                
-                    if (!isok)
+                    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;
+                    }
+                }
+                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))
+                    {
+                        StartPrint(tary_ID, "Honeywell PX240S (300 dpi)");
+                        M141Config.MES_codes.Clear();
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
+                    }
+                }
+            }
+            else if(plcnum[0] == 0 && plcnum1[0] != 0)
+            {
+                Issuccess = true;
+                if (M141Config.MES_codes.Count > 0)
+                {
+                    //闇�瑕佷笂浼犲熬鐩�
+                    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 (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
-                    {
-                        if (i == 49)
-                        {
-                            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鎵撳嵃骞朵笖淇濆瓨");
-                        }
-                        else
-                        {
-                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏉$爜锛歿tary_ID}涓嶆槸鍦ㄦ渶鍚庝竴浠朵骇鍝佽幏鍙�,鍚姩闆剁洏娓呴櫎澶嶄綅浜у搧涓婁紶鍔ㄤ綔");
-                            isStartclear = true;
-                        }
-                        
-                    }
-                    M141Config.Productioncode.RemoveAt(count - 1);
                 }
-                M141Config.Productioncode.Clear();
             }
-            else if (M141Config.Productioncode.Count > 0 && M141Config.Productioncode.Count < 50)
+
+            if (Issuccess && Issuccess1)
             {
-                //浜у搧缂哄皯闇�瑕佹竻闄ら浂鐩�
-                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 _);
-                        return msg;
-                    }
-                    if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
-                    {
-                        if (M141Config.Productioncode.Count == 1)
-                        {
-                            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鎵撳嵃骞朵笖淇濆瓨");
-                        }
-                        else
-                        {
-                            LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏉$爜锛歿tary_ID}涓嶆槸鍦ㄦ渶鍚庝竴浠朵骇鍝佽幏鍙�,鍚姩闆剁洏娓呴櫎澶嶄綅浜у搧涓婁紶鍔ㄤ綔");
-                            isStartclear = true;
-                        }
-                    }
-                    M141Config.Productioncode.RemoveAt(0);
-                }
-                M141Config.Productioncode.Clear();
+                Plc3.WriteSingleAddress(2120, 1, out _);
             }
-            else if (M141Config.Productioncode.Count == 0)
+            else
             {
-                if (M141Config.Isprint && !string.IsNullOrEmpty(saveTary_ID))
-                {
-                    StartPrint(saveTary_ID, "Honeywell PX240S (300 dpi)");
-                }      
+                Plc3.WriteSingleAddress(2120, 2, out _);
             }
-               Plc3.WriteSingleAddress(2120, 1, out _);
-               return msg;       
+
+            return msg;       
         }
 
         [ProcessMethod("", "MESup1", "MES涓婁紶杩涙枡鍙g┖绡�", InvokeType.TestInvoke)]

--
Gitblit v1.8.0