Browse Source

处理特殊字符序列号

yhluo 1 day ago
parent
commit
759284f84c

+ 107 - 49
UAS_MES_YTDZ/FunctionCode/Make/Make_ParseLog.Designer.cs

@@ -35,6 +35,8 @@
             this.Choose = new System.Windows.Forms.Button();
             this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
             this.panel1 = new System.Windows.Forms.Panel();
+            this.sideVal = new System.Windows.Forms.ComboBox();
+            this.label4 = new System.Windows.Forms.Label();
             this.FileBox = new System.Windows.Forms.GroupBox();
             this.Clear = new System.Windows.Forms.Button();
             this.Delete = new System.Windows.Forms.Button();
@@ -47,14 +49,16 @@
             this.SN1 = new System.Windows.Forms.TextBox();
             this.onWatch = new System.Windows.Forms.Button();
             this.claerBtn = new System.Windows.Forms.Button();
+            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
             this.allParse = new System.Windows.Forms.Button();
             this.label3 = new System.Windows.Forms.Label();
             this.lstOk = new System.Windows.Forms.ListBox();
             this.lstFiles = new System.Windows.Forms.ListBox();
             this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
-            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
-            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
+            this.lineVal = new System.Windows.Forms.ComboBox();
+            this.label5 = new System.Windows.Forms.Label();
             this.panel1.SuspendLayout();
             this.FileBox.SuspendLayout();
             this.tableLayoutPanel1.SuspendLayout();
@@ -67,7 +71,7 @@
             this.Device.FormattingEnabled = true;
             this.Device.Items.AddRange(new object[] {
             "Xray设备"});
-            this.Device.Location = new System.Drawing.Point(193, 88);
+            this.Device.Location = new System.Drawing.Point(193, 170);
             this.Device.Name = "Device";
             this.Device.Size = new System.Drawing.Size(387, 39);
             this.Device.TabIndex = 2;
@@ -77,7 +81,7 @@
             // 
             this.label1.AutoSize = true;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(61, 92);
+            this.label1.Location = new System.Drawing.Point(61, 174);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(101, 30);
             this.label1.TabIndex = 0;
@@ -87,7 +91,7 @@
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(61, 154);
+            this.label2.Location = new System.Drawing.Point(61, 225);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(123, 30);
             this.label2.TabIndex = 4;
@@ -96,7 +100,7 @@
             // txtPath
             // 
             this.txtPath.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.txtPath.Location = new System.Drawing.Point(193, 154);
+            this.txtPath.Location = new System.Drawing.Point(193, 225);
             this.txtPath.Name = "txtPath";
             this.txtPath.Size = new System.Drawing.Size(387, 31);
             this.txtPath.TabIndex = 3;
@@ -105,7 +109,7 @@
             // 
             this.Choose.Cursor = System.Windows.Forms.Cursors.Hand;
             this.Choose.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Choose.Location = new System.Drawing.Point(601, 155);
+            this.Choose.Location = new System.Drawing.Point(601, 226);
             this.Choose.Name = "Choose";
             this.Choose.Size = new System.Drawing.Size(122, 38);
             this.Choose.TabIndex = 4;
@@ -121,6 +125,10 @@
             // panel1
             // 
             this.panel1.BackColor = System.Drawing.SystemColors.Control;
+            this.panel1.Controls.Add(this.lineVal);
+            this.panel1.Controls.Add(this.label5);
+            this.panel1.Controls.Add(this.sideVal);
+            this.panel1.Controls.Add(this.label4);
             this.panel1.Controls.Add(this.FileBox);
             this.panel1.Controls.Add(this.onWatch);
             this.panel1.Controls.Add(this.claerBtn);
@@ -136,9 +144,32 @@
             this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
             this.panel1.Location = new System.Drawing.Point(0, 0);
             this.panel1.Name = "panel1";
-            this.panel1.Size = new System.Drawing.Size(1600, 296);
+            this.panel1.Size = new System.Drawing.Size(1600, 366);
             this.panel1.TabIndex = 7;
             // 
