SVN-Revision: r601
This commit is contained in:
wyf
2025-05-17 08:25:53 +00:00
parent fed11e216e
commit 220e672cef
2 changed files with 357 additions and 660 deletions
+92 -65
View File
@@ -80,7 +80,7 @@ namespace Lskj.PubBomImport
InitGridColumns();
InitMulitControl();
InitDataSource();
if (showTypeValue == 0 || showTypeValue == 3 || showTypeValue == 4 || showTypeValue == 44 || showTypeValue == 5 || showTypeValue == 55 || (showTypeValue > 0 && showType))
if (showTypeValue == 0 || showTypeValue == 3 || showTypeValue == 33 || showTypeValue == 4 || showTypeValue == 44 || showTypeValue == 5 || showTypeValue == 55 || (showTypeValue > 0 && showType))
{
OnBtnImportClick(null, null);
}
@@ -112,6 +112,17 @@ namespace Lskj.PubBomImport
if (dialogResult == DialogResult.OK)
{
Properties.Settings.Default.LastSelectFolder = Path.GetDirectoryName(dialog.FileName);
string[] fileNames = dialog.FileNames;
foreach (string fileName in fileNames)
{
string code = Path.GetFileNameWithoutExtension(fileName);
GetFileCodeInfo(code, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC);
int count = fileNames.Where(n => Path.GetFileNameWithoutExtension(n).Trim().StartsWith(code)).Count();
if (count > 1)//只允许存在一个
{
throw new Exception($"{code}存在多条记录\r\n不允许重复");
}
}
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
ShowType = Model.ShowType,
@@ -248,67 +259,83 @@ namespace Lskj.PubBomImport
// this.Close();
// }
//}
//else if (Model.ShowType.Equals("3"))//新增多个清单文件
//{
// BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
// {
// ShowType = Model.ShowType,
// AfterBomFieldName = Model.AfterBomFieldName,
// CanSave = true
// };
// FormDialogModel dialogModel = new FormDialogModel()
// {
// DialogDllName = "Lskj.PubBomImport.dll",
// PubDialogType = DialogType.PubAddRecord,
// ReturnTag = bomImpRtnModel
// };
// this.Tag = dialogModel;
// DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
// if (sourceTable.Columns.Contains("BomFieldNameDir"))
// {
// List<DataRow> selectRows = new List<DataRow>();
// foreach (DataRow sourceRow in sourceTable.Rows)
// {
// if (sourceRow.RowState == DataRowState.Deleted)
// {
// continue;
// }
// string fileName = sourceRow[Model.AfterBomFieldName] + "";
// string dirPath = sourceRow["BomFieldNameDir"] + "";
// FileInfo parentInfo = null;
// if (string.IsNullOrEmpty(dirPath))
// {
// continue;
// }
// parentInfo = new FileInfo(dirPath);
// selectRows.Add(sourceRow);
// }
// if (selectRows.Count > 0)
// {
// FrmProgress frmProgress = new FrmProgress();
// frmProgress.frmMain = this;
// frmProgress.Model = Model;
// frmProgress.ImportTimer.Tick += (ts, te) =>
// {
// frmProgress.ImportTimer.Enabled = false;
// frmProgress.StartImportInQDFile(selectRows);
// };
// frmProgress.ImportTimer.Enabled = true;
// DialogResult dialogResult = frmProgress.ShowDialog();
// bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
// frmProgress.Dispose();
// }
// else
// {
// this.Close();
// }
// }
// else
// {
// this.Close();
// }
//}
else if (Model.ShowType.Equals("4"))//新增或修改单个清单文件
else if (Model.ShowType.Equals("3"))//新增多个QD文件或图纸文件
{
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
ShowType = Model.ShowType,
AfterBomFieldName = Model.AfterBomFieldName,
CanSave = true
};
FormDialogModel dialogModel = new FormDialogModel()
{
DialogDllName = "Lskj.PubBomImport.dll",
PubDialogType = DialogType.PubAddRecord,
ReturnTag = bomImpRtnModel
};
this.Tag = dialogModel;
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
if (sourceTable.Columns.Contains("BomFieldNameDir"))
{
List<DataRow> selectRows = new List<DataRow>();
foreach (DataRow sourceRow in sourceTable.Rows)
{
if (sourceRow.RowState == DataRowState.Deleted)
{
continue;
}
string fileName = sourceRow[Model.AfterBomFieldName] + "";
string dirPath = sourceRow["BomFieldNameDir"] + "";
FileInfo parentInfo = null;
if (string.IsNullOrEmpty(dirPath))
{
continue;
}
parentInfo = new FileInfo(dirPath);
selectRows.Add(sourceRow);
}
if (selectRows.Count > 0)
{
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
frmProgress.Model = Model;
frmProgress.ImportTimer.Tick += (ts, te) =>
{
frmProgress.ImportTimer.Enabled = false;
frmProgress.StartImportInQDOrZZFiles(selectRows);
};
frmProgress.ImportTimer.Enabled = true;
DialogResult dialogResult = frmProgress.ShowDialog();
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
frmProgress.Dispose();
}
else
{
this.Close();
}
}
else
{
this.Close();
}
}
else if (Model.ShowType.Equals("33"))//结构补充终审同步
{
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
frmProgress.Model = Model;
frmProgress.ImportTimer.Tick += (ts, te) =>
{
frmProgress.ImportTimer.Enabled = false;
string productId = Model.MaintabFocusedRow != null && Model.MaintabFocusedRow.Table.Columns.Contains("ProductId") ? Model.MaintabFocusedRow["ProductId"] + "" : "";
frmProgress.StartCreateBomAdd(productId);
};
frmProgress.ImportTimer.Enabled = true;
frmProgress.ShowDialog();
frmProgress.Dispose();
}
else if (Model.ShowType.Equals("4"))//修改单个文件
{
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
@@ -336,7 +363,7 @@ namespace Lskj.PubBomImport
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
frmProgress.Dispose();
}
else if (Model.ShowType.Equals("44"))//通过已经上传的数据来解析并且建立BOM
else if (Model.ShowType.Equals("44"))//修改终审同步
{
FrmProgress frmProgress = new FrmProgress();
@@ -352,7 +379,7 @@ namespace Lskj.PubBomImport
frmProgress.ShowDialog();
frmProgress.Dispose();
}
else if (Model.ShowType.Equals("5"))//通过文件名进行文件上传和逻辑记录
else if (Model.ShowType.Equals("5"))//bom结构上传
{
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
@@ -412,7 +439,7 @@ namespace Lskj.PubBomImport
this.Close();
}
}
else if (Model.ShowType.Equals("55"))//通过已经上传的数据来解析并且建立BOM
else if (Model.ShowType.Equals("55"))//结构上传终审同步
{
FrmProgress frmProgress = new FrmProgress();
+231 -561
View File
@@ -45,75 +45,58 @@ namespace Lskj.PubBomImport
InitializeComponent();
this.ControlBox = false;
}
/// <summary>
/// 开始导入
/// Bom结构补充,新增QD或图纸
/// </summary>
/// <param name="dirPaths"></param>
public void StartImportInDir(string dirPath)
public void StartImportInQDOrZZFiles(List<DataRow> selectRows)
{
try
{
Model = frmMain.Model;
DirectoryInfo directoryInfo = new DirectoryInfo(dirPath);
FileInfo[] fileInfos = directoryInfo.GetFiles();
FileInfo parentInfo = fileInfos.Where(n => n.Name.StartsWith("MX") && n.Extension.Equals(".xlsx", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (parentInfo != null)
{
if (Directory.Exists("BomImportTemp"))
{
Directory.Delete("BomImportTemp", true);
}
Directory.CreateDirectory("BomImportTemp");
int execOrder = 1;
FrmBillInfo frmBillInfo = new FrmBillInfo();
DataTable parentTable = ExcelToDatatable(parentInfo.FullName, Model, "", 5);
parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "")).ToList().CopyToDataTable();
Dictionary<string, string> childFileDic = new Dictionary<string, string>();
foreach (DataRow parentRow in parentTable.Rows)
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow selectRow in selectRows)
{
string fileName = (parentRow["图号"] + "").Trim();
if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD"))
string fileName = selectRow[Model.AfterBomFieldName] + "";
string dirPath = selectRow["BomFieldNameDir"] + "";
FileInfo fileInfo = new FileInfo(dirPath);
if (fileInfo != null)
{
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(fileName)).FirstOrDefault();
if (childInfo == null)
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC);
if (sourceCode.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')";
DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
string sName = fileRow != null ? fileRow["sName"] + "" : "";
if (string.IsNullOrEmpty(webpath))
throw new Exception($"不允许补充ZZQD文件{sourceCode}\r\n请进行变更");
}
else if (sourceCode.StartsWith("MX"))
{
throw new Exception($"Bom明细附件{fileName}不存在\r\nBom导入失败");
throw new Exception($"不允许补充MX文件{sourceCode}\r\n请进行变更");
}
else
{
using (WebClient webClient = new WebClient())
if (!string.IsNullOrEmpty(sourceCode) && !string.IsNullOrEmpty(sourceBB))
{
try
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId 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}%'");
if (filetable.Rows.Count > 0)
{
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
string tempFileName = $"BomImportTemp/{sName}";
webClient.DownloadFile(url, tempFileName);
childFileDic.Add(fileName, tempFileName);
throw new Exception($"{sourceCode}的附件已存在\r\n请进行变更");
}
catch (Exception)
if (sourceCode.StartsWith("QD"))
{
throw new Exception($"Bom明细附件{fileName}获取失败\r\nBom导入失败");
stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{sourceCode}')");
stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{sourceCode.Replace("'", "''")}','{sourceName.Replace("'", "''")}','','0199') end;");
}
}
}
}
}
}
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow dataRow in parentTable.Rows)
else
{
string code = (dataRow["图号"] + "").Trim();
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
throw new Exception($"文件{fileNameWithoutExtension}名称不符合规范");
}
}
}
else
{
stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{dataRow[""] + ""}')");
stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{(dataRow[""] + "").Replace("'", "''")}','{(dataRow[""] + "").Replace("'", "''")}','{(dataRow[""] + "").Replace("'", "''")}','0199') end;");
throw new Exception($"{fileName}的文件不存在");
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
@@ -126,372 +109,146 @@ namespace Lskj.PubBomImport
{
try
{
SetProcessBar(0, 0);
SetProcessMsg($"正在导入:{Path.GetFileName(parentInfo.FullName)}");
DataTable childTable = new DataTable();
foreach (GridColumn gridColumn in frmBillInfo.GcMainView.Columns)
{
if (!childTable.Columns.Contains(gridColumn.FieldName))
{
childTable.Columns.Add(gridColumn.FieldName, gridColumn.ColumnType);
}
}
foreach (DataRow parentRow in parentTable.Rows)
{
string code = parentRow["图号"] + "";
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(code)).FirstOrDefault();
if (childInfo == null)
{
string tempFileName = childFileDic[code];
childInfo = new FileInfo(tempFileName);
}
if (childInfo != null)
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = parentRow["图号"] + "";
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = parentRow["备注"] + "";
childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
}
}
SetProcessBar(20, 0);
frmBillInfo.GcMainView.GridControl.DataSource = childTable;
SetProcessBar(40, 0);
string controlSql = "select '' as billdocument_id,'0' affirmer,'0' rtagid,'{材料代码}' as productid";
frmBillInfo.InitializeHeader(Model.MaintabFocusedRow, controlSql);
SetProcessBar(60, 0);
string billNo = "";
frmBillInfo.BillSave(ref billNo);
SetProcessBar(80, 0);
frmBillInfo.OnBillAdd();
string productId = Model.MaintabFocusedRow["材料代码"] + "";
string billdocumentId = Model.MaintabFocusedRow["单据编号"] + "";
string idValue = BaseImpl.GetResult($"select top 1 billdocument_id from bom_billListTab where ParentProduct = '{productId}'") + "";
string updateParentVerSql = @"update bom_BillListTab set Ver = '{0}' where Billdocument_Id='{1}' and ProductId='{0}'";
SqlHelper.ExecuteNonQuery(string.Format(updateParentVerSql, idValue, billdocumentId));
//上传文件
bool isUpload = UploadFile(parentInfo.FullName, idValue, out string msg, out string _);
SetProcessBar(100, (1 / (parentTable.Rows.Count + 1)) * 100);
SetProcessLabelAllMsg($"总进度:{1}/{parentTable.Rows.Count + 1}");
int.TryParse(Model.FirstRowIndex, out int index);
frmMain.FirstRowIndex = index;
foreach (DataRow dataRow in parentTable.Rows)
foreach (DataRow selectRow in selectRows)
{
int childIndex = parentTable.Rows.IndexOf(dataRow);
int childIndex = selectRows.IndexOf(selectRow);
int nowCount = 1 + childIndex;
int allCount = (int)((decimal)(1 + childIndex) / (parentTable.Rows.Count + 1) * 100);
int finishCount = (int)((decimal)(1 + nowCount) / (parentTable.Rows.Count + 1) * 100);
int.TryParse(dataRow["套数"] + "", out int tamount);
string code = (dataRow["图号"] + "").Trim();
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
int allCount = (int)((decimal)(1 + childIndex) / (selectRows.Count + 1) * 100);
int finishCount = (int)((decimal)(1 + nowCount) / (selectRows.Count + 1) * 100);
string fileName = selectRow[Model.AfterBomFieldName] + "";
string dirPath = selectRow["BomFieldNameDir"] + "";
FileInfo fileInfo = new FileInfo(dirPath);
if (fileInfo != null)
{
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
if (productRow == null)
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC);
if (sourceCode.StartsWith("QD"))
{
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(code)).FirstOrDefault();
if (childInfo == null)
{
string tempFileName = childFileDic[code];
childInfo = new FileInfo(tempFileName);
}
if (childInfo != null)
{
if ((code.StartsWith("QD") || code.StartsWith("ZZQD")))
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{sourceCode}'");
if (productRow == null)//如果不存在bom建立单
{
string childGuid = Guid.NewGuid() + "";
frmBillInfo.OnBillAdd();
SetProcessBar(0, allCount);
SetProcessMsg($"正在导入:{Path.GetFileName(childInfo.FullName)}");
SetProcessMsg($"正在导入:{Path.GetFileName(fileInfo.FullName)}");
DataTable detailTable = new DataTable();
frmMain.Invoke(new Action(() =>
{
detailTable = frmMain.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true);
detailTable = frmMain.ToExcelDataTable(fileInfo.FullName, out int count, out int errorCount, true);
}));
foreach (DataRow detailRow in detailTable.Rows)
{
int.TryParse(detailRow["amount"] + "", out int lastAmount);
detailRow["tamount"] = tamount;
detailRow["amount"] = lastAmount;
int.TryParse(detailRow["amount"] + "", out int amount);
//数量暂定为自身数量
detailRow["tamount"] = amount;
detailRow["amount"] = amount;
}
if (detailTable.Rows.Count == 0)
{
throw new Exception($"{sourceCode}明细数据为空");
}
frmBillInfo.GcMainView.GridControl.DataSource = detailTable;
SetProcessBar(20, allCount);
frmBillInfo.InitializeHeader(dataRow, Model.BillMasterSql);
SetProcessBar(40, allCount);
string childBillNo = "";
frmBillInfo.BillSave(ref childBillNo);
string childBillMasterSql = $"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 childMasterRow = BillImpl.GetDataRowResult(childBillMasterSql);
SetProcessBar(60, allCount);
frmBillInfo.OnBillAdd();
//记录历史版本号
string updateHistoryVerSql = @"update bom_BillListTab set historyVer = '{0}' where Billdocument_Id='{1}'";
SqlHelper.ExecuteNonQuery(string.Format(updateHistoryVerSql, code, childBillNo));
//备份Bom清单明细
string bakBomListSql = @"delete bom_BillListlogTab where parentProduct = '{0}' and historyVer = (select top 1 historyVer from bom_BillListTab where parentProduct = '{0}');insert into bom_BillListlogTab select * from bom_BillListTab where parentProduct = '{0}';";
SqlHelper.ExecuteNonQuery(string.Format(bakBomListSql, code));
//更新明细关联版本号
string updateChildVerSql = @"update bom_BillListTab set Ver = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{0}') where Billdocument_Id = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{1}') and ProductId='{0}'";
SqlHelper.ExecuteNonQuery(string.Format(updateChildVerSql, code, productId));
frmBillInfo.AddOrUpdateBill(childMasterRow, detailTable);
frmBillInfo.BillSaveSql(childGuid);
SetProcessBar(80, allCount);
isUpload = UploadFile(childInfo.FullName, idValue, out msg, out string _);
bool isUpload = UploadFileToAudit(fileInfo.FullName, sourceCode, "010106", out string msg, out string uploadFileId);
if (!isUpload)
{
throw new Exception($"{sourceCode}附件上传失败\r\n{msg}");
}
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
{
if (selectRow.Table.Columns.Contains("qms_laddf_FileId"))
{
int.TryParse(uploadFileId, out int qms_laddf_FileId);
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
}
if (selectRow.Table.Columns.Contains("qms_laddf_Exec"))
{
selectRow["qms_laddf_Exec"] = childGuid;
}
if (selectRow.Table.Columns.Contains("qms_laddf_ExecOrder"))
{
selectRow["qms_laddf_ExecOrder"] = execOrder;
}
}));
execOrder += 1;
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
}
else
{
SetProcessBar(0, allCount);
bool isUpload = UploadFileToAudit(fileInfo.FullName, sourceCode, "010106", out string msg, out string uploadFileId);
if (!isUpload)
{
throw new Exception($"{sourceCode}附件上传失败\r\n{msg}");
}
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
{
if (selectRow.Table.Columns.Contains("qms_laddf_FileId"))
{
int.TryParse(uploadFileId, out int qms_laddf_FileId);
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
}
}));
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
}
}
else
{
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(code)).FirstOrDefault();
if (childInfo != null)
SetProcessBar(0, allCount);
bool isUpload = UploadFileToAudit(fileInfo.FullName, sourceCode, "010106", out string msg, out string uploadFileId);
if (!isUpload)
{
isUpload = UploadFile(childInfo.FullName, idValue, out msg, out string _);
throw new Exception($"{sourceCode}附件上传失败\r\n{msg}");
}
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
{
if (selectRow.Table.Columns.Contains("qms_laddf_FileId"))
{
int.TryParse(uploadFileId, out int qms_laddf_FileId);
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
}
}));
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
}
}
}
}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
}
finally
{
this.DialogResult = DialogResult.OK;
this.Close();
ImportTimer?.Dispose();
}
});
task.Start();
};
frmBillInfo.OnLoad(Model);
frmMain.ParentView = frmBillInfo.GcMainView;
}
else
{
throw new Exception("未包含结构文件");
throw new Exception($"{fileName}的文件不存在");
}
}
catch (Exception ex)
this.Invoke(new Action(() =>
{
MessageUtil.Show(ex.Message);
this.DialogResult = DialogResult.OK;
Close();
ImportTimer?.Dispose();
}
}
/// <summary>
/// 开始导入
/// </summary>
/// <param name="dirPaths"></param>
public void StartImportInMxFile(string dirPath)
{
try
{
Model = frmMain.Model;
FileInfo parentInfo = new FileInfo(dirPath);
if (parentInfo != null && parentInfo.Name.Trim().StartsWith("MX"))
{
if (Directory.Exists("BomImportTemp"))
{
Directory.Delete("BomImportTemp", true);
}
Directory.CreateDirectory("BomImportTemp");
DataTable parentTable = ExcelToDatatable(parentInfo.FullName, Model, "", 5);
parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "")).ToList().CopyToDataTable();
Dictionary<string, string> childFileDic = new Dictionary<string, string>();
foreach (DataRow parentRow in parentTable.Rows)
{
string fileName = (parentRow["图号"] + "").Trim();
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')";
DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
string sName = fileRow != null ? fileRow["sName"] + "" : "";
if (string.IsNullOrEmpty(webpath))
{
throw new Exception($"Bom明细附件{fileName}不存在\r\nBom导入失败");
}
else
{
using (WebClient webClient = new WebClient())
{
try
{
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
string tempFileName = $"BomImportTemp/{sName}";
webClient.DownloadFile(url, tempFileName);
childFileDic.Add(fileName, tempFileName);
}
catch (Exception)
{
throw new Exception($"Bom明细附件{fileName}获取失败\r\nBom导入失败");
}
}
}
}
}
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow dataRow in parentTable.Rows)
{
string code = (dataRow["图号"] + "").Trim();
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{dataRow[""] + ""}')");
stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{(dataRow[""] + "").Replace("'", "''")}','{(dataRow[""] + "").Replace("'", "''")}','{(dataRow[""] + "").Replace("'", "''")}','0199') end;");
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
}
FrmBillInfo frmBillInfo = new FrmBillInfo();
frmBillInfo.OnControlSourceBind += (s, args) =>
{
Task task = new Task(() =>
{
try
{
SetProcessBar(0, 0);
SetProcessMsg($"正在导入:{Path.GetFileName(parentInfo.FullName)}");
DataTable childTable = new DataTable();
foreach (GridColumn gridColumn in frmBillInfo.GcMainView.Columns)
{
if (!childTable.Columns.Contains(gridColumn.FieldName))
{
childTable.Columns.Add(gridColumn.FieldName, gridColumn.ColumnType);
}
}
foreach (DataRow parentRow in parentTable.Rows)
{
string code = (parentRow["图号"] + "").Trim();
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
string tempFileName = childFileDic[code];
FileInfo childInfo = new FileInfo(tempFileName);
if (childInfo != null)
{
DataRow childRow = childTable.NewRow();
childRow["ProductId"] = parentRow["图号"] + "";
childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = parentRow["备注"] + "";
childRow["tamount"] = parentRow["套数"] + "";
childRow["amount"] = parentRow["套数"] + "";
childTable.Rows.Add(childRow);
}
else
{
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
}
}
}
SetProcessBar(20, 0);
frmBillInfo.GcMainView.GridControl.DataSource = childTable;
SetProcessBar(40, 0);
string controlSql = "select '' as billdocument_id,'0' affirmer,'0' rtagid,'{材料代码}' as productid";
frmBillInfo.InitializeHeader(Model.MaintabFocusedRow, controlSql);
SetProcessBar(60, 0);
string billNo = "";
frmBillInfo.BillSave(ref billNo);
SetProcessBar(80, 0);
frmBillInfo.OnBillAdd();
string productId = Model.MaintabFocusedRow["材料代码"] + "";
string billdocumentId = Model.MaintabFocusedRow["单据编号"] + "";
string idValue = BaseImpl.GetResult($"select top 1 billdocument_id from bom_billListTab where ParentProduct = '{productId}'") + "";
string updateParentVerSql = @"update bom_BillListTab set Ver = '{0}' where Billdocument_Id='{1}' and ProductId='{0}'";
SqlHelper.ExecuteNonQuery(string.Format(updateParentVerSql, idValue, billdocumentId));
//上传文件
bool isUpload = UploadFile(parentInfo.FullName, idValue, out string msg, out string _);
SetProcessBar(100, (1 / (parentTable.Rows.Count + 1)) * 100);
SetProcessLabelAllMsg($"总进度:{1}/{parentTable.Rows.Count + 1}");
int.TryParse(Model.FirstRowIndex, out int index);
frmMain.FirstRowIndex = index;
foreach (DataRow dataRow in parentTable.Rows)
{
int childIndex = parentTable.Rows.IndexOf(dataRow);
int nowCount = 1 + childIndex;
int allCount = (int)((decimal)(1 + childIndex) / (parentTable.Rows.Count + 1) * 100);
int finishCount = (int)((decimal)(1 + nowCount) / (parentTable.Rows.Count + 1) * 100);
int.TryParse(dataRow["套数"] + "", out int tamount);
string code = (dataRow["图号"] + "").Trim();
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
if (productRow == null)
{
string tempFileName = childFileDic[code];
FileInfo childInfo = new FileInfo(tempFileName);
if (childInfo != null)
{
SetProcessBar(0, allCount);
SetProcessMsg($"正在导入:{Path.GetFileName(childInfo.FullName)}");
DataTable detailTable = new DataTable();
frmMain.Invoke(new Action(() =>
{
detailTable = frmMain.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true);
}));
foreach (DataRow detailRow in detailTable.Rows)
{
int.TryParse(detailRow["amount"] + "", out int lastAmount);
detailRow["tamount"] = tamount;
detailRow["amount"] = lastAmount;
}
frmBillInfo.GcMainView.GridControl.DataSource = detailTable;
SetProcessBar(20, allCount);
frmBillInfo.InitializeHeader(dataRow, Model.BillMasterSql);
SetProcessBar(40, allCount);
string childBillNo = "";
frmBillInfo.BillSave(ref childBillNo);
SetProcessBar(60, allCount);
frmBillInfo.OnBillAdd();
//记录历史版本号
string updateHistoryVerSql = @"update bom_BillListTab set historyVer = '{0}' where Billdocument_Id='{1}'";
SqlHelper.ExecuteNonQuery(string.Format(updateHistoryVerSql, code, childBillNo));
//备份Bom清单明细
string bakBomListSql = @"delete bom_BillListlogTab where parentProduct = '{0}' and historyVer = (select top 1 historyVer from bom_BillListTab where parentProduct = '{0}');insert into bom_BillListlogTab select * from bom_BillListTab where parentProduct = '{0}';";
SqlHelper.ExecuteNonQuery(string.Format(bakBomListSql, code));
//更新明细关联版本
string updateChildVerSql = @"update bom_BillListTab set Ver = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{0}') where Billdocument_Id = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{1}') and ProductId='{0}'";
SqlHelper.ExecuteNonQuery(string.Format(updateChildVerSql, code, productId));
SetProcessBar(80, allCount);
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
}
else
{
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
}
}
}
}
}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
}
finally
this.Invoke(new Action(() =>
{
this.DialogResult = DialogResult.OK;
this.Close();
ImportTimer?.Dispose();
}
});
task.Start();
};
frmBillInfo.OnLoad(Model);
frmMain.ParentView = frmBillInfo.GcMainView;
}
else
{
MessageUtil.Show("不是MX文件");
this.DialogResult = DialogResult.Cancel;
Close();
ImportTimer?.Dispose();
}));
}
});
task.Start();
};
frmBillInfo.OnLoad(Model);
frmMain.ParentView = frmBillInfo.GcMainView;
}
catch (Exception ex)
{
@@ -502,14 +259,14 @@ namespace Lskj.PubBomImport
}
}
/// <summary>
/// 开始导入3
/// 修改单个文件
/// </summary>
/// <param name="dirPaths"></param>
public void StartImportInQDFile()
{
string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue;
try
{
string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue;
string productCode = "";
ControlModel controlModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("物料编码")).FirstOrDefault();
if (controlModel != null)
@@ -1007,6 +764,7 @@ namespace Lskj.PubBomImport
{
MessageUtil.Show(ex.Message);
this.DialogResult = DialogResult.Cancel;
BaseImpl.ExecSqlValue($"delete QMS_wenjiangenggaitab where qms_wjgg_billdocument_Id = '{primaryValue}'");
}
finally
{
@@ -1023,178 +781,13 @@ namespace Lskj.PubBomImport
{
MessageUtil.Show(ex.Message);
this.DialogResult = DialogResult.Cancel;
BaseImpl.ExecSqlValue($"delete QMS_wenjiangenggaitab where qms_wjgg_billdocument_Id = '{primaryValue}'");
Close();
ImportTimer?.Dispose();
}
}
/// <summary>
/// 开始导入3
/// </summary>
/// <param name="dirPaths"></param>
public void StartImportInQDFile(string dirPath)
{
try
{
Model = frmMain.Model;
string pattern = @"([A-Za-z]+)(\d*)$";
//原物料名称
string productCode = Model.MaintabFocusedRow != null && Model.MaintabFocusedRow.Table.Columns.Contains("qms_laddf_productid") ? Model.MaintabFocusedRow["qms_laddf_productid"] + "" : "";
Match match = Regex.Match(productCode, pattern);
if (match.Success)
{
string sourceModel = match.Groups[1].Value;
string sourceVersion = match.Groups[2].Value;
sourceVersion = string.IsNullOrEmpty(sourceVersion) ? "0" : sourceVersion;
//修改后的文件名
string newProductCode = Model.MaintabFocusedRow != null && Model.MaintabFocusedRow.Table.Columns.Contains("qms_laddf_appellationV123") ? Model.MaintabFocusedRow["qms_laddf_appellationV123"] + "" : "";
FileInfo parentInfo = new FileInfo(dirPath);
if (parentInfo != null && (parentInfo.Name.Trim().StartsWith("QD") || parentInfo.Name.Trim().StartsWith("ZZQD")))
{
string code = "";
string name = "";
string newcode = newProductCode.Trim();
string newname = "";
string namepattern = @"^(.*-S[A-Z]\d*)(.*)$";
Match newProductCodematch = Regex.Match(Path.GetFileNameWithoutExtension(newProductCode).Trim(), namepattern);
Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(parentInfo.Name).Trim(), namepattern);
if (namematch.Success)
{
code = namematch.Groups[1].Value;
name = namematch.Groups[2].Value;
}
if (newProductCodematch.Success)
{
newcode = newProductCodematch.Groups[1].Value;
newname = newProductCodematch.Groups[2].Value;
}
if (!newcode.Equals(code))//选择的文件和版本文件名不匹配
{
throw new Exception($"选择的文件名{code}和数据文件名{newProductCode}不匹配");
}
match = Regex.Match(code, pattern);
if (match.Success)
{
DataTable historyTable = BaseImpl.GetDataTableResult($"select * from bom_BillListlogTab where ParentProduct = '{productCode}' and historyVer = '{code}'");
if (historyTable != null && historyTable.Rows.Count > 0)
{
throw new Exception($"版本{code}已存在");
}
string newModel = match.Groups[1].Value;
string newVersion = match.Groups[2].Value;
newVersion = string.IsNullOrEmpty(newVersion) ? "0" : newVersion;
//新建或修改清单
StringBuilder stringBuilder = new StringBuilder();
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{code}')");
stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{code.Replace("'", "''")}','{name.Replace("'", "''")}','','0199') end;");
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
}
//更新并备份清单
FrmBillInfo frmBillInfo = new FrmBillInfo();
frmBillInfo.OnControlSourceBind += (s, args) =>
{
Task task = new Task(() =>
{
try
{
int.TryParse(Model.FirstRowIndex, out int index);
frmMain.FirstRowIndex = index;
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{
FileInfo childInfo = new FileInfo(dirPath);
if (childInfo != null)
{
frmBillInfo.OnBillAdd();
SetProcessBar(0, 0);
SetProcessMsg($"正在导入:{Path.GetFileName(childInfo.FullName)}");
DataTable detailTable = new DataTable();
frmMain.Invoke(new Action(() =>
{
detailTable = frmMain.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true);
}));
foreach (DataRow detailRow in detailTable.Rows)
{
int.TryParse(detailRow["amount"] + "", out int lastAmount);
detailRow["tamount"] = 1;
detailRow["amount"] = lastAmount;
}
SetProcessBar(20, 0);
string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productCode}') as billdocument_id,'0' affirmer,'0' rtagid,'{productCode}' as productid";
billMasterSql = ReplaceHelper.ReplaceRowParam(Model.MaintabFocusedRow, billMasterSql);
// 处理单据表头数据
DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql);
SetProcessBar(40, 0);
frmBillInfo.AddOrUpdateBill(masterRow, detailTable);
SetProcessBar(60, 0);
//备份Bom清单明细
string bakBomListSql = @"delete bom_BillListlogTab where parentProduct = '{0}' and historyVer = (select top 1 historyVer from bom_BillListTab where parentProduct = '{0}');insert into bom_BillListlogTab select * from bom_BillListTab where parentProduct = '{0}';";
SqlHelper.ExecuteNonQuery(string.Format(bakBomListSql, productCode));
string billNo = "";
frmBillInfo.BillSave(ref billNo);
SetProcessBar(80, 0);
frmBillInfo.OnBillAdd();
//记录历史版本号
string updateHistoryVerSql = @"update bom_BillListTab set historyVer = '{0}' where Billdocument_Id='{1}'";
SqlHelper.ExecuteNonQuery(string.Format(updateHistoryVerSql, code, billNo));
//上传文件
bool isUpload = UploadFile(childInfo.FullName, billNo, out string msg, out string _);
SetProcessBar(100, 100);
SetProcessLabelAllMsg($"总进度:1/1");
}
else
{
throw new Exception($"Bom明细获取失败\r\nBom导入失败");
}
}
}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
}
finally
{
this.DialogResult = DialogResult.OK;
this.Close();
ImportTimer?.Dispose();
}
});
task.Start();
};
frmBillInfo.OnLoad(Model);
frmMain.ParentView = frmBillInfo.GcMainView;
}
else
{
throw new Exception($"文件名{code}不符合规则");
}
}
else
{
MessageUtil.Show("不是QD或ZZQD文件");
this.DialogResult = DialogResult.Cancel;
Close();
ImportTimer?.Dispose();
}
}
else
{
throw new Exception($"文件名{productCode}不符合规则");
}
}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
this.DialogResult = DialogResult.Cancel;
Close();
ImportTimer?.Dispose();
}
}
/// <summary>
/// 开始导入5
/// bom结构上传
/// </summary>
/// <param name="dirPaths"></param>
public void StartImportInFiles(List<DataRow> selectRows)
@@ -1629,7 +1222,6 @@ namespace Lskj.PubBomImport
}
else
{
FileInfo childInfo = null;
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
if (childInfoRow != null)
@@ -1667,6 +1259,7 @@ namespace Lskj.PubBomImport
}
if (childInfo != null)
{
SetProcessBar(0, allCount);
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
if (filetable.Rows.Count == 0)
{
@@ -1735,7 +1328,7 @@ namespace Lskj.PubBomImport
}
}
/// <summary>
/// 根据已上传的数据进行Bom修改
/// 修改终审同步
/// </summary>
/// <param name="selectRows"></param>
public void StartExecBomUpdate(string billdocument)
@@ -1785,6 +1378,7 @@ namespace Lskj.PubBomImport
GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC);
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}'");
List<SqlParameter> sqlParamList = new List<SqlParameter>();
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
sqlParamList.Add(new SqlParameter("@copyToModule", SqlDbType.VarChar, 100) { Value = "1000202" });
@@ -1803,6 +1397,7 @@ namespace Lskj.PubBomImport
GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC);
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}'");
List<SqlParameter> sqlParamList = new List<SqlParameter>();
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
sqlParamList.Add(new SqlParameter("@copyToModule", SqlDbType.VarChar, 100) { Value = "1000202" });
@@ -1838,7 +1433,7 @@ namespace Lskj.PubBomImport
}
}
/// <summary>
/// 根据已上传的数据进行Bom生成
/// 结构上传终审同步
/// </summary>
/// <param name="selectRows"></param>
public void StartCreateBom(string parentProductId)
@@ -1849,7 +1444,104 @@ namespace Lskj.PubBomImport
{
throw new Exception($"物料编码不能为空");
}
string billdocumentId = BaseImpl.GetResult($"select qms_maddf_billdocument_id from qms_BillFileAddMaintab where qms_maddf_productid = '{parentProductId}'") + "";
string billdocumentId = BaseImpl.GetResult($"select qms_maddf_billdocument_id from qms_BillFileAddMaintab where qms_maddf_productid = '{parentProductId}' and isnull(qms_maddf_addMode,'0') = '0'") + "";
if (string.IsNullOrEmpty(billdocumentId))
{
throw new Exception($"未查询到物料编码{parentProductId}的Bom单据号");
}
if (Directory.Exists("BomImportTemp"))
{
Directory.Delete("BomImportTemp", true);
}
Directory.CreateDirectory("BomImportTemp");
DataTable sourceTable = BaseImpl.GetDataTableResult($"select qms_laddf_productid,qms_laddf_FileId,qms_laddf_Exec from qms_BillFileAddlisttab where qms_laddf_billdocument_id = '{billdocumentId}' order by qms_laddf_ExecOrder");
Task task = new Task(() =>
{
try
{
foreach (DataRow sourceRow in sourceTable.Rows)
{
string productid = sourceRow["qms_laddf_productid"] + "";
string fileId = sourceRow["qms_laddf_FileId"] + "";
string execGuid = sourceRow["qms_laddf_Exec"] + "";
int childIndex = sourceTable.Rows.IndexOf(sourceRow);
int nowCount = 1 + childIndex;
int allCount = (int)((decimal)(childIndex) / (sourceTable.Rows.Count) * 100);
int finishCount = (int)((decimal)(1 + childIndex) / (sourceTable.Rows.Count) * 100);
Model = frmMain.Model;
DataRow execRow = BaseImpl.GetDataRowResult($"select * from p_bomImportExecTab where isnull(success,0) = 0 and guid = '{execGuid}'");
if (!string.IsNullOrEmpty(execGuid) && execRow != null)
{
string masterSql = execRow["masterSql"] + "";
string detailSql = execRow["detailSql"] + "";
string afterSql = execRow["afterSql"] + "";
string detailTable = execRow["detailTable"] + "";
string detailGuid = execRow["detailGuid"] + "";
string billSeq = execRow["billSeq"] + "";
int.TryParse(execRow["billWay"] + "", out int billWay);
int.TryParse(execRow["comfirm"] + "", out int comfirm);
int.TryParse(execRow["auditFlag"] + "", out int auditFlag);
int.TryParse(execRow["newVer"] + "", out int newVer);
string billNo = execRow["billNo"] + "";
if (!string.IsNullOrEmpty(masterSql) && !string.IsNullOrEmpty(detailSql))
{
int result = BillImpl.BillSave(masterSql, detailSql, detailTable, ref billNo, detailGuid, billSeq, billWay, comfirm, out string tipMsg, auditFlag, newVer);
if (result == 1)
{
BaseImpl.ExecSqlValue(afterSql);
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
}
else
{
throw new Exception($"保存Bom失败\r\n{tipMsg}");
}
}
else
{
BaseImpl.ExecSqlValue(afterSql);
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
}
}
BaseImpl.ExecSqlValue($"update p_fm_filetab set isdisabled = 0 where fileid = '{fileId}'");
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{sourceTable.Rows.Count + 1}");
}
this.DialogResult = DialogResult.OK;
}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
this.DialogResult = DialogResult.Cancel;
}
finally
{
this.Close();
ImportTimer?.Dispose();
}
});
task.Start();
}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
this.DialogResult = DialogResult.Cancel;
Close();
ImportTimer?.Dispose();
}
}
/// <summary>
/// 结构补充终审同步
/// </summary>
/// <param name="selectRows"></param>
public void StartCreateBomAdd(string parentProductId)
{
try
{
if (string.IsNullOrEmpty(parentProductId))
{
throw new Exception($"物料编码不能为空");
}
string billdocumentId = BaseImpl.GetResult($"select qms_maddf_billdocument_id from qms_BillFileAddMaintab where qms_maddf_productid = '{parentProductId}' and isnull(qms_maddf_addMode,'0') = '1'") + "";
if (string.IsNullOrEmpty(billdocumentId))
{
throw new Exception($"未查询到物料编码{parentProductId}的Bom单据号");
@@ -1907,28 +1599,6 @@ namespace Lskj.PubBomImport
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
}
}
//using (WebClient webClient = new WebClient())
//{
// try
// {
// int.TryParse(fileId, out int convertFileId);
// DataRow fileRow = BaseImpl.GetDataRowResult($"select webpath,sname from p_fm_filetab where fileId = '{fileId}'");
// if (convertFileId > 0 && fileRow != null)
// {
// string webpath = fileRow["webpath"] + "";
// string sName = fileRow["sname"] + "";
// webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
// string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
// string tempFileName = $"BomImportTemp/{sName}";
// webClient.DownloadFile(url, tempFileName);
// bool isUpload = UploadFileToAudit(tempFileName, productid, "010106", out string msg, out string otherFieldId);
// }
// }
// catch (Exception)
// {
// throw new Exception($"Bom明细附件{productid}获取失败\r\nBom导入失败");
// }
//}
BaseImpl.ExecSqlValue($"update p_fm_filetab set isdisabled = 0 where fileid = '{fileId}'");
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{sourceTable.Rows.Count + 1}");