|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NPOI.HPSF;
|
|
|
|
using NPOI.HPSF;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
@ -134,32 +135,13 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
string fileRoot = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
string fileRoot = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
string relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
string relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(fileRoot))
|
|
|
|
|
|
|
|
fileRoot = _environment.WebRootPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
relativePath += $"\\{attachFileType}";
|
|
|
|
relativePath += $"\\{attachFileType}";
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
relativePath += $"\\{fileDictKey}";
|
|
|
|
relativePath += $"\\{fileDictKey}";
|
|
|
|
|
|
|
|
|
|
|
|
relativePath += $"\\{DateTime.Now.ToString("yyyyMMddHHmmssfff")}";
|
|
|
|
string? dirAbs;
|
|
|
|
|
|
|
|
|
|
|
|
string filePath = $"{fileRoot}\\{relativePath}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string fileFullName = $"{filePath}\\{fileName}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
relativePath = relativePath.Replace("\\", "/");
|
|
|
|
|
|
|
|
filePath = filePath.Replace("\\", "/");
|
|
|
|
|
|
|
|
fileFullName = fileFullName.Replace("\\", "/");
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dirAbs = string.Empty;
|
|
|
|
|
|
|
|
var fileRelaPath = string.Empty;
|
|
|
|
|
|
|
|
var fileAbsPath = string.Empty;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(fileRoot))
|
|
|
|
if (string.IsNullOrEmpty(fileRoot))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath ?? "", relativePath);
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath ?? "", relativePath);
|
|
|
@ -171,14 +153,15 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
|
|
|
|
|
|
|
|
// 先存库获取Id
|
|
|
|
// 先存库获取Id
|
|
|
|
var id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
var id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
|
|
|
|
|
|
|
|
var fileSuffix = Path.GetExtension(fileName).ToLower(); // 文件后缀
|
|
|
|
var fileSuffix = Path.GetExtension(fileName).ToLower(); // 文件后缀
|
|
|
|
|
|
|
|
|
|
|
|
var fileSaveName = $"{id}{fileSuffix}".ToLower();
|
|
|
|
var fileSaveName = $"{id}{fileSuffix}".ToLower();
|
|
|
|
fileRelaPath = Path.Combine(relativePath, fileSaveName).ToLower();
|
|
|
|
string fileRelaPath = Path.Combine(relativePath, fileSaveName).ToLower();
|
|
|
|
fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
|
|
|
|
string fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, "批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, fileAbsPath,
|
|
|
|
Logger.Log(NLog.LogLevel.Info, "批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, fileAbsPath,
|
|
|
|
RuntimeInformation.OSDescription);
|
|
|
|
RuntimeInformation.OSDescription);
|
|
|
@ -202,7 +185,7 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
// bookFilePath = System.Text.RegularExpressions.Regex.Match(dirAbs, relativePath.Replace("\\", "\\\\") + ".*").Value;
|
|
|
|
// bookFilePath = System.Text.RegularExpressions.Regex.Match(dirAbs, relativePath.Replace("\\", "\\\\") + ".*").Value;
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<string>.Success(fileSaveName);
|
|
|
|
return DataResult<string>.Success(fileAbsPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 转移文件
|
|
|
|
#region 转移文件
|
|
|
@ -223,32 +206,13 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
|
|
|
|
|
|
|
|
string relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
string relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(fileRoot))
|
|
|
|
|
|
|
|
fileRoot = _environment.WebRootPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
relativePath += $"\\{attachFileType}";
|
|
|
|
relativePath += $"\\{attachFileType}";
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
relativePath += $"\\{fileDictKey}";
|
|
|
|
relativePath += $"\\{fileDictKey}";
|
|
|
|
|
|
|
|
|
|
|
|
relativePath += $"\\{DateTime.Now.ToString("yyyyMMddHHmmss")}";
|
|
|
|
string? dirAbs;
|
|
|
|
|
|
|
|
|
|
|
|
string filePath = $"{fileRoot}\\{relativePath}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string fileFullName = $"{filePath}\\{new System.IO.FileInfo(sourceFilePath).Name}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
relativePath = relativePath.Replace("\\", "/");
|
|
|
|
|
|
|
|
filePath = filePath.Replace("\\", "/");
|
|
|
|
|
|
|
|
fileFullName = fileFullName.Replace("\\", "/");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
var dirAbs = string.Empty;
|
|
|
|
|
|
|
|
var fileRelaPath = string.Empty;
|
|
|
|
|
|
|
|
var fileAbsPath = string.Empty;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(fileRoot))
|
|
|
|
if (string.IsNullOrEmpty(fileRoot))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath ?? "", relativePath);
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath ?? "", relativePath);
|
|
|
@ -260,14 +224,15 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
|
|
|
|
|
|
|
|
// 先存库获取Id
|
|
|
|
// 先存库获取Id
|
|
|
|
var id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
var id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
|
|
|
|
|
|
|
|
var fileSuffix = Path.GetExtension(sourceFilePath).ToLower(); // 文件后缀
|
|
|
|
var fileSuffix = Path.GetExtension(sourceFilePath).ToLower(); // 文件后缀
|
|
|
|
|
|
|
|
|
|
|
|
var fileSaveName = $"{id}{fileSuffix}".ToLower();
|
|
|
|
var fileSaveName = $"{id}{fileSuffix}".ToLower();
|
|
|
|
fileRelaPath = Path.Combine(relativePath, fileSaveName).ToLower();
|
|
|
|
string fileRelaPath = Path.Combine(relativePath, fileSaveName).ToLower();
|
|
|
|
fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
|
|
|
|
string fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"批次={batchNo} 生成文件保存路径完成 路由={fileAbsPath} 服务器系统={RuntimeInformation.OSDescription}");
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"批次={batchNo} 生成文件保存路径完成 路由={fileAbsPath} 服务器系统={RuntimeInformation.OSDescription}");
|
|
|
|
|
|
|
|
|
|
|
@ -326,7 +291,7 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
// bookFilePath = System.Text.RegularExpressions.Regex.Match(fileFullName, relativePath.Replace("\\", "\\\\") + ".*").Value;
|
|
|
|
// bookFilePath = System.Text.RegularExpressions.Regex.Match(fileFullName, relativePath.Replace("\\", "\\\\") + ".*").Value;
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<string>.Success(fileSaveName);
|
|
|
|
return DataResult<string>.Success(fileAbsPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|