+            // sideVal
+            // 
+            this.sideVal.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.sideVal.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.sideVal.FormattingEnabled = true;
+            this.sideVal.Items.AddRange(new object[] {
+            "A",
+            "B"});
+            this.sideVal.Location = new System.Drawing.Point(193, 121);
+            this.sideVal.Name = "sideVal";
+            this.sideVal.Size = new System.Drawing.Size(88, 39);
+            this.sideVal.TabIndex = 12;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label4.Location = new System.Drawing.Point(105, 125);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(57, 30);
+            this.label4.TabIndex = 11;
+            this.label4.Text = "面别";
+            // 
             // FileBox
             // 
             this.FileBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -252,7 +283,7 @@
             // 
             this.onWatch.Cursor = System.Windows.Forms.Cursors.Hand;
             this.onWatch.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.onWatch.Location = new System.Drawing.Point(66, 232);
+            this.onWatch.Location = new System.Drawing.Point(66, 282);
             this.onWatch.Name = "onWatch";
             this.onWatch.Size = new System.Drawing.Size(122, 38);
             this.onWatch.TabIndex = 8;
@@ -264,7 +295,7 @@
             // 
             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(391, 231);
+            this.claerBtn.Location = new System.Drawing.Point(391, 281);
             this.claerBtn.Name = "claerBtn";
             this.claerBtn.Size = new System.Drawing.Size(122, 38);
             this.claerBtn.TabIndex = 7;
@@ -272,11 +303,45 @@
             this.claerBtn.UseVisualStyleBackColor = true;
             this.claerBtn.Click += new System.EventHandler(this.claerBtn_Click);
             // 
+            // 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(523, 30);
+            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.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            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(320, 42);
+            this.ma_code.TabIndex = 0;
+            this.ma_code.TableName = null;
+            this.ma_code.TextBoxEnable = true;
+            // 
             // allParse
             // 
             this.allParse.Cursor = System.Windows.Forms.Cursors.Hand;
             this.allParse.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.allParse.Location = new System.Drawing.Point(230, 232);
+            this.allParse.Location = new System.Drawing.Point(230, 282);
             this.allParse.Name = "allParse";
             this.allParse.Size = new System.Drawing.Size(122, 38);
             this.allParse.TabIndex = 5;
@@ -302,7 +367,7 @@
             this.lstOk.ItemHeight = 28;
             this.lstOk.Location = new System.Drawing.Point(3, 3);
             this.lstOk.Name = "lstOk";
-            this.lstOk.Size = new System.Drawing.Size(1594, 296);
+            this.lstOk.Size = new System.Drawing.Size(1594, 261);
             this.lstOk.TabIndex = 1;
             // 
             // lstFiles
@@ -312,9 +377,9 @@
             this.lstFiles.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.lstFiles.FormattingEnabled = true;
             this.lstFiles.ItemHeight = 22;
-            this.lstFiles.Location = new System.Drawing.Point(3, 305);
+            this.lstFiles.Location = new System.Drawing.Point(3, 270);
             this.lstFiles.Name = "lstFiles";
-            this.lstFiles.Size = new System.Drawing.Size(1594, 296);
+            this.lstFiles.Size = new System.Drawing.Size(1594, 261);
             this.lstFiles.TabIndex = 0;
             this.lstFiles.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstFiles_DrawItem);
             // 
@@ -329,47 +394,36 @@
             this.tableLayoutPanel1.Controls.Add(this.lstOk, 0, 0);
             this.tableLayoutPanel1.Controls.Add(this.lstFiles, 0, 1);
             this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 296);
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 366);
             this.tableLayoutPanel1.Name = "tableLayoutPanel1";
             this.tableLayoutPanel1.RowCount = 2;
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
-            this.tableLayoutPanel1.Size = new System.Drawing.Size(1600, 604);
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(1600, 534);
             this.tableLayoutPanel1.TabIndex = 8;
             // 
-            // 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(523, 30);
-            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.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            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(320, 42);
-            this.ma_code.TabIndex = 0;
-            this.ma_code.TableName = null;
-            this.ma_code.TextBoxEnable = true;
+            // lineVal
+            // 
+            this.lineVal.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.lineVal.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lineVal.FormattingEnabled = true;
+            this.lineVal.Items.AddRange(new object[] {
+            "A",
+            "B"});
+            this.lineVal.Location = new System.Drawing.Point(193, 72);
+            this.lineVal.Name = "lineVal";
+            this.lineVal.Size = new System.Drawing.Size(146, 39);
+            this.lineVal.TabIndex = 14;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label5.Location = new System.Drawing.Point(105, 76);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(57, 30);
+            this.label5.TabIndex = 13;
+            this.label5.Text = "线体";
             // 
             // Make_ParseLog
             // 
