Procházet zdrojové kódy

优化上传关联产品编号

callm před 3 týdny
rodič
revize
beb3ef22d4

+ 64 - 78
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.Designer.cs

@@ -41,11 +41,6 @@ namespace UAS_MES_NEW.Query
             this.SendSop = new System.Windows.Forms.Button();
             this.JPG = new System.Windows.Forms.RadioButton();
             this.SendDGV = new System.Windows.Forms.DataGridView();
-            this.CheckColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.fp_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.psd_iskey = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.ChooseALL = new System.Windows.Forms.Button();
             this.GetSOP = new System.Windows.Forms.Button();
             this.ChoosePrint = new System.Windows.Forms.Button();
@@ -64,14 +59,19 @@ namespace UAS_MES_NEW.Query
             this.RowCount = new System.Windows.Forms.NumericUpDown();
             this.label9 = new System.Windows.Forms.Label();
             this.PDF = new System.Windows.Forms.RadioButton();
+            this.label10 = new System.Windows.Forms.Label();
+            this.pr_code = new System.Windows.Forms.TextBox();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.ps_prodcode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
-            this.label10 = new System.Windows.Forms.Label();
-            this.pr_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
+            this.CheckColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.fp_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.psd_iskey = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.X)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.Y)).BeginInit();
@@ -191,47 +191,6 @@ namespace UAS_MES_NEW.Query
             this.SendDGV.TabIndex = 22;
             this.SendDGV.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.SendDGV_CellPainting);
             // 
-            // CheckColumn
-            // 
-            this.CheckColumn.DataPropertyName = "CheckColumn";
-            this.CheckColumn.HeaderText = "勾选";
-            this.CheckColumn.MinimumWidth = 100;
-            this.CheckColumn.Name = "CheckColumn";
-            this.CheckColumn.Width = 200;
-            // 
-            // fp_name
-            // 
-            this.fp_name.DataPropertyName = "fp_name";
-            this.fp_name.HeaderText = "文件名";
-            this.fp_name.MinimumWidth = 10;
-            this.fp_name.Name = "fp_name";
-            this.fp_name.Width = 200;
-            // 
-            // fp_path
-            // 
-            this.fp_path.DataPropertyName = "fp_path";
-            this.fp_path.HeaderText = "路径";
-            this.fp_path.MinimumWidth = 10;
-            this.fp_path.Name = "fp_path";
-            this.fp_path.Width = 200;
-            // 
-            // psd_iskey
-            // 
-            this.psd_iskey.DataPropertyName = "psd_iskey";
-            this.psd_iskey.HeaderText = "是否关键工序";
-            this.psd_iskey.MinimumWidth = 10;
-            this.psd_iskey.Name = "psd_iskey";
-            this.psd_iskey.Width = 200;
-            // 
-            // issend
-            // 
-            this.issend.DataPropertyName = "issend";
-            this.issend.HeaderText = "是否成功发送";
-            this.issend.MinimumWidth = 10;
-            this.issend.Name = "issend";
-            this.issend.Visible = false;
-            this.issend.Width = 200;
-            // 
             // ChooseALL
             // 
             this.ChooseALL.Location = new System.Drawing.Point(865, 61);
@@ -417,6 +376,24 @@ namespace UAS_MES_NEW.Query
             this.PDF.Text = "PDF";
             this.PDF.UseVisualStyleBackColor = true;
             // 
+            // label10
+            // 
+            this.label10.AutoSize = true;
+            this.label10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label10.Location = new System.Drawing.Point(17, 444);
+            this.label10.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label10.Name = "label10";
+            this.label10.Size = new System.Drawing.Size(146, 41);
+            this.label10.TabIndex = 242;
+            this.label10.Text = "产品编号";
+            // 
+            // pr_code
+            // 
+            this.pr_code.Location = new System.Drawing.Point(218, 450);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Size = new System.Drawing.Size(578, 35);
+            this.pr_code.TabIndex = 243;
+            // 
             // dataGridViewCheckBoxColumn1
             // 
             this.dataGridViewCheckBoxColumn1.DataPropertyName = "CheckColumn";
@@ -477,45 +454,54 @@ namespace UAS_MES_NEW.Query
             this.ps_prodcode.TextBoxEnable = false;
             this.ps_prodcode.UserControlTextChanged += new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox.OnTextChange(this.ps_prodcode_UserControlTextChanged);
             // 
-            // label10
+            // CheckColumn
             // 
-            this.label10.AutoSize = true;
-            this.label10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(17, 444);
-            this.label10.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label10.Name = "label10";
-            this.label10.Size = new System.Drawing.Size(146, 41);
-            this.label10.TabIndex = 242;
-            this.label10.Text = "产品编号";
+            this.CheckColumn.DataPropertyName = "CheckColumn";
+            this.CheckColumn.HeaderText = "勾选";
+            this.CheckColumn.MinimumWidth = 100;
+            this.CheckColumn.Name = "CheckColumn";
+            this.CheckColumn.Width = 200;
             // 
-            // pr_code
+            // fp_name
             // 
