Ver código fonte

Merge repos.ubtob.net:usoft/mes-client

callm 6 dias atrás
pai
commit
e46478c434

+ 13 - 13
UAS_MES_HYSX/FunctionCode/Make/Make_WirelessThroughput.cs

@@ -267,23 +267,23 @@ namespace UAS_MES_NEW.Make
                 ShowMsg(0, "请输入测试时长");
                 return true;
             }
-            if (comboBox1.SelectedIndex == -1)
-            {
-                ShowMsg(0, "请选择指令模式");
-                return true;
-            }
-
-            //if (Locat1.Checked == false || Locat2.Checked == false || Locat3.Checked == false)
+            //if (comboBox1.SelectedIndex == -1)
             //{
-            //    ShowMsg(0, "请选择固件位置");
+            //    ShowMsg(0, "请选择指令模式");
             //    return true;
             //}
 
-            //if (Radio1.Checked == false || Radio1.Checked == false )
+            //if (Locat1.Checked == false || Locat2.Checked == false || Locat3.Checked == false)
             //{
-            //    ShowMsg(0, "请选择测试类型");
+            //    ShowMsg(0, "请选择固件位置");
             //    return true;
             //}
+
+            if (Radio1.Checked == false || Radio1.Checked == false)
+            {
+                ShowMsg(0, "请选择测试类型");
+                return true;
+            }
             return false;
         }
 
@@ -417,7 +417,7 @@ namespace UAS_MES_NEW.Make
                     WriteStream(_telnetStream, cmdList[2]);
                     streamTxt.Append(ReadStream(_telnetStream));
 
-                    WriteStream(_telnetStream, cmdList[0].Replace("Port", iperfServerPort.ToString()));
+                    WriteStream(_telnetStream, cmdList[0].Trim().Replace("Port", iperfServerPort.ToString()));
                     streamTxt.Append(ReadStream(_telnetStream));
 
                     cmdLog = Path.Combine(logDirectory, $"{SN}_CMD.log");
@@ -426,8 +426,8 @@ namespace UAS_MES_NEW.Make
                     upLog = Path.Combine(logDirectory, $"{SN}_up.log");
                     downLog = Path.Combine(logDirectory, $"{SN}_down.log");
 
-                    RunIperfClient(cmdList[1].Replace("IP", cameraIp).Replace("Port", iperfServerPort.ToString()) + "-R", iperfPath, upLog);
-                    RunIperfClient(cmdList[1].Replace("IP", cameraIp).Replace("Port", iperfServerPort.ToString()), iperfPath, downLog);
+                    RunIperfClient(cmdList[1].Trim().Replace("IP", cameraIp).Replace("Port", iperfServerPort.ToString()) + " -R", iperfPath, upLog);
+                    RunIperfClient(cmdList[1].Trim().Replace("IP", cameraIp).Replace("Port", iperfServerPort.ToString()), iperfPath, downLog);
 
                     upRate = ParseIperfBitrate(upLog);
                     downRate = ParseIperfBitrate(downLog);

+ 282 - 0
UAS_MES_XMW/FunctionCode/Make/Make_ServerListen.Designer.cs

