diff --git a/插件库/Lskj.PubBomImport/FrmMain.cs b/插件库/Lskj.PubBomImport/FrmMain.cs index 3cc5e53..8e975f7 100644 --- a/插件库/Lskj.PubBomImport/FrmMain.cs +++ b/插件库/Lskj.PubBomImport/FrmMain.cs @@ -184,7 +184,7 @@ namespace Lskj.PubBomImport throw new Exception($"MX中只能存在一个ZZQD,请进行合并"); } } - GetFileCodeInfo(code, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(code, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, true); if (sourceBC > 0) { throw new Exception($"MX中的{code}不允许有版次"); @@ -197,7 +197,7 @@ namespace Lskj.PubBomImport string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; string sname = fileRow["sname"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -222,7 +222,7 @@ namespace Lskj.PubBomImport } foreach (var selectFile in selectFiles) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(selectFile), out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(selectFile, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { maxBc = fileBC; @@ -2262,7 +2262,7 @@ namespace Lskj.PubBomImport /// /// /// - private void GetFileCodeInfo(string sourceCode, out string code, out string name, out string bb, out int bc) + private void GetFileCodeInfo(string sourceCode, out string code, out string name, out string bb, out int bc, bool withoutExtension) { string namepattern = @"^(.*-S[A-Z]\d*)(.*)$"; string pattern = @"^(.*?)(\d+)?$"; @@ -2271,7 +2271,15 @@ namespace Lskj.PubBomImport string childsourceCode = ""; string childsourceBB = ""; int childsourceBC = 0; - Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(sourceCode).Trim(), namepattern); + Match namematch; + if (withoutExtension) + { + namematch = Regex.Match(sourceCode.Trim(), namepattern); + } + else + { + namematch = Regex.Match(Path.GetFileNameWithoutExtension(sourceCode).Trim(), namepattern); + } if (namematch.Success) { childcode = namematch.Groups[1].Value.Trim(); diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index 06dfcd4..51b55ec 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -59,7 +59,7 @@ namespace Lskj.PubBomImport if (fileInfo != null) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim(); - GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, true); //if (sourceCode.StartsWith("ZZQD")) //{ // throw new Exception($"不允许补充ZZQD文件{sourceCode}\r\n请进行变更"); @@ -125,7 +125,7 @@ namespace Lskj.PubBomImport if (fileInfo != null) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim(); - GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, true); if (sourceCode.StartsWith("QD")) { DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid = (select top 1 productid from p_ProductTab where spec = '{sourceCode}')"); @@ -1211,7 +1211,7 @@ namespace Lskj.PubBomImport } DataTable dataTable = SqlHelper.ExecuteDataTable($"select * from FileAttachmentMapping where MaterialCode = '{topProductId}'"); - GetFileCodeInfo(beforeName, out string beforeSourceCode, out string beforeSourceName, out string beforeSourceBB, out int beforeSourceBC); + GetFileCodeInfo(beforeName, out string beforeSourceCode, out string beforeSourceName, out string beforeSourceBB, out int beforeSourceBC, false); List labelRemarkList = new List(); List uploadModels = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.FileUploadControl).ToList(); @@ -1260,14 +1260,14 @@ namespace Lskj.PubBomImport //如果是ZZQD文件 if (parentInfo != null && (parentInfo.Name.Trim().StartsWith("ZZQD"))) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(parentInfo.Name.Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, false); DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{sourceCode}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{sourceCode}%'"); int childMaxBc = -1; foreach (DataRow fileRow in filetable.Rows) { string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -1394,14 +1394,14 @@ namespace Lskj.PubBomImport //如果是QD文件 if (parentInfo != null && (parentInfo.Name.Trim().StartsWith("QD"))) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(parentInfo.Name.Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, false); DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{sourceCode}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{sourceCode}%'"); int childMaxBc = -1; foreach (DataRow fileRow in filetable.Rows) { string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -1503,14 +1503,14 @@ namespace Lskj.PubBomImport //如果是MX文件 else if (parentInfo != null && (parentInfo.Name.Trim().StartsWith("MX"))) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(parentInfo.Name.Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, false); DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{topProductId}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{sourceCode}%'"); int childMaxBc = -1; foreach (DataRow fileRow in filetable.Rows) { string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -1617,7 +1617,7 @@ namespace Lskj.PubBomImport { int.TryParse(parentRow["套数"] + "", out int tamount); string childCode = parentRow["图号"] + ""; - GetFileCodeInfo(childCode, out string childsourceCode0, out string childsourceName0, out string childsourceBB0, out int childsourceBC0); + GetFileCodeInfo(childCode, out string childsourceCode0, out string childsourceName0, out string childsourceBB0, out int childsourceBC0, true); if (!childCode.StartsWith("RJ")) { if (childsourceBC0 > 0) @@ -1638,7 +1638,7 @@ namespace Lskj.PubBomImport if (childInfo == null) { //throw new Exception($"MX明细中不包含文件{childCode}"); - GetFileCodeInfo(childCode, out string childsourceCode, out string childsourceName, out string childsourceBB, out int childsourceBC); + GetFileCodeInfo(childCode, out string childsourceCode, out string childsourceName, out string childsourceBB, out int childsourceBC, true); if (childCode.StartsWith("QD")) { DataRow childRow = childTable.NewRow(); @@ -1659,7 +1659,7 @@ namespace Lskj.PubBomImport } if (childInfo != null) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childsourceName, out string childsourceBB, out int childsourceBC); + GetFileCodeInfo(childInfo.Name.Trim(), out string childsourceCode, out string childsourceName, out string childsourceBB, out int childsourceBC, false); if (childCode.StartsWith("ZZQD")) { zzqdTag = childCode; @@ -1762,14 +1762,14 @@ namespace Lskj.PubBomImport } else { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); + GetFileCodeInfo(parentInfo.Name.Trim(), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC, false); DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{sourceCode}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{sourceCode}%'"); int childMaxBc = -1; foreach (DataRow fileRow in filetable.Rows) { string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -1891,7 +1891,7 @@ namespace Lskj.PubBomImport throw new Exception($"物料编码{productId}的BOM建立单已终审\r\n禁止修改操作"); } } - GetFileCodeInfo(mxFileName.Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC); + GetFileCodeInfo(mxFileName.Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC, false); DataTable mxfiletable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{mxsourceCode}%'"); FileInfo mxInfo = null; @@ -1968,7 +1968,7 @@ namespace Lskj.PubBomImport { int.TryParse(parentRow["套数"] + "", out int tamount); string code = (parentRow["图号"] + "").Trim(); - GetFileCodeInfo(code, out string childsourceCode0, out string childsourceName0, out string childsourceBB0, out int childsourceBC0); + GetFileCodeInfo(code, out string childsourceCode0, out string childsourceName0, out string childsourceBB0, out int childsourceBC0, true); if (!code.StartsWith("RJ")) { if (childsourceBC0 > 0) @@ -1990,7 +1990,7 @@ namespace Lskj.PubBomImport { string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -2050,7 +2050,7 @@ namespace Lskj.PubBomImport { if (childInfo != null) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC); + GetFileCodeInfo(childInfo.Name.Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC, false); //如果文件夹中有附件,则比较版次,如果大于最大版次,则提示 if (childsourceBC > childMaxBc && filetable.Rows.Count > 0) { @@ -2232,7 +2232,7 @@ namespace Lskj.PubBomImport } if (childInfo != null) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC); + GetFileCodeInfo(childInfo.Name.Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC, false); DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid = (select top 1 productid from p_ProductTab where spec = '{code}')"); if (productRow == null) { @@ -2396,7 +2396,7 @@ namespace Lskj.PubBomImport string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1"; if (filetable.Rows.Count == 0) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC); + GetFileCodeInfo(childInfo.Name.Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC, false); if (filetable.Rows.Count == 0) { isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId); @@ -2816,7 +2816,7 @@ namespace Lskj.PubBomImport // throw new Exception($"物料编码{productId}的BOM建立单已终审\r\n禁止修改操作"); //} } - GetFileCodeInfo(mxFileName.Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC); + GetFileCodeInfo(mxFileName.Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC, false); DataTable mxfiletable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{mxsourceCode}%'"); FileInfo mxInfo = null; @@ -2907,7 +2907,7 @@ namespace Lskj.PubBomImport { string fileName = fileRow["sname"] + ""; string fileId = fileRow["fileId"] + ""; - GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC, false); if (fileBC >= childMaxBc) { childMaxBc = fileBC; @@ -2967,7 +2967,7 @@ namespace Lskj.PubBomImport { if (childInfo != null) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC); + GetFileCodeInfo(childInfo.Name.Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC, false); //如果文件夹中有附件,则比较版次,如果大于最大版次,则提示 if (childsourceBC > childMaxBc && filetable.Rows.Count > 0) { @@ -3138,7 +3138,7 @@ namespace Lskj.PubBomImport string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1"; if (filetable.Rows.Count == 0) { - GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC); + GetFileCodeInfo(childInfo.Name.Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC, false); if (filetable.Rows.Count == 0) { isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId); @@ -3264,7 +3264,7 @@ namespace Lskj.PubBomImport int result = BillImpl.BillSave(masterSql, detailSql, detailTable, ref billNo, detailGuid, billSeq, billWay, comfirm, out string tipMsg, auditFlag, newVer); if (result == 1) { - GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC, false); BaseImpl.ExecSqlValue(afterSql); BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'"); BaseImpl.ExecSqlValue($"update bom_bgRwTab set ComID = 1 where productid = '{productid}'"); @@ -3290,7 +3290,7 @@ namespace Lskj.PubBomImport } else { - GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC); + GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC, false); BaseImpl.ExecSqlValue(afterSql); BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'"); BaseImpl.ExecSqlValue($"update bom_bgRwTab set ComID = 1 where productid = '{productid}'"); @@ -4224,7 +4224,7 @@ namespace Lskj.PubBomImport /// /// /// - private void GetFileCodeInfo(string sourceCode, out string code, out string name, out string bb, out int bc) + private void GetFileCodeInfo(string sourceCode, out string code, out string name, out string bb, out int bc, bool withoutExtension) { string namepattern = @"^(.*-S[A-Z]\d*)(.*)$"; string pattern = @"^(.*?)(\d+)?$"; @@ -4233,7 +4233,15 @@ namespace Lskj.PubBomImport string childsourceCode = ""; string childsourceBB = ""; int childsourceBC = 0; - Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(sourceCode).Trim(), namepattern); + Match namematch; + if (withoutExtension) + { + namematch = Regex.Match(sourceCode.Trim(), namepattern); + } + else + { + namematch = Regex.Match(Path.GetFileNameWithoutExtension(sourceCode).Trim(), namepattern); + } if (namematch.Success) { childcode = namematch.Groups[1].Value.Trim();