|
@ -1,4 +1,4 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using EFCore.BulkExtensions; |
|
|
using EFCore.BulkExtensions; |
|
@ -30,52 +30,52 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
_emailSender = emailSender; |
|
|
_emailSender = emailSender; |
|
|
_dbcontext = dbcontext; |
|
|
_dbcontext = dbcontext; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
[UnitOfWork(false)] |
|
|
[UnitOfWork(false)] |
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value; |
|
|
var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value; |
|
|
var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value; |
|
|
var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value; |
|
|
var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value; |
|
|
var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value; |
|
|
var email = string.Empty; |
|
|
var email = string.Empty; |
|
|
// property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value;
|
|
|
// property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value;
|
|
|
var list = billList.Split(","); |
|
|
var list = billList.Split(","); |
|
|
var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位"); |
|
|
var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位"); |
|
|
if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian") |
|
|
if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian") |
|
|
|
|
|
{ |
|
|
|
|
|
var jisdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis
|
|
|
|
|
|
if (jisdetail != null && jisdetail.Count() > 0) |
|
|
{ |
|
|
{ |
|
|
var jisdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis
|
|
|
foreach (var itm in jisdetail) |
|
|
if (jisdetail != null && jisdetail.Any()) |
|
|
|
|
|
{ |
|
|
{ |
|
|
foreach (var itm in jisdetail) |
|
|
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) |
|
|
{ |
|
|
{ |
|
|
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; |
|
|
{ |
|
|
} |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description; |
|
|
{ |
|
|
|
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
Sync(jisdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); |
|
|
|
|
|
} |
|
|
} |
|
|
var mdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianBBAC);//买单件
|
|
|
Sync(jisdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); |
|
|
if (mdetail != null && mdetail.Any()) |
|
|
} |
|
|
|
|
|
var mdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianBBAC);//买单件
|
|
|
|
|
|
if (mdetail != null && mdetail.Count() > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var itm in jisdetail) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in jisdetail) |
|
|
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) |
|
|
{ |
|
|
{ |
|
|
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; |
|
|
{ |
|
|
} |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description; |
|
|
{ |
|
|
|
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList(); |
|
|
var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList(); |
|
|
|
|
|
|
|
@ -175,184 +175,176 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
select new VmiLog() |
|
|
select new VmiLog() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
CodeType = string.Empty, |
|
|
CodeType = string.Empty, |
|
|
BillTime = DateTime.Now, |
|
|
BillTime = DateTime.Now, |
|
|
ChangedTime = DateTime.Now, |
|
|
ChangedTime = DateTime.Now, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
|
RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU
|
|
|
RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU
|
|
|
RealCode = itm.RELU, |
|
|
RealCode = itm.RELU, |
|
|
LogType = Entities.BQ.Vmi.VmiLogType.Type200, |
|
|
LogType = Entities.BQ.Vmi.VmiLogType.Type200, |
|
|
ChangedQty = (flag == true) ? -itm.Qty : itm.Qty, |
|
|
ChangedQty = (flag == true) ? -itm.Qty : itm.Qty, |
|
|
ChangedType = VmiType.Out, |
|
|
ChangedType = VmiType.Out, |
|
|
//SubBillType = EnumDeliverSubBillType.小件BBAC,
|
|
|
//SubBillType = EnumDeliverSubBillType.小件BBAC,
|
|
|
//BillType = EnumDeliverBjBmpBillType.JIS件,
|
|
|
//BillType = EnumDeliverBjBmpBillType.JIS件,
|
|
|
CustPartCode = itm.LU, |
|
|
CustPartCode = itm.LU, |
|
|
SettlementVinCode = itm.PN, |
|
|
SettlementVinCode = itm.PN, |
|
|
DeliverBillType = bussinessType, |
|
|
DeliverBillType = bussinessType, |
|
|
VinCode = itm.PN, |
|
|
VinCode = itm.PN, |
|
|
OrderNum = itm.GroupNum, |
|
|
OrderNum = itm.GroupNum, |
|
|
ErpToLoc = itm.Extend2, //寄售库
|
|
|
ErpToLoc = itm.Extend2, //寄售库
|
|
|
}; |
|
|
}; |
|
|
var ls = query.ToList(); |
|
|
var ls = query.ToList(); |
|
|
foreach (var itm in ls) |
|
|
foreach (var itm in ls) |
|
|
{ |
|
|
{ |
|
|
itm.SetId(GuidGenerator.Create()); |
|
|
itm.SetId(GuidGenerator.Create()); |
|
|
} |
|
|
} |
|
|
var _first = p_ls.FirstOrDefault(); |
|
|
var _first = p_ls.FirstOrDefault(); |
|
|
|
|
|
bool issucess = true; |
|
|
bool issucess = true; |
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
|
|
|
{ |
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
try |
|
|
{ |
|
|
{ |
|
|
try |
|
|
// 执行批量数据操作
|
|
|
|
|
|
if (ls != null && ls.Count > 0) |
|
|
{ |
|
|
{ |
|
|
// 执行批量数据操作
|
|
|
var messagelist = new List<VmiMessage>(); |
|
|
if (ls != null && ls.Count > 0) |
|
|
foreach (var item in ls) |
|
|
{ |
|
|
{ |
|
|
var messagelist = new List<VmiMessage>(); |
|
|
var message = new VmiMessage |
|
|
foreach (var item in ls) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var message = new VmiMessage |
|
|
Message = System.Text.Json.JsonSerializer.Serialize(item), |
|
|
{ |
|
|
}; |
|
|
Message = System.Text.Json.JsonSerializer.Serialize(item), |
|
|
messagelist.Add(message); |
|
|
}; |
|
|
} |
|
|
messagelist.Add(message); |
|
|
_dbcontext.BulkInsert(messagelist); |
|
|
} |
|
|
_dbcontext.BulkInsert(ls, new BulkConfig() { }); |
|
|
_dbcontext.BulkInsert(messagelist); |
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); |
|
|
_dbcontext.BulkInsert(ls, new BulkConfig() { }); |
|
|
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); |
|
|
if (pdList.Count > 0) |
|
|
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
{ |
|
|
if (pdList.Count > 0) |
|
|
foreach (var item in pdList) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in pdList) |
|
|
if (flag == true) |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.已扣减; |
|
|
{ |
|
|
} |
|
|
item.State = SettleBillState.已扣减; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
item.State = SettleBillState.客户已收票; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.客户已收票; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(pdList); |
|
|
|
|
|
} |
|
|
} |
|
|
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
_dbcontext.BulkUpdate(pdList); |
|
|
if (bbacList.Count > 0) |
|
|
} |
|
|
|
|
|
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
|
|
if (bbacList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in bbacList) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in bbacList) |
|
|
if (flag == true) |
|
|
|
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.客户已收票; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.客户已收票; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
|
|
|
} |
|
|
} |
|
|
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
if (hbpoList.Count > 0) |
|
|
} |
|
|
|
|
|
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
|
|
if (hbpoList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in hbpoList) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in hbpoList) |
|
|
if (flag == true) |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.已扣减; |
|
|
{ |
|
|
} |
|
|
item.State = SettleBillState.已扣减; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
item.State = SettleBillState.客户已收票; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.客户已收票; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
|
|
|
} |
|
|
} |
|
|
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList(); |
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
if (invoiceList.Count > 0) |
|
|
} |
|
|
|
|
|
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList(); |
|
|
|
|
|
if (invoiceList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in invoiceList) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in invoiceList) |
|
|
if (flag == true) |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.已扣减; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(invoiceList); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
_dbcontext.BulkUpdate(invoiceList); |
|
|
} |
|
|
} |
|
|
// _emailSender.SendAsync(e)
|
|
|
|
|
|
// 提交事务
|
|
|
|
|
|
transaction.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception) |
|
|
|
|
|
{ |
|
|
|
|
|
issucess = false; |
|
|
|
|
|
// 回滚事务
|
|
|
|
|
|
transaction.Rollback(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
// _emailSender.SendAsync(e)
|
|
|
|
|
|
// 提交事务
|
|
|
|
|
|
transaction.Commit(); |
|
|
} |
|
|
} |
|
|
if (issucess == false) |
|
|
catch (Exception) |
|
|
{ |
|
|
{ |
|
|
|
|
|
issucess = false; |
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); |
|
|
// 回滚事务
|
|
|
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
transaction.Rollback(); |
|
|
if (pdList.Count > 0) |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (issucess ==false) |
|
|
|
|
|
{ |
|
|
|
|
|
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) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in pdList) |
|
|
if (flag == true) |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.客户已收票; |
|
|
{ |
|
|
} |
|
|
item.State = SettleBillState.客户已收票; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
item.State = SettleBillState.已扣减; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(pdList); |
|
|
|
|
|
} |
|
|
} |
|
|
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
_dbcontext.BulkUpdate(pdList); |
|
|
if (bbacList.Count > 0) |
|
|
} |
|
|
|
|
|
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
|
|
if (bbacList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in bbacList) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in bbacList) |
|
|
if (flag == true) |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.客户已收票; |
|
|
{ |
|
|
} |
|
|
item.State = SettleBillState.客户已收票; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
item.State = SettleBillState.已扣减; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
|
|
|
} |
|
|
} |
|
|
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
_dbcontext.BulkUpdate(bbacList); |
|
|
if (hbpoList.Count > 0) |
|
|
} |
|
|
|
|
|
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
|
|
|
if (hbpoList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in hbpoList) |
|
|
{ |
|
|
{ |
|
|
foreach (var item in hbpoList) |
|
|
if (flag == true) |
|
|
{ |
|
|
{ |
|
|
if (flag == true) |
|
|
item.State = SettleBillState.客户已收票; |
|
|
{ |
|
|
} |
|
|
item.State = SettleBillState.客户已收票; |
|
|
else |
|
|
} |
|
|
{ |
|
|
else |
|
|
item.State = SettleBillState.已扣减; |
|
|
{ |
|
|
|
|
|
item.State = SettleBillState.已扣减; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|