|
|
@ -361,6 +361,60 @@ namespace Win.Sfs.SettleAccount.ExcelImporter |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<T>> ExtendExcelOfSheetOneImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService, List<ImportColumnMap> p_list = null) |
|
|
|
where T : class, new() |
|
|
|
{ |
|
|
|
|
|
|
|
Type type = typeof(T); |
|
|
|
var ImportList = new List<T>(); |
|
|
|
ExcelImportResult returnResult = new ExcelImportResult(); |
|
|
|
|
|
|
|
|
|
|
|
List<string> _errorList = new List<string>(); |
|
|
|
foreach (var file in files) |
|
|
|
{ |
|
|
|
if (file == null) |
|
|
|
{ |
|
|
|
throw new BusinessException("上传附件不能为空!"); |
|
|
|
} |
|
|
|
string FileOriginName = file.FileName; |
|
|
|
string getFileName = Path.GetFileName(FileOriginName);//获取附件名称
|
|
|
|
using (var memoryStream = new MemoryStream()) |
|
|
|
{ |
|
|
|
//保存成物理文件
|
|
|
|
await file.CopyToAsync(memoryStream); |
|
|
|
await _excelImportService.SaveBlobAsync( |
|
|
|
new SaveExcelImportInputDto |
|
|
|
{ |
|
|
|
Name = Path.GetFileName(FileOriginName), |
|
|
|
Content = memoryStream.ToArray() |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
//读取文件保存的根目录
|
|
|
|
string fileSaveRootDir = ConfigDirHelper.GetAppSetting("App", "FileRootPath"); |
|
|
|
//读取WMS文件保存的模块的根目录
|
|
|
|
string fileSaveDir = ConfigDirHelper.GetAppSetting("App", "WMSFiles"); |
|
|
|
//文件保存的相对文件夹(保存到wwwroot目录下)
|
|
|
|
string absoluteFileDir = fileSaveRootDir + @"\" + fileSaveDir; |
|
|
|
//文件保存的路径(应用的工作目录+文件夹相对路径);
|
|
|
|
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container" + absoluteFileDir; |
|
|
|
var filePath = fileSavePath + getFileName;//获取到导入的excel
|
|
|
|
|
|
|
|
ExcelHelper _excelHelper = new ExcelHelper(filePath); |
|
|
|
if (p_list != null && p_list.Count > 0) |
|
|
|
{ |
|
|
|
ImportList = _excelHelper.ExcelToListByMap<T>(p_list); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ImportList = _excelHelper.ExcelToListOne<T>(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return ImportList;//返回客户端
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|