Administrator 3 years ago
parent
commit
4b2d5f5e39
  1. 2
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs
  2. 10
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs
  3. 54
      src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs
  4. 2
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs
  5. 19
      src/Modules/SettleAccount/src/SettleAccount.Domain/Settings/Helper.cs

2
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; string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename;
ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); ExcelHelper _excelHelper = new ExcelHelper(fileSavePath);
var _list = _excelHelper.ExcelToList<WmsSharePart90OutPutDetial>(); var _list = _excelHelper.ExcelToListOne<WmsSharePart90OutPutDetial>();
//var _list_withbillNo = _list.Select(p => p.BillNum != string.Empty); //var _list_withbillNo = _list.Select(p => p.BillNum != string.Empty);
//var _list_withNoBillNo= _list.Select(p => p.BillNum == string.Empty); //var _list_withNoBillNo= _list.Select(p => p.BillNum == string.Empty);

10
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; string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename;
ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); ExcelHelper _excelHelper = new ExcelHelper(fileSavePath);
var _listSummary = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>(); var _listSummary = _excelHelper.ExcelToListOne<WmsSharePartOutPutDetial>();//导入模板有多页签,需要取第一个页签
var _list = _listSummary.Where(p => p.OrderBillNum == "").ToList();//过滤 采购订单号为空的集合 var _list = _listSummary.Where(p => p.OrderBillNum == "").ToList();//过滤 采购订单号为空的集合
var _listBill = _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(); 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(); 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) foreach (var job in _joblist)
{ {
if (_lst != null) if (_lst != null && _lst.Count > 0)
{ {
job.FileName = _billNum + "/" + _billNoNum; job.FileName = _billNum + "/" + _billNoNum;
} }
@ -898,7 +898,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
{ {
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExtendExcelImport<WmsSharePartOutPutDetial>(files, _excelImportService); var result = await _exportImporter.ExtendExcelOfSheetOneImport<WmsSharePartOutPutDetial>(files, _excelImportService);
if (result == null) if (result == null)
{ {

54
src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

@ -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;//返回客户端
}
} }
} }

2
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs

@ -1,4 +1,5 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -1551,6 +1552,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
/// <summary> /// <summary>
/// 备件出库明细 /// 备件出库明细
/// </summary> /// </summary>
[ExcelImporter(SheetName = "大众备件数据输出")]
public class WmsSharePartOutPutDetial : FullAuditedAggregateRootBase<Guid> public class WmsSharePartOutPutDetial : FullAuditedAggregateRootBase<Guid>
{ {
public WmsSharePartOutPutDetial() public WmsSharePartOutPutDetial()

19
src/Modules/SettleAccount/src/SettleAccount.Domain/Settings/Helper.cs

@ -219,6 +219,25 @@ namespace Win.Sfs.SettleAccount
} }
public List<T> ExcelToListOne<T>() where T : class, new()
{
List<T> _ls = new List<T>();
//foreach (var sheetName in SheetNames)
//{
// var sheet = sheetName != null ? _workbook.GetSheet(sheetName) : _workbook.GetSheetAt(0);
// var list = ExportToList<T>(sheet);
// _ls.AddRange(list);
//}
var sheet = _workbook.GetSheetAt(0);
var list = ExportToList<T>(sheet);
_ls.AddRange(list);
return _ls;
}
/// <summary> /// <summary>
/// 实体字段 /// 实体字段
/// </summary> /// </summary>

Loading…
Cancel
Save