@@ -0,0 +1,282 @@
+namespace UAS_MES_NEW.Make
+{
+    partial class Make_ServerListen
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.Connet = new System.Windows.Forms.Button();
+            this.Start = new System.Windows.Forms.Button();
+            this.IpPort = new System.Windows.Forms.TextBox();
+            this.IpPortLab = new System.Windows.Forms.Label();
+            this.SettingBox = new System.Windows.Forms.Panel();
+            this.OperatResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
+            this.SNDetails = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+            this.productName = new System.Windows.Forms.Label();
+            this.productCode = new System.Windows.Forms.Label();
+            this.workOrder = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.serialNumber = new System.Windows.Forms.Label();
+            this.SettingBox.SuspendLayout();
+            this.SNDetails.SuspendLayout();
+            this.tableLayoutPanel1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // Connet
+            // 
+            this.Connet.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.Connet.Location = new System.Drawing.Point(1107, 28);
+            this.Connet.Name = "Connet";
+            this.Connet.Size = new System.Drawing.Size(144, 43);
+            this.Connet.TabIndex = 93;
+            this.Connet.Text = "开启连接";
+            this.Connet.UseVisualStyleBackColor = true;
+            this.Connet.Visible = false;
+            this.Connet.Click += new System.EventHandler(this.Connet_Click);
+            // 
+            // Start
+            // 
+            this.Start.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.Start.Location = new System.Drawing.Point(446, 39);
+            this.Start.Name = "Start";
+            this.Start.Size = new System.Drawing.Size(108, 31);
+            this.Start.TabIndex = 92;
+            this.Start.Text = "开启监听";
+            this.Start.UseVisualStyleBackColor = true;
+            this.Start.Click += new System.EventHandler(this.Start_Click);
+            // 
+            // IpPort
+            // 
+            this.IpPort.Location = new System.Drawing.Point(109, 43);
+            this.IpPort.Name = "IpPort";
+            this.IpPort.Size = new System.Drawing.Size(309, 31);
+            this.IpPort.TabIndex = 1;
+            // 
+            // IpPortLab
+            // 
+            this.IpPortLab.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.IpPortLab.Location = new System.Drawing.Point(22, 43);
+            this.IpPortLab.Name = "IpPortLab";
+            this.IpPortLab.Size = new System.Drawing.Size(117, 28);
+            this.IpPortLab.TabIndex = 0;
+            this.IpPortLab.Text = "服务地址:";
+            // 
+            // SettingBox
+            // 
+            this.SettingBox.Controls.Add(this.Connet);
+            this.SettingBox.Controls.Add(this.Start);
+            this.SettingBox.Controls.Add(this.IpPort);
+            this.SettingBox.Controls.Add(this.IpPortLab);
+            this.SettingBox.Dock = System.Windows.Forms.DockStyle.Top;
+            this.SettingBox.Location = new System.Drawing.Point(0, 123);
+            this.SettingBox.Name = "SettingBox";
+            this.SettingBox.Size = new System.Drawing.Size(1280, 194);
+            this.SettingBox.TabIndex = 98;
+            // 
+            // OperatResult
+            // 
+            this.OperatResult.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.OperatResult.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.OperatResult.Location = new System.Drawing.Point(0, 317);
+            this.OperatResult.Margin = new System.Windows.Forms.Padding(4);
+            this.OperatResult.Name = "OperatResult";
+            this.OperatResult.Size = new System.Drawing.Size(1280, 403);
+            this.OperatResult.TabIndex = 97;
+            this.OperatResult.Text = "";
+            // 
+            // SNDetails
+            // 
+            this.SNDetails.BorderColor = System.Drawing.Color.Black;
+            this.SNDetails.Controls.Add(this.tableLayoutPanel1);
+            this.SNDetails.Dock = System.Windows.Forms.DockStyle.Top;
+            this.SNDetails.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.SNDetails.Location = new System.Drawing.Point(0, 0);
+            this.SNDetails.Name = "SNDetails";
+            this.SNDetails.Size = new System.Drawing.Size(1280, 123);
+            this.SNDetails.TabIndex = 96;
+            this.SNDetails.TabStop = false;
+            this.SNDetails.Text = "产品序列信息";
+            this.SNDetails.TextColor = System.Drawing.Color.Black;
+            // 
+            // tableLayoutPanel1
+            // 
+            this.tableLayoutPanel1.ColumnCount = 8;
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.451613F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 12.09677F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.451613F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 12.09677F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.451613F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 13.19F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.451613F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 36.81F));
+            this.tableLayoutPanel1.Controls.Add(this.productName, 7, 0);
+            this.tableLayoutPanel1.Controls.Add(this.productCode, 5, 0);
+            this.tableLayoutPanel1.Controls.Add(this.workOrder, 3, 0);
+            this.tableLayoutPanel1.Controls.Add(this.label4, 6, 0);
+            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
+            this.tableLayoutPanel1.Controls.Add(this.label3, 4, 0);
+            this.tableLayoutPanel1.Controls.Add(this.label2, 2, 0);
+            this.tableLayoutPanel1.Controls.Add(this.serialNumber, 1, 0);
+            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 37);
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+            this.tableLayoutPanel1.RowCount = 1;
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 83F));
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(1274, 83);
+            this.tableLayoutPanel1.TabIndex = 0;
+            // 
+            // productName
+            // 
+            this.productName.AutoSize = true;
+            this.productName.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.productName.Location = new System.Drawing.Point(807, 0);
+            this.productName.Name = "productName";
+            this.productName.Size = new System.Drawing.Size(464, 83);
+            this.productName.TabIndex = 7;
+            this.productName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // productCode
+            // 
+            this.productCode.AutoSize = true;
+            this.productCode.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.productCode.Location = new System.Drawing.Point(557, 0);
+            this.productCode.Name = "productCode";
+            this.productCode.Size = new System.Drawing.Size(162, 83);
+            this.productCode.TabIndex = 6;
+            this.productCode.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // workOrder
+            // 
+            this.workOrder.AutoSize = true;
+            this.workOrder.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.workOrder.Location = new System.Drawing.Point(321, 0);
+            this.workOrder.Name = "workOrder";
+            this.workOrder.Size = new System.Drawing.Size(148, 83);
+            this.workOrder.TabIndex = 5;
+            this.workOrder.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.label4.Location = new System.Drawing.Point(725, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(76, 83);
+            this.label4.TabIndex = 3;
+            this.label4.Text = "产品名称: ";
+            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.label1.Location = new System.Drawing.Point(3, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(76, 83);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "序列号: ";
+            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.label3.Location = new System.Drawing.Point(475, 0);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(76, 83);
+            this.label3.TabIndex = 2;
+            this.label3.Text = "产品编号: ";
+            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.label2.Location = new System.Drawing.Point(239, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(76, 83);
+            this.label2.TabIndex = 1;
+            this.label2.Text = "工单: ";
+            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // serialNumber
+            // 
+            this.serialNumber.AutoSize = true;
+            this.serialNumber.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.serialNumber.Location = new System.Drawing.Point(85, 0);
+            this.serialNumber.Name = "serialNumber";
+            this.serialNumber.Size = new System.Drawing.Size(148, 83);
+            this.serialNumber.TabIndex = 4;
+            this.serialNumber.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // Make_ServerListen
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1280, 720);
+            this.Controls.Add(this.OperatResult);
+            this.Controls.Add(this.SettingBox);
+            this.Controls.Add(this.SNDetails);
+            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(4);
+            this.Name = "Make_ServerListen";
+            this.Text = "Make_ServerListen";
+            this.Load += new System.EventHandler(this.Make_ServerListen_Load);
+            this.SettingBox.ResumeLayout(false);
+            this.SettingBox.PerformLayout();
+            this.SNDetails.ResumeLayout(false);
+            this.tableLayoutPanel1.ResumeLayout(false);
+            this.tableLayoutPanel1.PerformLayout();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder SNDetails;
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+        private System.Windows.Forms.Label productName;
+        private System.Windows.Forms.Label productCode;
+        private System.Windows.Forms.Label workOrder;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label serialNumber;
+        private System.Windows.Forms.Button Connet;
+        private System.Windows.Forms.Button Start;
+        private System.Windows.Forms.TextBox IpPort;
+        private System.Windows.Forms.Label IpPortLab;
+        private CustomControl.RichText.RichTextAutoBottom OperatResult;
+        private System.Windows.Forms.Panel SettingBox;
+    }
+}

