Jelajahi Sumber

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

callm 1 Minggu lalu
induk
melakukan
4c9ed9d924

+ 0 - 2
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -28,8 +28,6 @@ using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
 using UAS_MES_NEW.PublicMethod;
-using static DevExpress.Xpo.DB.DataStoreLongrunnersWatch;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
 
 namespace UAS_MES_NEW.Make
 {

+ 84 - 18
UAS_MES_HYSX/FunctionCode/Make/Make_ListenSocket.Designer.cs

@@ -29,12 +29,16 @@
         private void InitializeComponent()
         {
             this.ContainerBox = new System.Windows.Forms.Panel();
-            this.OperatResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
             this.SettingBox = new System.Windows.Forms.Panel();
+            this.Clear = new System.Windows.Forms.Button();
             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.WoLab = new System.Windows.Forms.Label();
+            this.OperatResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
+            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
             this.SNDetails = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
             this.productName = new System.Windows.Forms.Label();
@@ -61,19 +65,12 @@
             this.ContainerBox.Size = new System.Drawing.Size(1600, 777);
             this.ContainerBox.TabIndex = 97;
             // 
-            // 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, 194);
-            this.OperatResult.Margin = new System.Windows.Forms.Padding(4);
-            this.OperatResult.Name = "OperatResult";
-            this.OperatResult.Size = new System.Drawing.Size(1600, 583);
-            this.OperatResult.TabIndex = 91;
-            this.OperatResult.Text = "";
-            // 
             // SettingBox
             // 
+            this.SettingBox.Controls.Add(this.ma_code);
+            this.SettingBox.Controls.Add(this.WoLab);
+            this.SettingBox.Controls.Add(this.LockMakeCode);
+            this.SettingBox.Controls.Add(this.Clear);
             this.SettingBox.Controls.Add(this.Connet);
             this.SettingBox.Controls.Add(this.Start);
             this.SettingBox.Controls.Add(this.IpPort);
@@ -84,12 +81,24 @@
             this.SettingBox.Size = new System.Drawing.Size(1600, 194);
             this.SettingBox.TabIndex = 96;
             // 
+            // Clear
+            // 
+            this.Clear.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.Clear.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Clear.Location = new System.Drawing.Point(486, 108);
+            this.Clear.Name = "Clear";
+            this.Clear.Size = new System.Drawing.Size(120, 35);
+            this.Clear.TabIndex = 94;
+            this.Clear.Text = "清除提示";
+            this.Clear.UseVisualStyleBackColor = true;
+            this.Clear.Click += new System.EventHandler(this.Clear_Click);
+            // 
             // Connet
             // 
             this.Connet.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.Connet.Location = new System.Drawing.Point(161, 93);
+            this.Connet.Location = new System.Drawing.Point(210, 109);
             this.Connet.Name = "Connet";
-            this.Connet.Size = new System.Drawing.Size(144, 43);
+            this.Connet.Size = new System.Drawing.Size(120, 35);
             this.Connet.TabIndex = 93;
             this.Connet.Text = "开启连接";
             this.Connet.UseVisualStyleBackColor = true;
@@ -99,9 +108,9 @@
             // Start
             // 
             this.Start.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.Start.Location = new System.Drawing.Point(335, 93);
+            this.Start.Location = new System.Drawing.Point(350, 108);
             this.Start.Name = "Start";
-            this.Start.Size = new System.Drawing.Size(144, 43);
+            this.Start.Size = new System.Drawing.Size(120, 35);
             this.Start.TabIndex = 92;
             this.Start.Text = "开启监听";
             this.Start.UseVisualStyleBackColor = true;
@@ -109,7 +118,7 @@
             // 
             // IpPort
             // 
-            this.IpPort.Location = new System.Drawing.Point(161, 47);
+            this.IpPort.Location = new System.Drawing.Point(161, 61);
             this.IpPort.Name = "IpPort";
             this.IpPort.Size = new System.Drawing.Size(309, 31);
             this.IpPort.TabIndex = 1;
@@ -118,12 +127,65 @@
             // 
             this.IpPortLab.AutoSize = true;
             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(60, 47);
+            this.IpPortLab.Location = new System.Drawing.Point(70, 61);
             this.IpPortLab.Name = "IpPortLab";
             this.IpPortLab.Size = new System.Drawing.Size(117, 28);
             this.IpPortLab.TabIndex = 0;
             this.IpPortLab.Text = "服务地址:";
             // 
+            // WoLab
+            // 
+            this.WoLab.AutoSize = true;
+            this.WoLab.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.WoLab.Location = new System.Drawing.Point(70, 19);
+            this.WoLab.Name = "WoLab";
+            this.WoLab.Size = new System.Drawing.Size(117, 28);
+            this.WoLab.TabIndex = 97;
+            this.WoLab.Text = "归属工单:";
+            // 
+            // 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, 194);
+            this.OperatResult.Margin = new System.Windows.Forms.Padding(4);
+            this.OperatResult.Name = "OperatResult";
+            this.OperatResult.Size = new System.Drawing.Size(1600, 583);
+            this.OperatResult.TabIndex = 91;
+            this.OperatResult.Text = "";
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.Caller = null;
+            this.ma_code.Condition = null;
+            this.ma_code.DBTitle = null;
+            this.ma_code.FormName = null;
+            this.ma_code.Location = new System.Drawing.Point(162, 17);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = null;
+            this.ma_code.ReturnData = null;
+            this.ma_code.SelectField = null;
+            this.ma_code.SetValueField = null;
+            this.ma_code.Size = new System.Drawing.Size(189, 32);
+            this.ma_code.TabIndex = 96;
+            this.ma_code.TableName = null;
+            this.ma_code.Tag = "ma_code";
+            this.ma_code.TextBoxEnable = true;
+            // 
+            // LockMakeCode
+            // 
+            this.LockMakeCode.AutoSize = true;
+            this.LockMakeCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.LockMakeCode.LeaveEvent = false;
+            this.LockMakeCode.Location = new System.Drawing.Point(358, 19);
+            this.LockMakeCode.Name = "LockMakeCode";
+            this.LockMakeCode.Size = new System.Drawing.Size(72, 28);
+            this.LockMakeCode.TabIndex = 95;
+            this.LockMakeCode.Text = "锁定";
+            this.LockMakeCode.UseVisualStyleBackColor = true;
+            // 
             // SNDetails
             // 
             this.SNDetails.BorderColor = System.Drawing.Color.Black;
@@ -292,5 +354,9 @@
         private System.Windows.Forms.Label IpPortLab;
         private System.Windows.Forms.TextBox IpPort;
         private System.Windows.Forms.Button Connet;
+        private System.Windows.Forms.Button Clear;
+        private CustomControl.TextBoxWithIcon.MaCodeSearchTextBox ma_code;
+        private System.Windows.Forms.Label WoLab;
+        private CustomControl.CustomCheckBox.LockCheckBox LockMakeCode;
     }
 }

