|
|
@ -11,6 +11,7 @@ using Magicodes.ExporterAndImporter.Excel; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.OpenApi.Writers; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using ShardingCore.Extensions; |
|
|
|
using Shouldly; |
|
|
@ -199,8 +200,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
bj.PartCode = itm.PartCode; |
|
|
|
bj.PRICE = itm.PRICE; |
|
|
|
|
|
|
|
//bj.InvGroupNum = itm.InvGroupNum;
|
|
|
|
//bj.DeliveryNumber= itm.GetProperty("DeliveryNumber", "");//交货号
|
|
|
|
bj.InvGroupNum = itm.InvGroupNum; |
|
|
|
bj.DeliveryNumber =itm.ExtraProperties["DeliveryIndexNumber"].ToSqlValue(); |
|
|
|
//bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号
|
|
|
|
//bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号
|
|
|
|
//bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码
|
|
|
|
//bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称
|
|
|
@ -338,10 +340,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
.Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); |
|
|
|
entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); |
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
{ |
|
|
|
entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
{ |
|
|
@ -349,7 +348,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) |
|
|
|
{ |
|
|
|
entity.INVOICE_MAP_GROUP = mdtos; |
|
|
|
List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO> maidan = new List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO>(); |
|
|
|
foreach (var itm in m) |
|
|
|
{ |
|
|
|
maidan.Add(new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() { |
|
|
|
Extend1=itm.Extend1, |
|
|
|
InvGroupNum=itm.InvGroupNum, |
|
|
|
SettleGroupNum=itm.SettleGroupNum |
|
|
|
}); |
|
|
|
} |
|
|
|
entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maidan; |
|
|
|
List<MAIDAN_HBPO_UNSETTLED_DETAIL_DTO> unsettle = new List<MAIDAN_HBPO_UNSETTLED_DETAIL_DTO>(); |
|
|
|
foreach (var itm in notquery.ToList()) |
|
|
|
{ |
|
|
|
unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() { |
|
|
|
GroupNum=itm.InvGroupNum, |
|
|
|
LU=itm.LU, |
|
|
|
PN=itm.Extend1, |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList(); |
|
|
@ -413,39 +432,52 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var bbac = invdetail.INVOICE_WAIT_DETAIL_BBAC;//BBACJIS明细
|
|
|
|
var bj = invdetail.INVOICE_WAIT_DETAIL_BJ;//备件明细
|
|
|
|
var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细
|
|
|
|
var hbpom = invdetail.MAIDAN_HBPO_INVOICE_MAP_GROUP;//买单HBPO分组对应
|
|
|
|
var hbpounsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL;//买单HBPO未结
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name; |
|
|
|
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|
|
|
|
|
|
|
//发票明细
|
|
|
|
#region 发票明细
|
|
|
|
if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
{ |
|
|
|
_excel.Append(bbac, "发票明细"); |
|
|
|
} |
|
|
|
else if (entities.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) |
|
|
|
{ |
|
|
|
|
|
|
|
_excel.Append(bj, "发票明细"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_excel.Append(detail, "发票明细"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
// 发票分组
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
{ |
|
|
|
_excel.Append(m, "发票结算分组对应");//发票分组对应结算号
|
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC ) |
|
|
|
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) |
|
|
|
{ |
|
|
|
_excel.Append(unsettle, "未结零件结算汇总"); |
|
|
|
if (hbpom != null) |
|
|
|
{ |
|
|
|
_excel.Append(hbpom, "发票结算分组对应"); |
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
if (unsettle != null) |
|
|
|
{ |
|
|
|
_excel.Append(unsettle, "未结零件列表"); |
|
|
|
_excel.Append(unsettle, "未结零件汇总"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) |
|
|
|
{ |
|
|
|
_excel.Append(unsettle, "未结零件结算汇总"); |
|
|
|
} |
|
|
|
//jis业务,发票分组对应关系,未结数据,调整数据
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
{ |
|
|
|
foreach (var itm in entities) |
|
|
|
{ |
|
|
|
var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
@ -465,7 +497,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
RealInvBillNum = p.Key.RealInvBillNum, |
|
|
|
InvDate = p.Key.InvDate, |
|
|
|
InvBillNum = p.Key.InvBillNum, |
|
|
|
|
|
|
|
InvGroupNum = p.Key.InvGroupNum, |
|
|
|
Qty = p.Sum(itm => itm.Qty) |
|
|
|
|
|
|
@ -491,7 +522,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var lineC = lsC.Count; |
|
|
|
var lineN = lsN.Count; |
|
|
|
List<INVOICE_NOT_SETTLE_EXT_DTO> ls = new List<INVOICE_NOT_SETTLE_EXT_DTO>(); |
|
|
|
|
|
|
|
for (int i = 0; i < 10000; i++) |
|
|
|
{ |
|
|
|
INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO(); |
|
|
@ -532,13 +562,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
ls[i].SettleGroupNum = disList[i]; |
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
{ |
|
|
|
_excel.Append(ls, "结算分组零件" + itm.InvbillNum); |
|
|
|
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
} |
|
|
|
} |
|
|
|
else//其他业务发票调整数据
|
|
|
|
{ |
|
|
|
foreach (var itm in entities) |
|
|
|
{ |
|
|
|
var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); |
|
|
|
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
var result = _excel.ExportAppendDataAsByteArray(); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
//保存导出文件到服务器存成二进制
|
|
|
@ -622,7 +657,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
|
// inv.RealAmt = newinv.RealAmt;
|
|
|
|
inv.TaxDiff = newinv.PreTaxDiff; |
|
|
|
|
|
|
|
// inv.ClientCode = newinv.ClientCode;
|
|
|
|
} |
|
|
|
foreach (var detail in invdetail) |
|
|
|