+ 576 - 0
UAS_MES_XMW/FunctionCode/Make/Make_ServerListen.cs

@@ -0,0 +1,576 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Windows.Forms;
+using UAS_MES_NEW.DataOperate;
+using UAS_MES_NEW.Entity;
+
+namespace UAS_MES_NEW.Make
+{
+    public partial class Make_ServerListen : Form
+    {
+        public Make_ServerListen()
+        {
+            InitializeComponent();
+        }
+
+        StringBuilder SQL = new StringBuilder();
+        DataTable dt;
+        DataHelper dh;
+
+        private SocketServer _server;
+        private int currCount = 0;
+
+        private void Make_ServerListen_Load(object sender, EventArgs e)
+        {
+            dh = SystemInf.dh;
+
+            _server = new SocketServer();
+            _server.ReceivedDatas += SocketServer_ReceivedDatas;
+            _server.ReceivedMsg += SocketServer_ReceivedMsg;
+
+            try
+            {
+                IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+
+                foreach (IPAddress ip in hostEntry.AddressList)
+                {
+                    if (ip.AddressFamily == AddressFamily.InterNetwork)
+                    {
+                        IpPort.Text = ip.ToString() + ":8088";
+                    }
+                }
+                if (string.IsNullOrEmpty(IpPort.Text))
+                {
+                    IpPort.Text = "127.0.0.1:8088";
+                }
+            }
+            catch (Exception ex)
+            {
+                ShowMsg(0, $"获取本机IPv4地址失败,请手动填写,{ex.Message}");
+            }
+        }
+
+        private void Connet_Click(object sender, EventArgs e)
+        {
+            if (Connet.Text == "开启连接")
+            {
+                Connet.Text = "关闭连接";
+            }
+            else if (Connet.Text == "关闭连接")
+            {
+                Connet.Text = "开启连接";
+            }
+        }
+
+        private void Start_Click(object sender, EventArgs e)
+        {
+            if (string.IsNullOrEmpty(IpPort.Text))
+            {
+                ShowMsg(0, "请填写服务地址");
+                return;
+            }
+
+            string ip = IpPort.Text.Split(':')[0];
+            int port = int.Parse(IpPort.Text.Split(':')[1]);
+            IPAddress ipAddress = IPAddress.Parse(ip);
+
+            if (Start.Text == "开启监听")
+            {
+                Start.Text = "关闭监听";
+                IpPort.Enabled = false;
+
+                string result = _server.Start(ipAddress, port, 10);
+                ShowMsg(result.StartsWith("OK") ? 1 : 0, result);
+            }
+            else if (Start.Text == "关闭监听")
+            {
+                Start.Text = "开启监听";
+                IpPort.Enabled = true;
+
+                if (_server != null)
+                {
+                    string result = _server.Stop();
+                    ShowMsg(result.StartsWith("OK") ? 1 : 0, result);
+                }
+            }
+        }
+
+        private void SocketServer_ReceivedDatas(object sender, ReceivedDatasEventArgs e)
+        {
+            this.Invoke(new Action(() =>
+            {
+                currCount += 1;
+                ShowMsg(1, $"第{currCount}次接收,收到来自 {e.ClientId} 的消息: {e.Message}");
+
+                /*VerifyResultMessage message = new VerifyResultMessage
+                {
+                    Name = "VerifyResult",
+                    Data = new VerifyResultData
+                    {
+                        ErrorCode = "0",
+                        ErrorMsg = "",
+                        Serial = "BG7349116"
+                    }
+                };
+                string jsonMessage = JsonConvert.SerializeObject(message, Formatting.None);
+                string sendMsg = _server.SendMessage(e.ClientId, jsonMessage);
+                ShowMsg(sendMsg.StartsWith("OK") ? 1 : 0, sendMsg);
+                currCount = currCount == 2 ? 0 : currCount;*/
+            }));
+        }
+
+        private void SocketServer_ReceivedMsg(object sender, ReceivedMsgEventArgs e)
+        {
+            this.Invoke(new Action(() =>
+            {
+                if (e.Msg.StartsWith("OK"))
+                {
+                    ShowMsg(1, $"提示 [{e.Operation}]: {e.Msg}");
+                }
+                else if (e.Msg.StartsWith("NG"))
+                {
+                    ShowMsg(2, $"提示 [{e.Operation}]: {e.Msg}");
+                }
+            }));
+        }
+
+        private void UpdateSN(string type, string sn)
+        {
+            if (type == "C")
+            {
+                serialNumber.Text = "";
+                workOrder.Text = "";
+                productCode.Text = "";
+                productName.Text = "";
+            }
+            else if (type == "L")
+            {
+                SQL.Clear();
+                SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product
+                        WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
+                dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
+                if (dt.Rows.Count > 0)
+                {
+                    serialNumber.Text = dt.Rows[0]["ms_sncode"].ToString();
+                    workOrder.Text = dt.Rows[0]["ma_code"].ToString();
+                    productCode.Text = dt.Rows[0]["pr_code"].ToString();
+                    productName.Text = dt.Rows[0]["pr_spec"].ToString();
+                }
+                else
+                {
+                    UpdateSN("C", sn);
+                }
+            }
+        }
+
+        private void ShowMsg(int type, string msg)
+        {
+            msg = msg.Replace("\r", "").Replace("\n", "");
+            string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            string showMsg = $"{msgTime}: {msg}\n";
+
+            if (type == 0)
+            {
+                OperatResult.AppendText(showMsg, Color.Red);
+            }
+            else if (type == 1)
+            {
+                OperatResult.AppendText(showMsg, Color.Green);
+            }
+            else if (type == 2)
+            {
+                OperatResult.AppendText(showMsg, Color.YellowGreen);
+            }
+            OperatResult.SelectionStart = OperatResult.Text.Length;
+            OperatResult.ScrollToCaret();
+        }
+
+
+        public class VerifyResultMessage
+        {
+            [JsonProperty("Name")]
+            public string Name { get; set; } = "VerifyResult";
+
+            [JsonProperty("Data")]
+            public VerifyResultData Data { get; set; }
+        }
+
+        public class VerifyResultData
+        {
+            [JsonProperty("ErrorCode")]
+            public string ErrorCode { get; set; } = "0";
+
+            [JsonProperty("ErrorMsg")]
+            public string ErrorMsg { get; set; } = "";
+
+            [JsonProperty("Serial")]
+            public string Serial { get; set; }
+        }
+
+        public class ReceivedDatasEventArgs : EventArgs
+        {
+            public string Message { get; set; }
+            public Socket ClientSocket { get; set; }
+            public string ClientId { get; set; }
+        }
+
+        public class ReceivedMsgEventArgs : EventArgs
+        {
+            public string Msg { get; set; }
+            public Exception Exception { get; set; }
+            public string Operation { get; set; }
+        }
+
+        public class SocketServer
+        {
+            private Socket _serverSocket;
+            private bool _isRunning = false;
+            private readonly Dictionary<string, Socket> _clients = new Dictionary<string, Socket>();
+
+            private class StateObject
+            {
+                public Socket ClientSocket { get; set; }
+                public string ClientId { get; set; }
+                public byte[] Buffer { get; set; }
+                public List<byte> DataBuffer { get; set; } = new List<byte>();
+            }
+
+            public event EventHandler<ReceivedDatasEventArgs> ReceivedDatas;
+
+            public event EventHandler<ReceivedMsgEventArgs> ReceivedMsg;
+
+            public string Start(IPAddress _ipAddress, int _port, int _maxConnections)
+            {
+                try
+                {
+                    if (_isRunning)
+                    {
+                        return "OK,服务器已经在运行中";
+                    }
+
+                    _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+                    IPEndPoint localEndPoint = new IPEndPoint(_ipAddress, _port);
+                    _serverSocket.Bind(localEndPoint);
+                    _serverSocket.Listen(_maxConnections);
+                    _isRunning = true;
+
+                    _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), _serverSocket);
+
+                    return "OK,服务器开始监听";
+                }
+                catch (Exception ex)
+                {
+                    return $"NG,启动服务器失败: {ex.Message}";
+                }
+            }
+
+            public string Stop()
+            {
+                try
+                {
+                    if (!_isRunning)
+                    {
+                        return "OK,服务器未运行";
+                    }
+
+                    _isRunning = false;
+
+                    List<string> clientIds;
+                    lock (_clients)
+                    {
+                        clientIds = new List<string>(_clients.Keys);
+                        foreach (var clientId in clientIds)
+                        {
+                            try
+                            {
+                                if (_clients.TryGetValue(clientId, out var clientSocket))
+                                {
+                                    if (clientSocket != null && clientSocket.Connected)
+                                    {
+                                        clientSocket.Shutdown(SocketShutdown.Both);
+                                        clientSocket.Close();
+                                    }
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                return $"NG,停止服务器异常: {ex.Message}";
+                            }
+                        }
+                        _clients.Clear();
+                    }
+
+                    if (_serverSocket != null)
+                    {
+                        _serverSocket.Close();
+                        _serverSocket.Dispose();
+                        _serverSocket = null;
+                    }
+
+                    return "OK,关闭服务器成功";
+                }
+                catch (Exception ex)
+                {
+                    return $"NG,停止服务器失败: {ex.Message}";
+                }
+            }
+
+            private void AcceptCallback(IAsyncResult ar)
+            {
+                if (!_isRunning) return;
+
+                try
+                {
+                    Socket serverSocket = (Socket)ar.AsyncState;
+                    Socket clientSocket = serverSocket.EndAccept(ar);
+
+                    string clientId = GenerateClientId(clientSocket);
+
+                    lock (_clients)
+                    {
+                        _clients[clientId] = clientSocket;
+                    }
+
+                    OnReceivedMsg($"OK,客户端连接成功: {clientId}", "AcceptCallback", null);
+
+                    StateObject state = new StateObject
+                    {
+                        ClientSocket = clientSocket,
+                        ClientId = clientId,
+                        Buffer = new byte[8192]
+                    };
+
+                    clientSocket.BeginReceive(state.Buffer, 0, state.Buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), state);
+
+                    serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), serverSocket);
+                }
+                catch (ObjectDisposedException)
+                {
+                    return; // 服务器已关闭,正常退出
+                }
+                catch (Exception ex)
+                {
+                    OnReceivedMsg("NG,接受客户端连接失败", "AcceptCallback", ex);
+                }
+            }
+
+            private void ReceiveCallback(IAsyncResult ar)
+            {
+                StateObject state = null;
+                int bytesRead = 0;
+
+                try
+                {
+                    state = (StateObject)ar.AsyncState;
+                    bytesRead = state.ClientSocket.EndReceive(ar);
+
+                    if (bytesRead > 0)
+                    {
+                        for (int i = 0; i < bytesRead; i++)
+                        {
+                            state.DataBuffer.Add(state.Buffer[i]);
+                        }
+
+                        ProcessReceivedData(state, bytesRead);
+
+                        Array.Clear(state.Buffer, 0, state.Buffer.Length);
+                        state.ClientSocket.BeginReceive(state.Buffer, 0, state.Buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), state);
+                    }
+                    else
+                    {
+                        OnReceivedMsg($"客户端 {state.ClientId} 断开连接", "ReceiveCallback", null);
+                        RemoveClient(state.ClientId, "客户端主动断开连接");
+                    }
+                }
+                catch (SocketException sockEx)
+                {
+                    string clientId = state?.ClientId ?? "未知客户端";
+                    OnReceivedMsg($"NG,接收数据时Socket异常: {sockEx.Message}", "ReceiveCallback", sockEx);
+                    RemoveClient(clientId, $"Socket异常: {sockEx.SocketErrorCode}");
+                }
+                catch (Exception ex)
+                {
+                    string clientId = state?.ClientId ?? "未知客户端";
+                    OnReceivedMsg("NG,接收数据失败", "ReceiveCallback", ex);
+                    RemoveClient(clientId, $"接收数据错误: {ex.Message}");
+                }
+            }
+
+            private void ProcessReceivedData(StateObject state, int bytesRead)
+            {
+                try
+                {
+                    byte[] allBytes = state.DataBuffer.ToArray();
+                    string receiveRes = Encoding.ASCII.GetString(allBytes);
+                    OnReceivedDatas(state.ClientSocket, state.ClientId, receiveRes);
+
+                    state.DataBuffer.Clear();
+                    Array.Clear(state.Buffer, 0, state.Buffer.Length);
+
+                    /*if (state.DataBuffer.Count >= 2)
+                    {
+                        byte[] allBytes = state.DataBuffer.ToArray();
+                        string receiveRes = Encoding.Unicode.GetString(allBytes);
+                        OnReceivedDatas(state.ClientSocket, state.ClientId, receiveRes);
+
+                        string jsonMessage = Encoding.Unicode.GetString(allBytes);
+                        jsonMessage = jsonMessage.Replace("\0", "").Trim();
+                        if (jsonMessage.Contains("{") && jsonMessage.Contains("}"))
+                        {
+                            int firstBrace = jsonMessage.IndexOf('{');
+                            int lastBrace = jsonMessage.LastIndexOf('}');
+                            string validJson = jsonMessage.Substring(firstBrace, lastBrace - firstBrace + 1);
+
+                            state.DataBuffer.Clear();
+                            OnReceivedDatas(state.ClientSocket, state.ClientId, validJson);
+                        }
+                        else
+                        {
+                            OnReceivedMsg($"NG,不是有效JSON格式: {jsonMessage}", "ProcessReceivedData", null);
+                        }
+                    }
+                    Array.Clear(state.Buffer, 0, state.Buffer.Length);*/
+
+                }
+                catch (Exception ex)
+                {
+                    state.DataBuffer.Clear();
+                    Array.Clear(state.Buffer, 0, state.Buffer.Length);
+                    OnReceivedMsg($"NG,解码处理异常: {ex.Message}", "ProcessReceivedData", null);
+                }
+            }
+
+
+            public string SendMessage(string clientId, string jsonMessage)
+            {
+                try
+                {
+                    if (!_isRunning)
+                    {
+                        return "NG,服务器未运行";
+                    }
+
+                    Socket clientSocket = null;
+                    lock (_clients)
+                    {
+                        if (!_clients.TryGetValue(clientId, out clientSocket) || clientSocket == null)
+                        {
+                            return $"NG,客户端 {clientId} 不存在或已断开";
+                        }
+                    }
+
+                    if (!clientSocket.Connected)
+                    {
+                        RemoveClient(clientId, "连接已断开");
+                        return $"NG,客户端 {clientId} 连接已断开";
+                    }
+
+                    byte[] messageBytes = Encoding.Unicode.GetBytes(jsonMessage);
+                    clientSocket.BeginSend(messageBytes, 0, messageBytes.Length, SocketFlags.None, new AsyncCallback(SendCallback),
+                        new { ClientId = clientId, ClientSocket = clientSocket });
+
+                    return $"OK,发送成功,已发送 字符数: {jsonMessage.Length}, 字节数: {messageBytes.Length} 到 {clientId}";
+                }
+                catch (Exception ex)
+                {
+                    return $"NG,发送失败: {ex.Message}";
+                }
+            }
+
+            private void SendCallback(IAsyncResult ar)
+            {
+                try
+                {
+                    dynamic state = ar.AsyncState;
+                    Socket clientSocket = state.ClientSocket;
+                    string clientId = state.ClientId;
+
+                    int bytesSent = clientSocket.EndSend(ar);
+                    OnReceivedMsg($"OK,发送完成, 客户端: {clientId}, 字节数: {bytesSent}", "SendCallback", null);
+                }
+                catch (Exception ex)
+                {
+                    OnReceivedMsg("NG,发送回调失败", "SendCallback", ex);
+                }
+            }
+
+            private void RemoveClient(string clientId, string reason)
+            {
+                try
+                {
+                    Socket clientSocket = null;
+                    lock (_clients)
+                    {
+                        if (_clients.TryGetValue(clientId, out clientSocket))
+                        {
+                            _clients.Remove(clientId);
+                        }
+                    }
+
+                    if (clientSocket != null)
+                    {
+                        try
+                        {
+                            if (clientSocket.Connected)
+                            {
+                                clientSocket.Shutdown(SocketShutdown.Both);
+                            }
+                            clientSocket.Close();
+                        }
+                        catch { }
+                    }
+
+                    OnReceivedMsg($"OK,移除客户端: {clientId}, 原因: {reason}", "RemoveClient", null);
+                }
+                catch (Exception ex)
+                {
+                    OnReceivedMsg($"NG,移除客户端 {clientId} 失败", "RemoveClient", ex);
+                }
+            }
+
+
+
+            private string GenerateClientId(Socket clientSocket)
+            {
+                try
+                {
+                    if (clientSocket.RemoteEndPoint is IPEndPoint remoteEndPoint)
+                    {
+                        return $"{remoteEndPoint.Address}:{remoteEndPoint.Port}";
+                    }
+                }
+                catch { }
+                return $"Client_{DateTime.Now:yyyyMMddHHmmssfff}_{Guid.NewGuid().ToString().Substring(0, 6)}";
+            }
+
+            protected virtual void OnReceivedDatas(Socket clientSocket, string clientId, string message)
+            {
+                ReceivedDatas?.Invoke(this, new ReceivedDatasEventArgs
+                {
+                    ClientSocket = clientSocket,
+                    ClientId = clientId,
+                    Message = message
+                });
+            }
+
+            protected virtual void OnReceivedMsg(string Message, string operation, Exception exception)
+            {
+                ReceivedMsg?.Invoke(this, new ReceivedMsgEventArgs
+                {
+                    Msg = Message,
+                    Operation = operation,
+                    Exception = exception
+                });
+            }
+        }
+
+    }
+}

