|
@ -380,7 +380,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public virtual async Task<bool> ReceivedAsync(List<string> p_invs) |
|
|
public virtual async Task<bool> ReceivedAsync(List<string> p_invs) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
|
|
|
var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
|
|
|
int count = invList.Select(p => p.InvGroupNum).Distinct().Count(); |
|
|
int count = invList.Select(p => p.InvGroupNum).Distinct().Count(); |
|
|
if (count > 1) |
|
|
if (count > 1) |
|
@ -594,8 +593,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
partcode:itm.PartCode |
|
|
partcode:itm.PartCode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -626,7 +623,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
partcode: itm.PartCode |
|
|
partcode: itm.PartCode |
|
|
|
|
|
|
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -645,7 +641,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
site: string.Empty |
|
|
site: string.Empty |
|
|
); |
|
|
); |
|
|
bbacmainlist.Add(bbac); |
|
|
bbacmainlist.Add(bbac); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
var bbacDetail = new List<HBPO_PD_DETAIL>(); |
|
|
var bbacDetail = new List<HBPO_PD_DETAIL>(); |
|
|
foreach (var itm in entityList) |
|
|
foreach (var itm in entityList) |
|
@ -678,7 +673,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
itm.State = SettleBillState.客户已收票; |
|
|
itm.State = SettleBillState.客户已收票; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
await _repository.DbContext.BulkUpdateAsync(invList); |
|
|
await _repository.DbContext.BulkUpdateAsync(invList); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -705,7 +699,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
|
|
|
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
|
|
|
} |
|
|
} |
|
|
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
|
|
|
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
|
|
|
|
|
|
|
|
|
List<PUB_CAN_SA_DETAIL> entityList = new List<PUB_CAN_SA_DETAIL>();//结算明细
|
|
|
List<PUB_CAN_SA_DETAIL> entityList = new List<PUB_CAN_SA_DETAIL>();//结算明细
|
|
|
var namelist = invList.Select(p => p.InvbillNum).ToList(); |
|
|
var namelist = invList.Select(p => p.InvbillNum).ToList(); |
|
|
if (oldlist.Count > 0) |
|
|
if (oldlist.Count > 0) |
|
@ -734,7 +727,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
groupNum: itm.GroupNum, |
|
|
groupNum: itm.GroupNum, |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
partcode:itm.PartCode |
|
|
partcode:itm.PartCode, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pobillnum:string.Empty |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
)); |
|
|
)); |
|
@ -766,7 +762,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
groupNum: itm.GroupNum, |
|
|
groupNum: itm.GroupNum, |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invGroupNum: itm.InvGroupNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
invbillnum: itm.InvBillNum, |
|
|
partcode: itm.PartCode |
|
|
partcode: itm.PartCode, |
|
|
|
|
|
pobillnum: string.Empty |
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -985,12 +982,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
/// <param name="p_parentInvBillNum">原发票号</param>
|
|
|
/// <param name="p_parentInvBillNum">原发票号</param>
|
|
|
public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) |
|
|
public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) |
|
|
where TDetail : SA_CAN_BASE |
|
|
where TDetail : SA_CAN_BASE |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
List<string> _invls = new List<string>(); |
|
|
List<string> _invls = new List<string>(); |
|
|
var groups1 = dtos.GroupBy(p => new {p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
{ |
|
|
{ |
|
|
PartCode=p.Key.PartCode, |
|
|
PartCode = p.Key.PartCode, |
|
|
LU = p.Key.LU, |
|
|
LU = p.Key.LU, |
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
Qty = p.Sum(itm => itm.Qty), |
|
|
Qty = p.Sum(itm => itm.Qty), |
|
@ -999,7 +996,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
BeginDate = p.Key.BeginDate, |
|
|
BeginDate = p.Key.BeginDate, |
|
|
EndDate = p.Key.EndDate |
|
|
EndDate = p.Key.EndDate |
|
|
}).ToList();//汇总记录不出现重复值
|
|
|
}).ToList();//汇总记录不出现重复值
|
|
|
var groups = dtos.GroupBy(p => new {p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
var groups = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
{ |
|
|
{ |
|
|
PartCode = p.Key.PartCode, |
|
|
PartCode = p.Key.PartCode, |
|
|
LU = p.Key.LU, |
|
|
LU = p.Key.LU, |
|
@ -1014,7 +1011,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
foreach (var group in groups) |
|
|
foreach (var group in groups) |
|
|
{ |
|
|
{ |
|
|
int i = groups1.Count(p => p.LU == group.LU |
|
|
int i = groups1.Count(p => p.LU == group.LU |
|
|
&& p.PartCode==group.PartCode |
|
|
&& p.PartCode == group.PartCode |
|
|
&& p.BeginDate == group.BeginDate |
|
|
&& p.BeginDate == group.BeginDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.ContractDocID == group.ContractDocID |
|
|
&& p.ContractDocID == group.ContractDocID |
|
@ -1053,8 +1050,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invoiceMap.Add(invoiceBillNum, tempList); |
|
|
invoiceMap.Add(invoiceBillNum, tempList); |
|
|
var query = from itm in groups1 //更新分组
|
|
|
var query = from itm in groups1 //更新分组
|
|
|
join itm1 in tempList |
|
|
join itm1 in tempList |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID ,itm.PartCode} |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode } |
|
|
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID,itm1.PartCode } into temp |
|
|
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp |
|
|
from tm in temp |
|
|
from tm in temp |
|
|
where tm == null |
|
|
where tm == null |
|
|
select new TMEP_INV |
|
|
select new TMEP_INV |
|
@ -1071,7 +1068,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
} |
|
|
} |
|
|
if (invoiceMap.Count > 0) |
|
|
if (invoiceMap.Count > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
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>(); |
|
@ -1082,36 +1078,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
var key = group.Key;//发票票号
|
|
|
var key = group.Key;//发票票号
|
|
|
var ls = group.Value;//发票明细
|
|
|
var ls = group.Value;//发票明细
|
|
|
|
|
|
//反向查找结算数据
|
|
|
//反向查找结算数据
|
|
|
var query = from itm in dtos |
|
|
var query = from itm in dtos |
|
|
join itm1 in ls |
|
|
join itm1 in ls |
|
|
on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
on new { itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } |
|
|
join itm2 in p_list on new { itm.PartCode,itm.PN, itm.SettleDate } equals new { itm2.PartCode,itm2.PN, itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
foreach (var itm in query) |
|
|
foreach (var itm in query) |
|
|
{ |
|
|
{ |
|
|
itm.InvbillNum = key; |
|
|
itm.InvbillNum = key; |
|
|
salist.Add(itm); |
|
|
salist.Add(itm); |
|
|
} |
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
{ |
|
|
{ |
|
|
//反向查找调整数据
|
|
|
//反向查找调整数据
|
|
|
var query1 = from itm in dtos |
|
|
var query1 = from itm in dtos |
|
|
join itm1 in ls |
|
|
join itm1 in ls |
|
|
on new { itm.LU,itm.PartCode ,itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in p_ajdlist on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } |
|
|
join itm2 in p_ajdlist on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
|
|
|
|
|
|
foreach (var itm in query1) |
|
|
foreach (var itm in query1) |
|
|
{ |
|
|
{ |
|
|
itm.InvBillNum = key; |
|
|
itm.InvBillNum = key; |
|
|
adjlist.Add(itm); |
|
|
adjlist.Add(itm); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
List < INVOICE_WAIT_DETAIL > _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
|
|
|
foreach (var detail in ls) |
|
|
foreach (var detail in ls) |
|
|
{ |
|
|
{ |
|
|
_entityDetailList.Add( |
|
|
_entityDetailList.Add( |
|
@ -1129,7 +1121,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
extend2: string.Empty, |
|
|
extend2: string.Empty, |
|
|
beginDate: detail.BeginDate, |
|
|
beginDate: detail.BeginDate, |
|
|
endDate: detail.EndDate, |
|
|
endDate: detail.EndDate, |
|
|
partcode:detail.PartCode |
|
|
partcode: detail.PartCode |
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
if (_entityDetailList.Count > 0) |
|
|
if (_entityDetailList.Count > 0) |
|
@ -1184,12 +1176,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
); |
|
|
); |
|
|
invlist.Add(invbill); |
|
|
invlist.Add(invbill); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repository.DbContext.BulkInsertAsync(invlist); |
|
|
await _repository.DbContext.BulkInsertAsync(invlist); |
|
|
await _repository.DbContext.BulkInsertAsync(groupList); |
|
|
await _repository.DbContext.BulkInsertAsync(groupList); |
|
|
await _repository.DbContext.BulkInsertAsync(detailList); |
|
|
await _repository.DbContext.BulkInsertAsync(detailList); |
|
|
if(salist.Count>0) |
|
|
if (salist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
await _repository.DbContext.BulkUpdateAsync(salist); |
|
|
await _repository.DbContext.BulkUpdateAsync(salist); |
|
|
} |
|
|
} |
|
@ -1197,7 +1187,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//await _repository.DbContext.BulkInsertAsync(notDetialList);
|
|
|
//await _repository.DbContext.BulkInsertAsync(notDetialList);
|
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
} |
|
|
} |
|
|