|
|
@ -153,28 +153,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
protected async Task<string> SaveFile(string fileDictKey, byte[] fileBytes, string batchNo, string fileNameNoSuffix,
|
|
|
|
protected async Task<string> SaveFile(string fileDictKey, byte[] fileBytes, string batchNo, string fileNameNoSuffix,
|
|
|
|
PrintFileTypeEnum printFileType, string attachFileType = "sofiles")
|
|
|
|
PrintFileTypeEnum printFileType, string attachFileType = "sofiles")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var basePath = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
// 获取文件存盘时保存的物理文件名:fileName
|
|
|
|
var relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
|
|
|
|
relativePath += $"\\{attachFileType}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
|
|
|
|
relativePath += $"\\{fileDictKey}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string? dirAbs;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(basePath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dirAbs = Path.Combine(environment.WebRootPath ?? "", relativePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dirAbs = Path.Combine(basePath, relativePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileType = string.Empty;
|
|
|
|
var fileType = string.Empty;
|
|
|
|
if (printFileType == PrintFileTypeEnum.PDF)
|
|
|
|
if (printFileType == PrintFileTypeEnum.PDF)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -196,38 +175,50 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fileType = ".doc";
|
|
|
|
fileType = ".doc";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var fileName = $"{fileNameNoSuffix}{fileType}"; // 文件存盘时保存的物理文件名
|
|
|
|
|
|
|
|
|
|
|
|
string curFileName = fileNameNoSuffix;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
// 获取文件存库时保存的文件名:fileInfoRelativePathWithName
|
|
|
|
var fileSaveName = $"{curFileName}{fileType}";
|
|
|
|
var fileInfoRelativeDic = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
string fileRelaPath = Path.Combine(relativePath, fileSaveName);
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
string fileAbsPath = Path.Combine(dirAbs, fileSaveName);
|
|
|
|
fileInfoRelativeDic = Path.Combine(fileInfoRelativeDic, attachFileType);
|
|
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
|
|
|
|
fileInfoRelativeDic = Path.Combine(fileInfoRelativeDic, fileDictKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 文件存库时保存的文件名
|
|
|
|
|
|
|
|
var fileInfoRelativePathWithName = Path.Combine(fileInfoRelativeDic, fileName); // 文件存库时保存的文件名
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文件存盘所需的绝对路径:absFilePath
|
|
|
|
|
|
|
|
var absFilePath = string.Empty;
|
|
|
|
|
|
|
|
var baseDicConfig = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
|
|
|
|
var relativeDicConfig = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(baseDicConfig))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
relativePath = relativePath.Replace("\\", "/");
|
|
|
|
absFilePath = Path.Combine(environment.WebRootPath ?? "", relativeDicConfig, fileInfoRelativeDic);
|
|
|
|
fileRelaPath = fileRelaPath.Replace("\\", "/");
|
|
|
|
}
|
|
|
|
fileAbsPath = fileAbsPath.Replace("\\", "/");
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
absFilePath = Path.Combine(baseDicConfig, relativeDicConfig, fileInfoRelativeDic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//logger.LogInformation("批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, fileRelaPath, RuntimeInformation.OSDescription);
|
|
|
|
if (!Directory.Exists(absFilePath))
|
|
|
|
|
|
|
|
Directory.CreateDirectory(absFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
await File.WriteAllBytesAsync(fileAbsPath, fileBytes);
|
|
|
|
absFilePath = Path.Combine(absFilePath, fileName);
|
|
|
|
|
|
|
|
|
|
|
|
//string bookFilePath;
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
//if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
fileInfoRelativePathWithName = fileInfoRelativePathWithName.Replace("\\", "/");
|
|
|
|
// bookFilePath = System.Text.RegularExpressions.Regex.Match(fileAbsPath, relativePath.Replace("/", "\\/") + ".*").Value;
|
|
|
|
absFilePath = absFilePath.Replace("\\", "/");
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
//else
|
|
|
|
await File.WriteAllBytesAsync(absFilePath, fileBytes);
|
|
|
|
//{
|
|
|
|
|
|
|
|
// bookFilePath = System.Text.RegularExpressions.Regex.Match(fileAbsPath, relativePath.Replace("\\", "\\\\") + ".*").Value;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return fileAbsPath;
|
|
|
|
return fileInfoRelativePathWithName;
|
|
|
|
//return bookFilePath;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -300,21 +291,21 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileEmpty)), taskId)
|
|
|
|
string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileEmpty)), taskId)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var basePath = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
var baseDicConfig = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
|
|
|
|
var relativeDicConfig = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
|
|
|
|
|
|
|
|
string fileFullPath;
|
|
|
|
string absFilePath;
|
|
|
|
if (string.IsNullOrEmpty(basePath))
|
|
|
|
if (string.IsNullOrEmpty(baseDicConfig))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fileFullPath = Path.Combine(environment.WebRootPath ?? "", fileInfo.FILE_PATH);
|
|
|
|
absFilePath = Path.Combine(environment.WebRootPath ?? "", relativeDicConfig, fileInfo.FILE_PATH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fileFullPath = Path.Combine(basePath, fileInfo.FILE_PATH);
|
|
|
|
absFilePath = Path.Combine(baseDicConfig, relativeDicConfig, fileInfo.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!File.Exists(fileFullPath))
|
|
|
|
if (!File.Exists(absFilePath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogError("根据任务主键获取文件信息失败:文件不存在,fileFullPath={fileFullPath}", fileFullPath);
|
|
|
|
logger.LogError("根据任务主键获取文件信息失败:文件不存在,fileFullPath={fileFullPath}", absFilePath);
|
|
|
|
//任务主键{0} 附件下载请求失败,请确认文件是否存在
|
|
|
|
//任务主键{0} 附件下载请求失败,请确认文件是否存在
|
|
|
|
throw new Exception(
|
|
|
|
throw new Exception(
|
|
|
|
string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileNotExists)), taskId)
|
|
|
|
string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileNotExists)), taskId)
|
|
|
@ -322,7 +313,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode(fileInfo.FILE_NAME, Encoding.GetEncoding("UTF-8"))!;
|
|
|
|
var fileName = HttpUtility.UrlEncode(fileInfo.FILE_NAME, Encoding.GetEncoding("UTF-8"))!;
|
|
|
|
return (fileFullPath, fileName);
|
|
|
|
return (absFilePath, fileName);
|
|
|
|
//return (new FileStream(fileFullPath, FileMode.Open), fileName);
|
|
|
|
//return (new FileStream(fileFullPath, FileMode.Open), fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|