Explorar o código

优化虚拟箱号处理

yhluo hai 1 semana
pai
achega
ce768863e5
Modificáronse 3 ficheiros con 112 adicións e 85 borrados
  1. 91 78
      UAS_Tools_HY/Main.Designer.cs
  2. 18 7
      UAS_Tools_HY/Main.cs
  3. 3 0
      UAS_Tools_HY/Main.resx

+ 91 - 78
UAS_Tools_HY/Main.Designer.cs

@@ -34,13 +34,6 @@
             this.checkPagination = new System.Windows.Forms.TabControl();
             this.checkPage1 = new System.Windows.Forms.TabPage();
             this.Datas = new System.Windows.Forms.DataGridView();
-            this.DbarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.DboxCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.DcountCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.DtimeCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Duser = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.DisCheckdcr = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Dresult = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.checkPage2 = new System.Windows.Forms.TabPage();
             this.checkSetting = new System.Windows.Forms.TableLayoutPanel();
             this.checkSettingRight = new System.Windows.Forms.GroupBox();
@@ -150,6 +143,14 @@
             this.currUser = new System.Windows.Forms.Label();
             this.currTime = new System.Windows.Forms.Label();
             this.top = new System.Windows.Forms.Panel();
+            this.DbarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.DboxCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.DcountCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.DtimeCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.Duser = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.DisCheckdcr = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.Dresult = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.visualOutboxNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Pagination.SuspendLayout();
             this.Page1.SuspendLayout();
             this.checkPagination.SuspendLayout();
@@ -249,7 +250,8 @@
             this.DtimeCol,
             this.Duser,
             this.DisCheckdcr,
-            this.Dresult});
+            this.Dresult,
+            this.visualOutboxNo});
             this.Datas.Dock = System.Windows.Forms.DockStyle.Fill;
             this.Datas.Location = new System.Drawing.Point(3, 3);
             this.Datas.MultiSelect = false;
@@ -260,69 +262,6 @@
             this.Datas.Size = new System.Drawing.Size(1224, 329);
             this.Datas.TabIndex = 0;
             // 
-            // DbarCode
-            // 
-            this.DbarCode.DataPropertyName = "DbarCode";
-            this.DbarCode.HeaderText = "条码";
-            this.DbarCode.MinimumWidth = 8;
-            this.DbarCode.Name = "DbarCode";
-            this.DbarCode.ReadOnly = true;
-            this.DbarCode.Width = 240;
-            // 
-            // DboxCode
-            // 
-            this.DboxCode.DataPropertyName = "DboxCode";
-            this.DboxCode.HeaderText = "箱号";
-            this.DboxCode.MinimumWidth = 8;
-            this.DboxCode.Name = "DboxCode";
-            this.DboxCode.ReadOnly = true;
-            this.DboxCode.Width = 260;
-            // 
-            // DcountCol
-            // 
-            this.DcountCol.DataPropertyName = "DcountCol";
-            this.DcountCol.HeaderText = "扫描次数";
-            this.DcountCol.MinimumWidth = 8;
-            this.DcountCol.Name = "DcountCol";
-            this.DcountCol.ReadOnly = true;
-            this.DcountCol.Width = 120;
-            // 
-            // DtimeCol
-            // 
-            this.DtimeCol.DataPropertyName = "DtimeCol";
-            this.DtimeCol.HeaderText = "扫描时间";
-            this.DtimeCol.MinimumWidth = 8;
-            this.DtimeCol.Name = "DtimeCol";
-            this.DtimeCol.ReadOnly = true;
-            this.DtimeCol.Width = 180;
-            // 
-            // Duser
-            // 
-            this.Duser.DataPropertyName = "Duser";
-            this.Duser.HeaderText = "扫描人";
-            this.Duser.MinimumWidth = 8;
-            this.Duser.Name = "Duser";
-            this.Duser.ReadOnly = true;
-            this.Duser.Width = 120;
-            // 
-            // DisCheckdcr
-            // 
-            this.DisCheckdcr.DataPropertyName = "DisCheckdcr";
-            this.DisCheckdcr.HeaderText = "是否核对DCR";
-            this.DisCheckdcr.MinimumWidth = 8;
-            this.DisCheckdcr.Name = "DisCheckdcr";
-            this.DisCheckdcr.ReadOnly = true;
-            this.DisCheckdcr.Width = 160;
-            // 
-            // Dresult
-            // 
-            this.Dresult.DataPropertyName = "Dresult";
-            this.Dresult.HeaderText = "扫描结果";
-            this.Dresult.MinimumWidth = 8;
-            this.Dresult.Name = "Dresult";
-            this.Dresult.ReadOnly = true;
-            this.Dresult.Width = 120;
-            // 
             // checkPage2
             // 
             this.checkPage2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@@ -520,6 +459,7 @@
             this.RulesCol4,
             this.RulesCol5,
             this.RulesCol6});