@@ -421,5 +475,9 @@
         private System.Windows.Forms.Button Delete;
         private System.Windows.Forms.Button Clear;
         private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+        private System.Windows.Forms.ComboBox sideVal;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.ComboBox lineVal;
+        private System.Windows.Forms.Label label5;
     }
 }

+ 85 - 20
UAS_MES_YTDZ/FunctionCode/Make/Make_ParseLog.cs

@@ -35,7 +35,7 @@ namespace UAS_MES_NEW.Make
         DataHelper dh;
         string currFileType = "", equiType = "";
 
-        string SN, omakeCode, oMsid, oErrorMessage = "";
+        string SN, uploadFile ,omakeCode, oMsid, oErrorMessage = "";
         List<string> fileList = new List<string>();
 
         Timer ChangeWoTimer;
@@ -74,6 +74,13 @@ namespace UAS_MES_NEW.Make
             ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
             ma_code.Condition = "ma_statuscode='STARTED'";
             ma_code.DbChange += Ma_code_DbChange;
+
+            dt = (DataTable)dh.ExecuteSql("select * from line where li_wccode = 'SMT' ORDER BY LI_ID", "select");
+            if (dt.Rows.Count > 0)
+            {
+                lineVal.Items.Clear();
+                lineVal.Items.AddRange(dt.AsEnumerable().Select(r => r.Field<string>("li_name")).ToArray());
+            }
         }
 
         private void Ma_code_DbChange(object sender, EventArgs e)
@@ -163,6 +170,21 @@ namespace UAS_MES_NEW.Make
                 MessageBox.Show(this.ParentForm, "请选择设备", "提示");
                 return;
             }