+ 120 - 0
UAS_MES_XMW/FunctionCode/Make/Make_ServerListen.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 0 - 1
UAS_MES_XMW/FunctionCode/Query/Query_SpecialReport.cs

@@ -1,5 +1,4 @@
 using DevExpress.Printing.Core.PdfExport.Metafile;
-using DevExpress.XtraCharts.Native;
 using ExcelHelper;
 using LabelManager2;
 using NPOI.HSSF.UserModel;

+ 0 - 4
UAS_MES_XMW/FunctionCode/Special/Special_Reset.cs

@@ -16,10 +16,6 @@ using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
 using UAS_MES_NEW.PublicMethod;
 
-using NPOI.HSSF.UserModel;
-using NPOI.SS.UserModel;
-using NPOI.SS.Formula.Functions;
-
 namespace UAS_MES_NEW.Special
 {
     public partial class Special_Reset : Form

+ 9 - 0
UAS_MES_XMW/UAS_MES_XMW.csproj

@@ -683,6 +683,12 @@
     <Compile Include="FunctionCode\Make\Make_SeqTransformPrint.Designer.cs">
       <DependentUpon>Make_SeqTransformPrint.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Make\Make_ServerListen.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_ServerListen.Designer.cs">
+      <DependentUpon>Make_ServerListen.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Make\Make_SMTBind.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1628,6 +1634,9 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_SeqTransformPrint.resx">
       <DependentUpon>Make_SeqTransformPrint.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_ServerListen.resx">
+      <DependentUpon>Make_ServerListen.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_SMTBind.resx">
       <DependentUpon>Make_SMTBind.cs</DependentUpon>
     </EmbeddedResource>

+ 25 - 0
UAS_MES_XMW/UAS_MES_XMW.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36804.6
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UAS_MES_XMW", "UAS_MES_XMW.csproj", "{6B45E923-32AA-47FB-A57F-F3FC3A650B79}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{6B45E923-32AA-47FB-A57F-F3FC3A650B79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6B45E923-32AA-47FB-A57F-F3FC3A650B79}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6B45E923-32AA-47FB-A57F-F3FC3A650B79}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6B45E923-32AA-47FB-A57F-F3FC3A650B79}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {3BA38CE0-008D-4928-8FCF-A7A5E46661B2}
+	EndGlobalSection
+EndGlobal

