SVN-Revision: r903
This commit is contained in:
wyf
2025-08-05 08:45:26 +00:00
parent becff23d95
commit 02bf3984bf
3 changed files with 269 additions and 149 deletions
+12 -1
View File
@@ -537,12 +537,23 @@ namespace Lskj.PubBomImport
this.SetBillStatus(null);
this.ControlObj.ResetControlValue(billModel.ManuallyTriggerCorrelation, true);
}
public void AddOrUpdateBill(DataRow rowItem, DataTable newSource)
public void AddOrUpdateBill(DataRow rowItem, DataTable newSource, string billSaveMode = "")
{
string masterSql = rowItem == null ? billModel.MasterSql.Replace("{" + billModel.PrimaryKey + "}", this.lblOrderNo.Text) : ReplaceHelper.ReplaceRowParam(rowItem, billModel.MasterSql);
// 加载单据信息
DataRow mainRow = BillImpl.GetDataRowResult(masterSql);
this.SetBillStatus(mainRow);
if (!string.IsNullOrEmpty(billSaveMode))
{
if (billSaveMode.Equals("1"))
{
billModel.SaveState = true;
}
else if (billSaveMode.Equals("2"))
{
billModel.SaveState = false;
}
}
if (!billModel.SaveState)
{
this.InitializeHeader(rowItem);
+3 -3
View File
@@ -216,7 +216,7 @@ namespace Lskj.PubBomImport
{
int maxBc = -1;
string maxSname = "";
if (selectFiles.Count() <= 0)
if (selectFiles.Count() <= 0 && !code.StartsWith("RJ"))
{
throw new Exception($"{code}不存在附件\r\n请检查BOM文件");
}
@@ -600,7 +600,7 @@ namespace Lskj.PubBomImport
frmProgress.ShowDialog();
frmProgress.Dispose();
}
else if (Model.ShowType.Equals("6"))//修改多个其它文件
else if (Model.ShowType.Equals("6"))//修改多个其它文件(版次)
{
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
@@ -720,7 +720,7 @@ namespace Lskj.PubBomImport
this.Close();
}
}
else if (Model.ShowType.Equals("8"))//修改多个版次LX-文件,新增附件
else if (Model.ShowType.Equals("8"))//修改多个其他文件(版本)
{
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
+254 -145
View File
@@ -1583,6 +1583,14 @@ namespace Lskj.PubBomImport
throw new Exception($"虚拟物料创建失败\r\n{msg}");
}
}
if (childCode.StartsWith("RJ"))
{
string rjProductid = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where productid = '{childCode}')") + "";
if (string.IsNullOrEmpty(rjProductid))
{
throw new Exception($"RJ软件物料编码不存在");
}
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
@@ -1601,9 +1609,12 @@ 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);
if (childsourceBC0 > 0)
if (!childCode.StartsWith("RJ"))
{
throw new Exception($"{childsourceCode0}的版次为{childsourceBC0}\r\n录入的版次不允许大于0");
if (childsourceBC0 > 0)
{
throw new Exception($"{childsourceCode0}的版次为{childsourceBC0}\r\n录入的版次不允许大于0");
}
}
string unionTzName = parentRow.Table.Columns.Contains("关联清单") ? (parentRow["关联清单"] + "").Trim() : "";
insertbulider.AppendLine($"insert into FileAttachmentMapping (MaterialCode,MxFileName,RelatedAttachmentName,OperatorUser,ChangeStatus,UnionTZName) values ('{topProductId}','{sourceCode }','{childCode}','{ERPInfo.Instance.UserName}','变更','{unionTzName}');");
@@ -1688,6 +1699,18 @@ namespace Lskj.PubBomImport
}
}
}
if (childCode.StartsWith("RJ"))
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where productid = '{childCode}')");
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = childCode;
childRow["bombb"] = "";
childRow["bombc"] = "0";
childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
}
SetProcessBar(20, 0);
if (childTable.Rows.Count == 0 && !zzqdTag.StartsWith("ZZQD"))
@@ -1898,6 +1921,14 @@ namespace Lskj.PubBomImport
throw new Exception($"虚拟物料创建失败\r\n{msg}");
}
}
if (code.StartsWith("RJ"))
{
string rjProductid = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where productid = '{code}')") + "";
if (string.IsNullOrEmpty(rjProductid))
{
throw new Exception($"RJ软件物料编码不存在");
}
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
@@ -1929,9 +1960,12 @@ 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);
if (childsourceBC0 > 0)
if (!code.StartsWith("RJ"))
{
throw new Exception($"{childsourceCode0}的版次为{childsourceBC0}\r\n录入的版次不允许大于0");
if (childsourceBC0 > 0)
{
throw new Exception($"{childsourceCode0}的版次为{childsourceBC0}\r\n录入的版次不允许大于0");
}
}
string unionTzName = parentRow.Table.Columns.Contains("关联清单") ? (parentRow["关联清单"] + "").Trim() : "";
int codeCount = mxCodeRows.Where(n => (n["图号"] + "").Trim().StartsWith(code)).Count();
@@ -1991,83 +2025,98 @@ namespace Lskj.PubBomImport
}
}
}
if (childInfo != null)
if (code.StartsWith("RJ"))
{
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
//如果文件夹中有附件,则比较版次,如果大于最大版次,则提示
if (childsourceBC > childMaxBc && filetable.Rows.Count > 0)
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where productid = '{code}')");//RJ的物料编码是什么开头的?保持原逻辑吗?
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = code;
childRow["bombb"] = "";
childRow["bombc"] = "0";
childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
else
{
if (childInfo != null)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
}
if (filetable.Rows.Count == 0 && !childsourceBB.Equals("SA"))
{
throw new Exception($"{childInfo.Name}\r\n版本不为SA不允许新增,请进行修改");
}
if (filetable.Rows.Count == 0 && childsourceBC > 0)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},不允许新增版次大于0的附件");
}
childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc;
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
DataTable qdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
DataView filterDataView = new DataView(qdTable);
try
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
//如果文件夹中有附件,则比较版次,如果大于最大版次,则提示
if (childsourceBC > childMaxBc && filetable.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(Model.ReadTableCond))
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
}
if (filetable.Rows.Count == 0 && !childsourceBB.Equals("SA"))
{
throw new Exception($"{childInfo.Name}\r\n版本不为SA不允许新增,请进行修改");
}
if (filetable.Rows.Count == 0 && childsourceBC > 0)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},不允许新增版次大于0的附件");
}
childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc;
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
DataTable qdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
DataView filterDataView = new DataView(qdTable);
try
{
filterDataView.RowFilter = Model.ReadTableCond;
if (!string.IsNullOrEmpty(Model.ReadTableCond))
{
filterDataView.RowFilter = Model.ReadTableCond;
}
}
}
catch (Exception)
{
}
qdTable = filterDataView.ToTable();
var qdCodeRows = qdTable.AsEnumerable();
foreach (DataRow qdItem in qdTable.Rows)
{
string qdCode = (qdItem["物料编码"] + "").Trim();
int qdCount = qdCodeRows.Where(n => (n["物料编码"] + "").Trim().StartsWith(qdCode)).Count();
if (qdCount > 1)//只允许存在一个
catch (Exception)
{
throw new Exception($"{childsourceCode}中的{qdCode}重复,请修改");
}
}
if (code.StartsWith("ZZQD"))
{
foreach (DataRow zzqdItem in qdTable.Rows)
qdTable = filterDataView.ToTable();
var qdCodeRows = qdTable.AsEnumerable();
foreach (DataRow qdItem in qdTable.Rows)
{
string qdCode = (qdItem["物料编码"] + "").Trim();
int qdCount = qdCodeRows.Where(n => (n["物料编码"] + "").Trim().StartsWith(qdCode)).Count();
if (qdCount > 1)//只允许存在一个
{
throw new Exception($"{childsourceCode}中的{qdCode}重复,请修改");
}
}
if (code.StartsWith("ZZQD"))
{
foreach (DataRow zzqdItem in qdTable.Rows)
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim();
childRow["appellation"] = zzqdItem["名称"] + "";
childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount);
childRow["amount"] = amount * tamount;
childTable.Rows.Add(childRow);
}
}
else if (code.StartsWith("QD"))
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim();
childRow["appellation"] = zzqdItem["名称"] + "";
childRow["ProductId"] = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where spec = '{code}')");
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount);
childRow["amount"] = amount * tamount;
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
}
else if (code.StartsWith("QD"))
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where spec = '{code}')");
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
}
}
else
{
if (filetable.Rows.Count == 0)
else
{
throw new Exception($"{code}的附件不存在,请检查文件");
if (filetable.Rows.Count == 0)
{
throw new Exception($"{code}的附件不存在,请检查文件");
}
}
}
}
@@ -2442,6 +2491,35 @@ namespace Lskj.PubBomImport
string mxDirPath = mxRow["BomFieldNameDir"] + "";
string productId = mxRow["BomMxMainProduct"] + "";
string addState = mxRow["BomMxAddState"] + "";
string selectModelValue = "";
string selectVerValue = "";
string selectBakValue = "";
ControlModel selectModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("生成模式")).FirstOrDefault();
ControlModel selectVerModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("覆盖版本")).FirstOrDefault();
ControlModel selectBakModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("备注信息")).FirstOrDefault();
if (selectModel != null)
{
selectModelValue = StaticControl.RightMenuMyControl.GetControlValue(selectModel);
}
if (selectVerModel != null)
{
selectVerValue = StaticControl.RightMenuMyControl.GetControlValue(selectVerModel);
}
if (selectBakModel != null)
{
selectBakValue = StaticControl.RightMenuMyControl.GetControlValue(selectBakModel);
}
if (string.IsNullOrEmpty(selectModelValue))
{
throw new Exception($"未选择生成模式");
}
if (selectModelValue.Equals("1"))
{
if (string.IsNullOrEmpty(selectVerValue))
{
throw new Exception($"覆盖模式未选择被覆盖版本");
}
}
if (string.IsNullOrEmpty(Model.MainFieldDic))
{
throw new Exception($"字段对应关系配置异常");
@@ -2450,27 +2528,27 @@ namespace Lskj.PubBomImport
{
throw new Exception($"保存失败\r\n请重新进行BOM上传后保存");
}
if (addState.Equals("新增"))
{
DataRow billRow = BaseImpl.GetDataRowResult($"select qms_maddf_billdocument_id from qms_BillFileAddMaintab where qms_maddf_productid = '{productId}' and isnull(qms_maddf_addMode,'0') = '0'");
if (billRow != null)
{
throw new Exception($"物料编码{productId}的BOM新增单已存在审批流\r\n请进行审批");
}
DataRow billbomRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}'");
if (billRow != null)
{
throw new Exception($"物料编码{productId}的BOM建立单已存在\r\n请进行修改操作");
}
}
else
{
DataRow billbomRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}' and stepover = '1'");
if (billbomRow != null)
{
throw new Exception($"物料编码{productId}的BOM建立单已终审\r\n禁止修改操作");
}
}
//if (addState.Equals("新增"))
//{
// DataRow billRow = BaseImpl.GetDataRowResult($"select qms_maddf_billdocument_id from qms_BillFileAddMaintab where qms_maddf_productid = '{productId}' and isnull(qms_maddf_addMode,'0') = '7' and isnull(qms_maddf_addMode,'0') = '7' ");
// if (billRow != null)
// {
// throw new Exception($"物料编码{productId}的BOM新增单已存在审批流\r\n请进行审批");
// }
// DataRow billbomRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}'");
// if (billRow != null)
// {
// throw new Exception($"物料编码{productId}的BOM建立单已存在\r\n请进行修改操作");
// }
//}
//else
//{
// DataRow billbomRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}' and stepover = '1'");
// if (billbomRow != null)
// {
// throw new Exception($"物料编码{productId}的BOM建立单已终审\r\n禁止修改操作");
// }
//}
FileInfo mxInfo = null;
if (!string.IsNullOrEmpty(mxDirPath))
{
@@ -2552,11 +2630,19 @@ namespace Lskj.PubBomImport
throw new Exception($"明细数据不能空");
}
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,'' as bak,'' as bombb,'' as bombc";
string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productId}') as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid,'{selectBakValue}' as bak,'' as bombb,'' as bombc";
if (selectModelValue.Equals("2"))
{
billMasterSql = $"select '' as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid,'{selectBakValue}' as bak,'' as bombb,'' as bombc";
}
else if (selectModelValue.Equals("1"))
{
billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productId}' and billdocument_id = '{selectVerValue}') as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid,'{selectBakValue}' as bak,'' as bombb,'' as bombc";
}
// 处理单据表头数据
DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql);
SetProcessBar(60, 0);
frmBillInfo.AddOrUpdateBill(masterRow, childTable);
frmBillInfo.AddOrUpdateBill(masterRow, childTable, selectModelValue);
string guid = Guid.NewGuid() + "";
frmBillInfo.BillSaveSql(guid);
SetProcessBar(80, 0);
@@ -2727,6 +2813,14 @@ namespace Lskj.PubBomImport
throw new Exception($"虚拟物料创建失败\r\n{msg}");
}
}
if (code.StartsWith("RJ"))
{
string rjProductid = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where productid = '{code}')") + "";
if (string.IsNullOrEmpty(rjProductid))
{
throw new Exception($"RJ软件物料编码不存在");
}
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
@@ -2815,69 +2909,84 @@ namespace Lskj.PubBomImport
}
}
}
if (childInfo != null)
if (code.StartsWith("RJ"))
{
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
//如果文件夹中有附件,则比较版次,如果大于最大版次,则提示
if (childsourceBC > childMaxBc && filetable.Rows.Count > 0)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
}
if (filetable.Rows.Count == 0 && !childsourceBB.Equals("SA"))
{
throw new Exception($"{childInfo.Name}\r\n版本不为SA不允许新增,请进行修改");
}
if (filetable.Rows.Count == 0 && childsourceBC > 0)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},不允许新增版次大于0的附件");
}
childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc;
if (code.StartsWith("ZZQD"))
{
DataTable qdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
DataView filterDataView = new DataView(qdTable);
try
{
if (!string.IsNullOrEmpty(Model.ReadTableCond))
{
filterDataView.RowFilter = Model.ReadTableCond;
}
}
catch (Exception)
{
}
qdTable = filterDataView.ToTable();
var qdCodeRows = qdTable.AsEnumerable();
foreach (DataRow qdItem in qdTable.Rows)
{
string qdCode = (qdItem["物料编码"] + "").Trim();
int qdCount = qdCodeRows.Where(n => (n["物料编码"] + "").Trim().StartsWith(qdCode)).Count();
if (qdCount > 1)//只允许存在一个
{
throw new Exception($"{childsourceCode}中的{qdCode}重复,请修改");
}
}
if (code.StartsWith("ZZQD"))
{
foreach (DataRow zzqdItem in qdTable.Rows)
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim();
childRow["appellation"] = zzqdItem["名称"] + "";
childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount);
childRow["amount"] = amount * tamount;
childTable.Rows.Add(childRow);
}
}
}
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = BaseImpl.GetResult($"(select top 1 productid from p_ProductTab where productid = '{code}')");//RJ的物料编码是什么开头的?保持原逻辑吗?
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = code;
childRow["bombb"] = "";
childRow["bombc"] = "0";
childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
else
{
throw new Exception($"{code}的附件不存在,请检查文件");
if (childInfo != null)
{
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
//如果文件夹中有附件,则比较版次,如果大于最大版次,则提示
if (childsourceBC > childMaxBc && filetable.Rows.Count > 0)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
}
if (filetable.Rows.Count == 0 && !childsourceBB.Equals("SA"))
{
throw new Exception($"{childInfo.Name}\r\n版本不为SA不允许新增,请进行修改");
}
if (filetable.Rows.Count == 0 && childsourceBC > 0)
{
throw new Exception($"{childsourceCode}的版次为{childsourceBC},不允许新增版次大于0的附件");
}
childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc;
if (code.StartsWith("ZZQD"))
{
DataTable qdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
DataView filterDataView = new DataView(qdTable);
try
{
if (!string.IsNullOrEmpty(Model.ReadTableCond))
{
filterDataView.RowFilter = Model.ReadTableCond;
}
}
catch (Exception)
{
}
qdTable = filterDataView.ToTable();
var qdCodeRows = qdTable.AsEnumerable();
foreach (DataRow qdItem in qdTable.Rows)
{
string qdCode = (qdItem["物料编码"] + "").Trim();
int qdCount = qdCodeRows.Where(n => (n["物料编码"] + "").Trim().StartsWith(qdCode)).Count();
if (qdCount > 1)//只允许存在一个
{
throw new Exception($"{childsourceCode}中的{qdCode}重复,请修改");
}
}
if (code.StartsWith("ZZQD"))
{
foreach (DataRow zzqdItem in qdTable.Rows)
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim();
childRow["appellation"] = zzqdItem["名称"] + "";
childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount);
childRow["amount"] = amount * tamount;
childTable.Rows.Add(childRow);
}
}
}
}
else
{
throw new Exception($"{code}的附件不存在,请检查文件");
}
}
}
SetProcessBar(20, 0);