|
@ -38,8 +38,6 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
|
|
|
|
|
|
public PendingDeductionService( |
|
|
public PendingDeductionService( |
|
|
SettleAccountDbContext dbcontext, |
|
|
SettleAccountDbContext dbcontext, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEmailSender emailSender |
|
|
IEmailSender emailSender |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
@ -48,47 +46,39 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
[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 == "库位"); |
|
|
|
|
|
|
|
|
//JisBBAC
|
|
|
|
|
|
//JisHBPO
|
|
|
if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian") |
|
|
//ZhiGongJianBBAC
|
|
|
|
|
|
//ZhiGongJianHBPO
|
|
|
|
|
|
//MaiDanJianBBAC
|
|
|
|
|
|
//MaiDanJianHBPO
|
|
|
|
|
|
//BeiJian
|
|
|
|
|
|
//YinDuJian
|
|
|
|
|
|
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
|
|
|
var jisdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis
|
|
|
if (jisdetail != null && jisdetail.Count() > 0) |
|
|
if (jisdetail != null && jisdetail.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(jisdetail.ToList(), EnumDeliverBjBmpBillType.JIS件,email ,isout == "out" ? true : false); |
|
|
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);//买单件
|
|
|
var mdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianBBAC);//买单件
|
|
|
if (mdetail !=null&&mdetail.Count() > 0) |
|
|
if (mdetail != null && mdetail.Count() > 0) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in jisdetail) |
|
|
foreach (var itm in jisdetail) |
|
|
{ |
|
|
{ |
|
@ -101,10 +91,10 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
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(); |
|
|
|
|
|
|
|
|
if (detailist1.Count > 0) |
|
|
if (detailist1.Count > 0) |
|
|
{ |
|
|
{ |
|
@ -120,7 +110,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "ZhiGongJianBBAC顺义").Description; |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "ZhiGongJianBBAC顺义").Description; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Sync(zgbbaclist, EnumDeliverBjBmpBillType.JIT直供件,email, isout == "out" ? true : false); |
|
|
Sync(zgbbaclist, EnumDeliverBjBmpBillType.JIT直供件, email, isout == "out" ? true : false); |
|
|
var ydlist = detailist1.Where(p => p.BusinessType == EnumBusinessType.YinDuJian).ToList(); |
|
|
var ydlist = detailist1.Where(p => p.BusinessType == EnumBusinessType.YinDuJian).ToList(); |
|
|
if (ydlist.Count > 0) |
|
|
if (ydlist.Count > 0) |
|
|
{ |
|
|
{ |
|
@ -131,7 +121,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "YinDuJian").Description; |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "YinDuJian").Description; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Sync(ydlist, EnumDeliverBjBmpBillType.印度件, email,isout == "out" ? true : false); |
|
|
Sync(ydlist, EnumDeliverBjBmpBillType.印度件, email, isout == "out" ? true : false); |
|
|
} |
|
|
} |
|
|
var bjlist = detailist1.Where(p => p.BusinessType == EnumBusinessType.BeiJian).ToList(); |
|
|
var bjlist = detailist1.Where(p => p.BusinessType == EnumBusinessType.BeiJian).ToList(); |
|
|
if (bjlist.Count > 0) |
|
|
if (bjlist.Count > 0) |
|
@ -143,7 +133,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "BeiJian").Description; |
|
|
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "BeiJian").Description; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Sync(bjlist, EnumDeliverBjBmpBillType.北汽4S备件,email ,isout == "out" ? true : false); |
|
|
Sync(bjlist, EnumDeliverBjBmpBillType.北汽4S备件, email, isout == "out" ? true : false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -152,12 +142,12 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
var detailist = _dbcontext.Set<HBPO_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisHBPO).ToList(); |
|
|
var detailist = _dbcontext.Set<HBPO_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisHBPO).ToList(); |
|
|
foreach (var itm in detailist) |
|
|
foreach (var itm in detailist) |
|
|
{ |
|
|
{ |
|
|
if ( string.IsNullOrEmpty(itm.Extend2)) |
|
|
if (string.IsNullOrEmpty(itm.Extend2)) |
|
|
{ |
|
|
{ |
|
|
itm.Extend2 = "CC017"; |
|
|
itm.Extend2 = "CC017"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Sync(detailist, EnumDeliverBjBmpBillType.JIS件,email ,isout == "out" ? true : false); |
|
|
Sync(detailist, EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); |
|
|
var mdetail = _dbcontext.Set<HBPO_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianHBPO);//买单件
|
|
|
var mdetail = _dbcontext.Set<HBPO_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianHBPO);//买单件
|
|
|
foreach (var itm in mdetail) |
|
|
foreach (var itm in mdetail) |
|
|
{ |
|
|
{ |
|
@ -166,7 +156,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
itm.Extend2 = "CC017"; |
|
|
itm.Extend2 = "CC017"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
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(); |
|
|
var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianHBPO).ToList(); |
|
|
var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianHBPO).ToList(); |
|
|
foreach (var itm in zgbbaclist) |
|
|
foreach (var itm in zgbbaclist) |
|
@ -176,9 +166,8 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
itm.Extend2 = "CC017"; |
|
|
itm.Extend2 = "CC017"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Sync(detailist, EnumDeliverBjBmpBillType.JIT直供件,email,isout == "out" ? true : false); |
|
|
Sync(detailist, EnumDeliverBjBmpBillType.JIT直供件, email, isout == "out" ? true : false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return id.ToString(); |
|
|
return id.ToString(); |
|
|
} |
|
|
} |
|
|
//public List<T> GetPagedData<T>(List<T> dataList, int pageNumber, int pageSize)
|
|
|
//public List<T> GetPagedData<T>(List<T> dataList, int pageNumber, int pageSize)
|
|
@ -197,37 +186,40 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
// return pageCount;
|
|
|
// return pageCount;
|
|
|
//}
|
|
|
//}
|
|
|
|
|
|
|
|
|
public void Sync<T>(List<T> p_ls, EnumDeliverBjBmpBillType bussinessType,string p_email ,bool flag=true) where T : PD_BASE,new() |
|
|
public void Sync<T>(List<T> p_ls, EnumDeliverBjBmpBillType bussinessType, string p_email, bool flag = true) where T : PD_BASE, new() |
|
|
{ |
|
|
{ |
|
|
var query = from itm in p_ls |
|
|
var query = from itm in p_ls |
|
|
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(); |
|
|
using (var transaction =_dbcontext.Database.BeginTransaction()) |
|
|
|
|
|
|
|
|
bool issucess = true; |
|
|
|
|
|
|
|
|
|
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -296,72 +288,73 @@ public class PendingDeductionService : ApplicationService, ITransientDependency, |
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
_dbcontext.BulkUpdate(hbpoList); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// _emailSender.SendAsync(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _emailSender.SendAsync(e)
|
|
|
|
|
|
|
|
|
|
|
|
// 提交事务
|
|
|
// 提交事务
|
|
|
transaction.Commit(); |
|
|
transaction.Commit(); |
|
|
} |
|
|
} |
|
|
catch (Exception) |
|
|
catch (Exception) |
|
|
{ |
|
|
{ |
|
|
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); |
|
|
issucess = false; |
|
|
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); |
|
|
// 回滚事务
|
|
|
if (pdList.Count > 0) |
|
|
transaction.Rollback(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
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); |
|
|
transaction.Rollback(); |
|
|
|
|
|
throw; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|