+ 75 - 10
UAS_MES_HYSX/FunctionCode/Make/Make_ListenSocket.cs

@@ -1,4 +1,5 @@
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -15,6 +16,7 @@ using System.Web.Services.Description;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicMethod;
 
 namespace UAS_MES_NEW.Make
 {
@@ -32,6 +34,9 @@ namespace UAS_MES_NEW.Make
         private SocketServer _server;
         private int currCount = 0;
 
+
+        DataTable Dbfind;
+
         private void Make_ListenSocket_Load(object sender, EventArgs e)
         {
             dh = SystemInf.dh;
@@ -41,6 +46,23 @@ namespace UAS_MES_NEW.Make
             _server.ReceivedMsg += SocketServer_ReceivedMsg;
 
             IpPort.Text = "127.0.0.1:9979";
+
+            LockMakeCode.GetMakeCodeCtl(ma_code);
+            ma_code.SetLockCheckBox(LockMakeCode);
+            //工单号放大镜配置
+            ma_code.TableName = "make left join product on ma_prodcode=pr_code";
+            ma_code.SelectField = "ma_code # 工单号,ma_pocode # 内部订单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_spec # 产品规格,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
+            ma_code.FormName = Name;
+            ma_code.SetValueField = new string[] { "ma_code", "ma_pocode", "ma_prodcode", "ma_qty", "substr(pr_spec,0,50)pr_spec", "ma_softversion", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype" };
+            ma_code.Condition = "ma_statuscode='STARTED'";
+            ma_code.DbChange += Ma_code_DbChange;
+            dh = SystemInf.dh;
+        }
+
+        private void Ma_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = ma_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
         private void Connet_Click(object sender, EventArgs e)
@@ -57,6 +79,12 @@ namespace UAS_MES_NEW.Make
 
         private void Start_Click(object sender, EventArgs e)
         {
+            if (string.IsNullOrEmpty(ma_code.Text))
+            {
+                ShowMsg(0, "请选择工单号");
+                return;
+            }
+
             if (string.IsNullOrEmpty(IpPort.Text))
             {
                 ShowMsg(0, "请填写Socket服务地址");
@@ -93,7 +121,27 @@ namespace UAS_MES_NEW.Make
             {
                 currCount += 1;
 
-                ShowMsg(1, $"第{currCount}次接收,收到来自 {e.ClientId} 的消息: {e.Message}");
+                //ShowMsg(1, $"第{currCount}次接收,收到来自 {e.ClientId} 的消息: {e.Message}");
+
+                JObject outerObj = JObject.Parse(e.Message);
+
+                string name = outerObj["Name"].ToString();
+                string dataString = outerObj["Data"].ToString();
+
+                JObject dataObj = JObject.Parse(dataString);
+                string serial = dataObj["Serial"].ToString();
+
+                ShowMsg(1, $"第{currCount}次接收,客户端:{e.ClientId}, {name}类型信息, 序列号: {serial}");
+
+                string omakeCode, oMsid, oErrorMessage = "";
+                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, serial, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
+                {
+                    if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, serial, "产测软件对接", "OK", User.UserCode, out oErrorMessage))
+                    {
+                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, omakeCode, User.UserLineCode, User.UserSourceCode, "产测软件对接", "产测软件对接成功", serial, "");
+                        ShowMsg(1, $"序列号: {serial} 过站处理成功");
+                    }
+                } 
 
                 VerifyResultMessage message = new VerifyResultMessage
                 {
@@ -102,7 +150,7 @@ namespace UAS_MES_NEW.Make
                     {
                         ErrorCode = "0",
                         ErrorMsg = "",
-                        Serial = "BG7349116"
+                        Serial = serial
                     }
                 };
                 string jsonMessage = JsonConvert.SerializeObject(message, Formatting.None);
@@ -191,6 +239,12 @@ namespace UAS_MES_NEW.Make
             OperatResult.ScrollToCaret();
         }
 
+        private void Clear_Click(object sender, EventArgs e)
+        {
+            OperatResult.Clear();
+            UpdateSN("C", "");
+        }
+
         private void UpdateSN(string type, string sn)
         {
             if (type == "C")
@@ -447,11 +501,6 @@ namespace UAS_MES_NEW.Make
 
                     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);
@@ -541,11 +590,26 @@ namespace UAS_MES_NEW.Make
                         return $"NG,客户端 {clientId} 连接已断开";
                     }
 
