SVN-Revision: r566
This commit is contained in:
wyf
2025-05-09 06:47:19 +00:00
parent 7d79a1bb2f
commit 3954a0f523
2 changed files with 148 additions and 13 deletions
+8 -1
View File
@@ -543,7 +543,14 @@ namespace Lskj.PubBomImport
{ {
this.InitializeHeader(rowItem); 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) if (mainRow != null)
{ {
//更新 //更新
+140 -12
View File
@@ -509,7 +509,7 @@ namespace Lskj.PubBomImport
{ {
try 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 namepattern = @"^(.+?)\s+(.+)$";
string pattern = @"^(.*?)(\d+)?$"; string pattern = @"^(.*?)(\d+)?$";
string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue; string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue;
@@ -558,6 +558,8 @@ namespace Lskj.PubBomImport
string code = ""; string code = "";
string name = ""; string name = "";
string sourceCode = ""; string sourceCode = "";
string sourceBB = "";
int sourceBC = 0;
Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern); Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern);
if (namematch.Success) if (namematch.Success)
{ {
@@ -568,6 +570,12 @@ namespace Lskj.PubBomImport
if (match.Success) if (match.Success)
{ {
sourceCode = match.Groups[1].Value; 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(); StringBuilder stringBuilder = new StringBuilder();
if (code.StartsWith("QD")) if (code.StartsWith("QD"))
@@ -604,9 +612,12 @@ namespace Lskj.PubBomImport
int.TryParse(detailRow["amount"] + "", out int amount); int.TryParse(detailRow["amount"] + "", out int amount);
detailRow["tamount"] = amount; detailRow["tamount"] = amount;
detailRow["amount"] = amount; detailRow["amount"] = amount;
detailRow["bak"] = sourceCode;
detailRow["bombb"] = sourceBB;
detailRow["bombc"] = sourceBC;
} }
SetProcessBar(20, allCount); 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); DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql);
SetProcessBar(40, allCount); SetProcessBar(40, allCount);
@@ -641,6 +652,8 @@ namespace Lskj.PubBomImport
string code = ""; string code = "";
string name = ""; string name = "";
string sourceCode = ""; string sourceCode = "";
string sourceBB = "";
int sourceBC = 0;
Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern); Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern);
if (namematch.Success) if (namematch.Success)
{ {
@@ -651,6 +664,12 @@ namespace Lskj.PubBomImport
if (match.Success) if (match.Success)
{ {
sourceCode = match.Groups[1].Value; 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); int.TryParse(Model.FirstRowIndex, out int index);
@@ -678,6 +697,8 @@ namespace Lskj.PubBomImport
detailRow["tamount"] = 1; detailRow["tamount"] = 1;
detailRow["amount"] = lastAmount; detailRow["amount"] = lastAmount;
detailRow["bak"] = sourceCode; detailRow["bak"] = sourceCode;
detailRow["bombb"] = sourceBB;
detailRow["bombc"] = sourceBC;
} }
SetProcessBar(20, allCount); 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"; 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 code = "";
string name = ""; string name = "";
string sourceCode = ""; string sourceCode = "";
string sourceBB = "";
int sourceBC = 0;
Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern); Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern);
if (namematch.Success) if (namematch.Success)
{ {
@@ -729,6 +752,12 @@ namespace Lskj.PubBomImport
if (match.Success) if (match.Success)
{ {
sourceCode = match.Groups[1].Value; 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); int.TryParse(Model.FirstRowIndex, out int index);
@@ -755,7 +784,7 @@ namespace Lskj.PubBomImport
if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD")) 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); DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
string sName = fileRow != null ? fileRow["sName"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : "";
@@ -815,6 +844,28 @@ namespace Lskj.PubBomImport
} }
if (childInfo != null) 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")) if (childCode.StartsWith("ZZQD"))
{ {
DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
@@ -839,7 +890,9 @@ namespace Lskj.PubBomImport
DataRow childRow = childTable.NewRow(); DataRow childRow = childTable.NewRow();
childRow["ProductId"] = zzqdItem["物料编码"] + ""; childRow["ProductId"] = zzqdItem["物料编码"] + "";
childRow["appellation"] = zzqdItem["名称"] + ""; childRow["appellation"] = zzqdItem["名称"] + "";
childRow["bak"] = childCode; childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + ""; childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount); int.TryParse(zzqdItem["数量"] + "", out int amount);
childRow["amount"] = amount * tamount; childRow["amount"] = amount * tamount;
@@ -851,7 +904,9 @@ namespace Lskj.PubBomImport
DataRow childRow = childTable.NewRow(); DataRow childRow = childTable.NewRow();
childRow["ProductId"] = parentRow["图号"] + ""; childRow["ProductId"] = parentRow["图号"] + "";
childRow["appellation"] = parentRow["名称"] + ""; childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = parentRow["备注"] + ""; childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + ""; childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + ""; childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow); childTable.Rows.Add(childRow);
@@ -864,7 +919,7 @@ namespace Lskj.PubBomImport
{ {
throw new Exception($"MX明细数据为空"); 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); DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql);
if (masterRow == null) if (masterRow == null)
@@ -1098,6 +1153,9 @@ namespace Lskj.PubBomImport
{ {
try try
{ {
string namepattern = @"^([A-Z]+(?:-[A-Z]+)*(?:-\d+)+-[A-Z]+\d*)\s*(.*)$";
//string namepattern = @"^(.+?)\s+(.+)$";
string pattern = @"^(.*?)(\d+)?$";
int execOrder = 1; int execOrder = 1;
DataRow mxRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith("MX")).FirstOrDefault(); DataRow mxRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith("MX")).FirstOrDefault();
if (mxRow != null) if (mxRow != null)
@@ -1117,6 +1175,28 @@ namespace Lskj.PubBomImport
FileInfo mxInfo = new FileInfo(mxDirPath); FileInfo mxInfo = new FileInfo(mxDirPath);
if (mxInfo != null) 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(); FrmBillInfo frmBillInfo = new FrmBillInfo();
DataTable parentTable = ExcelToDatatable(mxInfo.FullName, Model, "", 5); DataTable parentTable = ExcelToDatatable(mxInfo.FullName, Model, "", 5);
parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "") && !string.IsNullOrEmpty(n["名称"] + "")).ToList().CopyToDataTable(); parentTable = parentTable.Rows.Cast<DataRow>().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) foreach (DataRow parentRow in parentTable.Rows)
{ {
int.TryParse(parentRow["套数"] + "", out int tamount); int.TryParse(parentRow["套数"] + "", out int tamount);
string code = parentRow["图号"] + ""; string code = (parentRow["图号"] + "").Trim();
if (code.StartsWith("QD") || code.StartsWith("ZZQD")) if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{ {
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault(); DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
@@ -1194,6 +1274,28 @@ namespace Lskj.PubBomImport
} }
if (childInfo != null) 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")) if (code.StartsWith("ZZQD"))
{ {
DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
@@ -1218,7 +1320,9 @@ namespace Lskj.PubBomImport
DataRow childRow = childTable.NewRow(); DataRow childRow = childTable.NewRow();
childRow["ProductId"] = zzqdItem["物料编码"] + ""; childRow["ProductId"] = zzqdItem["物料编码"] + "";
childRow["appellation"] = zzqdItem["名称"] + ""; childRow["appellation"] = zzqdItem["名称"] + "";
childRow["bak"] = code; childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + ""; childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount); int.TryParse(zzqdItem["数量"] + "", out int amount);
childRow["amount"] = amount * tamount; childRow["amount"] = amount * tamount;
@@ -1230,7 +1334,9 @@ namespace Lskj.PubBomImport
DataRow childRow = childTable.NewRow(); DataRow childRow = childTable.NewRow();
childRow["ProductId"] = parentRow["图号"] + ""; childRow["ProductId"] = parentRow["图号"] + "";
childRow["appellation"] = parentRow["名称"] + ""; childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = parentRow["备注"] + ""; childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + ""; childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + ""; childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow); childTable.Rows.Add(childRow);
@@ -1245,7 +1351,7 @@ namespace Lskj.PubBomImport
throw new Exception($"MX明细数据为空"); throw new Exception($"MX明细数据为空");
} }
SetProcessBar(40, 0); 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); DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql);
SetProcessBar(60, 0); SetProcessBar(60, 0);
@@ -1319,6 +1425,29 @@ namespace Lskj.PubBomImport
} }
if (childInfo != null) 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}'"); DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
if (productRow == null) if (productRow == null)
{ {
@@ -1344,7 +1473,7 @@ namespace Lskj.PubBomImport
throw new Exception($"{code}明细数据为空"); throw new Exception($"{code}明细数据为空");
} }
SetProcessBar(40, allCount); 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); DataRow childMasterRow = BillImpl.GetDataRowResult(childBillMasterSql);
SetProcessBar(60, allCount); SetProcessBar(60, allCount);
@@ -1510,7 +1639,6 @@ namespace Lskj.PubBomImport
{ {
try try
{ {
string execGuid = sourceRow["qms_wjgg_uuid"] + ""; string execGuid = sourceRow["qms_wjgg_uuid"] + "";
string productid = sourceRow["qms_wjgg_productid"] + ""; string productid = sourceRow["qms_wjgg_productid"] + "";
int.TryParse(sourceRow["fileId"] + "", out int copyFileId); int.TryParse(sourceRow["fileId"] + "", out int copyFileId);