+            this.RulesDatas.Cursor = System.Windows.Forms.Cursors.Hand;
             this.RulesDatas.Dock = System.Windows.Forms.DockStyle.Fill;
             this.RulesDatas.Location = new System.Drawing.Point(0, 83);
             this.RulesDatas.MultiSelect = false;
@@ -527,6 +467,7 @@
             this.RulesDatas.ReadOnly = true;
             this.RulesDatas.RowHeadersWidth = 62;
             this.RulesDatas.RowTemplate.Height = 30;
+            this.RulesDatas.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.RulesDatas.Size = new System.Drawing.Size(1230, 252);
             this.RulesDatas.TabIndex = 16;
             this.RulesDatas.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.RulesDatas_CellMouseClick);
@@ -1532,6 +1473,77 @@
             this.top.Size = new System.Drawing.Size(1254, 625);
             this.top.TabIndex = 3;
             // 
+            // DbarCode
+            // 
+            this.DbarCode.DataPropertyName = "DbarCode";
+            this.DbarCode.HeaderText = "条码";
+            this.DbarCode.MinimumWidth = 8;
+            this.DbarCode.Name = "DbarCode";
+            this.DbarCode.ReadOnly = true;
+            this.DbarCode.Width = 240;
+            // 
+            // DboxCode
+            // 
+            this.DboxCode.DataPropertyName = "DboxCode";
+            this.DboxCode.HeaderText = "箱号";
+            this.DboxCode.MinimumWidth = 8;
+            this.DboxCode.Name = "DboxCode";
+            this.DboxCode.ReadOnly = true;
+            this.DboxCode.Width = 260;
+            // 
+            // DcountCol
+            // 
+            this.DcountCol.DataPropertyName = "DcountCol";
+            this.DcountCol.HeaderText = "扫描次数";
+            this.DcountCol.MinimumWidth = 8;
+            this.DcountCol.Name = "DcountCol";
+            this.DcountCol.ReadOnly = true;
+            this.DcountCol.Width = 120;
+            // 
+            // DtimeCol
+            // 
+            this.DtimeCol.DataPropertyName = "DtimeCol";
+            this.DtimeCol.HeaderText = "扫描时间";
+            this.DtimeCol.MinimumWidth = 8;
+            this.DtimeCol.Name = "DtimeCol";
+            this.DtimeCol.ReadOnly = true;
+            this.DtimeCol.Width = 180;
+            // 
+            // Duser
+            // 
+            this.Duser.DataPropertyName = "Duser";
+            this.Duser.HeaderText = "扫描人";
+            this.Duser.MinimumWidth = 8;
+            this.Duser.Name = "Duser";
+            this.Duser.ReadOnly = true;
+            this.Duser.Width = 120;
+            // 
+            // DisCheckdcr
+            // 
+            this.DisCheckdcr.DataPropertyName = "DisCheckdcr";
+            this.DisCheckdcr.HeaderText = "是否核对DCR";
+            this.DisCheckdcr.MinimumWidth = 8;
+            this.DisCheckdcr.Name = "DisCheckdcr";
+            this.DisCheckdcr.ReadOnly = true;
+            this.DisCheckdcr.Width = 160;
+            // 
+            // Dresult
+            // 
+            this.Dresult.DataPropertyName = "Dresult";
+            this.Dresult.HeaderText = "扫描结果";
+            this.Dresult.MinimumWidth = 8;
+            this.Dresult.Name = "Dresult";
+            this.Dresult.ReadOnly = true;
+            this.Dresult.Width = 120;
+            // 
+            // visualOutboxNo
+            // 
+            this.visualOutboxNo.HeaderText = "visualOutboxNo";
+            this.visualOutboxNo.MinimumWidth = 8;
+            this.visualOutboxNo.Name = "visualOutboxNo";
+            this.visualOutboxNo.ReadOnly = true;
+            this.visualOutboxNo.Visible = false;
+            // 
             // Main
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
@@ -1663,13 +1675,6 @@
         private System.Windows.Forms.Label rulesLab2;
         private System.Windows.Forms.TextBox rulesInput2;
         private System.Windows.Forms.Button rulesAdd;
