Browse Source

萤石产测对接

yhluo 1 week ago
parent
commit
6f109a869b

+ 8 - 9
UAS_MES_HYSX/FunctionCode/Make/Make_ListenSocket.Designer.cs

@@ -86,9 +86,8 @@
             // 
             // Connet
             // 
-            this.Connet.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.Connet.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.Connet.Location = new System.Drawing.Point(161, 119);
+            this.Connet.Location = new System.Drawing.Point(161, 93);
             this.Connet.Name = "Connet";
             this.Connet.Size = new System.Drawing.Size(144, 43);
             this.Connet.TabIndex = 93;
@@ -99,9 +98,8 @@
             // 
             // Start
             // 
-            this.Start.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.Start.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.Start.Location = new System.Drawing.Point(394, 119);
+            this.Start.Location = new System.Drawing.Point(335, 93);
             this.Start.Name = "Start";
             this.Start.Size = new System.Drawing.Size(144, 43);
             this.Start.TabIndex = 92;
@@ -264,13 +262,14 @@
             this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_ListenSocket";
             this.Text = "Make_ListenSocket";
-            this.ContainerBox.ResumeLayout(true);
-            this.SettingBox.ResumeLayout(true);
+            this.Load += new System.EventHandler(this.Make_ListenSocket_Load);
+            this.ContainerBox.ResumeLayout(false);
+            this.SettingBox.ResumeLayout(false);
             this.SettingBox.PerformLayout();
-            this.SNDetails.ResumeLayout(true);
-            this.tableLayoutPanel1.ResumeLayout(true);
+            this.SNDetails.ResumeLayout(false);
+            this.tableLayoutPanel1.ResumeLayout(false);
             this.tableLayoutPanel1.PerformLayout();
-            this.ResumeLayout(true);
+            this.ResumeLayout(false);
 
         }
 

+ 62 - 8
UAS_MES_HYSX/FunctionCode/Make/Make_ListenSocket.cs

@@ -12,6 +12,8 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Web.Services.Description;
 using System.Windows.Forms;
+using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.DataOperate;
 
 namespace UAS_MES_NEW.Make
 {
@@ -22,7 +24,30 @@ namespace UAS_MES_NEW.Make
             InitializeComponent();
         }
 
+        StringBuilder SQL = new StringBuilder();
+        DataTable dt;
+        DataHelper dh;
+
         SocketHandle client;
+        string saveFile, sendFile;
+
+        private void Make_ListenSocket_Load(object sender, EventArgs e)
+        {
+            dh = SystemInf.dh;
+
+            string currentPath = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).FullName;
+            saveFile = Path.Combine(currentPath, $"Received.txt");
+            sendFile = Path.Combine(currentPath, $"Send.txt");
+
+            if (!File.Exists(saveFile))
+            {
+                File.Create(saveFile).Dispose();
+            }
+            if (!File.Exists(sendFile))
+            {
+                File.Create(sendFile).Dispose();
+            }
+        }
 
         private void Connet_Click(object sender, EventArgs e)
         {
@@ -70,8 +95,7 @@ namespace UAS_MES_NEW.Make
                 }
                 ShowMsg(1, msg);
 
-                string savePath = @"C:\Users\MI\Desktop\testEquiment\ReceivedFiles\received_file.txt";
-                msg = await client.ReceiveFileAsync(savePath);
+                msg = await client.ReceiveFileAsync(saveFile);
                 if (!msg.StartsWith("OK"))
                 {
                     ShowMsg(0, msg);
@@ -79,25 +103,26 @@ namespace UAS_MES_NEW.Make
                 ShowMsg(1, msg);
             }
         }
+
         private async void OnFileReceived(string fileName, string savePath)
         {
-            Console.WriteLine("文件接收完成: " + fileName + " 保存到: " + savePath);
-
-            string localFilePath = @"C:\Users\MI\Desktop\testEquiment\ReceivedFiles\send_file.txt";
-            string msg = await client.SendFileAsync(localFilePath);
+            ShowMsg(1, "文件接收完成: " + fileName + " 保存到: " + savePath);
+            string msg = await client.SendFileAsync(sendFile);
             if (msg.StartsWith("NG"))
             {
                 ShowMsg(0, msg);
             }
             ShowMsg(1, "文件发送成功");
         }
+
         private void OnMessageReceived(string message)
         {
-            Console.WriteLine("收到服务器消息: " + message);
+            ShowMsg(1, "收到服务器消息: " + message);
         }
+
         private void OnConnectionStatusChanged(string status)
         {
-            Console.WriteLine("连接状态: " + status);
+            ShowMsg(0, "连接状态已变: " + status);
         }
 
         private void ShowMsg(int type, string msg)
@@ -115,6 +140,35 @@ namespace UAS_MES_NEW.Make
             }
         }
 
+        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);
+                }
+            }
+        }
+
         public class SocketHandle
         {
             private Socket clientSocket;

+ 2 - 1
UAS_MES_HYSX/FunctionCode/Make/Make_SMTStencil.cs

@@ -188,7 +188,7 @@ namespace UAS_MES_NEW.Make
                     st_table.SelectedItem = null;
                     SU_DEVCODE.Text = "";
                     em_code.Text = "";
-                    Receive.Enabled = false;
+                    Receive.Enabled = true;
                     LoadGridData();
 
                 }
@@ -258,6 +258,7 @@ namespace UAS_MES_NEW.Make
                         ST_ENSIONC.Text = "";
                         ST_ENSIOND.Text = "";
                         ST_ENSIONE.Text = "";
+                        Return.Enabled = true;
                         Confirm.PerformClick();
                     }
                     else