WIN-GH9CEESPLTB\Administrator hace 1 mes
padre
commit
d82288f875

+ 3 - 0
MainForm/ClassFile/ProjectClass/GlobalContext.cs

@@ -141,6 +141,9 @@ namespace MainForm
         public static bool IsSendAlarmData;      // 启用上传报警
         public static bool IsUseMESRoute;   // 启用边线MES软件
         public static bool MESIsConnect;  // MES是否正常连接
+        public static string UpFileUrl;  // 文档库地址
+        public static string UpFilePath;  // 本地文件路径
+        public static bool IsSendUpFile;    // 启用上传文件
 
         // IOT - MQTT
         public static bool IsUseIot;  // 是否 启用IOT

+ 450 - 0
MainForm/ClassFile/XiaomiAPI_MES/XiaomiMESHttp_UpLoadFile.cs

@@ -0,0 +1,450 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net.Http;
+using System.Security.Cryptography;
+using System.Security.Policy;
+using System.Text;
+using System.Threading.Tasks;
+using static MainForm.ClassFile.XiaomiAPI.XiaomiMqttClient_Extend;
+using static MainForm.ClassFile.XiaomiAPI_MES.XiaomiMESHttp_StationInbound;
+
+namespace MainForm.ClassFile.XiaomiAPI_MES
+{
+    /// <summary>
+    /// 小米MES - 进站接⼝
+    /// 接口地址:
+    /// 接口方法:UnitConfirmDataSetIn
+    /// </summary>
+    public class XiaomiMESHttp_UpLoadFile : XiaomiMESHttp_X5
+    {
+        #region 变量
+        /// <summary>
+        /// 接口地址
+        /// </summary>
+        protected new static string UpFileUrl { set; get; } = GlobalContext.UpFileUrl;
+
+        /// <summary>
+        /// 接口方法
+        /// </summary>
+        protected new static string Method { set; get; } = "UploadMqtt";
+        #endregion 变量
+        /// <summary>
+        /// 文件上传到 MES 系统
+        /// </summary>
+        /// <param name="wJPath">文件路径</param>
+        /// <param name="fileUpload_X5">文件上传参数</param>
+        /// <param name="fileMqttPayload">MQTT 负载参数</param>
+        /// <returns>(状态码, 结果信息)</returns>
+        public static async Task<(int, string)> FileUoladToMes(string wJPath, FileUpload_X5 fileUpload_X5, FileMqttPayload fileMqttPayload)
+        {
+            try
+            {
+                // 基础参数
+                string url = "http://cm.pre.mi.com/file/x5/file/upload/mqtt";
+                url = "http://im.pre.mi.com/file/x5/file/upload/mqtt";
+                //这个之后要加到配置文件config中
+                string appid = "Auto-Soft";
+                //这个之后要加到配置文件config中
+                string appkey = "5984710e-bb38-4806-b94d-7a9a727e3880";
+                string method = "UploadMqtt";
+
+                // 检查文件是否存在
+                if (!System.IO.File.Exists(wJPath))
+                {
+                    return (-1, "文件不存在");
+                }
+                // 获取文件信息
+                FileInfo file = new FileInfo(wJPath);
+
+                // 构造 body
+                string body = BuildBody(fileUpload_X5, fileMqttPayload);
+
+                // 计算 sign
+                string sign = GetSign(appid + body + appkey); // MD5 加密
+
+                // 构造 header
+                Dictionary<string, string> header = BuildHeader(url, appid, method, sign);
+
+                // 构造 data 参数
+                Dictionary<string, object> dataParam = new Dictionary<string, object>
+                {
+                    { "header", header },
+                    { "body", body }
+                };
+
+                // 将 data 参数序列化为 Base64 编码的字符串
+                string data = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(dataParam)));
+
+                // 调用上传方法
+                var uploadResult = await UploadFile(url, file, data);
+
+                // 判断上传结果
+                if (!string.IsNullOrEmpty(uploadResult) && !uploadResult.StartsWith("异常:") && !uploadResult.StartsWith("HTTP 错误:"))
+                {
+                    //删除文件
+                    (bool, string) newResult = DeleteFile(wJPath);
+                    if (!newResult.Item1)
+                    {
+                        return (0, fileUpload_X5.name+newResult.Item2);
+
+                    }
+                    return (0, fileUpload_X5.name+"文件上传成功");
+                }
+                else
+                {
+                    return (-2, fileUpload_X5.name+$"文件上传失败: {uploadResult}");
+                }
+            }
+            catch (Exception ex)
+            {
+                return (-3, fileUpload_X5.name+$"发生异常: {ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// 将文件复制到目标文件夹,并删除源文件
+        /// </summary>
+        /// <param name="sourceFilePath">源文件路径</param>
+        /// <param name="destinationFolderPath">目标文件夹路径</param>
+        static string CopyAndDeleteFile(string sourceFilePath, string destinationFolderPath)
+        {
+            try
+            {
+                // 检查目标文件夹是否存在,如果不存在则创建
+                if (!Directory.Exists(destinationFolderPath))
+                {
+                    Directory.CreateDirectory(destinationFolderPath);
+                }
+
+                // 构建目标文件的完整路径
+                string fileName = Path.GetFileName(sourceFilePath); // 获取源文件的文件名
+                string destinationFilePath = Path.Combine(destinationFolderPath, fileName);
+
+                // 如果目标文件已存在,则删除已有文件以避免冲突
+                if (File.Exists(destinationFilePath))
+                {
+                    File.Delete(destinationFilePath); // 删除已有文件
+                }
+
+                // 检查文件是否准备好
+                if (!IsFileReady(sourceFilePath))
+                {
+                    throw new IOException($"文件 {sourceFilePath} 正被其他进程占用,无法进行复制和删除操作。");
+                }
+
+                // 复制文件到目标文件夹
+                File.Copy(sourceFilePath, destinationFilePath);
+
+                // 删除源文件
+                File.Delete(sourceFilePath);
+
+                Console.WriteLine($"文件已从 {sourceFilePath} 成功复制到 {destinationFilePath} 并删除原文件。");
+
+                // 返回目标文件路径
+                return destinationFilePath;
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"文件转移失败: {ex.Message}");
+                return null; // 或者返回空字符串,根据需求决定
+            }
+        }
+
+        /// <summary>
+        /// 删除文件
+        /// </summary>
+        /// <param name="sourceFilePath">文件路径</param>
+        static (bool,string) DeleteFile(string sourceFilePath)
+        {
+            try
+            {
+                // 构建目标文件的完整路径
+                string fileName = Path.GetFileName(sourceFilePath); // 获取源文件的文件名
+
+                // 检查文件是否准备好
+                if (!IsFileReady(sourceFilePath))
+                {
+                    throw new IOException($"文件 {sourceFilePath} 正被其他进程占用,无法进行复制和删除操作。");
+                }
+                // 删除源文件
+                File.Delete(sourceFilePath);
+
+                return (true, "文件删除成功!");
+            }
+            catch (Exception ex)
+            {
+                return (false, "文件删除失败!"+ex.Message);
+            }
+        }
+        public static bool IsFileReady(string filePath)
+        {
+            try
+            {
+                using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
+                {
+                    stream.Close();
+                }
+                return true;
+            }
+            catch (IOException)
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 文件MD5加密
+        /// </summary>
+        /// <param name="file"></param>
+        /// <returns></returns>
+        public static string GetMD5Hex(FileInfo file)
+        {
+            using (MD5 md5 = MD5.Create())
+            {
+                using (FileStream stream = file.OpenRead())
+                {
+                    byte[] hashBytes = md5.ComputeHash(stream);
+                    StringBuilder sb = new StringBuilder();
+                    for (int i = 0; i < hashBytes.Length; i++)
+                    {
+                        sb.Append(hashBytes[i].ToString("x2"));
+                    }
+                    return sb.ToString();
+                }
+            }
+        }
+        /// <summary>
+        /// 数据pin接
+        /// </summary>
+        /// <param name="file"></param>
+        /// <param name="fileMd5Hex"></param>
+        /// <returns></returns>
+        public static string BuildBody(FileUpload_X5 file, FileMqttPayload payload)
+        {
+            Dictionary<string, object> fileMetadata = new Dictionary<string, object>();
+            Dictionary<string, string> mqttPayLoad = new Dictionary<string, string>();
+            mqttPayLoad.Add("factory", payload.factory);
+            mqttPayLoad.Add("project_name", payload.project_name);
+            mqttPayLoad.Add("product_mode", payload.product_mode);
+            mqttPayLoad.Add("line_no", payload.line_no);
+            mqttPayLoad.Add("work_station_no", payload.work_station_no);
+            mqttPayLoad.Add("equipment_no", payload.equipment_no);
+            mqttPayLoad.Add("station_no", payload.station_no);
+            mqttPayLoad.Add("file_id", payload.file_id);
+            mqttPayLoad.Add("file_name", payload.file_name);
+            mqttPayLoad.Add("sn", payload.sn);
+            mqttPayLoad.Add("opt_time", payload.opt_time);
+            mqttPayLoad.Add("file_type", payload.file_type);
+            mqttPayLoad.Add("file_category", payload.file_category);
+            mqttPayLoad.Add("tag", payload.tag);
+            mqttPayLoad.Add("reference_info", Newtonsoft.Json.JsonConvert.SerializeObject(new object[] { new { pass_station_id = payload.pass_station_id } }));
+
+
+            fileMetadata.Add("bucket", file.bucket);
+            fileMetadata.Add("name", file.name);
+            fileMetadata.Add("uuid", file.uuid);
+            fileMetadata.Add("md5", file.md5);
+            fileMetadata.Add("uploadCloud", file.uploadCloud);
+            fileMetadata.Add("informMqtt", file.informMqtt);
+            fileMetadata.Add("mqttPayload", Newtonsoft.Json.JsonConvert.SerializeObject(mqttPayLoad));
+            string body = Newtonsoft.Json.JsonConvert.SerializeObject(fileMetadata);
+            return body;
+        }
+        /// <summary>
+        /// 数据头拼接
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="appid"></param>
+        /// <param name="method"></param>
+        /// <param name="sign"></param>
+        /// <returns></returns>
+        public static Dictionary<string, string> BuildHeader(string url, string appid, string method, string sign)
+        {
+            Dictionary<string, string> header = new Dictionary<string, string>();
+            header.Add("appid", appid);
+            header.Add("method", method);
+            header.Add("sign", sign);
+            header.Add("url", url);
+            return header;
+        }
+
+        public static string GetGuid()
+        {
+            return (System.Guid.NewGuid().ToString("N"));
+        }
+
+        /// <summary>
+        /// 异步文件上传
+        /// </summary>
+        /// <param name="url">上传地址</param>
+        /// <param name="file">文件路径</param>
+        /// <param name="data">上传的数据</param>
+        /// <returns>返回上传结果</returns>
+        public static async Task<string> UploadFile(string url, FileInfo file, string data)
+        {
+            using (var httpClient = new HttpClient())
+            {
+                var formData = new MultipartFormDataContent();
+                // 添加文件
+                var fileContent = new StreamContent(file.OpenRead());
+                formData.Add(fileContent, "file", file.Name);
+                // 添加数据
+                formData.Add(new StringContent(data), "data");
+
+                try
+                {
+                    var response = await httpClient.PostAsync(url, formData);
+                    if (response.IsSuccessStatusCode)
+                    {
+                        return await response.Content.ReadAsStringAsync();
+                    }
+                    else
+                    {
+                        return $"HTTP 错误: {response.StatusCode}";
+                    }
+                }
+                catch (Exception e)
+                {
+                    return $"异常: {e.Message}";
+                }
+            }
+        }
+
+        /// <summary>
+        /// MD5加密
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
+        public static string GetSign(string data)
+        {
+            // 实例化一个md5对像
+            MD5 md5 = MD5.Create();
+            // MD5加密
+            byte[] encodingMd5Data = md5.ComputeHash(Encoding.UTF8.GetBytes(data));
+            // 生成签名字段
+            string sign = "";
+            for (int i = 0; i < encodingMd5Data.Length; i++)
+            {
+                // 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
+                sign += encodingMd5Data[i].ToString("X2");
+            }
+            return sign;
+        }
+
+
+        public class FileUpload_X5
+        {
+            /// <summary>
+            /// ⽂件所属包
+            /// 必填
+            /*
+             ${file_category}/${file_type}/${项⽬号}/${⽣
+                产阶段}/${运⾏模式}/${过站结果}/${装备编
+                码}/${sn}/${pass_station_id}
+                • 其中file_category的枚举值为:
+                ◦ IMAGE
+                ◦ TEXT
+                • 若对应字段的值为空,则使⽤默认值
+                UNKNOWN
+                注意:⾸位不能出现/,否则会出现路径错误
+                问题。
+                如:
+                正确⽰例
+                IMAGE/IMAGE/N3/debug/online/PASS/MPA-0001/P320N000006B/382f55e9-c2bb 
+             */
+            /// </summary>
+            public string bucket { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件名
+            /// </summary>
+            public string name { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件唯一标识符
+            /// </summary>
+            public string uuid { get; set; } = string.Empty;
+            /// <summary>
+            /// md5 传空
+            /// </summary>
+            public string md5 { get; set; } = string.Empty;
+            /// <summary>
+            /// 是否上云 默认true
+            /// </summary>
+            public Boolean uploadCloud { get; set; }
+            /// <summary>
+            /// 是否通知Mqtt 默认true
+            /// </summary>
+            public Boolean informMqtt { get; set; }
+
+        }
+
+        public class FileMqttPayload
+        {
+            /// <summary>
+            /// 工厂编码
+            /// </summary>
+            public string factory { get; set; } = string.Empty;
+            /// <summary>
+            /// 项目号
+            /// </summary>
+            public string project_name { get; set; } = string.Empty;
+            /// <summary>
+            /// 生产阶段
+            /// </summary>
+            public string product_mode { get; set; } = string.Empty;
+            /// <summary>
+            /// 线体
+            /// </summary>
+            public string line_no { get; set; } = string.Empty;
+            /// <summary>
+            /// 工站
+            /// </summary>
+            public string work_station_no { get; set; } = string.Empty;
+            /// <summary>
+            /// 装备
+            /// </summary>
+            public string equipment_no { get; set; } = string.Empty;
+            /// <summary>
+            /// 工位
+            /// </summary>
+            public string station_no { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件ID
+            /// </summary>
+            public string file_id { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件名
+            /// </summary>
+            public string file_name { get; set; } = string.Empty;
+            /// <summary>
+            /// 产品sn    
+            /// </summary>
+            public string sn { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件生成时间
+            /// </summary>
+            public string opt_time { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件类型
+            /// </summary>
+            public string file_type { get; set; } = string.Empty;
+            /// <summary>
+            /// 文件类别
+            /// </summary>
+            public string file_category { get; set; } = string.Empty;
+            /// <summary>
+            /// 自定义标签信息
+            /// </summary>
+            public string tag { get; set; } = string.Empty;
+            /// <summary>
+            /// 关联业务信息
+            /// </summary>
+            public string pass_station_id { get; set; } = string.Empty;
+        }
+
+    }
+
+
+}

+ 46 - 31
MainForm/FaForm/BandBarodeDialog.Designer.cs

@@ -29,38 +29,40 @@
         private void InitializeComponent()
         {
             this.button1 = new System.Windows.Forms.Button();
-            this.textBox1 = new System.Windows.Forms.TextBox();
-            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.ProductBarcode = new System.Windows.Forms.TextBox();
+            this.CarrierBarcode = new System.Windows.Forms.TextBox();
             this.label1 = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
-            this.textBox3 = new System.Windows.Forms.TextBox();
+            this.PCBBarcode = new System.Windows.Forms.TextBox();
             this.label3 = new System.Windows.Forms.Label();
+            this.ErrorLab = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
             // button1
             // 
-            this.button1.Location = new System.Drawing.Point(536, 278);
+            this.button1.Location = new System.Drawing.Point(530, 251);
             this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.Size = new System.Drawing.Size(135, 45);
             this.button1.TabIndex = 0;
             this.button1.Text = "取消";
             this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
-            // textBox1
+            // ProductBarcode
             // 
-            this.textBox1.Location = new System.Drawing.Point(230, 108);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.ReadOnly = true;
-            this.textBox1.Size = new System.Drawing.Size(280, 28);
-            this.textBox1.TabIndex = 1;
+            this.ProductBarcode.Location = new System.Drawing.Point(230, 108);
+            this.ProductBarcode.Name = "ProductBarcode";
+            this.ProductBarcode.ReadOnly = true;
+            this.ProductBarcode.Size = new System.Drawing.Size(280, 28);
+            this.ProductBarcode.TabIndex = 1;
             // 
-            // textBox2
+            // CarrierBarcode
             // 
-            this.textBox2.Location = new System.Drawing.Point(230, 47);
-            this.textBox2.Name = "textBox2";
-            this.textBox2.ReadOnly = true;
-            this.textBox2.Size = new System.Drawing.Size(280, 28);
-            this.textBox2.TabIndex = 2;
+            this.CarrierBarcode.Location = new System.Drawing.Point(230, 47);
+            this.CarrierBarcode.Name = "CarrierBarcode";
+            this.CarrierBarcode.ReadOnly = true;
+            this.CarrierBarcode.Size = new System.Drawing.Size(280, 28);
+            this.CarrierBarcode.TabIndex = 2;
             // 
             // label1
             // 
@@ -80,36 +82,48 @@
             this.label2.TabIndex = 4;
             this.label2.Text = "产品码";
             // 
-            // textBox3
+            // PCBBarcode
             // 
-            this.textBox3.Location = new System.Drawing.Point(230, 172);
-            this.textBox3.Name = "textBox3";
-            this.textBox3.Size = new System.Drawing.Size(280, 28);
-            this.textBox3.TabIndex = 5;
+            this.PCBBarcode.Location = new System.Drawing.Point(230, 172);
+            this.PCBBarcode.Name = "PCBBarcode";
+            this.PCBBarcode.Size = new System.Drawing.Size(280, 28);
+            this.PCBBarcode.TabIndex = 5;
+            this.PCBBarcode.TextChanged += new System.EventHandler(this.PCBBarcode_TextChanged);
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(124, 182);
+            this.label3.Location = new System.Drawing.Point(133, 175);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(62, 18);
+            this.label3.Size = new System.Drawing.Size(53, 18);
             this.label3.TabIndex = 6;
-            this.label3.Text = "产品码";
+            this.label3.Text = "PCB码";
+            // 
+            // ErrorLab
+            // 
+            this.ErrorLab.AutoSize = true;
+            this.ErrorLab.ForeColor = System.Drawing.Color.Red;
+            this.ErrorLab.Location = new System.Drawing.Point(227, 216);
+            this.ErrorLab.Name = "ErrorLab";
+            this.ErrorLab.Size = new System.Drawing.Size(0, 18);
+            this.ErrorLab.TabIndex = 7;
             // 
             // BandBarodeDialog
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(725, 328);
+            this.Controls.Add(this.ErrorLab);
             this.Controls.Add(this.label3);
-            this.Controls.Add(this.textBox3);
+            this.Controls.Add(this.PCBBarcode);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.label1);
-            this.Controls.Add(this.textBox2);
-            this.Controls.Add(this.textBox1);
+            this.Controls.Add(this.CarrierBarcode);
+            this.Controls.Add(this.ProductBarcode);
             this.Controls.Add(this.button1);
             this.Name = "BandBarodeDialog";
             this.Text = "BandBarodeDialog";
+            this.Load += new System.EventHandler(this.BandBarodeDialog_Load);
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -118,11 +132,12 @@
         #endregion
 
         private System.Windows.Forms.Button button1;
-        private System.Windows.Forms.TextBox textBox1;
-        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.TextBox ProductBarcode;
+        private System.Windows.Forms.TextBox CarrierBarcode;
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.TextBox textBox3;
+        private System.Windows.Forms.TextBox PCBBarcode;
         private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label ErrorLab;
     }
 }

+ 75 - 0
MainForm/FaForm/BandBarodeDialog.cs

@@ -7,15 +7,90 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using static MainForm.SQLHelper;
 
 namespace MainForm.FaForm
 {
     public partial class BandBarodeDialog : Form
     {
+        public string pcbCode { get; private set; }
+        public string _CarrierBarcode { private get;  set; }
+        public string _ProductBarcode { private get;  set; }
+
+        private Timer _inputTimer;
+
         public BandBarodeDialog()
         {
             InitializeComponent();
+            //置顶
+            this.TopMost = true; 
+            // 设置窗口相对于父窗口居中
+            this.StartPosition = FormStartPosition.CenterParent;
+            this.Shown += MainForm_Shown;
+        }
+
+        private void BandBarodeDialog_Load(object sender, EventArgs e)
+        {
+            CarrierBarcode.Text = _CarrierBarcode;
+            ProductBarcode.Text = _ProductBarcode;
+            PCBBarcode.Text = string.Empty;
+
+            // 初始化定时器
+            _inputTimer = new Timer();
+            _inputTimer.Interval = 500; // 500毫秒
+            _inputTimer.Tick += InputTimer_Tick;
+
+            // 绑定 TextChanged 事件
+            PCBBarcode.TextChanged += PCBBarcode_TextChanged;
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            Close();
         }
 
+        private void PCBBarcode_TextChanged(object sender, EventArgs e)
+        {
+            // 每次文本变化时重置定时器
+            _inputTimer.Stop();
+            _inputTimer.Start();
+        }
+
+        private void InputTimer_Tick(object sender, EventArgs e)
+        {
+            // 定时器触发,表示输入已经完成
+            _inputTimer.Stop();
+            // 处理条码
+            string pcbcode = PCBBarcode.Text.Trim();
+            if (!string.IsNullOrEmpty(pcbcode))
+            {
+                var Carrierdt = Db.Queryable<CarrierBind>()
+                  .Where(x => x.CarrierCode == _CarrierBarcode)
+                  .Where(x => x.PCBBarcode == pcbcode)
+                  .OrderByDescending(x => x.ID)
+                  .Take(1)
+                  .ToList();
+                if (Carrierdt != null && Carrierdt.Count > 0)
+                {
+                    closeWin();
+                }
+                else
+                {
+                    ErrorLab.Text=$"校验失败:PCB码[{pcbcode}]与载具码[{_CarrierBarcode}]未绑定";
+                }
+            }
+        }
+
+        private void closeWin() {
+            _CarrierBarcode = string.Empty;
+            _ProductBarcode = string.Empty;
+            this.DialogResult= DialogResult.OK;
+            this.Close();
+        }
+        private void MainForm_Shown(object sender, EventArgs e)
+        {
+            // 将焦点设置到 textBox1
+            PCBBarcode.Focus();
+        }
     }
 }

+ 91 - 133
MainForm/FaForm/Form_Home.Designer.cs

@@ -77,6 +77,7 @@
             this.colTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.colMessage = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.imageListState = new System.Windows.Forms.ImageList(this.components);
+            this.button1 = new System.Windows.Forms.Button();
             this.panel1.SuspendLayout();
             this.groupBox3.SuspendLayout();
             this.panel2.SuspendLayout();
@@ -115,14 +116,14 @@
             this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
             this.panel1.Controls.Add(this.groupBox3);
-            this.panel1.Location = new System.Drawing.Point(9, 10);
-            this.panel1.Margin = new System.Windows.Forms.Padding(2);
+            this.panel1.Location = new System.Drawing.Point(14, 15);
             this.panel1.Name = "panel1";
-            this.panel1.Size = new System.Drawing.Size(1026, 122);
+            this.panel1.Size = new System.Drawing.Size(1539, 183);
             this.panel1.TabIndex = 0;
             // 
             // groupBox3
             // 
+            this.groupBox3.Controls.Add(this.button1);
             this.groupBox3.Controls.Add(this.txt_CurSupplierCode);
             this.groupBox3.Controls.Add(this.label20);
             this.groupBox3.Controls.Add(this.currentMtltmrk);
@@ -134,10 +135,8 @@
             this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
             this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.groupBox3.Location = new System.Drawing.Point(0, 0);
-            this.groupBox3.Margin = new System.Windows.Forms.Padding(2);
             this.groupBox3.Name = "groupBox3";
-            this.groupBox3.Padding = new System.Windows.Forms.Padding(2);
-            this.groupBox3.Size = new System.Drawing.Size(1026, 122);
+            this.groupBox3.Size = new System.Drawing.Size(1539, 183);
             this.groupBox3.TabIndex = 2;
             this.groupBox3.TabStop = false;
             this.groupBox3.Text = "当前加工订单信息";
@@ -145,20 +144,18 @@
             // txt_CurSupplierCode
             // 
             this.txt_CurSupplierCode.Enabled = false;
-            this.txt_CurSupplierCode.Location = new System.Drawing.Point(433, 80);
-            this.txt_CurSupplierCode.Margin = new System.Windows.Forms.Padding(2);
+            this.txt_CurSupplierCode.Location = new System.Drawing.Point(650, 120);
             this.txt_CurSupplierCode.Name = "txt_CurSupplierCode";
-            this.txt_CurSupplierCode.Size = new System.Drawing.Size(176, 27);
+            this.txt_CurSupplierCode.Size = new System.Drawing.Size(262, 36);
             this.txt_CurSupplierCode.TabIndex = 95;
             this.txt_CurSupplierCode.Visible = false;
             // 
             // label20
             // 
             this.label20.AutoSize = true;
-            this.label20.Location = new System.Drawing.Point(338, 83);
-            this.label20.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label20.Location = new System.Drawing.Point(507, 124);
             this.label20.Name = "label20";
-            this.label20.Size = new System.Drawing.Size(88, 20);
+            this.label20.Size = new System.Drawing.Size(128, 30);
             this.label20.TabIndex = 94;
             this.label20.Text = "供应商代码:";
             this.label20.Visible = false;
@@ -166,48 +163,43 @@
             // currentMtltmrk
             // 
             this.currentMtltmrk.Enabled = false;
-            this.currentMtltmrk.Location = new System.Drawing.Point(433, 39);
-            this.currentMtltmrk.Margin = new System.Windows.Forms.Padding(2);
+            this.currentMtltmrk.Location = new System.Drawing.Point(650, 58);
             this.currentMtltmrk.Name = "currentMtltmrk";
-            this.currentMtltmrk.Size = new System.Drawing.Size(176, 27);
+            this.currentMtltmrk.Size = new System.Drawing.Size(262, 36);
             this.currentMtltmrk.TabIndex = 10;
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(353, 42);
-            this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label3.Location = new System.Drawing.Point(530, 63);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(73, 20);
+            this.label3.Size = new System.Drawing.Size(106, 30);
             this.label3.TabIndex = 7;
             this.label3.Text = "产品型号:";
             // 
             // currentBN
             // 
             this.currentBN.Enabled = false;
-            this.currentBN.Location = new System.Drawing.Point(119, 80);
-            this.currentBN.Margin = new System.Windows.Forms.Padding(2);
+            this.currentBN.Location = new System.Drawing.Point(178, 120);
             this.currentBN.Name = "currentBN";
-            this.currentBN.Size = new System.Drawing.Size(176, 27);
+            this.currentBN.Size = new System.Drawing.Size(262, 36);
             this.currentBN.TabIndex = 3;
             this.currentBN.Visible = false;
             // 
             // currentWC
             // 
             this.currentWC.Enabled = false;
-            this.currentWC.Location = new System.Drawing.Point(119, 39);
-            this.currentWC.Margin = new System.Windows.Forms.Padding(2);
+            this.currentWC.Location = new System.Drawing.Point(178, 58);
             this.currentWC.Name = "currentWC";
-            this.currentWC.Size = new System.Drawing.Size(176, 27);
+            this.currentWC.Size = new System.Drawing.Size(262, 36);
             this.currentWC.TabIndex = 2;
             // 
             // label2
             // 
             this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(46, 83);
-            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label2.Location = new System.Drawing.Point(69, 124);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(69, 20);
+            this.label2.Size = new System.Drawing.Size(101, 30);
             this.label2.TabIndex = 1;
             this.label2.Text = "批次号:";
             this.label2.Visible = false;
@@ -215,10 +207,9 @@
             // label1
             // 
             this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(19, 42);
-            this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label1.Location = new System.Drawing.Point(28, 63);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(88, 20);
+            this.label1.Size = new System.Drawing.Size(128, 30);
             this.label1.TabIndex = 0;
             this.label1.Text = "车间订单号:";
             // 
@@ -227,10 +218,9 @@
             this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
             this.panel2.Controls.Add(this.groupBox2);
-            this.panel2.Location = new System.Drawing.Point(9, 455);
-            this.panel2.Margin = new System.Windows.Forms.Padding(2);
+            this.panel2.Location = new System.Drawing.Point(14, 682);
             this.panel2.Name = "panel2";
-            this.panel2.Size = new System.Drawing.Size(1026, 100);
+            this.panel2.Size = new System.Drawing.Size(1539, 150);
             this.panel2.TabIndex = 1;
             // 
             // groupBox2
@@ -248,11 +238,9 @@
             this.groupBox2.Controls.Add(this.groupBox13);
             this.groupBox2.Controls.Add(this.groupBox11);
             this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.groupBox2.Location = new System.Drawing.Point(2, 2);
-            this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox2.Location = new System.Drawing.Point(3, 3);
             this.groupBox2.Name = "groupBox2";
-            this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
-            this.groupBox2.Size = new System.Drawing.Size(902, 94);
+            this.groupBox2.Size = new System.Drawing.Size(1353, 141);
             this.groupBox2.TabIndex = 1;
             this.groupBox2.TabStop = false;
             this.groupBox2.Text = "设备状态";
@@ -261,12 +249,10 @@
             // 
             this.groupBox15.Controls.Add(this.picAgvMqtt);
             this.groupBox15.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox15.Location = new System.Drawing.Point(245, 24);
-            this.groupBox15.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox15.Location = new System.Drawing.Point(368, 36);
             this.groupBox15.Name = "groupBox15";
-            this.groupBox15.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox15.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox15.Size = new System.Drawing.Size(90, 60);
+            this.groupBox15.Size = new System.Drawing.Size(135, 90);
             this.groupBox15.TabIndex = 14;
             this.groupBox15.TabStop = false;
             this.groupBox15.Text = "AGV Mqtt";
@@ -276,10 +262,9 @@
             this.picAgvMqtt.ErrorImage = ((System.Drawing.Image)(resources.GetObject("picAgvMqtt.ErrorImage")));
             this.picAgvMqtt.Image = ((System.Drawing.Image)(resources.GetObject("picAgvMqtt.Image")));
             this.picAgvMqtt.InitialImage = ((System.Drawing.Image)(resources.GetObject("picAgvMqtt.InitialImage")));
-            this.picAgvMqtt.Location = new System.Drawing.Point(32, 24);
-            this.picAgvMqtt.Margin = new System.Windows.Forms.Padding(2);
+            this.picAgvMqtt.Location = new System.Drawing.Point(48, 36);
             this.picAgvMqtt.Name = "picAgvMqtt";
-            this.picAgvMqtt.Size = new System.Drawing.Size(26, 28);
+            this.picAgvMqtt.Size = new System.Drawing.Size(39, 42);
             this.picAgvMqtt.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.picAgvMqtt.TabIndex = 10;
             this.picAgvMqtt.TabStop = false;
@@ -288,12 +273,10 @@
             // 
             this.groupBox14.Controls.Add(this.picAgvHttp);
             this.groupBox14.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox14.Location = new System.Drawing.Point(156, 24);
-            this.groupBox14.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox14.Location = new System.Drawing.Point(234, 36);
             this.groupBox14.Name = "groupBox14";
-            this.groupBox14.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox14.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox14.Size = new System.Drawing.Size(85, 60);
+            this.groupBox14.Size = new System.Drawing.Size(128, 90);
             this.groupBox14.TabIndex = 13;
             this.groupBox14.TabStop = false;
             this.groupBox14.Text = "AGV Http";
@@ -303,10 +286,9 @@
             this.picAgvHttp.ErrorImage = ((System.Drawing.Image)(resources.GetObject("picAgvHttp.ErrorImage")));
             this.picAgvHttp.Image = ((System.Drawing.Image)(resources.GetObject("picAgvHttp.Image")));
             this.picAgvHttp.InitialImage = ((System.Drawing.Image)(resources.GetObject("picAgvHttp.InitialImage")));
-            this.picAgvHttp.Location = new System.Drawing.Point(28, 24);
-            this.picAgvHttp.Margin = new System.Windows.Forms.Padding(2);
+            this.picAgvHttp.Location = new System.Drawing.Point(42, 36);
             this.picAgvHttp.Name = "picAgvHttp";
-            this.picAgvHttp.Size = new System.Drawing.Size(26, 28);
+            this.picAgvHttp.Size = new System.Drawing.Size(39, 42);
             this.picAgvHttp.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.picAgvHttp.TabIndex = 10;
             this.picAgvHttp.TabStop = false;
@@ -315,12 +297,10 @@
             // 
             this.groupBox1.Controls.Add(this.picIot);
             this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox1.Location = new System.Drawing.Point(88, 24);
-            this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox1.Location = new System.Drawing.Point(132, 36);
             this.groupBox1.Name = "groupBox1";
-            this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox1.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox1.Size = new System.Drawing.Size(64, 60);
+            this.groupBox1.Size = new System.Drawing.Size(96, 90);
             this.groupBox1.TabIndex = 12;
             this.groupBox1.TabStop = false;
             this.groupBox1.Text = "IOT";
@@ -330,10 +310,9 @@
             this.picIot.ErrorImage = ((System.Drawing.Image)(resources.GetObject("picIot.ErrorImage")));
             this.picIot.Image = ((System.Drawing.Image)(resources.GetObject("picIot.Image")));
             this.picIot.InitialImage = ((System.Drawing.Image)(resources.GetObject("picIot.InitialImage")));
-            this.picIot.Location = new System.Drawing.Point(18, 24);
-            this.picIot.Margin = new System.Windows.Forms.Padding(2);
+            this.picIot.Location = new System.Drawing.Point(27, 36);
             this.picIot.Name = "picIot";
-            this.picIot.Size = new System.Drawing.Size(26, 28);
+            this.picIot.Size = new System.Drawing.Size(39, 42);
             this.picIot.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.picIot.TabIndex = 10;
             this.picIot.TabStop = false;
@@ -342,12 +321,10 @@
             // 
             this.groupBox5.Controls.Add(this.picMESStatus);
             this.groupBox5.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox5.Location = new System.Drawing.Point(20, 24);
-            this.groupBox5.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox5.Location = new System.Drawing.Point(30, 36);
             this.groupBox5.Name = "groupBox5";
-            this.groupBox5.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox5.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox5.Size = new System.Drawing.Size(64, 60);
+            this.groupBox5.Size = new System.Drawing.Size(96, 90);
             this.groupBox5.TabIndex = 0;
             this.groupBox5.TabStop = false;
             this.groupBox5.Text = "MES";
@@ -357,10 +334,9 @@
             this.picMESStatus.ErrorImage = ((System.Drawing.Image)(resources.GetObject("picMESStatus.ErrorImage")));
             this.picMESStatus.Image = ((System.Drawing.Image)(resources.GetObject("picMESStatus.Image")));
             this.picMESStatus.InitialImage = ((System.Drawing.Image)(resources.GetObject("picMESStatus.InitialImage")));
-            this.picMESStatus.Location = new System.Drawing.Point(18, 24);
-            this.picMESStatus.Margin = new System.Windows.Forms.Padding(2);
+            this.picMESStatus.Location = new System.Drawing.Point(27, 36);
             this.picMESStatus.Name = "picMESStatus";
-            this.picMESStatus.Size = new System.Drawing.Size(26, 28);
+            this.picMESStatus.Size = new System.Drawing.Size(39, 42);
             this.picMESStatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.picMESStatus.TabIndex = 10;
             this.picMESStatus.TabStop = false;
@@ -369,12 +345,10 @@
             // 
             this.groupBox7.Controls.Add(this.pictureBox6);
             this.groupBox7.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox7.Location = new System.Drawing.Point(680, 24);
-            this.groupBox7.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox7.Location = new System.Drawing.Point(1020, 36);
             this.groupBox7.Name = "groupBox7";
-            this.groupBox7.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox7.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox7.Size = new System.Drawing.Size(64, 60);
+            this.groupBox7.Size = new System.Drawing.Size(96, 90);
             this.groupBox7.TabIndex = 1;
             this.groupBox7.TabStop = false;
             this.groupBox7.Text = "PLC6";
@@ -385,10 +359,9 @@
             this.pictureBox6.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox6.ErrorImage")));
             this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
             this.pictureBox6.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox6.InitialImage")));
-            this.pictureBox6.Location = new System.Drawing.Point(18, 24);
-            this.pictureBox6.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox6.Location = new System.Drawing.Point(27, 36);
             this.pictureBox6.Name = "pictureBox6";
-            this.pictureBox6.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox6.Size = new System.Drawing.Size(39, 42);
             this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox6.TabIndex = 16;
             this.pictureBox6.TabStop = false;
@@ -397,12 +370,10 @@
             // 
             this.groupBox12.Controls.Add(this.pictureBox8);
             this.groupBox12.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox12.Location = new System.Drawing.Point(816, 24);
-            this.groupBox12.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox12.Location = new System.Drawing.Point(1224, 36);
             this.groupBox12.Name = "groupBox12";
-            this.groupBox12.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox12.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox12.Size = new System.Drawing.Size(64, 60);
+            this.groupBox12.Size = new System.Drawing.Size(96, 90);
             this.groupBox12.TabIndex = 1;
             this.groupBox12.TabStop = false;
             this.groupBox12.Text = "PLC8";
@@ -413,10 +384,9 @@
             this.pictureBox8.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox8.ErrorImage")));
             this.pictureBox8.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox8.Image")));
             this.pictureBox8.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox8.InitialImage")));
-            this.pictureBox8.Location = new System.Drawing.Point(19, 24);
-            this.pictureBox8.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox8.Location = new System.Drawing.Point(28, 36);
             this.pictureBox8.Name = "pictureBox8";
-            this.pictureBox8.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox8.Size = new System.Drawing.Size(39, 42);
             this.pictureBox8.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox8.TabIndex = 18;
             this.pictureBox8.TabStop = false;
@@ -425,12 +395,10 @@
             // 
             this.groupBox9.Controls.Add(this.pictureBox7);
             this.groupBox9.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox9.Location = new System.Drawing.Point(748, 24);
-            this.groupBox9.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox9.Location = new System.Drawing.Point(1122, 36);
             this.groupBox9.Name = "groupBox9";
-            this.groupBox9.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox9.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox9.Size = new System.Drawing.Size(64, 60);
+            this.groupBox9.Size = new System.Drawing.Size(96, 90);
             this.groupBox9.TabIndex = 1;
             this.groupBox9.TabStop = false;
             this.groupBox9.Text = "PLC7";
@@ -441,10 +409,9 @@
             this.pictureBox7.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox7.ErrorImage")));
             this.pictureBox7.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox7.Image")));
             this.pictureBox7.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox7.InitialImage")));
-            this.pictureBox7.Location = new System.Drawing.Point(20, 24);
-            this.pictureBox7.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox7.Location = new System.Drawing.Point(30, 36);
             this.pictureBox7.Name = "pictureBox7";
-            this.pictureBox7.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox7.Size = new System.Drawing.Size(39, 42);
             this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox7.TabIndex = 17;
             this.pictureBox7.TabStop = false;
@@ -453,12 +420,10 @@
             // 
             this.groupBox8.Controls.Add(this.picPLC);
             this.groupBox8.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox8.Location = new System.Drawing.Point(339, 24);
-            this.groupBox8.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox8.Location = new System.Drawing.Point(508, 36);
             this.groupBox8.Name = "groupBox8";
-            this.groupBox8.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox8.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox8.Size = new System.Drawing.Size(64, 60);
+            this.groupBox8.Size = new System.Drawing.Size(96, 90);
             this.groupBox8.TabIndex = 1;
             this.groupBox8.TabStop = false;
             this.groupBox8.Text = "PLC";
@@ -468,10 +433,9 @@
             this.picPLC.ErrorImage = ((System.Drawing.Image)(resources.GetObject("picPLC.ErrorImage")));
             this.picPLC.Image = ((System.Drawing.Image)(resources.GetObject("picPLC.Image")));
             this.picPLC.InitialImage = ((System.Drawing.Image)(resources.GetObject("picPLC.InitialImage")));
-            this.picPLC.Location = new System.Drawing.Point(20, 24);
-            this.picPLC.Margin = new System.Windows.Forms.Padding(2);
+            this.picPLC.Location = new System.Drawing.Point(30, 36);
             this.picPLC.Name = "picPLC";
-            this.picPLC.Size = new System.Drawing.Size(26, 28);
+            this.picPLC.Size = new System.Drawing.Size(39, 42);
             this.picPLC.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.picPLC.TabIndex = 0;
             this.picPLC.TabStop = false;
@@ -480,12 +444,10 @@
             // 
             this.groupBox6.Controls.Add(this.pictureBox2);
             this.groupBox6.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox6.Location = new System.Drawing.Point(407, 24);
-            this.groupBox6.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox6.Location = new System.Drawing.Point(610, 36);
             this.groupBox6.Name = "groupBox6";
-            this.groupBox6.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox6.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox6.Size = new System.Drawing.Size(64, 60);
+            this.groupBox6.Size = new System.Drawing.Size(96, 90);
             this.groupBox6.TabIndex = 11;
             this.groupBox6.TabStop = false;
             this.groupBox6.Text = "PLC2";
@@ -496,10 +458,9 @@
             this.pictureBox2.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox2.ErrorImage")));
             this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
             this.pictureBox2.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox2.InitialImage")));
-            this.pictureBox2.Location = new System.Drawing.Point(20, 24);
-            this.pictureBox2.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox2.Location = new System.Drawing.Point(30, 36);
             this.pictureBox2.Name = "pictureBox2";
-            this.pictureBox2.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox2.Size = new System.Drawing.Size(39, 42);
             this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox2.TabIndex = 12;
             this.pictureBox2.TabStop = false;
@@ -508,12 +469,10 @@
             // 
             this.groupBox10.Controls.Add(this.pictureBox3);
             this.groupBox10.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox10.Location = new System.Drawing.Point(475, 24);
-            this.groupBox10.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox10.Location = new System.Drawing.Point(712, 36);
             this.groupBox10.Name = "groupBox10";
-            this.groupBox10.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox10.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox10.Size = new System.Drawing.Size(64, 60);
+            this.groupBox10.Size = new System.Drawing.Size(96, 90);
             this.groupBox10.TabIndex = 1;
             this.groupBox10.TabStop = false;
             this.groupBox10.Text = "PLC3";
@@ -524,10 +483,9 @@
             this.pictureBox3.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox3.ErrorImage")));
             this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
             this.pictureBox3.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox3.InitialImage")));
-            this.pictureBox3.Location = new System.Drawing.Point(18, 24);
-            this.pictureBox3.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox3.Location = new System.Drawing.Point(27, 36);
             this.pictureBox3.Name = "pictureBox3";
-            this.pictureBox3.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox3.Size = new System.Drawing.Size(39, 42);
             this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox3.TabIndex = 13;
             this.pictureBox3.TabStop = false;
@@ -536,12 +494,10 @@
             // 
             this.groupBox13.Controls.Add(this.pictureBox5);
             this.groupBox13.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox13.Location = new System.Drawing.Point(611, 24);
-            this.groupBox13.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox13.Location = new System.Drawing.Point(916, 36);
             this.groupBox13.Name = "groupBox13";
-            this.groupBox13.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox13.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox13.Size = new System.Drawing.Size(64, 60);
+            this.groupBox13.Size = new System.Drawing.Size(96, 90);
             this.groupBox13.TabIndex = 1;
             this.groupBox13.TabStop = false;
             this.groupBox13.Text = "PLC5";
@@ -552,10 +508,9 @@
             this.pictureBox5.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox5.ErrorImage")));
             this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
             this.pictureBox5.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox5.InitialImage")));
-            this.pictureBox5.Location = new System.Drawing.Point(20, 24);
-            this.pictureBox5.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox5.Location = new System.Drawing.Point(30, 36);
             this.pictureBox5.Name = "pictureBox5";
-            this.pictureBox5.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox5.Size = new System.Drawing.Size(39, 42);
             this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox5.TabIndex = 15;
             this.pictureBox5.TabStop = false;
@@ -564,12 +519,10 @@
             // 
             this.groupBox11.Controls.Add(this.pictureBox4);
             this.groupBox11.Font = new System.Drawing.Font("微软雅黑", 9.6F);
-            this.groupBox11.Location = new System.Drawing.Point(543, 24);
-            this.groupBox11.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox11.Location = new System.Drawing.Point(814, 36);
             this.groupBox11.Name = "groupBox11";
-            this.groupBox11.Padding = new System.Windows.Forms.Padding(2);
             this.groupBox11.RightToLeft = System.Windows.Forms.RightToLeft.No;
-            this.groupBox11.Size = new System.Drawing.Size(64, 60);
+            this.groupBox11.Size = new System.Drawing.Size(96, 90);
             this.groupBox11.TabIndex = 1;
             this.groupBox11.TabStop = false;
             this.groupBox11.Text = "PLC4";
@@ -580,10 +533,9 @@
             this.pictureBox4.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox4.ErrorImage")));
             this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
             this.pictureBox4.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox4.InitialImage")));
-            this.pictureBox4.Location = new System.Drawing.Point(20, 24);
-            this.pictureBox4.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox4.Location = new System.Drawing.Point(30, 36);
             this.pictureBox4.Name = "pictureBox4";
-            this.pictureBox4.Size = new System.Drawing.Size(26, 28);
+            this.pictureBox4.Size = new System.Drawing.Size(39, 42);
             this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBox4.TabIndex = 14;
             this.pictureBox4.TabStop = false;
@@ -594,10 +546,9 @@
             | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
             this.panel3.Controls.Add(this.groupBox4);
-            this.panel3.Location = new System.Drawing.Point(9, 137);
-            this.panel3.Margin = new System.Windows.Forms.Padding(2);
+            this.panel3.Location = new System.Drawing.Point(14, 206);
             this.panel3.Name = "panel3";
-            this.panel3.Size = new System.Drawing.Size(1026, 313);
+            this.panel3.Size = new System.Drawing.Size(1539, 470);
             this.panel3.TabIndex = 2;
             // 
             // groupBox4
@@ -606,10 +557,8 @@
             this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill;
             this.groupBox4.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.groupBox4.Location = new System.Drawing.Point(0, 0);
-            this.groupBox4.Margin = new System.Windows.Forms.Padding(2);
             this.groupBox4.Name = "groupBox4";
-            this.groupBox4.Padding = new System.Windows.Forms.Padding(2);
-            this.groupBox4.Size = new System.Drawing.Size(1026, 313);
+            this.groupBox4.Size = new System.Drawing.Size(1539, 470);
             this.groupBox4.TabIndex = 1;
             this.groupBox4.TabStop = false;
             this.groupBox4.Text = "数据采集";
@@ -638,8 +587,7 @@
             this.systemLog.Dock = System.Windows.Forms.DockStyle.Fill;
             this.systemLog.EnableHeadersVisualStyles = false;
             this.systemLog.GridColor = System.Drawing.Color.Gainsboro;
-            this.systemLog.Location = new System.Drawing.Point(2, 22);
-            this.systemLog.Margin = new System.Windows.Forms.Padding(2);
+            this.systemLog.Location = new System.Drawing.Point(3, 32);
             this.systemLog.Name = "systemLog";
             this.systemLog.ReadOnly = true;
             dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
@@ -657,7 +605,7 @@
             this.systemLog.RowsDefaultCellStyle = dataGridViewCellStyle4;
             this.systemLog.RowTemplate.Height = 27;
             this.systemLog.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
-            this.systemLog.Size = new System.Drawing.Size(1022, 289);
+            this.systemLog.Size = new System.Drawing.Size(1533, 435);
             this.systemLog.TabIndex = 0;
             // 
             // colDate
@@ -697,16 +645,25 @@
             this.imageListState.Images.SetKeyName(1, "light_green.png");
             this.imageListState.Images.SetKeyName(2, "light_red.png");
             // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(1155, 78);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(168, 36);
+            this.button1.TabIndex = 96;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
             // Form_Home
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.White;
-            this.ClientSize = new System.Drawing.Size(1044, 561);
+            this.ClientSize = new System.Drawing.Size(1566, 842);
             this.Controls.Add(this.panel3);
             this.Controls.Add(this.panel2);
             this.Controls.Add(this.panel1);
-            this.Margin = new System.Windows.Forms.Padding(2);
             this.Name = "Form_Home";
             this.Text = "Form_Home";
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form_Home_FormClosed);
@@ -792,5 +749,6 @@
         private System.Windows.Forms.PictureBox picAgvHttp;
         private System.Windows.Forms.GroupBox groupBox15;
         private System.Windows.Forms.PictureBox picAgvMqtt;
+        private System.Windows.Forms.Button button1;
     }
 }

+ 43 - 2
MainForm/FaForm/Form_Home.cs

@@ -36,6 +36,7 @@ using Org.BouncyCastle.Asn1.IsisMtt;
 using System.Web.Services.Description;
 using System.Numerics;
 using MathNet.Numerics.RootFinding;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
 
 /*
  * 注:本源码对外提供,所以有些地方使用中文命名方法及变量
@@ -115,8 +116,9 @@ namespace MainForm
         /// </summary>
         private Dictionary<string, List<Alarm>> DicAlarms_Cur = new Dictionary<string, List<Alarm>>();
 
-
         Dictionary<int, Inovance_EIP> FunsEip = new Dictionary<int, Inovance_EIP>();
+
+
         #endregion 变量
 
         #region 窗体基础事件
@@ -1006,6 +1008,7 @@ namespace MainForm
         private static readonly object lockObj = new object(); // 锁对象
         private static bool isCollectingFlagLeft;
         private static bool isCollectingFlagRight;
+        private bool OpenDailogFalg = true;//是否开启扫码弹窗标识
         /// <summary>
         /// float[]转为string
         /// </summary>
@@ -3391,7 +3394,6 @@ namespace MainForm
         {
             Stopwatch stopwatch1 = new Stopwatch();
             Stopwatch stopwatch2 = new Stopwatch();
-
             try
             {
                 stopwatch1.Start();
@@ -3400,6 +3402,7 @@ namespace MainForm
                 string MachineId = GlobalContext.S6_MachineId;  // 装备ID(可配置)
                 string StationId = GlobalContext.S6_StationId;  // 工位ID(可配置)
                 string strCarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode;  // 产品SN(物料码)
+                strCarrierBarcode = "N801A-003";
                 //载具码验证产品码 
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
@@ -3410,6 +3413,21 @@ namespace MainForm
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
 
+                if (OpenDailogFalg)
+                {
+                    using (var dialog = new BandBarodeDialog())
+                    {
+                        dialog._CarrierBarcode = strCarrierBarcode;
+                        dialog._ProductBarcode = sn;
+                        var rs = dialog.ShowDialog();
+                        if (rs == DialogResult.OK)
+                        {
+                            AddMessage(LogType.Info, $"扫码校验通过,载具码:{strCarrierBarcode};产品码:{sn};产品码:{sn}");
+                            OpenDailogFalg = false;//关闭扫码
+                        }
+                    }
+                }
+
                 // 产品SN(物料码)校验
                 List<TestItem> item = new List<TestItem>();
                 stopwatch2.Start();
@@ -3442,6 +3460,7 @@ namespace MainForm
             AddMessage(LogType.Info, stationNameStr + "_进站结束");
             AddMessage(LogType.Info, stationNameStr + "_进站;总用时" + stopwatch1.ElapsedMilliseconds + "ms;调用MES用时" + stopwatch2.ElapsedMilliseconds + "ms");
             ProgressState = false;
+            OpenDailogFalg = true; //开启下一个物料的扫码
         }
 
 
@@ -10921,5 +10940,27 @@ namespace MainForm
             //DicAlarms.Add(2, keyValues);
             #endregion 第二个工站-原来的写法(废弃)
         }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            OpenDailogFalg=true;
+            if (OpenDailogFalg)
+            {
+                using (var dialog = new BandBarodeDialog())
+                {
+                    string strCarrierBarcode = "N801A-003";
+
+                    dialog._CarrierBarcode = strCarrierBarcode;
+                    string sn = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
+                    dialog._ProductBarcode = sn;
+                    var rs = dialog.ShowDialog();
+                    if (rs == DialogResult.OK)
+                    {
+                        AddMessage(LogType.Info, $"扫码校验通过,载具码:{strCarrierBarcode};产品码:{sn};产品码:{sn}");
+                        OpenDailogFalg = false;//关闭扫码
+                    }
+                }
+            }
+        }
     }
 }

+ 1 - 1
MainForm/FaForm/Form_Home.resx

@@ -8367,7 +8367,7 @@
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACQ
-        PgAAAk1TRnQBSQFMAgEBAwEAAbgBCAG4AQgBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
+        PgAAAk1TRnQBSQFMAgEBAwEAAcABCAHAAQgBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
         AwABIAMAAQEBAAEgBgABQP8A/wA8AAP5Af8DzgH/A6gB/wOLAf8DeAH/A3EB/wNxAf8DeAH/A4sB/wOo
         Af8DzwH/A/kB/1AAAfcB+wH3Af8BuwHgAbYB/wGGAcgBfAH/AV0BtQFQAf8BQgGpATMB/wE5AaUBKQH/
         ATkBpQEpAf8BQwGqATQB/wFdAbYBUAH/AYUByAF7Af8BvAHhAbcB/wH3AfsB9wH/UAAB9gH1AfsB/wGw

+ 13 - 0
MainForm/MainForm.csproj

@@ -291,6 +291,16 @@
     <Compile Include="ClassFile\XiaomiAPI_MES\XiaomiMESHttp_X5.cs" />
     <Compile Include="ClassFile\XiaomiAPI_MES\XiaomiMESResponse_ErrCode.cs" />
     <Compile Include="ClassFile\XiaomiAPI_RouteCom\XiaomiMES_RouteCommunication.cs" />
+    <Compile Include="ClassFile\XiaomiClass\AGVHelper.cs" />
+    <Compile Include="ClassFile\XiaomiClass\IoTHelper.cs" />
+    <Compile Include="ClassFile\XiaomiClass\MesHelper.cs" />
+    <Compile Include="ClassFile\XiaomiClass\ProcessHelper.cs" />
+    <Compile Include="FaForm\BandBarodeDialog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FaForm\BandBarodeDialog.Designer.cs">
+      <DependentUpon>BandBarodeDialog.cs</DependentUpon>
+    </Compile>
     <Compile Include="FaForm\Form_DevAlarm.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -408,6 +418,9 @@
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
     <Compile Include="Settings.cs" />
+    <EmbeddedResource Include="FaForm\BandBarodeDialog.resx">
+      <DependentUpon>BandBarodeDialog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FaForm\Form_DevAlarm.resx">
       <DependentUpon>Form_DevAlarm.cs</DependentUpon>
     </EmbeddedResource>