|
|
@ -1,6 +1,7 @@ |
|
|
|
using CodeArts.Db; |
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
|
using DocumentFormat.OpenXml.Drawing.Diagrams; |
|
|
|
using DocumentFormat.OpenXml.Spreadsheet; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Magicodes.ExporterAndImporter.Core; |
|
|
|
using Magicodes.ExporterAndImporter.Csv; |
|
|
@ -149,11 +150,96 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
public virtual async Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input) |
|
|
|
{ |
|
|
|
INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); |
|
|
|
|
|
|
|
var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m); |
|
|
|
var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w); |
|
|
|
|
|
|
|
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
{ |
|
|
|
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var AMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BBAC_DTO>>(A); |
|
|
|
var wquery = from itm in AMap |
|
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
|
select |
|
|
|
new INVOICE_WAIT_DETAIL_BBAC_DTO() |
|
|
|
{ |
|
|
|
InvDate = itm1.CreationTime, |
|
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
|
Version = itm.Version, |
|
|
|
InvbillNum = itm.InvbillNum, |
|
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
|
LU = itm.LU, |
|
|
|
PartCode = itm.PartCode, |
|
|
|
PRICE = itm.PRICE, |
|
|
|
Qty = itm.Qty, |
|
|
|
Amt = itm.Amt, |
|
|
|
BussiessType = itm.BussiessType, |
|
|
|
Extend1 = itm.Extend1, |
|
|
|
BeginDate = itm.BeginDate, |
|
|
|
EndDate = itm.EndDate, |
|
|
|
}; |
|
|
|
entity.INVOICE_WAIT_DETAIL_BBAC = AMap; |
|
|
|
} |
|
|
|
else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) |
|
|
|
{ |
|
|
|
var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B); |
|
|
|
|
|
|
|
var wquery = from itm in BMap |
|
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
|
select |
|
|
|
new INVOICE_WAIT_DETAIL_BJ_DTO() |
|
|
|
{ |
|
|
|
InvDate = itm1.CreationTime, |
|
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
|
Version = itm.Version, |
|
|
|
InvbillNum = itm.InvbillNum, |
|
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
|
LU = itm.LU, |
|
|
|
PartCode = itm.PartCode, |
|
|
|
PRICE = itm.PRICE, |
|
|
|
Qty = itm.Qty, |
|
|
|
Amt = itm.Amt, |
|
|
|
BussiessType = itm.BussiessType, |
|
|
|
Extend1 = itm.Extend1, |
|
|
|
BeginDate = itm.BeginDate, |
|
|
|
EndDate = itm.EndDate, |
|
|
|
}; |
|
|
|
entity.INVOICE_WAIT_DETAIL_BJ = BMap; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w); |
|
|
|
var wquery = from itm in wdtos |
|
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
|
select |
|
|
|
new INVOICE_WAIT_DETAIL_DTO() |
|
|
|
{ |
|
|
|
InvDate = itm1.CreationTime, |
|
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
|
Version = itm.Version, |
|
|
|
InvbillNum = itm.InvbillNum, |
|
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
|
LU = itm.LU, |
|
|
|
PartCode = itm.PartCode, |
|
|
|
PRICE = itm.PRICE, |
|
|
|
Qty = itm.Qty, |
|
|
|
Amt = itm.Amt, |
|
|
|
BussiessType = itm.BussiessType, |
|
|
|
//Extend1 = itm.Extend1,
|
|
|
|
BeginDate = itm.BeginDate, |
|
|
|
EndDate = itm.EndDate, |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity.INVOICE_WAIT_DETAIL = wdtos; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s); |
|
|
|
var adjs =await _adjRepository.GetListByFilterAsync(input.Filters); |
|
|
@ -173,26 +259,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
Extend1 = itm.Extend1, |
|
|
|
}; |
|
|
|
|
|
|
|
var wquery = from itm in wdtos |
|
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
|
select |
|
|
|
new INVOICE_WAIT_DETAIL_DTO() |
|
|
|
{ |
|
|
|
InvDate = itm1.CreationTime, |
|
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
|
Version = itm.Version, |
|
|
|
InvbillNum = itm.InvbillNum, |
|
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
|
LU = itm.LU, |
|
|
|
PartCode = itm.PartCode, |
|
|
|
PRICE = itm.PRICE, |
|
|
|
Qty = itm.Qty, |
|
|
|
Amt = itm.Amt, |
|
|
|
BussiessType = itm.BussiessType, |
|
|
|
Extend1 = itm.Extend1, |
|
|
|
BeginDate = itm.BeginDate, |
|
|
|
EndDate = itm.EndDate, |
|
|
|
}; |
|
|
|
|
|
|
|
var mquery = from itm in mdtos |
|
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
|
select |
|
|
@ -222,7 +289,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
}; |
|
|
|
|
|
|
|
entity.INVOICE_NOT_SETTLE = notquery.ToList(); |
|
|
|
entity.INVOICE_WAIT_DETAIL = wquery.ToList(); |
|
|
|
|
|
|
|
entity.INVOICE_MAP_GROUP = mquery.ToList(); |
|
|
|
entity.ADJ_DETAIL = adjQuery.ToList(); |
|
|
|
return entity; |
|
|
@ -243,6 +310,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
byte[] result = null; |
|
|
|
|
|
|
|
result = await _excel.ExportAsByteArray(dtoDetails); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//switch (input.FileType)
|
|
|
|
//{
|
|
|
|
// case 0:
|
|
|
@ -275,22 +351,51 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
IExporter _csv = new CsvExporter(); |
|
|
|
ExcelExporter _excel = new ExcelExporter(); |
|
|
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities); |
|
|
|
var invdetail= await DetailQueryAsync(input); |
|
|
|
var m = invdetail.INVOICE_MAP_GROUP; |
|
|
|
var not=invdetail.INVOICE_NOT_SETTLE; |
|
|
|
var detail =invdetail.INVOICE_WAIT_DETAIL; |
|
|
|
var adj = invdetail.ADJ_DETAIL; |
|
|
|
var bbac = invdetail.INVOICE_WAIT_DETAIL_BBAC; |
|
|
|
var bj = invdetail.INVOICE_WAIT_DETAIL_BJ; |
|
|
|
|
|
|
|
|
|
|
|
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name; |
|
|
|
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|
|
|
|
|
|
|
foreach (var itm in entities) |
|
|
|
{ |
|
|
|
var invlist = detail.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
|
|
|
|
|
var mgroup =m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
|
var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); |
|
|
|
var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); |
|
|
|
_excel.Append(invlist, "发票号" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
{ |
|
|
|
var bbaclist = bbac.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
|
_excel.Append(bbaclist, "发票号" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
} |
|
|
|
else if (entities.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) |
|
|
|
{ |
|
|
|
var bjlist = bj.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
|
_excel.Append(bjlist, "发票号" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var invlist = detail.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
|
_excel.Append(invlist, "发票号" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
} |
|
|
|
_excel.Append(mgroup, "发票结算分组对应" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
_excel.Append(nolist, "结算分组零件" + itm.InvbillNum); |
|
|
|