SVN r597
SVN-Revision: r597
This commit is contained in:
@@ -1272,7 +1272,6 @@ namespace Lskj.PubBomImport
|
||||
DataRow parentProductRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}'");
|
||||
Dictionary<string, DataRow> maxBcFileDic = new Dictionary<string, DataRow>();
|
||||
Dictionary<string, DataTable> fileTableDic = new Dictionary<string, DataTable>();
|
||||
List<string> notUploadFileList = new List<string>();
|
||||
if (parentProductRow == null)
|
||||
{
|
||||
frmBillInfo.OnBillAdd();
|
||||
@@ -1312,17 +1311,7 @@ namespace Lskj.PubBomImport
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
childInfo = new FileInfo(childDirPath);
|
||||
}
|
||||
//如果存在附件则判断是否已经上传了附件
|
||||
if (childInfo != null)
|
||||
{
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
|
||||
if (childsourceBC <= childMaxBc && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
notUploadFileList.Add(code);
|
||||
childInfo = null;//设置为空下载附件使用
|
||||
}
|
||||
}
|
||||
if (childInfo == null && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
if ((childInfo == null || filetable.Rows.Count > 0) && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
@@ -1480,124 +1469,90 @@ namespace Lskj.PubBomImport
|
||||
DataTable filetable = fileTableDic.ContainsKey(code) ? fileTableDic[code] : null;
|
||||
if (code.StartsWith("QD"))
|
||||
{
|
||||
if (!notUploadFileList.Contains(code))
|
||||
|
||||
FileInfo childInfo = null;
|
||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||
if (childInfoRow != null)
|
||||
{
|
||||
FileInfo childInfo = null;
|
||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||
if (childInfoRow != null)
|
||||
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
childInfo = new FileInfo(childDirPath);
|
||||
}
|
||||
if ((childInfo == null || filetable.Rows.Count > 0) && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
childInfo = new FileInfo(childDirPath);
|
||||
}
|
||||
if (childInfo == null && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
try
|
||||
{
|
||||
try
|
||||
string webpath = maxBcFileDic[code]["webpath"] + "";
|
||||
string sName = maxBcFileDic[code]["sName"] + "";
|
||||
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
|
||||
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
|
||||
string tempFileName = $"BomImportTemp/{sName}";
|
||||
if (!File.Exists(tempFileName))
|
||||
{
|
||||
string webpath = maxBcFileDic[code]["webpath"] + "";
|
||||
string sName = maxBcFileDic[code]["sName"] + "";
|
||||
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
|
||||
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
|
||||
string tempFileName = $"BomImportTemp/{sName}";
|
||||
if (!File.Exists(tempFileName))
|
||||
{
|
||||
webClient.DownloadFile(url, tempFileName);
|
||||
}
|
||||
childInfo = new FileInfo(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
|
||||
webClient.DownloadFile(url, tempFileName);
|
||||
}
|
||||
childInfo = new FileInfo(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
|
||||
}
|
||||
}
|
||||
if (childInfo == null)
|
||||
}
|
||||
if (childInfo == null)
|
||||
{
|
||||
throw new Exception($"MX明细中的{code}文件不存在");
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC);
|
||||
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
|
||||
if (productRow == null)
|
||||
{
|
||||
throw new Exception($"MX明细中的{code}文件不存在");
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC);
|
||||
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
|
||||
if (productRow == null)
|
||||
{
|
||||
if ((code.StartsWith("QD") || code.StartsWith("ZZQD")))
|
||||
{
|
||||
frmBillInfo.OnBillAdd();
|
||||
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 amount);
|
||||
//数量暂定为自身数量
|
||||
detailRow["tamount"] = amount;
|
||||
detailRow["amount"] = amount;
|
||||
}
|
||||
if (detailTable.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception($"{code}明细数据为空");
|
||||
}
|
||||
SetProcessBar(40, allCount);
|
||||
string childBillMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{code}') as billdocument_id,'0' affirmer,'0' rtagid,'{code}' as productid,'{qdsourceCode}' as bak,'{qdsourceBB}' as bombb,'{qdsourceBC}' as bombc";
|
||||
// 处理单据表头数据
|
||||
DataRow childMasterRow = BillImpl.GetDataRowResult(childBillMasterSql);
|
||||
SetProcessBar(60, allCount);
|
||||
frmBillInfo.AddOrUpdateBill(childMasterRow, detailTable);
|
||||
string childGuid = Guid.NewGuid() + "";
|
||||
frmBillInfo.BillSaveSql(childGuid);
|
||||
SetProcessBar(80, allCount);
|
||||
//记录历史版本号
|
||||
//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);
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_Exec"))
|
||||
{
|
||||
childInfoRow["qms_laddf_Exec"] = childGuid;
|
||||
}
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_ExecOrder"))
|
||||
{
|
||||
childInfoRow["qms_laddf_ExecOrder"] = execOrder;
|
||||
}
|
||||
}));
|
||||
execOrder += 1;
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
||||
}
|
||||
}
|
||||
else
|
||||
string childGuid = Guid.NewGuid() + "";
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
frmBillInfo.OnBillAdd();
|
||||
SetProcessBar(0, allCount);
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
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 amount);
|
||||
//数量暂定为自身数量
|
||||
detailRow["tamount"] = amount;
|
||||
detailRow["amount"] = amount;
|
||||
}
|
||||
if (detailTable.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception($"{code}明细数据为空");
|
||||
}
|
||||
SetProcessBar(40, allCount);
|
||||
string childBillMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{code}') as billdocument_id,'0' affirmer,'0' rtagid,'{code}' as productid,'{qdsourceCode}' as bak,'{qdsourceBB}' as bombb,'{qdsourceBC}' as bombc";
|
||||
// 处理单据表头数据
|
||||
DataRow childMasterRow = BillImpl.GetDataRowResult(childBillMasterSql);
|
||||
SetProcessBar(60, allCount);
|
||||
frmBillInfo.AddOrUpdateBill(childMasterRow, detailTable);
|
||||
frmBillInfo.BillSaveSql(childGuid);
|
||||
SetProcessBar(80, allCount);
|
||||
//记录历史版本号
|
||||
//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);
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId);
|
||||
@@ -1606,66 +1561,30 @@ namespace Lskj.PubBomImport
|
||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_Exec"))
|
||||
{
|
||||
childInfoRow["qms_laddf_Exec"] = childGuid;
|
||||
}
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_ExecOrder"))
|
||||
{
|
||||
childInfoRow["qms_laddf_ExecOrder"] = execOrder;
|
||||
}
|
||||
}));
|
||||
execOrder += 1;
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"目录中不包含文件{code}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!notUploadFileList.Contains(code))
|
||||
{
|
||||
FileInfo childInfo = null;
|
||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||
if (childInfoRow != null)
|
||||
{
|
||||
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
childInfo = new FileInfo(childDirPath);
|
||||
}
|
||||
if (childInfo == null && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
string webpath = maxBcFileDic[code]["webpath"] + "";
|
||||
string sName = maxBcFileDic[code]["sName"] + "";
|
||||
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
|
||||
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
|
||||
string tempFileName = $"BomImportTemp/{sName}";
|
||||
if (!File.Exists(tempFileName))
|
||||
{
|
||||
webClient.DownloadFile(url, tempFileName);
|
||||
}
|
||||
childInfo = new FileInfo(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (childInfo == null)
|
||||
{
|
||||
throw new Exception($"目录中不包含文件{code}");
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC);
|
||||
SetProcessBar(0, allCount);
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
@@ -1686,11 +1605,80 @@ namespace Lskj.PubBomImport
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"目录中不包含文件{code}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
FileInfo childInfo = null;
|
||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||
if (childInfoRow != null)
|
||||
{
|
||||
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
childInfo = new FileInfo(childDirPath);
|
||||
}
|
||||
if ((childInfo == null || filetable.Rows.Count > 0) && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
throw new Exception($"目录中不包含文件{code}");
|
||||
try
|
||||
{
|
||||
string webpath = maxBcFileDic[code]["webpath"] + "";
|
||||
string sName = maxBcFileDic[code]["sName"] + "";
|
||||
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
|
||||
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
|
||||
string tempFileName = $"BomImportTemp/{sName}";
|
||||
if (!File.Exists(tempFileName))
|
||||
{
|
||||
webClient.DownloadFile(url, tempFileName);
|
||||
}
|
||||
childInfo = new FileInfo(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (childInfo == null)
|
||||
{
|
||||
throw new Exception($"目录中不包含文件{code}");
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC);
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"目录中不包含文件{code}");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Invoke(new Action(() =>
|
||||
|
||||
Reference in New Issue
Block a user