-        private System.Windows.Forms.DataGridViewTextBoxColumn DbarCode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn DboxCode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn DcountCol;
-        private System.Windows.Forms.DataGridViewTextBoxColumn DtimeCol;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Duser;
-        private System.Windows.Forms.DataGridViewTextBoxColumn DisCheckdcr;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Dresult;
         private System.Windows.Forms.Button DRulesBtn1;
         private System.Windows.Forms.DataGridViewTextBoxColumn ruleId;
         private System.Windows.Forms.DataGridViewTextBoxColumn RulesCol1;
@@ -1713,5 +1718,13 @@
         private System.Windows.Forms.Label handExeLab1;
         private System.Windows.Forms.TextBox handExeVal;
         private System.Windows.Forms.Button buildConfirm;
+        private System.Windows.Forms.DataGridViewTextBoxColumn DbarCode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn DboxCode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn DcountCol;
+        private System.Windows.Forms.DataGridViewTextBoxColumn DtimeCol;
+        private System.Windows.Forms.DataGridViewTextBoxColumn Duser;
+        private System.Windows.Forms.DataGridViewTextBoxColumn DisCheckdcr;
+        private System.Windows.Forms.DataGridViewTextBoxColumn Dresult;
+        private System.Windows.Forms.DataGridViewTextBoxColumn visualOutboxNo;
     }
 }

+ 18 - 7
UAS_Tools_HY/Main.cs

