|
@ -13,9 +13,11 @@ using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax; |
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Minio.DataModel; |
|
|
using Minio.DataModel; |
|
|
|
|
|
using Org.BouncyCastle.Asn1.Cmp; |
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using ShardingCore.Sharding.MergeContexts; |
|
|
using ShardingCore.Sharding.MergeContexts; |
|
|
|
|
|
using SqlSugar; |
|
|
using TaskJob.EventArgs; |
|
|
using TaskJob.EventArgs; |
|
|
using TaskJob.Interfaces; |
|
|
using TaskJob.Interfaces; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
@ -638,8 +640,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
} |
|
|
} |
|
|
_invls = GenSecInvoice(ls, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
_invls = GenSecInvoice(ls, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -656,6 +656,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
smalllist.Add(itm); |
|
|
smalllist.Add(itm); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var groupList = new List<INVOICE_MAP_GROUP>(); |
|
|
var groupList = new List<INVOICE_MAP_GROUP>(); |
|
|
var notDetialList = new List<INVOICE_NOT_SETTLE>(); |
|
|
var notDetialList = new List<INVOICE_NOT_SETTLE>(); |
|
|
var detailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
var detailList = new List<INVOICE_WAIT_DETAIL>(); |
|
@ -666,15 +668,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
{ |
|
|
{ |
|
|
var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); |
|
|
var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); |
|
|
var gener = new InvoiceGeneratorSame<TDetail>(); |
|
|
var gener = new InvoiceGeneratorSame<TDetail>(); |
|
|
gener.GenerateInvoices(p_list); |
|
|
|
|
|
|
|
|
var entitylist=list.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
gener.GenerateInvoices(entitylist); |
|
|
var invList = gener.Invoices; |
|
|
var invList = gener.Invoices; |
|
|
foreach (var inv in invList) |
|
|
foreach (var inv in invList) |
|
|
{ |
|
|
{ |
|
|
var partlist = inv.Parts; |
|
|
var partlist = inv.Parts; |
|
|
|
|
|
//var query = from itm in p_list join itm1 in partlist on itm.Id equals itm1.Id select itm;
|
|
|
|
|
|
foreach (var detail in partlist) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = entitylist.FirstOrDefault(p => p.Id == detail.Id); |
|
|
|
|
|
entity.InvbillNum = inv.InvBillNum; |
|
|
|
|
|
salist.Add(entity); |
|
|
|
|
|
} |
|
|
if (partlist.Count > 0) |
|
|
if (partlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var query = from itm in partlist |
|
|
var query = from itm in partlist |
|
@ -724,11 +732,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
} |
|
|
} |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
|
|
|
|
|
|
|
|
|
var parlist = partlist.ToList(); |
|
|
//if (partlist is List<BBAC_CAN_SA_DETAIL>)
|
|
|
if (parlist is List<BBAC_CAN_SA_DETAIL>) |
|
|
//{
|
|
|
{ |
|
|
var partlist1 = partlist as List<BBAC_CAN_SA_DETAIL>; |
|
|
var partlist1 = parlist as List<BBAC_CAN_SA_DETAIL>; |
|
|
var sq = partlist1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum}) |
|
|
var sq = partlist1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) |
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); |
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); |
|
|
foreach (var sitm in sq) |
|
|
foreach (var sitm in sq) |
|
|
{ |
|
|
{ |
|
@ -817,107 +825,132 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
invlist.Add(invbill); |
|
|
invlist.Add(invbill); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) |
|
|
|
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); |
|
|
|
|
|
foreach (var sitm in sq) |
|
|
|
|
|
{ |
|
|
|
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
version: p_version, |
|
|
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: sitm.GroupNum, |
|
|
|
|
|
lU: sitm.LU, |
|
|
|
|
|
lU1: sitm.LU, |
|
|
|
|
|
extend1: "可结算", |
|
|
|
|
|
extend2: string.Empty, |
|
|
|
|
|
qty: sitm.Qty, |
|
|
|
|
|
p_invbillnum: inv.InvBillNum |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
if (innotls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
notDetialList.AddRange(innotls); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 发票明细
|
|
|
//}
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
//else
|
|
|
foreach (var detail in detailDtos) |
|
|
//{
|
|
|
{ |
|
|
// var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
|
|
|
_entityDetailList.Add( |
|
|
// .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum });
|
|
|
new INVOICE_WAIT_DETAIL( |
|
|
// foreach (var sitm in sq)
|
|
|
guid: GuidGenerator.Create(), |
|
|
// {
|
|
|
version: p_version, |
|
|
// innotls.Add(new INVOICE_NOT_SETTLE(
|
|
|
invbillNum: inv.InvBillNum, |
|
|
// guid: GuidGenerator.Create(),
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
// version: p_version,
|
|
|
lU: detail.LU, |
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
qty: detail.Qty, |
|
|
// settleGroupNum: sitm.GroupNum,
|
|
|
bussiessType: businessType, |
|
|
// lU: sitm.LU,
|
|
|
amt: detail.Amt, |
|
|
// lU1: sitm.LU,
|
|
|
pRICE: detail.Price, |
|
|
// extend1: "可结算",
|
|
|
extend1: detail.ContactDocID, |
|
|
// extend2: string.Empty,
|
|
|
extend2: string.Empty, |
|
|
// qty: sitm.Qty,
|
|
|
beginDate: detail.BeginDate, |
|
|
// p_invbillnum: inv.InvBillNum
|
|
|
endDate: detail.EndDate, |
|
|
// ));
|
|
|
partcode: detail.PartCode |
|
|
// }
|
|
|
)); |
|
|
// if (innotls.Count > 0)
|
|
|
} |
|
|
// {
|
|
|
if (_entityDetailList.Count > 0) |
|
|
// notDetialList.AddRange(innotls);
|
|
|
{ |
|
|
// }
|
|
|
detailList.AddRange(_entityDetailList); |
|
|
|
|
|
} |
|
|
// #region 发票明细
|
|
|
#endregion
|
|
|
// List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
|
|
|
#region 发票
|
|
|
// foreach (var detail in detailDtos)
|
|
|
var invbill = new INVOICE_GRP |
|
|
// {
|
|
|
( |
|
|
// _entityDetailList.Add(
|
|
|
guid: GuidGenerator.Create(), |
|
|
// new INVOICE_WAIT_DETAIL(
|
|
|
realnvBillNum: string.Empty, |
|
|
// guid: GuidGenerator.Create(),
|
|
|
invbillNum: inv.InvBillNum, |
|
|
// version: p_version,
|
|
|
amt: amt, |
|
|
// invbillNum: inv.InvBillNum,
|
|
|
taxAmt: txtAmt, |
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
fileName: string.Empty, |
|
|
// lU: detail.LU,
|
|
|
businessType: businessType, |
|
|
// qty: detail.Qty,
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
// bussiessType: businessType,
|
|
|
state: SettleBillState.已开票, |
|
|
// amt: detail.Amt,
|
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
// pRICE: detail.Price,
|
|
|
tax: 0.13m, |
|
|
// extend1: detail.ContactDocID,
|
|
|
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, |
|
|
// extend2: string.Empty,
|
|
|
preTaxDiff: 0, |
|
|
// beginDate: detail.BeginDate,
|
|
|
taxDiff: 0, |
|
|
// endDate: detail.EndDate,
|
|
|
clientCode: string.Empty, |
|
|
// partcode: detail.PartCode
|
|
|
realAmt: realAmt |
|
|
// ));
|
|
|
); |
|
|
// }
|
|
|
string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; |
|
|
// if (_entityDetailList.Count > 0)
|
|
|
string clientCode = string.Empty; |
|
|
// {
|
|
|
switch (site) |
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
{ |
|
|
// }
|
|
|
case "1040": |
|
|
// #endregion
|
|
|
clientCode = "C001"; |
|
|
// #region 发票
|
|
|
break; |
|
|
// var invbill = new INVOICE_GRP
|
|
|
case "1046": |
|
|
// (
|
|
|
clientCode = "C171"; |
|
|
// guid: GuidGenerator.Create(),
|
|
|
break; |
|
|
// realnvBillNum: string.Empty,
|
|
|
default: |
|
|
// invbillNum: inv.InvBillNum,
|
|
|
clientCode = "C004"; |
|
|
// amt: amt,
|
|
|
break; |
|
|
// taxAmt: txtAmt,
|
|
|
} |
|
|
// fileName: string.Empty,
|
|
|
invbill.ClientCode = clientCode; |
|
|
// businessType: businessType,
|
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
invbill.CreationTime = DateTime.MinValue; |
|
|
// state: SettleBillState.已开票,
|
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
// invoiceBillState: InvoiceBillState.正常,
|
|
|
invlist.Add(invbill); |
|
|
// tax: 0.13m,
|
|
|
#endregion
|
|
|
// parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
|
|
|
} |
|
|
// preTaxDiff: 0,
|
|
|
|
|
|
// taxDiff: 0,
|
|
|
|
|
|
// clientCode: string.Empty,
|
|
|
|
|
|
// realAmt: realAmt
|
|
|
|
|
|
// );
|
|
|
|
|
|
// string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site;
|
|
|
|
|
|
// string clientCode = string.Empty;
|
|
|
|
|
|
// switch (site)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// case "1040":
|
|
|
|
|
|
// clientCode = "C001";
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// case "1046":
|
|
|
|
|
|
// clientCode = "C171";
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// default:
|
|
|
|
|
|
// clientCode = "C004";
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// invbill.ClientCode = clientCode;
|
|
|
|
|
|
// invbill.Site = dtos.FirstOrDefault().Site;
|
|
|
|
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
|
|
|
// invlist.Add(invbill);
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
//}
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
_dbcontext.BulkInsert(invlist); |
|
|
_dbcontext.BulkInsert(invlist); |
|
|
_dbcontext.BulkInsert(groupList); |
|
|
_dbcontext.BulkInsert(groupList); |
|
|
_dbcontext.BulkInsert(detailList); |
|
|
_dbcontext.BulkInsert(detailList); |
|
|
|
|
|
|
|
|
|
|
|
if (salist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_dbcontext.BulkUpdate(salist); |
|
|
|
|
|
//带库位发票
|
|
|
|
|
|
var detailext = salist.GroupBy(p => new { p.InvbillNum, p.InvGroupNum, p.PartCode, p.LU, p.Price, p.ErpLoc, p.BusinessType }) |
|
|
|
|
|
.Select(p => new INVOICE_DETAIL_EXT |
|
|
|
|
|
{ |
|
|
|
|
|
Version = p_version, |
|
|
|
|
|
InvbillNum = p.Key.InvbillNum, |
|
|
|
|
|
InvGroupNum = p.Key.InvGroupNum, |
|
|
|
|
|
PartCode = p.Key.PartCode, |
|
|
|
|
|
PRICE = p.Key.Price, |
|
|
|
|
|
ErpLoc = p.Key.ErpLoc, |
|
|
|
|
|
Qty = p.Sum(k => k.Qty), |
|
|
|
|
|
BussiessType = p.Key.BusinessType, |
|
|
|
|
|
Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前
|
|
|
|
|
|
LU = p.Key.LU |
|
|
|
|
|
} |
|
|
|
|
|
).ToList(); |
|
|
|
|
|
foreach (var itm in detailext) |
|
|
|
|
|
{ |
|
|
|
|
|
itm.SetId(GuidGenerator.Create()); |
|
|
|
|
|
itm.CreationTime = DateTime.Now; |
|
|
|
|
|
} |
|
|
|
|
|
_dbcontext.BulkInsert(detailext); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (adjlist.Count > 0) |
|
|
if (adjlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
_dbcontext.BulkInsert(adjlist); |
|
|
_dbcontext.BulkInsert(adjlist); |
|
@ -927,17 +960,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
_dbcontext.BulkInsert(notDetialList); |
|
|
_dbcontext.BulkInsert(notDetialList); |
|
|
} |
|
|
} |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (smalllist.Count > 0) |
|
|
if (smalllist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
_invls = GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
_invls = GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return _invls; |
|
|
return _invls; |
|
|
} |
|
|
} |
|
|