+ 93 - 0
UAS_Tools_HY/Loading.Designer.cs

@@ -0,0 +1,93 @@
+namespace UAS_Tools_HY
+{
+    partial class Loading
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.loadingBar = new System.Windows.Forms.ProgressBar();
+            this.Confirm = new System.Windows.Forms.Button();
+            this.Msg = new System.Windows.Forms.Label();
+            this.SuspendLayout();
+            // 
+            // loadingBar
+            // 
+            this.loadingBar.Location = new System.Drawing.Point(15, 42);
+            this.loadingBar.Margin = new System.Windows.Forms.Padding(4);
+            this.loadingBar.MarqueeAnimationSpeed = 30;
+            this.loadingBar.Name = "loadingBar";
+            this.loadingBar.Size = new System.Drawing.Size(350, 35);
+            this.loadingBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
+            this.loadingBar.TabIndex = 0;
+            // 
+            // Confirm
+            // 
+            this.Confirm.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.Confirm.Location = new System.Drawing.Point(132, 100);
+            this.Confirm.Margin = new System.Windows.Forms.Padding(4);
+            this.Confirm.Name = "Confirm";
+            this.Confirm.Size = new System.Drawing.Size(100, 35);
+            this.Confirm.TabIndex = 2;
+            this.Confirm.Text = "确定";
+            this.Confirm.UseVisualStyleBackColor = true;
+            this.Confirm.Click += new System.EventHandler(this.Confirm_Click);
+            // 
+            // Msg
+            // 
+            this.Msg.Location = new System.Drawing.Point(12, 42);
+            this.Msg.Name = "Msg";
+            this.Msg.Size = new System.Drawing.Size(353, 24);
+            this.Msg.TabIndex = 3;
+            this.Msg.Text = "已找到:0条数据";
+            this.Msg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+            // 
+            // Loading
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(378, 148);
+            this.Controls.Add(this.Msg);
+            this.Controls.Add(this.Confirm);
+            this.Controls.Add(this.loadingBar);
+            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+            this.Margin = new System.Windows.Forms.Padding(4);
+            this.Name = "Loading";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+            this.Text = "Loading";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Loading_FormClosing);
+            this.Load += new System.EventHandler(this.Loading_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ProgressBar loadingBar;
+        private System.Windows.Forms.Button Confirm;
+        private System.Windows.Forms.Label Msg;
+    }
+}

