Quellcode durchsuchen

贴片机对接信息写入

yhluo vor 5 Monaten
Ursprung
Commit
12ab2b1973

+ 1 - 1
UAS_MES_BG/App.config

@@ -78,7 +78,7 @@
   <applicationSettings>
     <UAS_MES_NEW.Properties.Settings>
       <setting name="MES" serializeAs="String">
-        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.92)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
+        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11717)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
       </setting>
     </UAS_MES_NEW.Properties.Settings>
     <UAS_MES.Properties.Settings>

+ 51 - 50
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.Designer.cs

@@ -39,15 +39,15 @@
             this.time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.fileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.panel1 = new System.Windows.Forms.Panel();
-            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
-            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
+            this.claerBtn = new System.Windows.Forms.Button();
             this.allParse = new System.Windows.Forms.Button();
             this.label3 = new System.Windows.Forms.Label();
             this.panel2 = new System.Windows.Forms.Panel();
             this.panel3 = new System.Windows.Forms.Panel();
-            this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
             this.lstFiles = new System.Windows.Forms.ListBox();
-            this.claerBtn = new System.Windows.Forms.Button();
+            this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
+            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
             this.panel1.SuspendLayout();
             this.panel2.SuspendLayout();
             this.panel3.SuspendLayout();
@@ -61,7 +61,8 @@
             this.Device.Items.AddRange(new object[] {
             "SPI设备",
             "AOI设备",
-            "印刷机"});
+            "印刷机",
+            "贴片机"});
             this.Device.Location = new System.Drawing.Point(193, 88);
             this.Device.Name = "Device";
             this.Device.Size = new System.Drawing.Size(328, 32);
@@ -164,38 +165,17 @@
             this.panel1.Size = new System.Drawing.Size(1304, 334);
             this.panel1.TabIndex = 7;
             // 
-            // 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(520, 25);
-            this.LockMakeCode.Margin = new System.Windows.Forms.Padding(4);
-            this.LockMakeCode.Name = "LockMakeCode";
-            this.LockMakeCode.Size = new System.Drawing.Size(72, 28);
-            this.LockMakeCode.TabIndex = 1;
-            this.LockMakeCode.Text = "锁定";
-            this.LockMakeCode.UseVisualStyleBackColor = true;
-            // 
-            // ma_code
+            // claerBtn
             // 
-            this.ma_code.AllPower = null;
-            this.ma_code.BackColor = System.Drawing.SystemColors.Control;
-            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(193, 25);
-            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(224, 32);
-            this.ma_code.TabIndex = 0;
-            this.ma_code.TableName = null;
-            this.ma_code.TextBoxEnable = true;
+            this.claerBtn.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.claerBtn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.claerBtn.Location = new System.Drawing.Point(978, 151);
+            this.claerBtn.Name = "claerBtn";
+            this.claerBtn.Size = new System.Drawing.Size(122, 38);
+            this.claerBtn.TabIndex = 7;
+            this.claerBtn.Text = "清除";
+            this.claerBtn.UseVisualStyleBackColor = true;
+            this.claerBtn.Click += new System.EventHandler(this.claerBtn_Click);
             // 
             // allParse
             // 
@@ -238,10 +218,6 @@
             this.panel3.Size = new System.Drawing.Size(958, 492);
             this.panel3.TabIndex = 7;
             // 
-            // openFileDialog2
-            // 
-            this.openFileDialog2.FileName = "openFileDialog2";
-            // 
             // lstFiles
             // 
             this.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -252,17 +228,42 @@
             this.lstFiles.Size = new System.Drawing.Size(958, 492);
             this.lstFiles.TabIndex = 0;
             // 
-            // claerBtn
+            // openFileDialog2
             // 
