From 2df69b4e66736d7c9fdb04ab91d4dceccb62858a Mon Sep 17 00:00:00 2001 From: "ruoxing.wang" <88384874@qq.com> Date: Wed, 6 Aug 2025 17:06:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E6=A7=9B=E8=A3=85=E9=85=8D=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PunchingMistake/FrmAssemble.Designer.cs | 41 +++++++++-------- PunchingMistake/FrmAssemble.cs | 24 ++++++---- PunchingMistake/Function2.cs | 61 +++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 29 deletions(-) diff --git a/PunchingMistake/FrmAssemble.Designer.cs b/PunchingMistake/FrmAssemble.Designer.cs index af0ebdf..c6d7a0f 100644 --- a/PunchingMistake/FrmAssemble.Designer.cs +++ b/PunchingMistake/FrmAssemble.Designer.cs @@ -29,6 +29,7 @@ namespace PunchingMistake /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmAssemble)); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.panel1 = new System.Windows.Forms.Panel(); @@ -99,9 +100,9 @@ namespace PunchingMistake this.label8 = new System.Windows.Forms.Label(); this.lbScrewL = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); - this.showHintTimer = new System.Windows.Forms.Timer(); - this.LoadScrewTimer = new System.Windows.Forms.Timer(); - this.txtBoxFocusTimer = new System.Windows.Forms.Timer(); + this.showHintTimer = new System.Windows.Forms.Timer(this.components); + this.LoadScrewTimer = new System.Windows.Forms.Timer(this.components); + this.txtBoxFocusTimer = new System.Windows.Forms.Timer(this.components); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); this.panel12.SuspendLayout(); @@ -232,9 +233,9 @@ namespace PunchingMistake this.lbPlanQty.ForeColor = System.Drawing.Color.LightSeaGreen; this.lbPlanQty.Location = new System.Drawing.Point(150, 195); this.lbPlanQty.Name = "lbPlanQty"; - this.lbPlanQty.Size = new System.Drawing.Size(575, 300); + this.lbPlanQty.Size = new System.Drawing.Size(275, 300); this.lbPlanQty.TabIndex = 3; - this.lbPlanQty.Text = "150"; + this.lbPlanQty.Text = "0"; // // label12 // @@ -268,9 +269,9 @@ namespace PunchingMistake this.lbCompleteQty.ForeColor = System.Drawing.Color.LimeGreen; this.lbCompleteQty.Location = new System.Drawing.Point(150, 179); this.lbCompleteQty.Name = "lbCompleteQty"; - this.lbCompleteQty.Size = new System.Drawing.Size(575, 300); + this.lbCompleteQty.Size = new System.Drawing.Size(275, 300); this.lbCompleteQty.TabIndex = 4; - this.lbCompleteQty.Text = "695"; + this.lbCompleteQty.Text = "0"; // // label13 // @@ -321,6 +322,8 @@ namespace PunchingMistake // // txtBarCode // + this.txtBarCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtBarCode.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtBarCode.Location = new System.Drawing.Point(30, 125); this.txtBarCode.Name = "txtBarCode"; @@ -361,9 +364,9 @@ namespace PunchingMistake this.lbPartDesc.ForeColor = System.Drawing.Color.White; this.lbPartDesc.Location = new System.Drawing.Point(32, 115); this.lbPartDesc.Name = "lbPartDesc"; - this.lbPartDesc.Size = new System.Drawing.Size(317, 37); + this.lbPartDesc.Size = new System.Drawing.Size(93, 37); this.lbPartDesc.TabIndex = 4; - this.lbPartDesc.Text = "X247MF S后保冲孔"; + this.lbPartDesc.Text = " "; // // label5 // @@ -398,9 +401,9 @@ namespace PunchingMistake this.lbPart.ForeColor = System.Drawing.Color.White; this.lbPart.Location = new System.Drawing.Point(32, 114); this.lbPart.Name = "lbPart"; - this.lbPart.Size = new System.Drawing.Size(317, 37); + this.lbPart.Size = new System.Drawing.Size(93, 37); this.lbPart.TabIndex = 3; - this.lbPart.Text = "X247MF S后保冲孔"; + this.lbPart.Text = " "; // // label4 // @@ -435,9 +438,9 @@ namespace PunchingMistake this.lbPlan.ForeColor = System.Drawing.Color.White; this.lbPlan.Location = new System.Drawing.Point(32, 117); this.lbPlan.Name = "lbPlan"; - this.lbPlan.Size = new System.Drawing.Size(317, 37); + this.lbPlan.Size = new System.Drawing.Size(112, 37); this.lbPlan.TabIndex = 2; - this.lbPlan.Text = "X247MF S后保冲孔"; + this.lbPlan.Text = " "; // // label3 // @@ -472,9 +475,9 @@ namespace PunchingMistake this.lbStation.ForeColor = System.Drawing.Color.White; this.lbStation.Location = new System.Drawing.Point(23, 108); this.lbStation.Name = "lbStation"; - this.lbStation.Size = new System.Drawing.Size(317, 37); + this.lbStation.Size = new System.Drawing.Size(74, 37); this.lbStation.TabIndex = 1; - this.lbStation.Text = "X247MF S后保冲孔"; + this.lbStation.Text = " "; // // label1 // @@ -546,7 +549,7 @@ namespace PunchingMistake this.btnPlanFinish.Font = new System.Drawing.Font("微软雅黑", 15.85714F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnPlanFinish.ForeColor = System.Drawing.Color.White; this.btnPlanFinish.Location = new System.Drawing.Point(269, 133); - this.btnPlanFinish.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnPlanFinish.Margin = new System.Windows.Forms.Padding(4); this.btnPlanFinish.Name = "btnPlanFinish"; this.btnPlanFinish.Size = new System.Drawing.Size(240, 88); this.btnPlanFinish.TabIndex = 28; @@ -559,7 +562,7 @@ namespace PunchingMistake this.btnPlanSearch.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); this.btnPlanSearch.Font = new System.Drawing.Font("微软雅黑", 15.85714F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnPlanSearch.Location = new System.Drawing.Point(16, 133); - this.btnPlanSearch.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnPlanSearch.Margin = new System.Windows.Forms.Padding(4); this.btnPlanSearch.Name = "btnPlanSearch"; this.btnPlanSearch.Size = new System.Drawing.Size(240, 88); this.btnPlanSearch.TabIndex = 27; @@ -572,7 +575,7 @@ namespace PunchingMistake this.btnPlanDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); this.btnPlanDown.Font = new System.Drawing.Font("微软雅黑", 15.85714F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnPlanDown.Location = new System.Drawing.Point(269, 18); - this.btnPlanDown.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnPlanDown.Margin = new System.Windows.Forms.Padding(4); this.btnPlanDown.Name = "btnPlanDown"; this.btnPlanDown.Size = new System.Drawing.Size(240, 88); this.btnPlanDown.TabIndex = 23; @@ -585,7 +588,7 @@ namespace PunchingMistake this.btnPlanUp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); this.btnPlanUp.Font = new System.Drawing.Font("微软雅黑", 15.85714F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnPlanUp.Location = new System.Drawing.Point(16, 18); - this.btnPlanUp.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnPlanUp.Margin = new System.Windows.Forms.Padding(4); this.btnPlanUp.Name = "btnPlanUp"; this.btnPlanUp.Size = new System.Drawing.Size(240, 88); this.btnPlanUp.TabIndex = 22; diff --git a/PunchingMistake/FrmAssemble.cs b/PunchingMistake/FrmAssemble.cs index 6e68ebf..fbb8c12 100644 --- a/PunchingMistake/FrmAssemble.cs +++ b/PunchingMistake/FrmAssemble.cs @@ -295,9 +295,8 @@ namespace PunchingMistake } } - DataTable productTable = PartScanVerify(); + _partNo2 = PartScanVerify(); - _partNo2 = productTable.Rows[0]["PartNo"].ToString(); _partNo1 = Function2.GetAssemblePartCode(_partNo2, _stationNo); if (lbPart.Text?.ToLower() != _partNo1?.ToLower()) @@ -310,7 +309,7 @@ namespace PunchingMistake //需要校验的关键件 List list = bomTable.AsEnumerable().Where(p => p.Field("IsChecked") == true).ToList(); //螺钉铆钉数量BOM集合 - List list2 = bomTable.AsEnumerable().Where(p => p.Field("PartDesc2").Contains("螺钉") || p.Field("PartDesc2").Contains("铆钉") || p.Field("PartDesc2").Contains("虹膜")).ToList(); + List list2 = bomTable.AsEnumerable().Where(p => !string.IsNullOrEmpty(p.Field("PartDesc2")) &&( p.Field("PartDesc2").Contains("螺钉") || p.Field("PartDesc2").Contains("铆钉") || p.Field("PartDesc2").Contains("虹膜"))).ToList(); if (list.Count > 0) { //需要校验关键件 @@ -358,7 +357,7 @@ namespace PunchingMistake /// 扫描半成品的校验 /// /// - DataTable PartScanVerify() + string PartScanVerify() { if (_sjBarCode.Length != 20) { @@ -368,7 +367,7 @@ namespace PunchingMistake DataTable stockInTable = Function2.SearchStockIn(_sjBarCode); if (stockInTable.Rows.Count == 0) { - throw new Exception("扫描半成品码没有喷涂完工记录,无法使用."); + throw new Exception("扫描半成品码没有喷涂完工记录[StockIn],无法使用."); } DataTable punchTable = Function2.SearchPunchCodeRecord(_sjBarCode); if (punchTable.Rows.Count > 0) @@ -378,12 +377,17 @@ namespace PunchingMistake throw new Exception("扫描半成品码已存在装配记录,无法使用."); } } - DataTable productTable = Function2.GetProductInfo(_sjBarCode.Substring(0, 10)); - if (productTable.Rows.Count == 0) + string paintCode = stockInTable.Rows[0]["PaintCode"].ToString(); + if (string.IsNullOrEmpty(paintCode)) + { + paintCode = Function2.SearchPaintNo(_sjBarCode); + } + if (string.IsNullOrEmpty(paintCode)) { - throw new Exception($"扫描半成品码的存货代码[{_sjBarCode.Substring(0, 10)}]在零件表找不对对应零件号,请检查系统维护."); + throw new Exception($"无法查询到塑件码[{_sjBarCode}]对应的喷涂零件号,请检查颜色配置数据维护"); } - return productTable; + + return paintCode; } bool ScrewCompleteVerify() { @@ -523,7 +527,7 @@ namespace PunchingMistake { try { - lbPartDesc.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + label10.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Thread.Sleep(500); } catch (Exception ex) diff --git a/PunchingMistake/Function2.cs b/PunchingMistake/Function2.cs index 1ace8cc..9f503af 100644 --- a/PunchingMistake/Function2.cs +++ b/PunchingMistake/Function2.cs @@ -243,6 +243,52 @@ namespace PunchingMistake return res; } } + public static string SearchPaintNo(string sjBarCode) + { + DataTable res = new DataTable(); + try + { + string stockNo = sjBarCode.Substring(0, 10); + string sql = $" select * from tb_InspectResult where barcode='{sjBarCode}' and inspectResult='合格'"; + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if(res.Rows.Count == 0) + { + throw new Exception($"塑件码[{sjBarCode}]缺少喷涂质检的合格记录!"); + } + string partcode = res.Rows[0]["ForeignPartCode"].ToString(); + if (string.IsNullOrEmpty(partcode)) + { + string color = res.Rows[0]["remark1"].ToString(); + string sql2 = $" select * from tb_PaintColorInfo where Color='{color}' and StockNo='{stockNo}' "; + DataTable res2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + if (res2.Rows.Count > 0) + { + return res2.Rows[0]["Paint_No"].ToString(); + } + else + { + //DataTable productTable = GetProductInfo(stockNo); + + //string sql3 = $" select * from tb_Color where Des='{color}'"; + //DataTable res3= SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + //if(productTable.Rows.Count>0 && res3.Rows.Count > 0) + //{ + // return productTable.Rows[0]["PartNo"].ToString() + res3.Rows[0]["ColorCode"].ToString(); + //} + throw new Exception($"喷涂颜色表[PaintColorInfo]未配置存货代码[{stockNo}],颜色值[{color}]的零件号"); + + } + } + + return ""; + } + catch (Exception ex) + { + + LogHelper.WriteLog("小件装配,查询StockIn发生异常,异常原因:" + ex.ToString()); + return ""; + } + } public static DataTable SearchPunchCodeRecord(string sjBarCode) { @@ -275,6 +321,21 @@ namespace PunchingMistake return res; } } + public static DataTable GetProductInfo2(string partNo) + { + DataTable res = new DataTable(); + try + { + string sql = $" select Top 1 * from tb_Product where PartNo='{partNo}' "; + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + return res; + } + catch (Exception ex) + { + LogHelper.WriteLog("小件装配,tb_Product,异常原因:" + ex.ToString()); + return res; + } + } public static string GetProductName(string partNo) { DataTable res = new DataTable();