From 3954a0f5230147de3a5a49ea852113da08f3f2b2 Mon Sep 17 00:00:00 2001 From: wyf Date: Fri, 9 May 2025 06:47:19 +0000 Subject: [PATCH] SVN r566 SVN-Revision: r566 --- 插件库/Lskj.PubBomImport/FrmBillInfo.cs | 9 +- 插件库/Lskj.PubBomImport/FrmProgress.cs | 152 ++++++++++++++++++++++-- 2 files changed, 148 insertions(+), 13 deletions(-) diff --git a/插件库/Lskj.PubBomImport/FrmBillInfo.cs b/插件库/Lskj.PubBomImport/FrmBillInfo.cs index 7316303..5c044a4 100644 --- a/插件库/Lskj.PubBomImport/FrmBillInfo.cs +++ b/插件库/Lskj.PubBomImport/FrmBillInfo.cs @@ -543,7 +543,14 @@ namespace Lskj.PubBomImport { this.InitializeHeader(rowItem); } - string controlSql = "select '' as billdocument_id,'0' affirmer,'0' rtagid,'{材料代码}' as productid"; + else + { + if (rowItem != null) + { + DataRow dataRow = BaseImpl.GetDataRowResult($"select '{rowItem["bombb"] + ""}' as bombb,'{rowItem["bombc"] + ""}' as bombc"); + this.InitializeHeader(dataRow); + } + } if (mainRow != null) { //更新 diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index 598bb4e..d67f8ee 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -509,7 +509,7 @@ namespace Lskj.PubBomImport { try { - string namepattern = @"^([A-Z]+(?:-[A-Z]+)*(?:-\d+)+-[A-Z]+\d*)\s*(.+)"; + string namepattern = @"^([A-Z]+(?:-[A-Z]+)*(?:-\d+)+-[A-Z]+\d*)\s*(.*)$"; //string namepattern = @"^(.+?)\s+(.+)$"; string pattern = @"^(.*?)(\d+)?$"; string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue; @@ -558,6 +558,8 @@ namespace Lskj.PubBomImport string code = ""; string name = ""; string sourceCode = ""; + string sourceBB = ""; + int sourceBC = 0; Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern); if (namematch.Success) { @@ -568,6 +570,12 @@ namespace Lskj.PubBomImport if (match.Success) { sourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out sourceBC);//版次 + Match bbMatch = Regex.Match(sourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + sourceBB = bbMatch.Groups[1].Value.Trim(); + } } StringBuilder stringBuilder = new StringBuilder(); if (code.StartsWith("QD")) @@ -604,9 +612,12 @@ namespace Lskj.PubBomImport int.TryParse(detailRow["amount"] + "", out int amount); detailRow["tamount"] = amount; detailRow["amount"] = amount; + detailRow["bak"] = sourceCode; + detailRow["bombb"] = sourceBB; + detailRow["bombc"] = sourceBC; } SetProcessBar(20, allCount); - string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{sourceCode}') as billdocument_id,'0' affirmer,'0' rtagid,'{sourceCode}' as productid"; + string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{sourceCode}') as billdocument_id,'0' affirmer,'0' rtagid,'{sourceCode}' as productid,'{sourceCode}' as bak,'{sourceBB}' as bombb,'{sourceBC}' as bombc"; // 处理单据表头数据 DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql); SetProcessBar(40, allCount); @@ -641,6 +652,8 @@ namespace Lskj.PubBomImport string code = ""; string name = ""; string sourceCode = ""; + string sourceBB = ""; + int sourceBC = 0; Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern); if (namematch.Success) { @@ -651,6 +664,12 @@ namespace Lskj.PubBomImport if (match.Success) { sourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out sourceBC);//版次 + Match bbMatch = Regex.Match(sourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + sourceBB = bbMatch.Groups[1].Value.Trim(); + } } //更新或新增并备份清单 int.TryParse(Model.FirstRowIndex, out int index); @@ -678,6 +697,8 @@ namespace Lskj.PubBomImport detailRow["tamount"] = 1; detailRow["amount"] = lastAmount; detailRow["bak"] = sourceCode; + detailRow["bombb"] = sourceBB; + detailRow["bombc"] = sourceBC; } SetProcessBar(20, allCount); string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productCode}') as billdocument_id,'0' affirmer,'0' rtagid,'{productCode}' as productid"; @@ -719,6 +740,8 @@ namespace Lskj.PubBomImport string code = ""; string name = ""; string sourceCode = ""; + string sourceBB = ""; + int sourceBC = 0; Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern); if (namematch.Success) { @@ -729,6 +752,12 @@ namespace Lskj.PubBomImport if (match.Success) { sourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out sourceBC);//版次 + Match bbMatch = Regex.Match(sourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + sourceBB = bbMatch.Groups[1].Value.Trim(); + } } //更新或新增并备份清单 int.TryParse(Model.FirstRowIndex, out int index); @@ -755,7 +784,7 @@ namespace Lskj.PubBomImport if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD")) { - string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%' and speciesno = '010106' and parentId in (select dirid from p_fm_directorytab where dllcoid = '1000202')"; + string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%' and speciesno = '010106' and parentId in (select dirid from p_fm_directorytab where dllcoid = '1000202') and isdisabled = '0'"; DataRow fileRow = BaseImpl.GetDataRowResult(fileSql); string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : ""; @@ -815,6 +844,28 @@ namespace Lskj.PubBomImport } if (childInfo != null) { + string childcode = ""; + string childname = ""; + string childsourceCode = ""; + string childsourceBB = ""; + int childsourceBC = 0; + namematch = Regex.Match(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), namepattern); + if (namematch.Success) + { + childcode = namematch.Groups[1].Value.Trim(); + childname = namematch.Groups[2].Value.Trim(); + } + match = Regex.Match(childcode, pattern); + if (match.Success) + { + childsourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out childsourceBC);//版次 + Match bbMatch = Regex.Match(childsourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + childsourceBB = bbMatch.Groups[1].Value.Trim(); + } + } if (childCode.StartsWith("ZZQD")) { DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); @@ -839,7 +890,9 @@ namespace Lskj.PubBomImport DataRow childRow = childTable.NewRow(); childRow["ProductId"] = zzqdItem["物料编码"] + ""; childRow["appellation"] = zzqdItem["名称"] + ""; - childRow["bak"] = childCode; + childRow["bak"] = childsourceCode; + childRow["bombb"] = childsourceBB; + childRow["bombc"] = childsourceBC; childRow["tamount"] = parentRow["套数"] + ""; int.TryParse(zzqdItem["数量"] + "", out int amount); childRow["amount"] = amount * tamount; @@ -851,7 +904,9 @@ namespace Lskj.PubBomImport DataRow childRow = childTable.NewRow(); childRow["ProductId"] = parentRow["图号"] + ""; childRow["appellation"] = parentRow["名称"] + ""; - childRow["bak"] = parentRow["备注"] + ""; + childRow["bak"] = childsourceCode; + childRow["bombb"] = childsourceBB; + childRow["bombc"] = childsourceBC; childRow["tamount"] = parentRow["套数"] + ""; childRow["amount"] = parentRow["套数"] + ""; childTable.Rows.Add(childRow); @@ -864,7 +919,7 @@ namespace Lskj.PubBomImport { throw new Exception($"MX明细数据为空"); } - string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productCode}') as billdocument_id,'0' affirmer,'0' rtagid,'{productCode}' as productid"; + string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productCode}') as billdocument_id,'0' affirmer,'0' rtagid,'{productCode}' as productid,'{sourceCode}' as bak,'{sourceBB}' as bombb,'{sourceBC}' as bombc"; // 处理单据表头数据 DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql); if (masterRow == null) @@ -1098,6 +1153,9 @@ namespace Lskj.PubBomImport { try { + string namepattern = @"^([A-Z]+(?:-[A-Z]+)*(?:-\d+)+-[A-Z]+\d*)\s*(.*)$"; + //string namepattern = @"^(.+?)\s+(.+)$"; + string pattern = @"^(.*?)(\d+)?$"; int execOrder = 1; DataRow mxRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith("MX")).FirstOrDefault(); if (mxRow != null) @@ -1117,6 +1175,28 @@ namespace Lskj.PubBomImport FileInfo mxInfo = new FileInfo(mxDirPath); if (mxInfo != null) { + string mxcode = ""; + string mxname = ""; + string mxsourceCode = ""; + string mxsourceBB = ""; + int mxsourceBC = 0; + Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(mxInfo.Name).Trim(), namepattern); + if (namematch.Success) + { + mxcode = namematch.Groups[1].Value.Trim(); + mxname = namematch.Groups[2].Value.Trim(); + } + Match match = Regex.Match(mxcode, pattern); + if (match.Success) + { + mxsourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out mxsourceBC);//版次 + Match bbMatch = Regex.Match(mxsourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + mxsourceBB = bbMatch.Groups[1].Value.Trim(); + } + } FrmBillInfo frmBillInfo = new FrmBillInfo(); DataTable parentTable = ExcelToDatatable(mxInfo.FullName, Model, "", 5); parentTable = parentTable.Rows.Cast().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "") && !string.IsNullOrEmpty(n["名称"] + "")).ToList().CopyToDataTable(); @@ -1179,7 +1259,7 @@ namespace Lskj.PubBomImport foreach (DataRow parentRow in parentTable.Rows) { int.TryParse(parentRow["套数"] + "", out int tamount); - string code = parentRow["图号"] + ""; + string code = (parentRow["图号"] + "").Trim(); if (code.StartsWith("QD") || code.StartsWith("ZZQD")) { DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault(); @@ -1194,6 +1274,28 @@ namespace Lskj.PubBomImport } if (childInfo != null) { + string childcode = ""; + string childname = ""; + string childsourceCode = ""; + string childsourceBB = ""; + int childsourceBC = 0; + namematch = Regex.Match(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), namepattern); + if (namematch.Success) + { + childcode = namematch.Groups[1].Value.Trim(); + childname = namematch.Groups[2].Value.Trim(); + } + match = Regex.Match(childcode, pattern); + if (match.Success) + { + childsourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out childsourceBC);//版次 + Match bbMatch = Regex.Match(childsourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + childsourceBB = bbMatch.Groups[1].Value.Trim(); + } + } if (code.StartsWith("ZZQD")) { DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); @@ -1218,7 +1320,9 @@ namespace Lskj.PubBomImport DataRow childRow = childTable.NewRow(); childRow["ProductId"] = zzqdItem["物料编码"] + ""; childRow["appellation"] = zzqdItem["名称"] + ""; - childRow["bak"] = code; + childRow["bak"] = childsourceCode; + childRow["bombb"] = childsourceBB; + childRow["bombc"] = childsourceBC; childRow["tamount"] = parentRow["套数"] + ""; int.TryParse(zzqdItem["数量"] + "", out int amount); childRow["amount"] = amount * tamount; @@ -1230,7 +1334,9 @@ namespace Lskj.PubBomImport DataRow childRow = childTable.NewRow(); childRow["ProductId"] = parentRow["图号"] + ""; childRow["appellation"] = parentRow["名称"] + ""; - childRow["bak"] = parentRow["备注"] + ""; + childRow["bak"] = childsourceCode; + childRow["bombb"] = childsourceBB; + childRow["bombc"] = childsourceBC; childRow["tamount"] = parentRow["套数"] + ""; childRow["amount"] = parentRow["套数"] + ""; childTable.Rows.Add(childRow); @@ -1245,7 +1351,7 @@ namespace Lskj.PubBomImport throw new Exception($"MX明细数据为空"); } SetProcessBar(40, 0); - string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productId}') as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid"; + string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productId}') as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid,'{mxcode}' as bak,'{mxsourceBB}' as bombb,'{mxsourceBC}' as bombc"; // 处理单据表头数据 DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql); SetProcessBar(60, 0); @@ -1319,6 +1425,29 @@ namespace Lskj.PubBomImport } if (childInfo != null) { + + string qdcode = ""; + string qdname = ""; + string qdsourceCode = ""; + string qdsourceBB = ""; + int qdsourceBC = 0; + namematch = Regex.Match(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), namepattern); + if (namematch.Success) + { + qdcode = namematch.Groups[1].Value.Trim(); + qdname = namematch.Groups[2].Value.Trim(); + } + match = Regex.Match(qdcode, pattern); + if (match.Success) + { + qdsourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out qdsourceBC);//版次 + Match bbMatch = Regex.Match(qdsourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + qdsourceBB = bbMatch.Groups[1].Value.Trim(); + } + } DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'"); if (productRow == null) { @@ -1344,7 +1473,7 @@ namespace Lskj.PubBomImport throw new Exception($"{code}明细数据为空"); } SetProcessBar(40, allCount); - string childBillMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{code}') as billdocument_id,'0' affirmer,'0' rtagid,'{code}' as productid"; + string childBillMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{code}') as billdocument_id,'0' affirmer,'0' rtagid,'{code}' as productid,'{qdcode}' as bak,'{qdsourceBB}' as bombb,'{qdsourceBC}' as bombc"; // 处理单据表头数据 DataRow childMasterRow = BillImpl.GetDataRowResult(childBillMasterSql); SetProcessBar(60, allCount); @@ -1510,7 +1639,6 @@ namespace Lskj.PubBomImport { try { - string execGuid = sourceRow["qms_wjgg_uuid"] + ""; string productid = sourceRow["qms_wjgg_productid"] + ""; int.TryParse(sourceRow["fileId"] + "", out int copyFileId);