-            this.claerBtn.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.claerBtn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.claerBtn.Location = new System.Drawing.Point(978, 151);
-            this.claerBtn.Name = "claerBtn";
-            this.claerBtn.Size = new System.Drawing.Size(122, 38);
-            this.claerBtn.TabIndex = 7;
-            this.claerBtn.Text = "清除";
-            this.claerBtn.UseVisualStyleBackColor = true;
-            this.claerBtn.Click += new System.EventHandler(this.claerBtn_Click);
+            this.openFileDialog2.FileName = "openFileDialog2";
+            // 
+            // 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(520, 25);
+            this.LockMakeCode.Margin = new System.Windows.Forms.Padding(4);
+            this.LockMakeCode.Name = "LockMakeCode";
+            this.LockMakeCode.Size = new System.Drawing.Size(72, 28);
+            this.LockMakeCode.TabIndex = 1;
+            this.LockMakeCode.Text = "锁定";
+            this.LockMakeCode.UseVisualStyleBackColor = true;
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.BackColor = System.Drawing.SystemColors.Control;
+            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(193, 25);
+            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(224, 32);
+            this.ma_code.TabIndex = 0;
+            this.ma_code.TableName = null;
+            this.ma_code.TextBoxEnable = true;
             // 
             // Make_ParseLog
             // 

+ 93 - 4
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -143,6 +143,11 @@ namespace UAS_MES_NEW.Make
                         currFileType = "xml";
                         equiType = "3";
                         break;
+                    case 3:
+                        dialog.Description = "请选择读取贴片机的文本文件夹";
+                        currFileType = "xml";
+                        equiType = "4";
+                        break;
                 }
                 if (dialog.ShowDialog() == DialogResult.OK)
                 {
@@ -265,6 +270,43 @@ namespace UAS_MES_NEW.Make
                             PrinterData xmlData = ReadWithXmlReader(file);
                             Console.WriteLine();
                         }
+                        else if (Device.SelectedIndex == 3) // 贴片机
+                        {
+                            if (!File.Exists(file))
+                            {
+                                LogMessage($"文件不存在: {file}");
+                            }
+                            string xmlContent = File.ReadAllText(file);
+                            var xmlList = ParseXml(xmlContent);
+                            if(ConsoleLog(xmlContent, file))
+                            {
+                                File.Delete(file);
+                            }
+                            List<string> param = new List<string>() { };
+                            string PS_CODE = "";
+                            LogicHandler.GetSerialNumByCaller("Make!ParseLog", out PS_CODE);
+
+                            foreach (var item in xmlList)
+                            {
+                                param.Clear();
+                                param.Add(item.MachineName);
+                                param.Add(item.Part);
+                                param.Add(item.Station);
+                                param.Add(item.ReelNo);
+                                param.Add(User.UserCode);
+                                param.Add(PS_CODE);
+                                string res = "";
+                                param.Add(res);
+                                string[] paramList = param.ToArray();
+                                dh.CallProcedure("CS_INSERT_STATION", ref paramList);
+                                res = paramList[6];
+                                if (!string.IsNullOrEmpty(res))
+                                {
+                                    LogMessage(res);
+                                }
+                            }
+                            Console.WriteLine();
+                        }
                     }
                     LogMessage($"共找到{txtFiles.Length}个{currFileType.ToUpper()}文件");
                 }
@@ -284,8 +326,6 @@ namespace UAS_MES_NEW.Make
                 SR.Close();
                 SR.Dispose();
 
-                ConsoleLog(restOfStream, PathName);
-
                 List<Log> logArr = new List<Log>() { };
                 string[] lines = restOfStream.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                 LogMessage($"文件夹{PathName},共{lines.Length}条记录");
@@ -329,7 +369,10 @@ namespace UAS_MES_NEW.Make
                 InsertDb(logArr, PathName);
 
                 File.WriteAllText(PathName, string.Empty);
-                File.Delete(PathName);
+                if (ConsoleLog(restOfStream, PathName))
+                {
+                    File.Delete(PathName);
+                }
             }
             catch (Exception ex) 
             {
@@ -398,7 +441,7 @@ namespace UAS_MES_NEW.Make
             }
         }
 
