|
|
@ -1,9 +1,19 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Security.Policy; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Magicodes.ExporterAndImporter.Core; |
|
|
|
using Magicodes.ExporterAndImporter.Csv; |
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Win.Abp.Snowflakes; |
|
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
|
using Win.Sfs.SettleAccount.Bases; |
|
|
@ -12,6 +22,8 @@ using Win.Sfs.SettleAccount.CommonManagers; |
|
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
using Win.Sfs.SettleAccount.ExportReports; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
@ -37,6 +49,89 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
_bbacNotMng = bbacNotMng; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
//[Route("export")]
|
|
|
|
public override async Task<string> ExportAsync(BBAC_NOT_SA_DETAIL_REQ_DTO input) |
|
|
|
{ |
|
|
|
var ls = input.Filters.Where(p => p.Column == "businessType").ToList(); |
|
|
|
if (ls.Count > 0) |
|
|
|
{ |
|
|
|
var entiy = input.Filters.Where(p => p.Column == "businessType").FirstOrDefault(); |
|
|
|
var value = entiy.Value; |
|
|
|
|
|
|
|
input.Filters.Remove(entiy); |
|
|
|
} |
|
|
|
|
|
|
|
IExporter _csv = new CsvExporter(); |
|
|
|
IExporter _excel = new ExcelExporter(); |
|
|
|
var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dtoDetails = ObjectMapper.Map<List<BBAC_NOT_SA_DETAIL>, List<BBAC_NOT_SA_DETAIL_EXP_DTO>>(entities); |
|
|
|
|
|
|
|
var inner = from d in entities |
|
|
|
join p in dtoDetails on d.Id equals p.Id |
|
|
|
|
|
|
|
select |
|
|
|
new BBAC_NOT_SA_DETAIL_EXP_DTO() |
|
|
|
{ |
|
|
|
SettleBillNum=d.SettleBillNum, |
|
|
|
Site=d.Site, |
|
|
|
Category=p.Category, |
|
|
|
IsReturn=p.IsReturn, |
|
|
|
IsMaiDan=p.IsMaiDan, |
|
|
|
RealPN = d.GetProperty("RealPN", ""), |
|
|
|
InvGroupNum=p.InvGroupNum, |
|
|
|
SettleDate = d.SettleDate, |
|
|
|
LU = d.LU, |
|
|
|
PN = d.PN, |
|
|
|
Qty = d.Qty, |
|
|
|
GroupNum = d.GroupNum, |
|
|
|
KeyCode = d.KeyCode, |
|
|
|
Price = p.Price, |
|
|
|
}; |
|
|
|
|
|
|
|
//dtoDetails.ForEach(dtoDetail =>
|
|
|
|
//{
|
|
|
|
// var item= entities.FirstOrDefault(e => e.Id == dtoDetail.Id);
|
|
|
|
// dtoDetail.RealPN = item.GetProperty("RealPN", "");
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
var classDisplayName = typeof(BBAC_NOT_SA_DETAIL_EXP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(BBAC_NOT_SA_DETAIL_EXP_DTO).Name; |
|
|
|
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|
|
|
byte[] result = null; |
|
|
|
|
|
|
|
//switch (input.FileType)
|
|
|
|
//{
|
|
|
|
// case 0:
|
|
|
|
// result = await _csv.ExportAsByteArray(dtoDetails).ConfigureAwait(false);
|
|
|
|
// break;
|
|
|
|
// case 1:
|
|
|
|
// result = await _excel.ExportAsByteArray(dtoDetails).ConfigureAwait(false);
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
|
|
|
|
result = await _excel.ExportAsByteArray(inner.ToList()).ConfigureAwait(false); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
|
|
|
|
//保存导出文件到服务器存成二进制
|
|
|
|
await _excelImportService.SaveBlobAsync( |
|
|
|
new SaveExcelImportInputDto |
|
|
|
{ |
|
|
|
Name = _fileName, |
|
|
|
Content = result |
|
|
|
} |
|
|
|
).ConfigureAwait(false); |
|
|
|
return _fileName; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
public override async Task<IActionResult> GenerateSettlementOrder(BBAC_NOT_SA_DETAIL_REQ_DTO input) |
|
|
|
{ |
|
|
|