-                    byte[] messageBytes = Encoding.Unicode.GetBytes(jsonMessage);
-                    clientSocket.BeginSend(messageBytes, 0, messageBytes.Length, SocketFlags.None, new AsyncCallback(SendCallback),
+                    byte[] jsonBytes = Encoding.Unicode.GetBytes(jsonMessage);  // UTF-16 LE编码
+                    long length = jsonBytes.Length;  // UTF-16字节长度
+
+                    byte[] packet = new byte[8 + jsonBytes.Length];  // 8字节长度头
+                                                                     // 8字节小端序(与客户端4字节小端序对应,只是扩展为8字节)
+                    packet[0] = (byte)(length);
+                    packet[1] = (byte)(length >> 8);
+                    packet[2] = (byte)(length >> 16);
+                    packet[3] = (byte)(length >> 24);
+                    packet[4] = (byte)(length >> 32);
+                    packet[5] = (byte)(length >> 40);
+                    packet[6] = (byte)(length >> 48);
+                    packet[7] = (byte)(length >> 56);
+
+                    Array.Copy(jsonBytes, 0, packet, 8, jsonBytes.Length);
+                    clientSocket.BeginSend(packet, 0, packet.Length, SocketFlags.None,
+                        new AsyncCallback(SendCallback),
                         new { ClientId = clientId, ClientSocket = clientSocket });
 
-                    return $"OK,发送成功,已发送 字符数: {jsonMessage.Length}, 字节数: {messageBytes.Length} 到 {clientId}";
+                    return $"OK,发送成功,JSON长度: {jsonMessage.Length}, 报文总字节: {packet.Length} 到 {clientId}";
                 }
                 catch (Exception ex)
                 {
@@ -639,5 +703,6 @@ namespace UAS_MES_NEW.Make
                 });
             }
         }
+
     }
 }