SVN-Revision: r545
This commit is contained in:
wyf
2025-05-07 10:59:01 +00:00
parent 96932b6ff1
commit ac9958ee5d
+26 -29
View File
@@ -76,7 +76,7 @@ namespace Lskj.PubBomImport
FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(fileName)).FirstOrDefault(); FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(fileName)).FirstOrDefault();
if (childInfo == null) if (childInfo == null)
{ {
string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%'"; 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); DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
string sName = fileRow != null ? fileRow["sName"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : "";
@@ -306,7 +306,7 @@ namespace Lskj.PubBomImport
string fileName = (parentRow["图号"] + "").Trim(); string fileName = (parentRow["图号"] + "").Trim();
if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD")) if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD"))
{ {
string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%'"; 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); DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
string sName = fileRow != null ? fileRow["sName"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : "";
@@ -752,7 +752,7 @@ namespace Lskj.PubBomImport
if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD")) if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD"))
{ {
string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%'"; 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); DataRow fileRow = BaseImpl.GetDataRowResult(fileSql);
string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string webpath = fileRow != null ? fileRow["webpath"] + "" : "";
string sName = fileRow != null ? fileRow["sName"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : "";
@@ -1618,7 +1618,7 @@ namespace Lskj.PubBomImport
int finishCount = (int)((decimal)(1 + childIndex) / (sourceTable.Rows.Count) * 100); int finishCount = (int)((decimal)(1 + childIndex) / (sourceTable.Rows.Count) * 100);
Model = frmMain.Model; Model = frmMain.Model;
DataRow execRow = BaseImpl.GetDataRowResult($"select * from p_bomImportExecTab where isnull(success,0) = 0 and guid = '{execGuid}'"); DataRow execRow = BaseImpl.GetDataRowResult($"select * from p_bomImportExecTab where isnull(success,0) = 0 and guid = '{execGuid}'");
if (execRow != null) if (!string.IsNullOrEmpty(execGuid) && execRow != null)
{ {
string masterSql = execRow["masterSql"] + ""; string masterSql = execRow["masterSql"] + "";
string detailSql = execRow["detailSql"] + ""; string detailSql = execRow["detailSql"] + "";
@@ -1634,37 +1634,34 @@ namespace Lskj.PubBomImport
if (result == 1) if (result == 1)
{ {
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
{
DataRow fileRow = BaseImpl.GetDataRowResult($"select webpath,sname from p_fm_filetab where fileId = '{fileId}'");
if (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);
}
else
{
throw new Exception($"Bom明细附件{productid}获取失败\r\nBom导入失败");
}
}
catch (Exception)
{
throw new Exception($"Bom明细附件{productid}获取失败\r\nBom导入失败");
}
}
} }
else else
{ {
throw new Exception($"保存Bom失败\r\n{tipMsg}"); throw new Exception($"保存Bom失败\r\n{tipMsg}");
} }
} }
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导入失败");
}
}
} }
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
} }