SVN r601
SVN-Revision: r601
This commit is contained in:
@@ -80,7 +80,7 @@ namespace Lskj.PubBomImport
|
|||||||
InitGridColumns();
|
InitGridColumns();
|
||||||
InitMulitControl();
|
InitMulitControl();
|
||||||
InitDataSource();
|
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);
|
OnBtnImportClick(null, null);
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,17 @@ namespace Lskj.PubBomImport
|
|||||||
if (dialogResult == DialogResult.OK)
|
if (dialogResult == DialogResult.OK)
|
||||||
{
|
{
|
||||||
Properties.Settings.Default.LastSelectFolder = Path.GetDirectoryName(dialog.FileName);
|
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()
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
{
|
{
|
||||||
ShowType = Model.ShowType,
|
ShowType = Model.ShowType,
|
||||||
@@ -248,67 +259,83 @@ namespace Lskj.PubBomImport
|
|||||||
// this.Close();
|
// this.Close();
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//else if (Model.ShowType.Equals("3"))//新增多个清单文件
|
else if (Model.ShowType.Equals("3"))//新增多个QD文件或图纸文件
|
||||||
//{
|
{
|
||||||
// BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
// {
|
{
|
||||||
// ShowType = Model.ShowType,
|
ShowType = Model.ShowType,
|
||||||
// AfterBomFieldName = Model.AfterBomFieldName,
|
AfterBomFieldName = Model.AfterBomFieldName,
|
||||||
// CanSave = true
|
CanSave = true
|
||||||
// };
|
};
|
||||||
// FormDialogModel dialogModel = new FormDialogModel()
|
FormDialogModel dialogModel = new FormDialogModel()
|
||||||
// {
|
{
|
||||||
// DialogDllName = "Lskj.PubBomImport.dll",
|
DialogDllName = "Lskj.PubBomImport.dll",
|
||||||
// PubDialogType = DialogType.PubAddRecord,
|
PubDialogType = DialogType.PubAddRecord,
|
||||||
// ReturnTag = bomImpRtnModel
|
ReturnTag = bomImpRtnModel
|
||||||
// };
|
};
|
||||||
// this.Tag = dialogModel;
|
this.Tag = dialogModel;
|
||||||
// DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
|
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
|
||||||
// if (sourceTable.Columns.Contains("BomFieldNameDir"))
|
if (sourceTable.Columns.Contains("BomFieldNameDir"))
|
||||||
// {
|
{
|
||||||
// List<DataRow> selectRows = new List<DataRow>();
|
List<DataRow> selectRows = new List<DataRow>();
|
||||||
// foreach (DataRow sourceRow in sourceTable.Rows)
|
foreach (DataRow sourceRow in sourceTable.Rows)
|
||||||
// {
|
{
|
||||||
// if (sourceRow.RowState == DataRowState.Deleted)
|
if (sourceRow.RowState == DataRowState.Deleted)
|
||||||
// {
|
{
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// string fileName = sourceRow[Model.AfterBomFieldName] + "";
|
string fileName = sourceRow[Model.AfterBomFieldName] + "";
|
||||||
// string dirPath = sourceRow["BomFieldNameDir"] + "";
|
string dirPath = sourceRow["BomFieldNameDir"] + "";
|
||||||
// FileInfo parentInfo = null;
|
FileInfo parentInfo = null;
|
||||||
// if (string.IsNullOrEmpty(dirPath))
|
if (string.IsNullOrEmpty(dirPath))
|
||||||
// {
|
{
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// parentInfo = new FileInfo(dirPath);
|
parentInfo = new FileInfo(dirPath);
|
||||||
// selectRows.Add(sourceRow);
|
selectRows.Add(sourceRow);
|
||||||
// }
|
}
|
||||||
// if (selectRows.Count > 0)
|
if (selectRows.Count > 0)
|
||||||
// {
|
{
|
||||||
// FrmProgress frmProgress = new FrmProgress();
|
FrmProgress frmProgress = new FrmProgress();
|
||||||
// frmProgress.frmMain = this;
|
frmProgress.frmMain = this;
|
||||||
// frmProgress.Model = Model;
|
frmProgress.Model = Model;
|
||||||
// frmProgress.ImportTimer.Tick += (ts, te) =>
|
frmProgress.ImportTimer.Tick += (ts, te) =>
|
||||||
// {
|
{
|
||||||
// frmProgress.ImportTimer.Enabled = false;
|
frmProgress.ImportTimer.Enabled = false;
|
||||||
// frmProgress.StartImportInQDFile(selectRows);
|
frmProgress.StartImportInQDOrZZFiles(selectRows);
|
||||||
// };
|
};
|
||||||
// frmProgress.ImportTimer.Enabled = true;
|
frmProgress.ImportTimer.Enabled = true;
|
||||||
// DialogResult dialogResult = frmProgress.ShowDialog();
|
DialogResult dialogResult = frmProgress.ShowDialog();
|
||||||
// bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
|
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
|
||||||
// frmProgress.Dispose();
|
frmProgress.Dispose();
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// this.Close();
|
this.Close();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// this.Close();
|
this.Close();
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
else if (Model.ShowType.Equals("4"))//新增或修改单个清单文件
|
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()
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
{
|
{
|
||||||
@@ -336,7 +363,7 @@ namespace Lskj.PubBomImport
|
|||||||
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
|
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
|
||||||
frmProgress.Dispose();
|
frmProgress.Dispose();
|
||||||
}
|
}
|
||||||
else if (Model.ShowType.Equals("44"))//通过已经上传的数据来解析并且建立BOM
|
else if (Model.ShowType.Equals("44"))//修改终审同步
|
||||||
{
|
{
|
||||||
|
|
||||||
FrmProgress frmProgress = new FrmProgress();
|
FrmProgress frmProgress = new FrmProgress();
|
||||||
@@ -352,7 +379,7 @@ namespace Lskj.PubBomImport
|
|||||||
frmProgress.ShowDialog();
|
frmProgress.ShowDialog();
|
||||||
frmProgress.Dispose();
|
frmProgress.Dispose();
|
||||||
}
|
}
|
||||||
else if (Model.ShowType.Equals("5"))//通过文件名进行文件上传和逻辑记录
|
else if (Model.ShowType.Equals("5"))//bom结构上传
|
||||||
{
|
{
|
||||||
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
{
|
{
|
||||||
@@ -412,7 +439,7 @@ namespace Lskj.PubBomImport
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Model.ShowType.Equals("55"))//通过已经上传的数据来解析并且建立BOM
|
else if (Model.ShowType.Equals("55"))//结构上传终审同步
|
||||||
{
|
{
|
||||||
|
|
||||||
FrmProgress frmProgress = new FrmProgress();
|
FrmProgress frmProgress = new FrmProgress();
|
||||||
|
|||||||
@@ -45,453 +45,210 @@ namespace Lskj.PubBomImport
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.ControlBox = false;
|
this.ControlBox = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始导入
|
/// Bom结构补充,新增QD或图纸
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dirPaths"></param>
|
/// <param name="dirPaths"></param>
|
||||||
public void StartImportInDir(string dirPath)
|
public void StartImportInQDOrZZFiles(List<DataRow> selectRows)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Model = frmMain.Model;
|
int execOrder = 1;
|
||||||
DirectoryInfo directoryInfo = new DirectoryInfo(dirPath);
|
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||||
FileInfo[] fileInfos = directoryInfo.GetFiles();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
FileInfo parentInfo = fileInfos.Where(n => n.Name.StartsWith("MX") && n.Extension.Equals(".xlsx", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
foreach (DataRow selectRow in selectRows)
|
||||||
if (parentInfo != null)
|
|
||||||
{
|
{
|
||||||
if (Directory.Exists("BomImportTemp"))
|
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||||
|
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||||
|
FileInfo fileInfo = new FileInfo(dirPath);
|
||||||
|
if (fileInfo != null)
|
||||||
{
|
{
|
||||||
Directory.Delete("BomImportTemp", true);
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
}
|
GetFileCodeInfo(fileNameWithoutExtension, out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC);
|
||||||
Directory.CreateDirectory("BomImportTemp");
|
if (sourceCode.StartsWith("ZZQD"))
|
||||||
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)
|
|
||||||
{
|
|
||||||
string fileName = (parentRow["图号"] + "").Trim();
|
|
||||||
if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD"))
|
|
||||||
{
|
{
|
||||||
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(fileName)).FirstOrDefault();
|
throw new Exception($"不允许补充ZZQD文件{sourceCode}\r\n请进行变更");
|
||||||
if (childInfo == null)
|
}
|
||||||
|
else if (sourceCode.StartsWith("MX"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充MX文件{sourceCode}\r\n请进行变更");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(sourceCode) && !string.IsNullOrEmpty(sourceBB))
|
||||||
{
|
{
|
||||||
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')";
|
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}%'");
|
||||||
DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
|
if (filetable.Rows.Count > 0)
|
||||||
string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
|
|
||||||
string sName = fileRow != null ? fileRow["sName"] + "" : "";
|
|
||||||
if (string.IsNullOrEmpty(webpath))
|
|
||||||
{
|
{
|
||||||
throw new Exception($"Bom明细附件{fileName}不存在\r\nBom导入失败");
|
throw new Exception($"{sourceCode}的附件已存在\r\n请进行变更");
|
||||||
}
|
}
|
||||||
else
|
if (sourceCode.StartsWith("QD"))
|
||||||
{
|
{
|
||||||
using (WebClient webClient = new WebClient())
|
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;");
|
||||||
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导入失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"文件{fileNameWithoutExtension}名称不符合规范");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
else
|
||||||
foreach (DataRow dataRow in parentTable.Rows)
|
|
||||||
{
|
{
|
||||||
string code = (dataRow["图号"] + "").Trim();
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
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()))
|
}
|
||||||
|
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
|
||||||
|
{
|
||||||
|
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
|
||||||
|
}
|
||||||
|
frmBillInfo.OnControlSourceBind += (s, args) =>
|
||||||
|
{
|
||||||
|
Task task = new Task(() =>
|
||||||
{
|
{
|
||||||
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
|
try
|
||||||
}
|
|
||||||
frmBillInfo.OnControlSourceBind += (s, args) =>
|
|
||||||
{
|
|
||||||
Task task = new Task(() =>
|
|
||||||
{
|
{
|
||||||
try
|
int.TryParse(Model.FirstRowIndex, out int index);
|
||||||
|
frmMain.FirstRowIndex = index;
|
||||||
|
foreach (DataRow selectRow in selectRows)
|
||||||
{
|
{
|
||||||
SetProcessBar(0, 0);
|
int childIndex = selectRows.IndexOf(selectRow);
|
||||||
SetProcessMsg($"正在导入:{Path.GetFileName(parentInfo.FullName)}");
|
int nowCount = 1 + childIndex;
|
||||||
DataTable childTable = new DataTable();
|
int allCount = (int)((decimal)(1 + childIndex) / (selectRows.Count + 1) * 100);
|
||||||
foreach (GridColumn gridColumn in frmBillInfo.GcMainView.Columns)
|
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)
|
||||||
{
|
{
|
||||||
if (!childTable.Columns.Contains(gridColumn.FieldName))
|
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"))
|
||||||
{
|
{
|
||||||
childTable.Columns.Add(gridColumn.FieldName, gridColumn.ColumnType);
|
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{sourceCode}'");
|
||||||
}
|
if (productRow == null)//如果不存在bom建立单
|
||||||
}
|
|
||||||
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];
|
string childGuid = Guid.NewGuid() + "";
|
||||||
childInfo = new FileInfo(tempFileName);
|
frmBillInfo.OnBillAdd();
|
||||||
}
|
SetProcessBar(0, allCount);
|
||||||
if (childInfo != null)
|
SetProcessMsg($"正在导入:{Path.GetFileName(fileInfo.FullName)}");
|
||||||
{
|
DataTable detailTable = new DataTable();
|
||||||
DataRow childRow = childTable.NewRow();
|
frmMain.Invoke(new Action(() =>
|
||||||
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)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(code)).FirstOrDefault();
|
|
||||||
if (childInfo == null)
|
|
||||||
{
|
{
|
||||||
string tempFileName = childFileDic[code];
|
detailTable = frmMain.ToExcelDataTable(fileInfo.FullName, out int count, out int errorCount, true);
|
||||||
childInfo = new FileInfo(tempFileName);
|
}));
|
||||||
|
foreach (DataRow detailRow in detailTable.Rows)
|
||||||
|
{
|
||||||
|
int.TryParse(detailRow["amount"] + "", out int amount);
|
||||||
|
//数量暂定为自身数量
|
||||||
|
detailRow["tamount"] = amount;
|
||||||
|
detailRow["amount"] = amount;
|
||||||
}
|
}
|
||||||
if (childInfo != null)
|
if (detailTable.Rows.Count == 0)
|
||||||
{
|
{
|
||||||
if ((code.StartsWith("QD") || code.StartsWith("ZZQD")))
|
throw new Exception($"{sourceCode}明细数据为空");
|
||||||
|
}
|
||||||
|
SetProcessBar(40, allCount);
|
||||||
|
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.AddOrUpdateBill(childMasterRow, detailTable);
|
||||||
|
frmBillInfo.BillSaveSql(childGuid);
|
||||||
|
SetProcessBar(80, 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"))
|
||||||
{
|
{
|
||||||
SetProcessBar(0, allCount);
|
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||||
SetProcessMsg($"正在导入:{Path.GetFileName(childInfo.FullName)}");
|
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||||
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);
|
|
||||||
isUpload = UploadFile(childInfo.FullName, idValue, out msg, out string _);
|
|
||||||
SetProcessBar(100, finishCount);
|
|
||||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
|
||||||
}
|
}
|
||||||
|
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}/{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
|
else
|
||||||
{
|
{
|
||||||
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(code)).FirstOrDefault();
|
SetProcessBar(0, allCount);
|
||||||
if (childInfo != null)
|
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}");
|
||||||
SetProcessBar(100, finishCount);
|
|
||||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
this.Invoke(new Action(() =>
|
||||||
{
|
|
||||||
MessageUtil.Show(ex.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
{
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
this.Close();
|
Close();
|
||||||
ImportTimer?.Dispose();
|
ImportTimer?.Dispose();
|
||||||
}
|
}));
|
||||||
});
|
|
||||||
task.Start();
|
|
||||||
};
|
|
||||||
frmBillInfo.OnLoad(Model);
|
|
||||||
frmMain.ParentView = frmBillInfo.GcMainView;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("未包含结构文件");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
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导入失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
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["图号"] + ""}')");
|
MessageUtil.Show(ex.Message);
|
||||||
stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{(dataRow["图号"] + "").Replace("'", "''")}','{(dataRow["名称"] + "").Replace("'", "''")}','{(dataRow["备注"] + "").Replace("'", "''")}','0199') end;");
|
this.Invoke(new Action(() =>
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
this.DialogResult = DialogResult.Cancel;
|
||||||
SetProcessMsg($"正在导入:{Path.GetFileName(parentInfo.FullName)}");
|
Close();
|
||||||
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.DialogResult = DialogResult.OK;
|
|
||||||
this.Close();
|
|
||||||
ImportTimer?.Dispose();
|
ImportTimer?.Dispose();
|
||||||
}
|
}));
|
||||||
});
|
}
|
||||||
task.Start();
|
});
|
||||||
};
|
task.Start();
|
||||||
frmBillInfo.OnLoad(Model);
|
};
|
||||||
frmMain.ParentView = frmBillInfo.GcMainView;
|
frmBillInfo.OnLoad(Model);
|
||||||
}
|
frmMain.ParentView = frmBillInfo.GcMainView;
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageUtil.Show("不是MX文件");
|
|
||||||
this.DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
ImportTimer?.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -502,14 +259,14 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始导入3
|
/// 修改单个文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dirPaths"></param>
|
/// <param name="dirPaths"></param>
|
||||||
public void StartImportInQDFile()
|
public void StartImportInQDFile()
|
||||||
{
|
{
|
||||||
|
string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string primaryValue = StaticControl.RightMenuMyControl.PrimaryValue;
|
|
||||||
string productCode = "";
|
string productCode = "";
|
||||||
ControlModel controlModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("物料编码")).FirstOrDefault();
|
ControlModel controlModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("物料编码")).FirstOrDefault();
|
||||||
if (controlModel != null)
|
if (controlModel != null)
|
||||||
@@ -1007,6 +764,7 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
MessageUtil.Show(ex.Message);
|
MessageUtil.Show(ex.Message);
|
||||||
this.DialogResult = DialogResult.Cancel;
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
BaseImpl.ExecSqlValue($"delete QMS_wenjiangenggaitab where qms_wjgg_billdocument_Id = '{primaryValue}'");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -1023,178 +781,13 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
MessageUtil.Show(ex.Message);
|
MessageUtil.Show(ex.Message);
|
||||||
this.DialogResult = DialogResult.Cancel;
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
BaseImpl.ExecSqlValue($"delete QMS_wenjiangenggaitab where qms_wjgg_billdocument_Id = '{primaryValue}'");
|
||||||
Close();
|
Close();
|
||||||
ImportTimer?.Dispose();
|
ImportTimer?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始导入3
|
/// bom结构上传
|
||||||
/// </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
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dirPaths"></param>
|
/// <param name="dirPaths"></param>
|
||||||
public void StartImportInFiles(List<DataRow> selectRows)
|
public void StartImportInFiles(List<DataRow> selectRows)
|
||||||
@@ -1629,7 +1222,6 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
FileInfo childInfo = null;
|
FileInfo childInfo = null;
|
||||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||||
if (childInfoRow != null)
|
if (childInfoRow != null)
|
||||||
@@ -1667,6 +1259,7 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
if (childInfo != null)
|
if (childInfo != null)
|
||||||
{
|
{
|
||||||
|
SetProcessBar(0, allCount);
|
||||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||||
if (filetable.Rows.Count == 0)
|
if (filetable.Rows.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -1735,7 +1328,7 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据已上传的数据进行Bom修改
|
/// 修改终审同步
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="selectRows"></param>
|
/// <param name="selectRows"></param>
|
||||||
public void StartExecBomUpdate(string billdocument)
|
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);
|
GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC);
|
||||||
BaseImpl.ExecSqlValue(afterSql);
|
BaseImpl.ExecSqlValue(afterSql);
|
||||||
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
|
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>();
|
List<SqlParameter> sqlParamList = new List<SqlParameter>();
|
||||||
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
|
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
|
||||||
sqlParamList.Add(new SqlParameter("@copyToModule", SqlDbType.VarChar, 100) { Value = "1000202" });
|
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);
|
GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC);
|
||||||
BaseImpl.ExecSqlValue(afterSql);
|
BaseImpl.ExecSqlValue(afterSql);
|
||||||
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
|
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>();
|
List<SqlParameter> sqlParamList = new List<SqlParameter>();
|
||||||
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
|
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
|
||||||
sqlParamList.Add(new SqlParameter("@copyToModule", SqlDbType.VarChar, 100) { Value = "1000202" });
|
sqlParamList.Add(new SqlParameter("@copyToModule", SqlDbType.VarChar, 100) { Value = "1000202" });
|
||||||
@@ -1838,7 +1433,7 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据已上传的数据进行Bom生成
|
/// 结构上传终审同步
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="selectRows"></param>
|
/// <param name="selectRows"></param>
|
||||||
public void StartCreateBom(string parentProductId)
|
public void StartCreateBom(string parentProductId)
|
||||||
@@ -1849,7 +1444,104 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
throw new Exception($"物料编码不能为空");
|
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))
|
if (string.IsNullOrEmpty(billdocumentId))
|
||||||
{
|
{
|
||||||
throw new Exception($"未查询到物料编码{parentProductId}的Bom单据号");
|
throw new Exception($"未查询到物料编码{parentProductId}的Bom单据号");
|
||||||
@@ -1907,28 +1599,6 @@ namespace Lskj.PubBomImport
|
|||||||
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
|
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}'");
|
BaseImpl.ExecSqlValue($"update p_fm_filetab set isdisabled = 0 where fileid = '{fileId}'");
|
||||||
SetProcessBar(100, finishCount);
|
SetProcessBar(100, finishCount);
|
||||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{sourceTable.Rows.Count + 1}");
|
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{sourceTable.Rows.Count + 1}");
|
||||||
|
|||||||
Reference in New Issue
Block a user