-        private void ConsoleLog(string Content, string PathName)
+        private bool ConsoleLog(string Content, string PathName)
         {
             try
             {
@@ -414,10 +457,12 @@ namespace UAS_MES_NEW.Make
                 string newFilePath = Path.Combine(newFolderPath, newFileName);
 
                 File.AppendAllText(newFilePath, Content + Environment.NewLine);
+                return true;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(this.ParentForm, ex.Message, "警告");
+                return false;
             }
         }
         private void LogMessage(string message)
@@ -527,6 +572,41 @@ namespace UAS_MES_NEW.Make
             }
         }
 
+
+        public List<MachineList> ParseXml(string xmlContent)
+        {
+            List<MachineList> result = new List<MachineList>();
+            try
+            {
+                XmlDocument xmlDoc = new XmlDocument();
+                xmlDoc.LoadXml(xmlContent);
+
+                XmlNode machineNode = xmlDoc.SelectSingleNode("//TotalProductionInfo");
+                string machineName = machineNode?.Attributes["MachineName"]?.Value ?? "Unknown";
+                string part = machineNode?.Attributes["ProductionProgramName"]?.Value ?? "Unknown";
+
+                XmlNodeList feederNodes = xmlDoc.SelectNodes("//FeederProductionManageInfo");
+                foreach (XmlNode feederNode in feederNodes)
+                {
+                    MachineList machineList = new MachineList();
+                    string feederBankPosition = feederNode.Attributes["FeederBankPosition"]?.Value ?? "Unknown";
+                    string holeNo = feederNode.Attributes["HoleNo"]?.Value ?? "Unknown";
+                    string componentName = feederNode.Attributes["ComponentName"]?.Value ?? "Unknown";
+
+                    machineList.MachineName = machineName;
+                    machineList.Part = part;
+                    machineList.ReelNo = componentName;
+                    machineList.Station = $"{machineName}-{feederBankPosition[0]}-{holeNo}";
+                    result.Add(machineList);
+                }
+            }
+            catch (Exception ex)
+            {
+                LogMessage($"Error parsing XML: {ex.Message}");
+            }
+
+            return result;
+        }
         private class Log
         {
             public string SN { set; get; }
@@ -535,6 +615,15 @@ namespace UAS_MES_NEW.Make
             public string Details { set; get; }
         }
 
+        public class MachineList
+        {
+            public string MachineName { set; get; }
+
+            public string Part { set; get; }
+            public string Station {  set; get; }
+            public string ReelNo { set; get; }
+        }
+
         private class NgData
         {
             public string Code { set; get; }

+ 1 - 1
UAS_MES_BG/Login.cs

@@ -89,7 +89,7 @@ namespace UAS_MES_NEW
             //设置选中数据库的链接
             string DBUser = DB.SelectedValue.ToString().Split('#')[0];
             string Address = DB.SelectedValue.ToString().Split('#')[1];
-            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Address + ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11717)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             //DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11717)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             SystemInf.CurrentDB = DBUser;
             //设置屏幕的宽高信息

+ 1 - 1
UAS_MES_BG/Properties/Settings.settings

@@ -33,7 +33,7 @@
       <Value Profile="(Default)" />
     </Setting>
     <Setting Name="MES" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.92)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
+      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11717)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
     </Setting>
   </Settings>
 </SettingsFile>

+ 3 - 3
UAS_MES_BG/Properties/Settings1.Designer.cs

@@ -12,7 +12,7 @@ namespace UAS_MES_NEW.Properties {
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -146,8 +146,8 @@ namespace UAS_MES_NEW.Properties {
         [global::System.Configuration.ApplicationScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [global::System.Configuration.DefaultSettingValueAttribute("Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=fal" +
-            "se;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1" +
-            ".92)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
+            "se;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.2" +
+            "08)(PORT=11717)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
         public string MES {
             get {
                 return ((string)(this["MES"]));