SVN r662
SVN-Revision: r662
This commit is contained in:
@@ -107,7 +107,7 @@ namespace Lskj.PubBomImport
|
|||||||
dialog.Multiselect = true;
|
dialog.Multiselect = true;
|
||||||
dialog.InitialDirectory = Properties.Settings.Default.LastSelectFolder;
|
dialog.InitialDirectory = Properties.Settings.Default.LastSelectFolder;
|
||||||
dialog.Title = "选择导入文件";
|
dialog.Title = "选择导入文件";
|
||||||
dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
|
//dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
|
||||||
DialogResult dialogResult = dialog.ShowDialog();
|
DialogResult dialogResult = dialog.ShowDialog();
|
||||||
if (dialogResult == DialogResult.OK)
|
if (dialogResult == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -269,19 +269,48 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
int execOrder = 1;
|
int execOrder = 1;
|
||||||
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||||
|
string bomOtherAddMode = selectRows[0]["qms_laddf_mode"] + "";
|
||||||
|
if (string.IsNullOrEmpty(bomOtherAddMode))
|
||||||
|
{
|
||||||
|
throw new Exception("未选择上传模式");
|
||||||
|
}
|
||||||
|
if (bomOtherAddMode.Equals("9040"))//有规则
|
||||||
|
{
|
||||||
|
string pattern = @"^(\S+)\s+(\S+)\s+(.+)$";
|
||||||
foreach (DataRow selectRow in selectRows)
|
foreach (DataRow selectRow in selectRows)
|
||||||
{
|
{
|
||||||
string productId = selectRow["BomMxMainProduct"] + "";
|
|
||||||
if (string.IsNullOrEmpty(productId))
|
|
||||||
{
|
|
||||||
throw new Exception($"物料编码不能为空");
|
|
||||||
}
|
|
||||||
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||||
string dirPath = selectRow["BomFieldNameDir"] + "";
|
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||||
FileInfo fileInfo = new FileInfo(dirPath);
|
FileInfo fileInfo = new FileInfo(dirPath);
|
||||||
if (fileInfo != null)
|
if (fileInfo != null)
|
||||||
{
|
{
|
||||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
var match = Regex.Match(fileNameWithoutExtension, pattern);
|
||||||
|
string code = "";
|
||||||
|
string spec = "";
|
||||||
|
string name = "";
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
code = match.Groups[1].Value.Trim();
|
||||||
|
spec = match.Groups[2].Value.Trim();
|
||||||
|
name = match.Groups[3].Value.Trim();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}不满足规则");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(code))
|
||||||
|
{
|
||||||
|
throw new Exception($"编码解析为空");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(spec))
|
||||||
|
{
|
||||||
|
throw new Exception($"规格解析为空");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
throw new Exception($"名称解析为空");
|
||||||
|
}
|
||||||
if (fileNameWithoutExtension.StartsWith("ZZQD"))
|
if (fileNameWithoutExtension.StartsWith("ZZQD"))
|
||||||
{
|
{
|
||||||
throw new Exception($"不允许补充ZZQD文件{fileNameWithoutExtension}");
|
throw new Exception($"不允许补充ZZQD文件{fileNameWithoutExtension}");
|
||||||
@@ -296,8 +325,7 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{code}' and dllcoid = '1000202') and speciesno = '010105' and sname = '{ fileInfo.Name}'");
|
||||||
DataTable filetable = 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 = '{fileNameWithoutExtension}'");
|
|
||||||
if (filetable.Rows.Count > 0)
|
if (filetable.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
throw new Exception($"{fileNameWithoutExtension}的附件已存在");
|
throw new Exception($"{fileNameWithoutExtension}的附件已存在");
|
||||||
@@ -330,8 +358,22 @@ namespace Lskj.PubBomImport
|
|||||||
if (fileInfo != null)
|
if (fileInfo != null)
|
||||||
{
|
{
|
||||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
var match = Regex.Match(fileNameWithoutExtension, pattern);
|
||||||
|
string code = "";
|
||||||
|
string spec = "";
|
||||||
|
string name = "";
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
code = match.Groups[1].Value.Trim();
|
||||||
|
spec = match.Groups[2].Value.Trim();
|
||||||
|
name = match.Groups[3].Value.Trim();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}不满足规则");
|
||||||
|
}
|
||||||
SetProcessBar(0, allCount);
|
SetProcessBar(0, allCount);
|
||||||
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, "010106", out string msg, out string uploadFileId);
|
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, "010105", out string msg, out string uploadFileId);
|
||||||
if (!isUpload)
|
if (!isUpload)
|
||||||
{
|
{
|
||||||
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
||||||
@@ -372,6 +414,116 @@ namespace Lskj.PubBomImport
|
|||||||
});
|
});
|
||||||
task.Start();
|
task.Start();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
else if (bomOtherAddMode.Equals("9041"))//无规则
|
||||||
|
{
|
||||||
|
foreach (DataRow selectRow in selectRows)
|
||||||
|
{
|
||||||
|
string productId = selectRow["BomMxMainProduct"] + "";
|
||||||
|
if (string.IsNullOrEmpty(productId))
|
||||||
|
{
|
||||||
|
throw new Exception($"物料编码不能为空");
|
||||||
|
}
|
||||||
|
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||||
|
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||||
|
FileInfo fileInfo = new FileInfo(dirPath);
|
||||||
|
if (fileInfo != null)
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
if (fileNameWithoutExtension.StartsWith("ZZQD"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充ZZQD文件{fileNameWithoutExtension}");
|
||||||
|
}
|
||||||
|
else if (fileNameWithoutExtension.StartsWith("MX"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充MX文件{fileNameWithoutExtension}");
|
||||||
|
}
|
||||||
|
else if (fileNameWithoutExtension.StartsWith("QD"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充QD文件{fileNameWithoutExtension}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DataTable filetable = 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 = '010105' and sname = '{fileInfo.Name}'");
|
||||||
|
if (filetable.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}的附件已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frmBillInfo.OnControlSourceBind += (s, args) =>
|
||||||
|
{
|
||||||
|
Task task = new Task(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int.TryParse(Model.FirstRowIndex, out int index);
|
||||||
|
frmMain.FirstRowIndex = index;
|
||||||
|
foreach (DataRow selectRow in selectRows)
|
||||||
|
{
|
||||||
|
string productId = selectRow["BomMxMainProduct"] + "";
|
||||||
|
int childIndex = selectRows.IndexOf(selectRow);
|
||||||
|
int nowCount = 1 + childIndex;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
SetProcessBar(0, allCount);
|
||||||
|
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, "010105", out string msg, out string uploadFileId);
|
||||||
|
if (!isUpload)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}附件上传失败\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
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
ImportTimer?.Dispose();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageUtil.Show(ex.Message);
|
||||||
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
ImportTimer?.Dispose();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
task.Start();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("上传模式编码不合法");
|
||||||
|
}
|
||||||
frmBillInfo.OnLoad(Model);
|
frmBillInfo.OnLoad(Model);
|
||||||
frmMain.ParentView = frmBillInfo.GcMainView;
|
frmMain.ParentView = frmBillInfo.GcMainView;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user