+
+            if (lineVal.SelectedIndex == -1)
+            {
+                lineVal.Focus();
+                MessageBox.Show(this.ParentForm, "请选择线体", "提示");
+                return;
+            }
+
+            if (sideVal.SelectedIndex == -1)
+            {
+                sideVal.Focus();
+                MessageBox.Show(this.ParentForm, "请选择面别", "提示");
+                return;
+            }
+
             if (String.IsNullOrEmpty(txtPath.Text))
             {
                 txtPath.Focus();
@@ -424,31 +446,42 @@ namespace UAS_MES_NEW.Make
                             foreach (string floderFileItem in floderFile)
                             {
                                 SN = Path.GetFileName(floderFileItem).Split('_')[0];
-                                if(SN.ToLower() == "none")
-                                {
-                                    SN = Path.GetFileName(currPath).Split('_')[1];
+                            }
 
-                                    if (UploadImageToFtp(floderFileItem, SN))
-                                    {
-                                        string time = File.GetCreationTime(floderFileItem).ToString("yyyy:MM:dd HH:mm:ss");
-                                        dh.ExecuteSql($@"UPDATE xraytest SET xt_url = 'http://192.168.41.232:8098/Xray/{DateTime.Now.ToString("yyyyMMdd")}/{SN}/{Path.GetFileName(floderFileItem)}',
-                                            xt_macode = '{ma_code.Text.Trim()}' WHERE checkdate = to_date('{time}','YYYY:MM:DD HH24:MI:SS')", "update");
-                                    }
+                            uploadFile = floderFile.FirstOrDefault(i => i.Contains("result"));
+                            if (uploadFile == null)
+                            {
+                                uploadFile = floderFile[0];
+                            }
+
+
+                            if (SN.ToLower() == "none")
+                            {
+                                SN = Path.GetFileName(currPath).Split('_')[1];
+
+                                if (UploadImageToFtp(uploadFile, SN))
+                                {
+                                    string time = File.GetCreationTime(uploadFile).ToString("yyyy:MM:dd HH:mm:ss");
+                                    dh.ExecuteSql($@"UPDATE xraytest SET xt_url = 'http://192.168.41.232:8098/Xray/{DateTime.Now.ToString("yyyyMMdd")}/{SN.Replace("#","")}/{Path.GetFileName(uploadFile).Replace("#", "")}',
+                                            xt_macode = '{ma_code.Text.Trim()}',xt_side = '{sideVal.Text}',xt_line = '{lineVal.Text}' WHERE checkdate = to_date('{time}','YYYY:MM:DD HH24:MI:SS')", "update");
                                 }
-                                else
+                            }
+                            else
+                            {
+                                if (UploadImageToFtp(uploadFile, SN))
                                 {
-                                    if (UploadImageToFtp(floderFileItem, SN))
-                                    {
-                                        dh.ExecuteSql($@"UPDATE xraytest SET xt_url = 'http://192.168.41.232:8098/Xray/{DateTime.Now.ToString("yyyyMMdd")}/{SN}/{Path.GetFileName(floderFileItem)}',
-                                            xt_macode = '{ma_code.Text.Trim()}' WHERE barcode = '{SN}'", "update");
-                                    }
+                                    dh.ExecuteSql($@"UPDATE xraytest SET xt_url = 'http://192.168.41.232:8098/Xray/{DateTime.Now.ToString("yyyyMMdd")}/{SN.Replace("#", "")}/{Path.GetFileName(uploadFile).Replace("#", "")}',
+                                            xt_macode = '{ma_code.Text.Trim()}',xt_side = '{sideVal.Text}',xt_line = '{lineVal.Text}' WHERE barcode = '{SN}'", "update");
                                 }
-                                
                             }
                         }
 
                         string newFloderName = Path.GetDirectoryName(file);
-                        Directory.Move(file, Path.Combine(newFloderName, "Log_" + Path.GetFileName(file)));
+                        //Directory.Move(file, Path.Combine(newFloderName, "Log_" + Path.GetFileName(file)));
+                        string source = file;
+                        string dest = Path.Combine(newFloderName, "Log_" + Path.GetFileName(file));
+                        MoveDirectoryWithMerge(source, dest);
+
                     }
                     else if(equiType == "CCD")
                     {
@@ -522,6 +555,38 @@ namespace UAS_MES_NEW.Make
             }
         }
 
+        public static void MoveDirectoryWithMerge(string sourceDir, string destDir)
+        {
+            if (!Directory.Exists(sourceDir))
+            {
+                throw new DirectoryNotFoundException($"源目录不存在: {sourceDir}");
+            }
+
+            if (!Directory.Exists(destDir))
+            {
+                Directory.Move(sourceDir, destDir);
+                return;
+            }
+            foreach (string subDir in Directory.GetDirectories(sourceDir, "*", SearchOption.TopDirectoryOnly))
+            {
+                string dirName = Path.GetFileName(subDir);
+                string destSubDir = Path.Combine(destDir, dirName);
+                MoveDirectoryWithMerge(subDir, destSubDir);
+            }
+
+            foreach (string file in Directory.GetFiles(sourceDir, "*", SearchOption.TopDirectoryOnly))
+            {
+                string fileName = Path.GetFileName(file);
+                string destFile = Path.Combine(destDir, fileName);
+
+                if (File.Exists(destFile))
+                {
+                    File.Delete(destFile);
+                }
+                File.Move(file, destFile);
+            }
+            Directory.Delete(sourceDir);
+        }
 
         private bool InsertDb(List<Log> logs, string PathName, int fileNum)
         {
@@ -710,7 +775,7 @@ namespace UAS_MES_NEW.Make
                 return false;
             }
 
-            string ftpFullPath = $"{ftpTimePath}/{Sn}";
+            string ftpFullPath = $"{ftpTimePath}/{Sn.Replace("#","")}";
             outResult = CreateFtpDirectoryIfNotExists(ftpFullPath, username, password);
             if (outResult.Substring(0, 2) != "OK")
             {
@@ -718,7 +783,7 @@ namespace UAS_MES_NEW.Make
                 return false;
             }
 
-            string remoteFileName = Path.GetFileName(localFilePath);
+            string remoteFileName = Path.GetFileName(localFilePath).Replace("#","");
             string uri = $"{ftpFullPath}/{remoteFileName}";
 
             try