From 48f005ea04ee8ce6c9a044dd2fcb0febc7f74788 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期四, 25 十二月 2025 21:22:21 +0800
Subject: [PATCH] S5数据保存及数据上传逻辑添加日志,手动打印条码区分S6和S9

---
 src/Bro.M141.Process/UI/UIPrinter.cs |  137 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 104 insertions(+), 33 deletions(-)

diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index d44f6f1..ba876a4 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -1,5 +1,4 @@
-锘�
-using Bro.Common.Helper;
+锘縰sing Bro.Common.Helper;
 using Bro.Common.Interface;
 using Bro.M135.Common;
 using Bro.UI.Model.Winform;
@@ -17,8 +16,12 @@
 using System.Windows.Forms;
 using ZXing;
 using ZXing.Common;
-using ZXing.QrCode;
+using static Bro.M141.Process.BasketCodeUI;
+using ZXing.QrCode.Internal;
 using static System.Windows.Forms.AxHost;
+using ZXing.QrCode;
+
+
 
 //using System.Printing;
 
@@ -42,24 +45,22 @@
         {
             base.OnProcessUpdated();
             printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print);
-
-            Process141.StartPrinter += StartPrint;
-            textBox1.Text = "Broconcentric";
+            textBox1.Text = "C229M2508250500002";
         }
 
 
 
         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))
@@ -73,6 +74,14 @@
                 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.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
+                //this.printDocument1.Print();
+
+
+
             }
             catch
             {
@@ -83,10 +92,65 @@
             string status = GetPrinterStatusMessage(statuscode);
 
             //Config141
-            Process141.PlcwritePrinter(1520, 0);
-            Process141.PlcwritePrinter(1510, 1);
-
+            try
+            {
+                Process141.PlcwritePrinter(1520, 0);
+                Process141.PlcwritePrinter(1510, 1);
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
         }
+        public void StartPrint1(string str)
+        {
+            try
+            {
+                ttwith = 240;
+                ttheigh = 80;
+                message = str;
+
+                if (string.IsNullOrEmpty(message))
+                {
+                    message = textBox1.Text;
+                }
+
+                //this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)";
+                //this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+
+                //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.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
+                this.printDocument1.Print();
+
+
+
+            }
+            catch
+            {
+
+            }
+
+            int statuscode = GetPrinterStatusCodeInt();
+            string status = GetPrinterStatusMessage(statuscode);
+
+            //Config141
+            try
+            {
+                Process141.PlcwritePrinter(1520, 0);
+                Process141.PlcwritePrinter(1510, 1);
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+        }
+
+        //C229M2508250500002
         private void printDocument_Print(object sender, PrintPageEventArgs e)
         {
             Font fntTxt = new Font("榛戜綋", 15, System.Drawing.FontStyle.Bold);//姝f枃鏂囧瓧               
@@ -118,14 +182,14 @@
                 {
                     DisableECI = true,//璁剧疆鍐呭缂栫爜
                     CharacterSet = "UTF-8",  //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
-                    Width = 123,
-                    Height = 123,
+                    Width = 60,
+                    Height = 60,
                     Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
                 };
 
                 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));
 
 
                 // 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
@@ -135,7 +199,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);
                 }
@@ -146,6 +210,16 @@
                 //g.DrawString("鍘傚晢", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);//
                 //g.DrawString("鍢夊桨绉戞妧", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale);
 
+                //BarcodeWriter writer = new BarcodeWriter();
+                //writer.Format = BarcodeFormat.QR_CODE;
+                //QrCodeEncodingOptions options = new QrCodeEncodingOptions()
+                //{
+                //    DisableECI = true,//璁剧疆鍐呭缂栫爜
+                //    CharacterSet = "UTF-8",  //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
+                //    Width = 123,
+                //    Height = 123,
+                //    Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
+                //};
 
                 ////绗簩琛屾暟鎹�
                 //g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale);
@@ -383,7 +457,16 @@
             }
             StartPrint(message);
         }
-
+        private void button4_Click(object sender, EventArgs e)
+        {
+            message = textBox1.Text;
+            if (string.IsNullOrEmpty(message))
+            {
+                MessageBox.Show("鎵撳嵃鍐呭涓嶅彲涓虹┖");
+                return;
+            }
+            StartPrint1(message);
+        }
 
         //棰勮
         private void button2_Click(object sender, EventArgs e)
@@ -421,7 +504,7 @@
 
             //bmp.SetResolution(320, 160);
 
-            Graphics g = Graphics.FromImage(bmp);//鍒╃敤璇ュ浘鐗囧璞$敓鎴愨�滅敾鏉库��
+            Graphics g = Graphics.FromImage(bmp);//鍒╃敤璇ュ浘鐗囧璞$敓鎴愨�滅敾鏉库�漨o
 
             Font font = new Font("Arial", 8 * Scale);//璁剧疆瀛椾綋棰滆壊
             Font font2 = new Font("Arial", 11 * Scale);//璁剧疆瀛椾綋棰滆壊
@@ -505,16 +588,6 @@
 
             return bmp;
         }
-
-
-
-
-
-
-
-
-
-
 
 
         #region 
@@ -773,7 +846,7 @@
         int pronum = 0;
         private void button6_Click(object sender, EventArgs e)//sn,result,zword,zno,entray
         {
-            string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text ,Zword= textBox5.Text}, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result;
+            string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text, Zword = textBox5.Text }, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result;
             if (Msg == null)
             {
                 CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 鐗╂枡 杩斿洖鏁版嵁涓� null");
@@ -784,8 +857,6 @@
             }
         }
 
-      
-
-
+        
     }
 }

--
Gitblit v1.8.0