-            this.pr_code.AllPower = "ifall";
-            this.pr_code.Caller = null;
-            this.pr_code.Condition = null;
-            this.pr_code.DBTitle = "选择物料";
-            this.pr_code.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.pr_code.FormName = null;
-            this.pr_code.Location = new System.Drawing.Point(218, 444);
-            this.pr_code.Margin = new System.Windows.Forms.Padding(5);
-            this.pr_code.Name = "pr_code";
-            this.pr_code.Power = "ifspecial";
-            this.pr_code.ReturnData = null;
-            this.pr_code.SelectField = null;
-            this.pr_code.SetValueField = null;
-            this.pr_code.Size = new System.Drawing.Size(580, 44);
-            this.pr_code.TabIndex = 241;
-            this.pr_code.TableName = null;
-            this.pr_code.Tag = "";
-            this.pr_code.TextBoxEnable = false;
+            this.fp_name.DataPropertyName = "fp_name";
+            this.fp_name.HeaderText = "文件名";
+            this.fp_name.MinimumWidth = 10;
+            this.fp_name.Name = "fp_name";
+            this.fp_name.Width = 200;
+            // 
+            // fp_path
+            // 
+            this.fp_path.DataPropertyName = "fp_path";
+            this.fp_path.HeaderText = "路径";
+            this.fp_path.MinimumWidth = 10;
+            this.fp_path.Name = "fp_path";
+            this.fp_path.Width = 200;
+            // 
+            // psd_iskey
+            // 
+            this.psd_iskey.DataPropertyName = "psd_iskey";
+            this.psd_iskey.HeaderText = "是否关键工序";
+            this.psd_iskey.MinimumWidth = 10;
+            this.psd_iskey.Name = "psd_iskey";
+            this.psd_iskey.Width = 200;
+            // 
+            // issend
+            // 
+            this.issend.DataPropertyName = "issend";
+            this.issend.HeaderText = "是否成功发送";
+            this.issend.MinimumWidth = 10;
+            this.issend.Name = "issend";
+            this.issend.Visible = false;
+            this.issend.Width = 200;
             // 
             // Query_SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1945, 1234);
-            this.Controls.Add(this.label10);
             this.Controls.Add(this.pr_code);
+            this.Controls.Add(this.label10);
             this.Controls.Add(this.PDF);
             this.Controls.Add(this.label9);
             this.Controls.Add(this.RowCount);
@@ -602,6 +588,6 @@ namespace UAS_MES_NEW.Query
         private System.Windows.Forms.Label label9;
         private System.Windows.Forms.RadioButton PDF;
         private System.Windows.Forms.Label label10;
-        private SearchTextBox pr_code;
+        private System.Windows.Forms.TextBox pr_code;
     }
 }

+ 12 - 86
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

@@ -47,12 +47,12 @@ namespace UAS_MES_NEW.Query
             ps_prodcode.Condition = "";
             ps_prodcode.DbChange += nr_rule_DBChange;
 
-            pr_code.TableName = "product";
-            pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_spec # 产品规格";
-            pr_code.FormName = Name;
-            pr_code.DBTitle = "物料查询";
-            pr_code.Condition = "pr_code not like '%LX%'";
-            pr_code.SetValueField = new string[] { "pr_code" };
+            //pr_code.TableName = "product";
+            //pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_spec # 产品规格";
+            //pr_code.FormName = Name;
+            //pr_code.DBTitle = "物料查询";
+            //pr_code.Condition = "pr_code not like '%LX%'";
+            //pr_code.SetValueField = new string[] { "pr_code" };
             DateTime targetMonth = DateCode.Value.AddMonths(2);
             DateTime endOfMonth = new DateTime(targetMonth.Year, targetMonth.Month,
                                                DateTime.DaysInMonth(targetMonth.Year, targetMonth.Month));
@@ -80,21 +80,13 @@ namespace UAS_MES_NEW.Query
             //}
             if (JPG.Checked)
             {
-                string fileName = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".xls", "").Replace(".xlsx", "");
+                string fileName = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".xlsx", "").Replace(".xls", "");
                 // 入库的ps_prodcode用完整文件名,如 (R1)WI-LC-31-544 冷端热端铜柱焊接组件检漏作业指导书x
                 ps_prodcode.Text = fileName;
                 // 匹配/删除时用截取出来的编号,如 WI-LC-31-544(新旧版本号都指向同一条数据)
                 string prodCode = GetProdCodeFromFileName(fileName);
                 OperatResult.AppendText("解析SOP编号: " + prodCode + ",文件名: " + ps_prodcode.Text + "\n");
-                pr_code_Leave(new object(), new EventArgs());
                 Workbook workbook = new Workbook(FilePath.Text);
-                string pnTools = GetPnToolsFromExcel(workbook);
-                if (pnTools == null)
-                {
-                    // 整个Excel都没有PN/TOOLS列时,回退用表单上的产品编号
-                    pnTools = pr_code.Text;
-                }
-                OperatResult.AppendText("解析PN/TOOLS: " + pnTools + "\n");
                 // 匹配已存在的旧数据:新旧版本号不同(如(R0)/(R1))、或历史数据存的是完整文件名,都按中间不变的SOP编号(如WI-LC-31-544)来匹配
                 List<string> oldIds = FindDuplicatedSopIds(prodCode);
                 if (oldIds.Count > 0)
