Browse Source

更新版本

master
学 赵 1 year ago
parent
commit
1042d0e8d5
  1. 161
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  2. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs

161
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs

@ -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;
} }
} }
} }

6
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs

@ -20,9 +20,6 @@ public class PD_MNG<TEntity,TEntityDetail>:DomainService
private readonly INormalEfCoreRepository<TEntity, Guid> _repository; private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository; private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
protected PD_MNG( protected PD_MNG(
INormalEfCoreRepository<TEntity, Guid> repository, INormalEfCoreRepository<TEntity, Guid> repository,
@ -30,11 +27,8 @@ public class PD_MNG<TEntity,TEntityDetail>:DomainService
) )
{ {
_repository = repository; _repository = repository;
_detailRepository = detailRepository; _detailRepository = detailRepository;
} }
public PD_MNG() public PD_MNG()

Loading…
Cancel
Save