@@ -183,6 +183,11 @@ namespace UAS_MES_Tools
             }
             else
             {
+                if (string.IsNullOrEmpty(BoxNo.Text) && string.IsNullOrEmpty(BaseUtil.GetCacheData("VisualOutboxNo").ToString()))
+                {
+                    BaseUtil.SetCacheData("VisualOutboxNo", DateTime.Now.ToString("yyyyMMddHHmmss"));
+                    BoxNo_KeyDown(null, new KeyEventArgs(Keys.Enter));
+                }
                 DataGridViewRow row = new DataGridViewRow();
                 row.CreateCells(Datas);
                 row.Cells[0].Value = SN.Text.Trim();
@@ -192,6 +197,7 @@ namespace UAS_MES_Tools
                 row.Cells[4].Value = _UserName;
                 row.Cells[5].Value = radio1.Checked ? "是" : "否";
                 row.Cells[6].Value = checkRes ? "OK" : "NG";
+                row.Cells[7].Value = string.IsNullOrEmpty(BoxNo.Text) ? BaseUtil.GetCacheData("VisualOutboxNo") : "";
                 Datas.Rows.Add(row);
                 PlaySound("OK");
                 Datas.FirstDisplayedScrollingRowIndex = Datas.Rows.Count - 1;
@@ -214,6 +220,7 @@ namespace UAS_MES_Tools
                         BoxNo.SelectAll();
                         //BoxNo.Text = "";
                         //Datas.Rows.Clear();
+                        BaseUtil.SetCacheData("VisualOutboxNo", "");
 
                         Application excelApp = null;
                         Workbook workbook = null;
@@ -222,7 +229,9 @@ namespace UAS_MES_Tools
                         string tempTemplatePath = null;
                         try
                         {
-                            string checkExportModel = Path.Combine(settingRightInput2.Text, BoxNo.Text.Trim() + ".xlsx");
+                            string visualOutboxNo = string.IsNullOrEmpty(row.Cells[1].Value.ToString()) ? row.Cells[7].Value.ToString() : row.Cells[1].Value.ToString();
+                            string generateFileName = string.IsNullOrEmpty(row.Cells[1].Value.ToString()) ? DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") : row.Cells[1].Value.ToString();
+                            string checkExportModel = Path.Combine(settingRightInput2.Text, generateFileName + ".xlsx");
 
                             if (string.IsNullOrEmpty(settingRightInput2.Text) || !Directory.Exists(settingRightInput2.Text))
                             {
@@ -247,11 +256,11 @@ namespace UAS_MES_Tools
                             object sheetIndex = 1;
                             worksheet = (Worksheet)workbook.Worksheets[sheetIndex];
 
-                            dt = ConnectDB.ExecuteSelect($@"select * from g_packing_sncheck where outbox_no = '{BoxNo.Text.Trim()}'");
+                            dt = ConnectDB.ExecuteSelect($@"select * from g_packing_sncheck where outbox_no = '{visualOutboxNo}'");
                             if (dt.Rows.Count > 0)
                             {
                                 worksheet.Cells[1, 3] = DateTime.Now.ToString("yyyy-MM-dd");
-                                worksheet.Cells[1, 7] = BoxNo.Text.Trim();
+                                worksheet.Cells[1, 7] = visualOutboxNo;
 
                                 int startRow = 3;
                                 int startColumn = 2;
@@ -373,9 +382,10 @@ namespace UAS_MES_Tools
         {
             int inputSum = Convert.ToInt32(dCount.Text);
             dCount.Text = (inputSum + 1).ToString();
+            string visualOutboxNo = string.IsNullOrEmpty(row.Cells[1].Value.ToString()) ? row.Cells[7].Value.ToString() : row.Cells[1].Value.ToString();
             int insertCount = ConnectDB.ExecuteInsert($@"INSERT INTO g_packing_sncheck (work_order,part_no,sn,outbox_no,
                             count,update_time,update_name,check_id,rule_name,rule_value,capacity,ISCHECHK_DCR,rule_id) 
-                            VALUES ( '', '', '{row.Cells[0].Value}', '{row.Cells[1].Value}',
+                            VALUES ( '', '', '{row.Cells[0].Value}', '{visualOutboxNo}',
                             '{row.Cells[2].Value}',sysdate,'{_UserName}',packcheckid_seq.NEXTVAL,'{dRules.Text.Trim()}','{curRule}','{dSum.Text}','{row.Cells[5].Value}','{curRuleId}' )");
             if (Convert.ToInt32(dCount.Text) < Convert.ToInt32(dSum.Text))
             {
@@ -415,8 +425,9 @@ namespace UAS_MES_Tools
         private void BoxNo_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode != Keys.Enter) return;
-
-            dt = ConnectDB.ExecuteSelect($@"SELECT * FROM g_packing_sncheck a,g_packing_rules b WHERE a.outbox_no = '{BoxNo.Text}' AND a.rule_id = b.rule_id");
+            
+            string visualOutboxNo = string.IsNullOrEmpty(BoxNo.Text) ? BaseUtil.GetCacheData("VisualOutboxNo").ToString() : BoxNo.Text.Trim();
+            dt = ConnectDB.ExecuteSelect($@"SELECT * FROM g_packing_sncheck a,g_packing_rules b WHERE a.outbox_no = '{visualOutboxNo}' AND a.rule_id = b.rule_id");
             if (dt.Rows.Count > 0)
             {
                 if (Convert.ToInt32(dt.Rows[0]["CAPACITY"].ToString()) > dt.Rows.Count)
@@ -454,7 +465,7 @@ namespace UAS_MES_Tools
                 {
                     BoxNo.Focus();
                     BoxNo.SelectAll();
-                    MessageBox.Show($"核对完成,此箱{BoxNo.Text} 已装满{dt.Rows[0]["CAPACITY"].ToString()} 个,请扫描未核对箱号", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    MessageBox.Show($"核对完成,此箱{visualOutboxNo} 已装满{dt.Rows[0]["CAPACITY"].ToString()} 个,请扫描未核对箱号", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     BoxNo.Text = "";
                     return;
                 }

+ 3 - 0
UAS_Tools_HY/Main.resx

@@ -138,6 +138,9 @@
   <metadata name="Dresult.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="visualOutboxNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="ruleId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>