|
@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Http; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using NPOI.HPSF; |
|
|
using NPOI.HPSF; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
|
|
|
using ShardingCore.Extensions; |
|
|
using Shouldly; |
|
|
using Shouldly; |
|
|
using SqlSugar; |
|
|
using SqlSugar; |
|
|
using System; |
|
|
using System; |
|
@ -25,6 +26,7 @@ using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
|
|
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Uow; |
|
|
using Win.Abp.Snowflakes; |
|
|
using Win.Abp.Snowflakes; |
|
@ -165,8 +167,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m); |
|
|
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m); |
|
|
var first = invs.FirstOrDefault(); |
|
|
var first = invs.FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
{ |
|
|
{ |
|
|
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
@ -201,8 +201,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
|
|
|
|
|
|
B.OrderBy(p => p.LineCode); |
|
|
B.OrderBy(p => p.LineCode); |
|
|
var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<INVOICE_WAIT_DETAIL_BJ_DTO> BMap = new List<INVOICE_WAIT_DETAIL_BJ_DTO>(); |
|
|
|
|
|
foreach (var itm in B) |
|
|
|
|
|
{ |
|
|
|
|
|
INVOICE_WAIT_DETAIL_BJ_DTO bj = new INVOICE_WAIT_DETAIL_BJ_DTO(); |
|
|
|
|
|
bj.LU = itm.LU; |
|
|
|
|
|
bj.PartCode = itm.PartCode; |
|
|
|
|
|
bj.PRICE = itm.PRICE; |
|
|
|
|
|
|
|
|
|
|
|
bj.InvGroupNum = itm.InvGroupNum; |
|
|
|
|
|
bj.DeliveryNumber= itm.GetProperty("DeliveryNumber", "");//交货号
|
|
|
|
|
|
bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号
|
|
|
|
|
|
bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码
|
|
|
|
|
|
bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称
|
|
|
|
|
|
bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
|
|
|
|
|
|
bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
|
|
|
|
|
|
bj.PartName = itm.GetProperty("PartName", "");//零件名称
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
|
|
|
var wquery = from itm in BMap |
|
|
var wquery = from itm in BMap |
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp |
|
|
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp |
|
@ -221,7 +239,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
PRICE = itm.PRICE, |
|
|
PRICE = itm.PRICE, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
BussiessType = itm.BussiessType, |
|
|
DeliveryNumber = itm.DeliveryNumber , |
|
|
|
|
|
VendorCode = itm.VendorCode , |
|
|
|
|
|
VendorName = itm.VendorName , |
|
|
|
|
|
PurchaseOrderNumber = itm.PurchaseOrderNumber, |
|
|
|
|
|
DeliveryIndexNumber =itm.DeliveryIndexNumber , |
|
|
Extend1 = itm.Extend1, |
|
|
Extend1 = itm.Extend1, |
|
|
BeginDate = itm.BeginDate, |
|
|
BeginDate = itm.BeginDate, |
|
|
EndDate = itm.EndDate, |
|
|
EndDate = itm.EndDate, |
|
@ -230,7 +252,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
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 wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w); |
|
|
var wquery = from itm in wdtos |
|
|
var wquery = from itm in wdtos |
|
@ -240,7 +261,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
select |
|
|
select |
|
|
new INVOICE_WAIT_DETAIL_DTO() |
|
|
new INVOICE_WAIT_DETAIL_DTO() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
InvDate = itm1.CreationTime, |
|
|
InvDate = itm1.CreationTime, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
@ -318,26 +338,46 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
SettleGroupNum = p.FirstOrDefault().SettleGroupNum, |
|
|
SettleGroupNum = p.FirstOrDefault().SettleGroupNum, |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)//BBAC直供未结
|
|
|
{ |
|
|
{ |
|
|
//var all = entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号
|
|
|
//var all = entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号
|
|
|
//var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号
|
|
|
//var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号
|
|
|
//var unsettled = all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结
|
|
|
//var unsettled = all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结
|
|
|
var unsettledList = sdtos |
|
|
var unsettledList = sdtos |
|
|
.GroupBy(p => new { p.LU, p.SettleGroupNum }) |
|
|
.GroupBy(p => new { p.LU, p.SettleGroupNum }) |
|
|
.Select(p => new UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); |
|
|
.Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); |
|
|
entity.UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); |
|
|
entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
|
|
{ |
|
|
{ |
|
|
entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
|
|
|
entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
|
|
|
} |
|
|
} |
|
|
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) |
|
|
|
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO)//hbpo买单未结
|
|
|
|
|
|
{ |
|
|
|
|
|
List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO> hbpomaplist = new List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO>(); |
|
|
|
|
|
foreach (var itm in m) |
|
|
{ |
|
|
{ |
|
|
entity.INVOICE_MAP_GROUP = mdtos; |
|
|
hbpomaplist.Add(new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() |
|
|
|
|
|
{ |
|
|
|
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
|
|
|
SettleGroupNum = itm.SettleGroupNum, |
|
|
|
|
|
Extend1 = itm.Extend1, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = hbpomaplist; |
|
|
|
|
|
if (sdtos != null && sdtos.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var hbpo=sdtos.Select(p => new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO(){ |
|
|
|
|
|
GroupNum = p.SettleGroupNum,//五联单号
|
|
|
|
|
|
LU=p.LU, |
|
|
|
|
|
PN=p.Extend1,//生产码
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
entity.MAIDAN_HBPO_UNSETTLED_DETAIL = hbpo.ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList(); |
|
|
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList(); |
|
|
return entity; |
|
|
return entity; |
|
|
} |
|
|
} |
|
@ -403,6 +443,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细
|
|
|
var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jitunsettle = invdetail.JIT_UNSETTLED_DETAIL; |
|
|
|
|
|
var maidanunsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL; |
|
|
|
|
|
var maidangroup = invdetail.MAIDAN_HBPO_INVOICE_MAP_GROUP; |
|
|
|
|
|
|
|
|
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name; |
|
|
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name; |
|
|
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|
|
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|
|
|
|
|
|
|
@ -427,15 +471,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
} |
|
|
} |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC ) |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC ) |
|
|
{ |
|
|
{ |
|
|
_excel.Append(unsettle, "未结零件结算汇总"); |
|
|
if(jitunsettle != null) |
|
|
} |
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
|
|
{ |
|
|
{ |
|
|
_excel.Append(unsettle, "未结零件列表"); |
|
|
_excel.Append(jitunsettle, "未结零件结算汇总"); |
|
|
} |
|
|
} |
|
|
|
|
|
//_excel.Append(m, "发票结算分组对应");
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) |
|
|
|
|
|
{ |
|
|
|
|
|
if(maidangroup != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_excel.Append(maidangroup, "结算对应关系"); |
|
|
|
|
|
} |
|
|
|
|
|
if (maidanunsettle != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_excel.Append(maidanunsettle, "未结零件结算汇总"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
foreach (var itm in entities) |
|
|
foreach (var itm in entities) |
|
|
{ |
|
|
{ |
|
@ -530,6 +583,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); |
|
|
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = _excel.ExportAppendDataAsByteArray(); |
|
|
var result = _excel.ExportAppendDataAsByteArray(); |
|
|
result.ShouldNotBeNull(); |
|
|
result.ShouldNotBeNull(); |
|
|
//保存导出文件到服务器存成二进制
|
|
|
//保存导出文件到服务器存成二进制
|
|
|