Browse Source

更新版本

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

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

@ -38,57 +38,47 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
public PendingDeductionService(
SettleAccountDbContext dbcontext,
IEmailSender emailSender
)
{
_emailSender = emailSender;
_dbcontext = dbcontext;
}
[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 type = property.Where(p => p.Name == "Type").FirstOrDefault().Value;
var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value;
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 projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位");
//JisBBAC
//JisHBPO
//ZhiGongJianBBAC
//ZhiGongJianHBPO
//MaiDanJianBBAC
//MaiDanJianHBPO
//BeiJian
//YinDuJian
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)
{
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
{
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);//买单件
if (mdetail !=null&&mdetail.Count() > 0)
if (mdetail != null && mdetail.Count() > 0)
{
foreach (var itm in jisdetail)
{
@ -101,11 +91,11 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
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)
{
var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianBBAC).ToList();
@ -120,7 +110,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
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();
if (ydlist.Count > 0)
{
@ -131,7 +121,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
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();
if (bjlist.Count > 0)
@ -143,7 +133,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
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();
foreach (var itm in detailist)
{
if ( string.IsNullOrEmpty(itm.Extend2))
if (string.IsNullOrEmpty(itm.Extend2))
{
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);//买单件
foreach (var itm in mdetail)
{
@ -166,7 +156,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
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 zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianHBPO).ToList();
foreach (var itm in zgbbaclist)
@ -176,9 +166,8 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
itm.Extend2 = "CC017";
}
}
Sync(detailist, EnumDeliverBjBmpBillType.JIT直供件,email,isout == "out" ? true : false);
Sync(detailist, EnumDeliverBjBmpBillType.JIT直供件, email, isout == "out" ? true : false);
}
return id.ToString();
}
//public List<T> GetPagedData<T>(List<T> dataList, int pageNumber, int pageSize)
@ -197,37 +186,40 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
// 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
select new VmiLog()
select new VmiLog()
{
CodeType=string.Empty,
CodeType = string.Empty,
BillTime = DateTime.Now,
ChangedTime = DateTime.Now,
Qty = itm.Qty,
RealPartCode=itm.RELU,//替换件 结算数据 RealPartCode->RELU
RealCode=itm.RELU,
RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU
RealCode = itm.RELU,
LogType = Entities.BQ.Vmi.VmiLogType.Type200,
ChangedQty =(flag==true)? -itm.Qty:itm.Qty,
ChangedQty = (flag == true) ? -itm.Qty : itm.Qty,
ChangedType = VmiType.Out,
//SubBillType = EnumDeliverSubBillType.小件BBAC,
//BillType = EnumDeliverBjBmpBillType.JIS件,
CustPartCode = itm.LU,
SettlementVinCode = itm.PN,
DeliverBillType=bussinessType,
DeliverBillType = bussinessType,
VinCode = itm.PN,
OrderNum = itm.GroupNum,
ErpToLoc = itm.Extend2, //寄售库
ErpToLoc = itm.Extend2, //寄售库
};
var ls = query.ToList();
foreach (var itm in ls)
{
itm.SetId(GuidGenerator.Create());
}
var _first= p_ls.FirstOrDefault();
using (var transaction =_dbcontext.Database.BeginTransaction())
var _first = p_ls.FirstOrDefault();
bool issucess = true;
using (var transaction = _dbcontext.Database.BeginTransaction())
{
try
{
@ -296,74 +288,75 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
_dbcontext.BulkUpdate(hbpoList);
}
}
// _emailSender.SendAsync(e)
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
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)
issucess = false;
// 回滚事务
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.;
}
else
{
item.State = SettleBillState.;
}
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(pdList);
}
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (bbacList.Count > 0)
_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)
{
foreach (var item in bbacList)
if (flag == true)
{
if (flag == true)
{
item.State = SettleBillState.;
}
else
{
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();
if (hbpoList.Count > 0)
_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)
{
foreach (var item in hbpoList)
if (flag == true)
{
if (flag == true)
{
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
}
_dbcontext.BulkUpdate(hbpoList);
}
// 回滚事务
transaction.Rollback();
throw;
_dbcontext.BulkUpdate(hbpoList);
}
}
}
}

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

@ -20,21 +20,15 @@ public class PD_MNG<TEntity,TEntityDetail>:DomainService
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
protected PD_MNG(
INormalEfCoreRepository<TEntity, Guid> repository,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
)
{
{
_repository = repository;
_detailRepository = detailRepository;
}
public PD_MNG()

Loading…
Cancel
Save