+ 88 - 0
UAS_Tools_HY/Loading.cs

@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using UAS_Tools_HY.PublicMethods;
+
+namespace UAS_Tools_HY
+{
+    public partial class Loading : Form
+    {
+        public Loading()
+        {
+            InitializeComponent();
+        }
+
+        public DataTable ResultData { get; private set; }
+
+        string Filter;
+
+        private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
+
+        public Loading(string str)
+        {
+            InitializeComponent();
+            Filter = str;
+        }
+
+        private async void Loading_Load(object sender, EventArgs e)
+        {
+            Msg.Visible = false;
+            Confirm.Enabled = false;
+            try
+            {
+                ResultData = ConnectDB.ExecuteSelect($@"SELECT count(*) num FROM g_packing_sncheck {Filter}");
+                if(ResultData.Rows.Count > 0)
+                {
+                    int allCount = Convert.ToInt32(ResultData.Rows[0]["num"].ToString());
+                    loadingBar.Visible = true;
+                    await Task.Run(() =>
+                    {
+                        /*ResultData = ConnectDB.ExecuteSelect($@"SELECT sn dqsn,outbox_no dqoutbox_no,count dqcount,
+                            update_time dqupdate_time,update_name dqname,rule_name dqrule_name,rule_value dqrule_value
+                            FROM g_packing_sncheck {Filter} ORDER BY sn,update_time desc");*/
+
+                        Task<DataTable> task = ConnectDB.ExecuteSelectCancellableSimpleAsync(
+                            sqlQuery: $@"SELECT sn dqsn,outbox_no dqoutbox_no,count dqcount,
+                                update_time dqupdate_time,update_name dqname,rule_name dqrule_name,rule_value dqrule_value
+                                FROM g_packing_sncheck {Filter} ORDER BY sn,update_time desc",
+                            cancellationToken: _cancellationTokenSource.Token);
+
+                        ResultData = task.Result;
+
+                        this.Invoke(new Action(() =>
+                        {
+                            loadingBar.Visible = false;
+                            Msg.Visible = true;
+                            Msg.Text = $"已查询到:{ResultData.Rows.Count}条数据";
+                            Confirm.Enabled = true;
+                        }));
+                    });
+                }
+            } catch(Exception ex) { }
+        }
+
+        private void Confirm_Click(object sender, EventArgs e)
+        {
+            _cancellationTokenSource?.Dispose();
+            _cancellationTokenSource = null;
+
+            this.DialogResult = DialogResult.OK;
+            this.Dispose();
+            this.Close();
+            GC.Collect();
+        }
+
+        private void Loading_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            _cancellationTokenSource?.Dispose();
+            _cancellationTokenSource = null;
+        }
+    }
+}