@@ -111,22 +103,22 @@ namespace UAS_MES_NEW.Query
                 ps_code.Text = code;
                 if (VaildDate.Checked)
                 {
-                    dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_vailddate,ps_prcode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING',to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd'),'" + pnTools + "')", "insert");
+                    dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_vailddate,ps_prcode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING',to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd'),'" + pr_code.Text + "')", "insert");
                 }
                 else
                 {
-                    dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_prcode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING','" + pnTools + "')", "insert");
+                    dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_prcode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING','" + pr_code.Text + "')", "insert");
                 }
                 List<Worksheet> list = new List<Worksheet>();
                 List<string> filename = new List<string>();
 
                 if (VaildDate.Checked)
                 {
-                    dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_prcode='" + pnTools + "',ps_vailddate=to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') where ps_prodcode='" + ps_prodcode.Text + "'", "update");
+                    dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_prcode='" + pr_code.Text + "',ps_vailddate=to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') where ps_prodcode='" + ps_prodcode.Text + "'", "update");
                 }
                 else
                 {
-                    dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_prcode='" + pnTools + "' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
+                    dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_prcode='" + pr_code.Text + "' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
                 }
 
                 OperatResult.AppendText("一共Sheet: " + workbook.Worksheets.Count + "\n");
@@ -373,7 +365,6 @@ namespace UAS_MES_NEW.Query
                 // 匹配/删除时用截取出来的编号
                 string prodCode = GetProdCodeFromFileName(fileName);
                 OperatResult.AppendText("解析SOP编号: " + prodCode + ",文件名: " + ps_prodcode.Text + "\n");
-                pr_code_Leave(new object(), new EventArgs());
                 // 匹配已存在的旧数据:新旧版本号不同(如(R0)/(R1))、或历史数据存的是完整文件名,都按中间不变的SOP编号(如WI-LC-31-544)来匹配
                 List<string> oldIds = FindDuplicatedSopIds(prodCode);
                 if (oldIds.Count > 0)
@@ -476,72 +467,7 @@ namespace UAS_MES_NEW.Query
         /// 值为JT开头的不记录
         /// 找不到PN/TOOLS列时返回null;找到但内容为空(或被JT过滤完)时返回空字符串
         /// </summary>
-        private string GetPnToolsFromExcel(Workbook workbook)
-        {
-            bool headerFound = false;
-            List<string> values = new List<string>();
-            for (int i = 0; i < workbook.Worksheets.Count; i++)
-            {
-                Worksheet she = workbook.Worksheets[i];
-                Cells cells = she.Cells;
-                int maxRow = cells.MaxDataRow;
-                int maxCol = cells.MaxDataColumn;
-                int headerCol = -1;
-                int headerRow = -1;
-                // 1. 先在单元格中查找PN/TOOLS标题
-                for (int r = 0; r <= maxRow && headerCol < 0; r++)
-                {
-                    for (int c = 0; c <= maxCol; c++)
-                    {
-                        object val = cells[r, c].Value;
-                        if (val == null) continue;
-                        string text = val.ToString().Trim().ToUpper();
-                        if (text.Contains("PN/TOOLS") || text.Contains("PN/TOOLS"))
-                        {
-                            headerCol = c;
-                            headerRow = r;
-                            break;
-                        }
-                    }
-                }
-                // 2. 单元格中没找到时,尝试从形状(文本框)标题中定位列
-                if (headerCol < 0)
-                {
-                    for (int s = 0; s < she.Shapes.Count; s++)
-                    {
-                        string shapeText;
-                        try { shapeText = she.Shapes[s].Text; }
-                        catch { continue; }
-                        if (shapeText != null && shapeText.Trim().ToUpper().Contains("PN/TOOLS"))
-                        {
-                            headerCol = she.Shapes[s].UpperLeftColumn;
-                            headerRow = she.Shapes[s].UpperLeftRow;
-                            break;
-                        }
-                    }
-                }
-                if (headerCol < 0) continue;
-                headerFound = true;
-                // 3. 收集标题下方该列所有非空内容,去重(保持顺序),JT开头的不记录
-                for (int r = headerRow + 1; r <= Math.Max(maxRow, cells.MaxDataRow); r++)
-                {
-                    object val = cells[r, headerCol].Value;
-                    if (val == null) continue;
-                    string text = val.ToString().Trim();
-                    if (text == "") continue;
-                    if (text.ToUpper().StartsWith("JT")) continue;
-                    if (!values.Contains(text))
-                    {
-                        values.Add(text);
-                    }
-                }
-            }
-            if (!headerFound)
-            {
-                return null;
-            }
-            return string.Join(",", values.ToArray());
-        }
+    
 
         /// <summary>
         /// 请求上传图片到阿里云

+ 0 - 15
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.resx

@@ -135,19 +135,4 @@
   <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="CheckColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="fp_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="fp_path.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="psd_iskey.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
 </root>