diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs index 46caa532..fe93d079 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs @@ -244,7 +244,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS { string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); - var _list = _excelHelper.ExcelToList(); + var _list = _excelHelper.ExcelToListOne(); //var _list_withbillNo = _list.Select(p => p.BillNum != string.Empty); //var _list_withNoBillNo= _list.Select(p => p.BillNum == string.Empty); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs index 631c1f0b..1f853ff6 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs @@ -244,7 +244,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts { string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); - var _listSummary = _excelHelper.ExcelToList(); + var _listSummary = _excelHelper.ExcelToListOne();//导入模板有多页签,需要取第一个页签 var _list = _listSummary.Where(p => p.OrderBillNum == "").ToList();//过滤 采购订单号为空的集合 var _listBill = _listSummary.Where(p => p.OrderBillNum != "").ToList();//过滤 采购订单号不为空的集合 @@ -316,7 +316,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts } - if (_lst != null) + if (_lst != null && _lst.Count>0) { //没有采购订单号 var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version && p.OrderBillNum == "").ToListAsync(); @@ -397,7 +397,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts - if (_lstBill != null) + if (_lstBill != null && _lstBill.Count>0) { //有采购订单号 var outPutDetailBill = await _wmsRepository.Where(p => p.Version == input.Version && p.OrderBillNum != "").ToListAsync(); @@ -455,7 +455,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts } foreach (var job in _joblist) { - if (_lst != null) + if (_lst != null && _lst.Count > 0) { job.FileName = _billNum + "/" + _billNoNum; } @@ -898,7 +898,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts { ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); + var result = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); if (result == null) { diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs index 0e8880d2..d5d2d23a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs @@ -360,7 +360,61 @@ namespace Win.Sfs.SettleAccount.ExcelImporter return ImportList;//返回客户端 } - + + public virtual async Task> ExtendExcelOfSheetOneImport([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService, List p_list = null) + where T : class, new() + { + + Type type = typeof(T); + var ImportList = new List(); + ExcelImportResult returnResult = new ExcelImportResult(); + + + List _errorList = new List(); + 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(p_list); + } + else + { + ImportList = _excelHelper.ExcelToListOne(); + } + + } + return ImportList;//返回客户端 + } + } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs index 5583a692..0f927229 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -1,4 +1,5 @@ using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; using System; using System.Collections.Generic; using System.Linq; @@ -1551,6 +1552,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS /// /// 备件出库明细 /// + [ExcelImporter(SheetName = "大众备件数据输出")] public class WmsSharePartOutPutDetial : FullAuditedAggregateRootBase { public WmsSharePartOutPutDetial() diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Settings/Helper.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Settings/Helper.cs index 231694c4..090d7749 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Settings/Helper.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Settings/Helper.cs @@ -219,6 +219,25 @@ namespace Win.Sfs.SettleAccount } + public List ExcelToListOne() where T : class, new() + { + + List _ls = new List(); + //foreach (var sheetName in SheetNames) + //{ + // var sheet = sheetName != null ? _workbook.GetSheet(sheetName) : _workbook.GetSheetAt(0); + // var list = ExportToList(sheet); + // _ls.AddRange(list); + //} + + var sheet = _workbook.GetSheetAt(0); + var list = ExportToList(sheet); + _ls.AddRange(list); + return _ls; + + } + + /// /// 实体字段 /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs index 497f56f0..9c5335a9 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -85,7 +85,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " PurchaseOrderNoText,\n" + " AmountNoTax \n" + " FROM\n" + - " Set_SparePart WHERE Extend != 'is90' \n" + + " Set_SparePart WHERE Extend != 'is90' \n" + " GROUP BY\n" + " PurchaseOrderNo,\n" + " MaterialCode,\n" +