|
|
@ -199,97 +199,109 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
var _first = p_ls.FirstOrDefault(); |
|
|
|
bool issucess = true; |
|
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
|
{ |
|
|
|
try |
|
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
|
{ |
|
|
|
// 执行批量数据操作
|
|
|
|
if (ls != null && ls.Count > 0) |
|
|
|
try |
|
|
|
{ |
|
|
|
var messagelist = new List<VmiMessage>(); |
|
|
|
foreach (var item in ls) |
|
|
|
// 执行批量数据操作
|
|
|
|
if (ls != null && ls.Count > 0) |
|
|
|
{ |
|
|
|
var message = new VmiMessage |
|
|
|
var messagelist = new List<VmiMessage>(); |
|
|
|
foreach (var item in ls) |
|
|
|
{ |
|
|
|
Message = System.Text.Json.JsonSerializer.Serialize(item), |
|
|
|
}; |
|
|
|
messagelist.Add(message); |
|
|
|
} |
|
|
|
_dbcontext.BulkInsert(messagelist); |
|
|
|
_dbcontext.BulkInsert(ls, new BulkConfig() { }); |
|
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); |
|
|
|
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
if (pdList.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var item in pdList) |
|
|
|
var message = new VmiMessage |
|
|
|
{ |
|
|
|
Message = System.Text.Json.JsonSerializer.Serialize(item), |
|
|
|
}; |
|
|
|
messagelist.Add(message); |
|
|
|
} |
|
|
|
_dbcontext.BulkInsert(messagelist); |
|
|
|
_dbcontext.BulkInsert(ls, new BulkConfig() { }); |
|
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();//同步数据的发票号
|
|
|
|
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();//扣减单内容
|
|
|
|
var pdinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList(); |
|
|
|
if (pdList.Count > 0) |
|
|
|
{ |
|
|
|
if (flag == true) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
foreach (var item in pdList) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
foreach (var item in pdinvList) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(pdList); |
|
|
|
_dbcontext.BulkUpdate(pdinvList); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
item.State = SettleBillState.客户已收票; |
|
|
|
_dbcontext.BulkDelete(pdList); |
|
|
|
_dbcontext.BulkDelete(p_ls); |
|
|
|
} |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(pdList); |
|
|
|
} |
|
|
|
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
if (bbacList.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var item in bbacList) |
|
|
|
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
var bbacinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList(); |
|
|
|
if (bbacList.Count > 0) |
|
|
|
{ |
|
|
|
if (flag == true) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
foreach (var item in bbacList) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
foreach (var item in bbacinvList) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
|
_dbcontext.BulkUpdate(bbacinvList); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
item.State = SettleBillState.客户已收票; |
|
|
|
_dbcontext.BulkDelete(pdList); |
|
|
|
_dbcontext.BulkDelete(p_ls); |
|
|
|
} |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
|
} |
|
|
|
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
if (hbpoList.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var item in hbpoList) |
|
|
|
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
var hbpoinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();//发票
|
|
|
|
if (hbpoList.Count > 0) |
|
|
|
{ |
|
|
|
if (flag == true) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
foreach (var item in bbacList) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
foreach (var item in bbacinvList) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
|
_dbcontext.BulkUpdate(bbacinvList); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
item.State = SettleBillState.客户已收票; |
|
|
|
_dbcontext.BulkDelete(pdList); |
|
|
|
_dbcontext.BulkDelete(p_ls); |
|
|
|
} |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
|
} |
|
|
|
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList(); |
|
|
|
if (invoiceList.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var item in invoiceList) |
|
|
|
{ |
|
|
|
if (flag == true) |
|
|
|
{ |
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
} |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(invoiceList); |
|
|
|
} |
|
|
|
// _emailSender.SendAsync(e)
|
|
|
|
// 提交事务
|
|
|
|
transaction.Commit(); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
issucess = false; |
|
|
|
// 回滚事务
|
|
|
|
transaction.Rollback(); |
|
|
|
} |
|
|
|
// _emailSender.SendAsync(e)
|
|
|
|
// 提交事务
|
|
|
|
transaction.Commit(); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
issucess = false; |
|
|
|
// 回滚事务
|
|
|
|
transaction.Rollback(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (issucess ==false) |
|
|
|
{ |
|
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); |
|
|
|