+ 120 - 0
UAS_Tools_HY/Loading.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 33 - 6
UAS_Tools_HY/Main.cs

@@ -143,6 +143,15 @@ namespace UAS_MES_Tools
                 return;
             }
 
+            dt = ConnectDB.ExecuteSelect($@"select * from g_packing_sncheck where sn = '{SN.Text.Trim()}'");
+            if (dt.Rows.Count > 0)
+            {
+                PlaySound("NG");
+                MessageBox.Show($"{SN.Text.Trim()},历史记录中已核对", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                checkRes = false;
+                return;
+            }
+
             ishaveInd = -1;
             if (Datas.Rows.Count > 0)
             {
@@ -157,11 +166,16 @@ namespace UAS_MES_Tools
 
             if (ishaveInd >= 0)
             {
-                int iCou = Convert.ToInt32(Datas.Rows[ishaveInd].Cells[2].Value);
+                PlaySound("NG");
+                MessageBox.Show($"{SN.Text.Trim()},已核对装箱", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                checkRes = false;
+                return;
+
+                /*int iCou = Convert.ToInt32(Datas.Rows[ishaveInd].Cells[2].Value);
                 iCou += 1;
                 Datas.Rows[ishaveInd].Cells[3].Value = currTime.Text;
                 Datas.Rows[ishaveInd].Cells[6].Value = checkRes ? "OK" : "NG";
-                PlaySound("OK");
+                PlaySound("OK");*/
             }
             else
             {
@@ -326,10 +340,23 @@ namespace UAS_MES_Tools
                     filterStr.Append($" AND update_time > TO_DATE('{dtp1}','YYYY-MM-DD HH24:MI:SS') AND update_time <= TO_DATE('{dtp2}','YYYY-MM-DD HH24:MI:SS')");
                 }
             }
-            dt = ConnectDB.ExecuteSelect($@"SELECT sn dqsn,outbox_no dqoutbox_no,count dqcount,
-                update_time dqupdate_time,update_name dqname,rule_name dqrule_name,rule_value dqrule_value
-                FROM g_packing_sncheck {filterStr.ToString()} ORDER BY sn,update_time desc");
-            QDDatas.DataSource = dt;
+
+            if(sender == null)
+            {
+                dt = ConnectDB.ExecuteSelect($@"SELECT sn dqsn,outbox_no dqoutbox_no,count dqcount,
+                    update_time dqupdate_time,update_name dqname,rule_name dqrule_name,rule_value dqrule_value
+                    FROM g_packing_sncheck {filterStr.ToString()} ORDER BY sn,update_time desc");
+                QDDatas.DataSource = dt;
+            }
+            else
+            {
+                Loading LoadingForm = new Loading(filterStr.ToString());
+                if (LoadingForm.ShowDialog() == DialogResult.OK)
+                {
+                    DataTable dt = LoadingForm.ResultData;
+                    QDDatas.DataSource = dt;
+                }
+            }
         }
 
         private void QDexport_Click(object sender, EventArgs e)

+ 47 - 0
UAS_Tools_HY/PublicMethods/ConnectDB.cs

@@ -3,6 +3,8 @@ using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Security.Cryptography;
+using System.Threading;
+using System.Threading.Tasks;
 
 namespace UAS_Tools_HY.PublicMethods
 {
@@ -136,6 +138,51 @@ namespace UAS_Tools_HY.PublicMethods
                 throw new Exception(ex.Message);
             }
         }
+
+        public static async Task<DataTable> ExecuteSelectCancellableSimpleAsync(string sqlQuery,Dictionary<string, object> parameters = null,CancellationToken cancellationToken = default)
+        {
+            DataTable dataTable = new DataTable();
+            try
+            {
+                using (OracleConnection connection = new OracleConnection(ConnectionString))
+                {
+                    await connection.OpenAsync(cancellationToken);
+
+                    using (OracleCommand command = new OracleCommand(sqlQuery, connection))
+                    {
+                        if (parameters != null && parameters.Count > 0)
+                        {
+                            foreach (var param in parameters)
+                            {
+                                command.Parameters.Add(new OracleParameter(param.Key, param.Value ?? DBNull.Value));
+                            }
+                        }
+
+                        command.CommandTimeout = 0;
+
+                        using (OracleDataAdapter adapter = new OracleDataAdapter(command))
+                        {
+                            await Task.Run(() =>
+                            {
+                                adapter.Fill(dataTable);
+
+                                cancellationToken.ThrowIfCancellationRequested();
+                            }, cancellationToken);
+                        }
+                    }
+                }
+            }
+            catch (OperationCanceledException)
+            {
+                throw new OperationCanceledException("数据库查询已取消");
+            }
+            catch (Exception ex)
+            {
+                throw new Exception($"数据库查询失败: {ex.Message}");
+            }
+
+            return dataTable;
+        }
     }
 }
 

+ 9 - 0
UAS_Tools_HY/UAS_Tools_HY.csproj

@@ -82,6 +82,12 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Loading.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Loading.Designer.cs">
+      <DependentUpon>Loading.cs</DependentUpon>
+    </Compile>
     <Compile Include="Login.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -107,6 +113,9 @@
     <Compile Include="RulesList.Designer.cs">
       <DependentUpon>RulesList.cs</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="Loading.resx">
+      <DependentUpon>Loading.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Login.resx">
       <DependentUpon>Login.cs</DependentUpon>
     </EmbeddedResource>