SVN-Revision: r618
This commit is contained in:
wyf
2025-05-22 06:18:41 +00:00
parent d5489dc011
commit 1549d52346
3 changed files with 322 additions and 294 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ namespace Lskj.PubBomImport
//param[6].Value = "";
//param[7].Value = auditFlag;
//param[8].Value = comfirm;
SqlHelper.ExecuteNonQuery($"delete p_bomImportExecTab where guid = '{guid}'");
SqlHelper.ExecuteNonQuery($"insert into p_bomImportExecTab (guid,detailTable,masterSql,detailSql,billNo,detailGuid,UserId,billWay,billSeq,auditFlag,comfirm,newVer) " +
$"values ('{guid}','{billModel.DetailTable}','{masterSql.Replace("'", "''")}','{detailSql.Replace("'", "''")}','{billNo}','{detailGuid.Replace("'", "''")}','{ERPInfo.Instance.UserId}','{(billModel.SaveState ? 2 : 1)}','{billModel.BillSeq}','0','{comfirm}','{billModel.NewVer}')");
//int result = BillImpl.BillSave(masterSql, detailSql, billModel.DetailTable, ref billNo, detailGuid, billModel.BillSeq, billModel.SaveState ? 2 : 1, comfirm, out tipMsg, 0, billModel.NewVer);
-6
View File
@@ -460,12 +460,6 @@ namespace Lskj.PubBomImport
}
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)
+69 -35
View File
@@ -817,7 +817,12 @@ namespace Lskj.PubBomImport
}
Directory.CreateDirectory("BomImportTemp");
int execOrder = 1;
DataRow mxRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith("MX")).FirstOrDefault();
var mxRows = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith("MX"));
if (mxRows.Count() > 1)
{
throw new Exception($"不允许出现多个MX文件");
}
DataRow mxRow = mxRows.FirstOrDefault();
if (mxRow != null)
{
string mxFileName = mxRow[Model.AfterBomFieldName] + "";
@@ -841,15 +846,53 @@ namespace Lskj.PubBomImport
throw new Exception($"物料编码{productId}的BOM建立单已存在\r\n请进行修改操作");
}
}
FileInfo mxInfo = new FileInfo(mxDirPath);
if (mxInfo != null)
else
{
GetFileCodeInfo(Path.GetFileNameWithoutExtension(mxInfo.Name).Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC);
DataTable mxfiletable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{mxsourceCode}%'");
DataRow billbomRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}' and stepover = '1'");
if (billbomRow != null)
{
throw new Exception($"物料编码{productId}的BOM建立单已终审\r\n禁止修改操作");
}
}
GetFileCodeInfo(mxFileName.Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC);
DataTable mxfiletable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{mxsourceCode}%'");
FileInfo mxInfo = null;
if (!string.IsNullOrEmpty(mxDirPath))
{
mxInfo = new FileInfo(mxDirPath);
}
if (mxInfo != null || mxfiletable.Rows.Count > 0)
{
if (mxfiletable.Rows.Count > 1)
{
throw new Exception($"{mxsourceCode}存在多个版次,请进行MX修改");
}
if (mxfiletable.Rows.Count > 0)
{
throw new Exception($"{mxsourceCode}的附件已存在");
using (WebClient webClient = new WebClient())
{
try
{
string webpath = mxfiletable.Rows[0]["webpath"] + "";
string sName = mxfiletable.Rows[0]["sName"] + "";
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
string tempFileName = $"BomImportTemp/{sName}";
if (!File.Exists(tempFileName))
{
webClient.DownloadFile(url, tempFileName);
}
mxInfo = new FileInfo(tempFileName);
}
catch (Exception)
{
throw new Exception($"Bom明细附件{mxsourceCode}获取失败\r\nBom导入失败");
}
}
}
if (mxInfo != null)
{
int mxMaxBc = 0;
string mxMaxBcFileId = "-1";
foreach (DataRow mxfileRow in mxfiletable.Rows)
@@ -871,7 +914,6 @@ namespace Lskj.PubBomImport
FrmBillInfo frmBillInfo = new FrmBillInfo();
DataTable parentTable = ExcelToDatatable(mxInfo.FullName, Model, "", 5);
parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "") && !string.IsNullOrEmpty(n["名称"] + "")).ToList().CopyToDataTable();
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow dataRow in parentTable.Rows)
{
@@ -896,11 +938,9 @@ namespace Lskj.PubBomImport
frmMain.FirstRowIndex = index;
bool isUpload = false;
string msg = "";
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>();
if (parentProductRow == null)
{
#region MX
frmBillInfo.OnBillAdd();
SetProcessBar(0, 0);
SetProcessMsg($"正在导入:{Path.GetFileName(mxInfo.FullName)}");
@@ -936,8 +976,11 @@ namespace Lskj.PubBomImport
{
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
if (!string.IsNullOrEmpty(childDirPath))
{
childInfo = new FileInfo(childDirPath);
}
}
if ((childInfo == null || filetable.Rows.Count > 0) && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
{
using (WebClient webClient = new WebClient())
@@ -1036,10 +1079,10 @@ namespace Lskj.PubBomImport
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set afterSql = '{insertbulider.ToString().Replace("'", "''")}' where guid = '{guid}'");
SetProcessBar(80, 0);
//上传文件
string uploadFileId = mxMaxBcFileId;
string uploadMxFileId = mxMaxBcFileId;
if (mxfiletable.Rows.Count == 0)
{
isUpload = UploadFileToAudit(mxInfo.FullName, productId, "010106", out msg, out uploadFileId);
isUpload = UploadFileToAudit(mxInfo.FullName, productId, "010106", out msg, out uploadMxFileId);
if (!isUpload)
{
throw new Exception($"{mxInfo.Name}附件上传失败\r\n{msg}");
@@ -1049,7 +1092,7 @@ namespace Lskj.PubBomImport
{
if (mxRow.Table.Columns.Contains("qms_laddf_FileId"))
{
int.TryParse(uploadFileId, out int qms_laddf_FileId);
int.TryParse(uploadMxFileId, out int qms_laddf_FileId);
mxRow["qms_laddf_FileId"] = qms_laddf_FileId;
}
if (mxRow.Table.Columns.Contains("qms_laddf_Exec"))
@@ -1062,27 +1105,7 @@ namespace Lskj.PubBomImport
}
}));
execOrder += 1;
}
else
{
string uploadFileId = mxMaxBcFileId;
if (mxfiletable.Rows.Count == 0)
{
isUpload = UploadFileToAudit(mxInfo.FullName, mxsourceCode, "010106", out msg, out uploadFileId);
if (!isUpload)
{
throw new Exception($"{mxInfo.Name}附件上传失败\r\n{msg}");
}
}
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
{
if (mxRow.Table.Columns.Contains("qms_laddf_FileId"))
{
int.TryParse(uploadFileId, out int qms_laddf_FileId);
mxRow["qms_laddf_FileId"] = qms_laddf_FileId;
}
}));
}
#endregion
SetProcessBar(100, (1 / (parentTable.Rows.Count + 1)) * 100);
SetProcessLabelAllMsg($"总进度:{1}/{parentTable.Rows.Count + 1}");
foreach (DataRow dataRow in parentTable.Rows)
@@ -1102,8 +1125,11 @@ namespace Lskj.PubBomImport
{
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
if (!string.IsNullOrEmpty(childDirPath))
{
childInfo = new FileInfo(childDirPath);
}
}
if ((childInfo == null || filetable.Rows.Count > 0) && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
{
using (WebClient webClient = new WebClient())
@@ -1137,7 +1163,7 @@ namespace Lskj.PubBomImport
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
if (productRow == null)
{
string childGuid = Guid.NewGuid() + "";
string childGuid = childInfoRow != null && !string.IsNullOrEmpty(childInfoRow["qms_laddf_Exec"] + "") ? childInfoRow["qms_laddf_Exec"] + "" : Guid.NewGuid() + "";
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
if (filetable.Rows.Count == 0)
{
@@ -1245,8 +1271,11 @@ namespace Lskj.PubBomImport
{
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
if (!string.IsNullOrEmpty(childDirPath))
{
childInfo = new FileInfo(childDirPath);
}
}
if ((childInfo == null || filetable.Rows.Count > 0) && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
{
using (WebClient webClient = new WebClient())
@@ -1331,6 +1360,11 @@ namespace Lskj.PubBomImport
frmMain.ParentView = frmBillInfo.GcMainView;
}
else
{
throw new Exception("未找到MX文件");
}
}
else
{
throw new Exception("未包含MX文件");
}