Browse Source

获取新版本

master
学 赵 1 year ago
parent
commit
8457ea86ad
  1. 72
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  2. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs
  3. 655
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  4. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs
  5. 54
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

72
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -210,40 +210,46 @@ namespace Win.Sfs.SettleAccount.Bases
[HttpPost] [HttpPost]
[UnitOfWork(false)] [UnitOfWork(false)]
public virtual async Task<string> ReceivedAsync(INVOICE_GRP_REQ_DTO input) public virtual async Task<string> ReceivedAsync(List<string> p_ins)
{ {
var entity = await _invMng.GetMainAsync(input.InvbillNum);
if (entity.InvoiceState == InvoiceBillState.) await _invMng.ReceivedAsync(p_ins);
{
throw new BusinessException("8989", $"发票号{entity.InvbillNum}为报废状态, 不能提交!");
}
if (entity.InvoiceState == InvoiceBillState. )
{ //var entity = await _invMng.GetMainAsync(input.InvbillNum);
throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}现在为提交状态!"); //if (entity.InvoiceState == InvoiceBillState.报废)
} //{
if (entity.State != SettleBillState.) // throw new BusinessException("8989", $"发票号{entity.InvbillNum}为报废状态, 不能提交!");
{ //}
throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}不是财务已审核状态,不能收票!"); //if (entity.InvoiceState == InvoiceBillState.提交 )
} //{
if (entity != null) // throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}现在为提交状态!");
{ //}
List<CustomCondition> customConditionList = new List<CustomCondition>(); //if (entity.State != SettleBillState.财务已审核)
customConditionList.Add(new CustomCondition() { Name = "InvGroupNum", Value = entity.InvGroupNum?? string.Empty }); //{
var invlist= _repository.Where(p => p.InvGroupNum == entity.InvGroupNum).ToList(); // throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}不是财务已审核状态,不能收票!");
foreach (var inv in invlist) { //}
//if (entity != null)
if (inv.InvoiceState != InvoiceBillState.) //{
{ // List<CustomCondition> customConditionList = new List<CustomCondition>();
inv.InvoiceState = InvoiceBillState.; // customConditionList.Add(new CustomCondition() { Name = "InvGroupNum", Value = entity.InvGroupNum?? string.Empty });
} // var invlist= _repository.Where(p => p.InvGroupNum == entity.InvGroupNum).ToList();
} // foreach (var inv in invlist) {
await _repository.DbContext.BulkUpdateAsync(invlist);
var _taskid = await _service.ExportEnqueueAsync($"发票分组{entity.InvGroupNum}收票任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyymm"), string.Empty, CurrentUser, typeof(PD_SERVICE), customConditionList, (rs) => // if (inv.InvoiceState != InvoiceBillState.报废)
{ // {
// inv.InvoiceState = InvoiceBillState.提交;
}); // }
return _taskid; // }
} // await _repository.DbContext.BulkUpdateAsync(invlist);
// var _taskid = await _service.ExportEnqueueAsync($"发票分组{entity.InvGroupNum}收票任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyymm"), string.Empty, CurrentUser, typeof(PD_SERVICE), customConditionList, (rs) =>
// {
// });
// return _taskid;
//}
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input) protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input)

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs

@ -264,6 +264,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
/// <summary>
/// 通过发票号获取结算数据
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<HBPO_CAN_SA_DETAIL>> GetDetailByInbillNumAsync(List<string> p_invs)
{
return await _detailRepository.Where(p => p_invs.Contains(p.BillNum)).ToListAsync();
}
} }

655
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -36,8 +36,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository; private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository;
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository; private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<PUB_PD, Guid> _pdRepository; private readonly INormalEfCoreRepository<BBAC_PD, Guid> _pdbbacRepository;
private readonly INormalEfCoreRepository<HBPO_PD, Guid> _pdhbpoRepository;
private readonly INormalEfCoreRepository<PUB_PD, Guid> _pdpubRepository;
private readonly PUB_CAN_SA_MNG _pubMng; private readonly PUB_CAN_SA_MNG _pubMng;
private readonly BBAC_CAN_SA_MNG _bbacMng; private readonly BBAC_CAN_SA_MNG _bbacMng;
private readonly HBPO_CAN_SA_MNG _hbpoMng; private readonly HBPO_CAN_SA_MNG _hbpoMng;
@ -46,15 +47,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
PUB_CAN_SA_MNG pubMng, PUB_CAN_SA_MNG pubMng,
BBAC_CAN_SA_MNG bbacMng, BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng, HBPO_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<PUB_PD, Guid> pdRepository, INormalEfCoreRepository<BBAC_PD, Guid> pdbbacRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<HBPO_PD, Guid> pdhbpoRepository,
INormalEfCoreRepository<PUB_PD, Guid> pdpubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository
) )
{ {
_pdRepository= pdRepository;
//_canRepository = canRepository; //_canRepository = canRepository;
_repository = repository; _repository = repository;
_detailRepository = detailRepository; _detailRepository = detailRepository;
@ -64,6 +67,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_pubMng = pubMng; _pubMng = pubMng;
_bbacMng = bbacMng; _bbacMng = bbacMng;
_hbpoMng = hbpoMng; _hbpoMng = hbpoMng;
_pdbbacRepository=pdbbacRepository;
_pdhbpoRepository=pdhbpoRepository;
_pdpubRepository =pdpubRepository;
} }
public INV_MNG() public INV_MNG()
@ -303,244 +309,437 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <returns></returns> /// <returns></returns>
public virtual async Task<bool> ReceivedAsync(List<string> p_invs) public virtual async Task<bool> ReceivedAsync(List<string> p_invs)
{ {
//var invList = _repository.Where(p =>p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
//int count = invList.Select(p => p.InvGroupNum).Count();
//if (count > 0)
//{
// throw new UserFriendlyException($"发票不属于一个发票分组");
//}
//var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//父发票号
//List<string> oldinvs = new List<string>();
//oldinvs.AddRange(p_invs);
//if (parentList != null && parentList.Count > 0)
//{
// oldinvs.AddRange(parentList);
//}
//List<string> seclist = new List<string>();
//List<string> firstlist = new List<string>();
//var pdlist = _pdRepository.Where(p => oldinvs.Contains(p.BillNum)).ToList();
//if (pdlist != null && pdlist.Count > 0)
//{
// seclist = pdlist.Select(p => p.BillNum).ToList();//那些在待扣减里已经有了属于作废重开
//}
//firstlist = p_invs.Where(p => !seclist.Contains(p)).ToList();
var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
int count = invList.Select(p => p.InvGroupNum).Distinct().Count();
if (count > 1)
{
throw new UserFriendlyException($"发票不属于一个发票分组");
}
var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.).ToList();
if (lostlist.Count > 0)
{
var invs=lostlist.Select(p => p.InvbillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",",invs)}");
}
//var inv=invList.FirstOrDefault(); var inv = invList.FirstOrDefault();
//if (inv.BusinessType == EnumBusinessType.JisBBAC) if (inv.BusinessType == EnumBusinessType.JisBBAC)
//{ {
// var namelist=invList.Select(p => p.InvbillNum).ToList(); var pdlist = _pdbbacRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
// var entityDetail = await _bbacMng.GetDetailByInbillNumAsync(namelist);//结算明细 if (pdlist != null && pdlist.Count > 0)
// var adjlist=_adjRepository.Where(p => namelist.Contains(p.OldInvBillNum)).ToList();//调整表明细明细 {
var invs = pdlist.Select(p => p.BillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交");
}
var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号
List<string> oldinvs = new List<string>();
oldinvs.AddRange(p_invs);
if (parentList != null && parentList.Count > 0)
{
oldinvs.AddRange(parentList);
}
List<string> oldlist = new List<string>();//以前提交过的发票
List<string> newlist = new List<string>();//没有提交过的发票
var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList();
if (pdoldlist != null && pdoldlist.Count > 0)
{
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
// if (adjlist != null && adjlist.Count() > 0) List<BBAC_CAN_SA_DETAIL> entityList = new List<BBAC_CAN_SA_DETAIL>();//结算明细
// { var namelist = invList.Select(p => p.InvbillNum).ToList();
// foreach (var itm in adjlist) if (oldlist.Count > 0)
// { {
// entityDetail.Add(new BBAC_CAN_SA_DETAIL( var involdList= invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
// guid: GuidGenerator.Create(), var involdname=involdList.Select(p => p.InvbillNum);
// keyCode: itm.KeyCode, var adjlist=_adjRepository.Where(p => involdname.Contains(p.InvBillNum));
// version: itm.Version,
// billNum: itm.InvGroupNum, if (adjlist != null && adjlist.Count() > 0)
// settleBillNum: itm.SettleBillNum, {
// lU: itm.LU, foreach (var itm in adjlist)
// pN: itm.PN, {
// site: itm.Site, entityList.Add(new BBAC_CAN_SA_DETAIL(
// qty: itm.Qty, guid: GuidGenerator.Create(),
// price: itm.Price, keyCode: itm.KeyCode,
// category: itm.BusinessType, version: itm.Version,
// isReturn: itm.Qty > 0 ? false : true, billNum: itm.InvGroupNum,
// settleDate: itm.SettleDate, settleBillNum: itm.SettleBillNum,
// groupNum: itm.GroupNum, lU: itm.LU,
// invGroupNum: itm.InvGroupNum, pN: itm.PN,
// contactid: itm.Extend1//生产号 site: itm.Site,
// )); qty: itm.Qty,
// } price: 0,
// } category: itm.BusinessType,
isReturn: itm.Qty > 0 ? false : true,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: itm.InvBillNum
));
}
}
}
if (newlist.Count > 0)
{
var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList();
var entityDetail = await _bbacMng.GetDetailByInbillNumAsync(newlist);//结算明细
var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityDetail.Add(new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
category: itm.BusinessType,
isReturn: itm.Qty > 0 ? false : true,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: itm.InvBillNum
));
}
}
entityList.AddRange(entityDetail);
//entityDetail.GroupBy(p =>new { }
// p.LU,
// p.PN, var bbacmainlist = new List<BBAC_PD>();
// p.Site, foreach (var itm in invList)
// p.Qty, {
// p.BusinessType var bbac = new BBAC_PD(
//}).Select(p =>new BBAC_PD_DETAIL( guid: itm.Id,
version:int.Parse(DateTime.Now.ToString("yyyyMM")),
billNum: itm.InvbillNum,
settleBillNum: itm.InvGroupNum,
state: SettleBillState.,
invGroupNum: itm.InvGroupNum,
site: string.Empty
);
bbacmainlist.Add( bbac );
// guid: GuidGenerator.Create(), }
// keyCode: p.Key.PN.Trim()+p.Key.LU, var bbacDetail = new List<BBAC_PD_DETAIL>();
// version: p.Key.Version, foreach (var itm in entityList)
// billNum: string.Empty, {
// lU: p.Key.LU, bbacDetail.Add(
// rELU: string.Empty, new BBAC_PD_DETAIL(
// pN: p.Key.PN, guid: itm.Id,
// rEPN: string.Empty, keyCode: itm.KeyCode,
// site: string.Empty, version: itm.Version,
// qty:p.Sum(itm=>itm.Qty), billNum: itm.BillNum,
// price: 0, lU: itm.LU,
// invGroupNum: p.Key., rELU: string.Empty,
// settleDate: p.SettleDate, pN: itm.PN,
// groupNum: p.GroupNum, rEPN: string.Empty,
// extend1: string.Empty, site: itm.Site,
// extend2: string.Empty, qty: itm.Qty,
// extend3: string.Empty, price: 0,
// extend4: string.Empty invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
await _repository.DbContext.BulkInsertAsync(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
}
else if (inv.BusinessType == EnumBusinessType.JisHBPO)
{
var pdlist = _pdhbpoRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
if (pdlist != null && pdlist.Count > 0)
{
var invs = pdlist.Select(p => p.BillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交");
}
var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号
List<string> oldinvs = new List<string>();
oldinvs.AddRange(p_invs);
if (parentList != null && parentList.Count > 0)
{
oldinvs.AddRange(parentList);
}
List<string> oldlist = new List<string>();//以前提交过的发票
List<string> newlist = new List<string>();//没有提交过的发票
var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList();
if (pdoldlist != null && pdoldlist.Count > 0)
{
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
List<HBPO_CAN_SA_DETAIL> entityList = new List<HBPO_CAN_SA_DETAIL>();//结算明细
var namelist = invList.Select(p => p.InvbillNum).ToList();
if (oldlist.Count > 0)
{
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
var involdname = involdList.Select(p => p.InvbillNum);
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum));
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityList.Add(new HBPO_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
}
if (newlist.Count > 0)
{
var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList();
var entityDetail = await _hbpoMng.GetDetailByInbillNumAsync(newlist);//结算明细
var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityDetail.Add(new HBPO_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
entityList.AddRange(entityDetail);
//); }
var bbacmainlist = new List<HBPO_PD>();
foreach (var itm in invList)
{
var bbac = new HBPO_PD(
guid: itm.Id,
version: int.Parse(DateTime.Now.ToString("yyyyMM")),
billNum: itm.InvbillNum,
settleBillNum: itm.InvGroupNum,
state: SettleBillState.,
invGroupNum: itm.InvGroupNum,
site: string.Empty
);
bbacmainlist.Add(bbac);
}
var bbacDetail = new List<HBPO_PD_DETAIL>();
foreach (var itm in entityList)
{
bbacDetail.Add(
new HBPO_PD_DETAIL(
guid: itm.Id,
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.Empty,
pN: itm.PN,
rEPN: string.Empty,
site: itm.Site,
qty: itm.Qty,
price: 0,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
await _repository.DbContext.BulkInsertAsync(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
}
else
{
var pdlist = _pdpubRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
if (pdlist != null && pdlist.Count > 0)
{
var invs = pdlist.Select(p => p.BillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交");
}
var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号
List<string> oldinvs = new List<string>();
oldinvs.AddRange(p_invs);
if (parentList != null && parentList.Count > 0)
{
oldinvs.AddRange(parentList);
}
List<string> oldlist = new List<string>();//以前提交过的发票
List<string> newlist = new List<string>();//没有提交过的发票
var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList();
if (pdoldlist != null && pdoldlist.Count > 0)
{
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
List<PUB_CAN_SA_DETAIL> entityList = new List<PUB_CAN_SA_DETAIL>();//结算明细
var namelist = invList.Select(p => p.InvbillNum).ToList();
if (oldlist.Count > 0)
{
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
var involdname = involdList.Select(p => p.InvbillNum);
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum));
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityList.Add(new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
}
if (newlist.Count > 0)
{
var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList();
var entityDetail = await _pubMng.GetDetailByInbillNumAsync(newlist);//结算明细
var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityDetail.Add(new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
entityList.AddRange(entityDetail);
// var bbac = new BBAC_PD( }
// guid: entity.Id,
// version: entity.Version,
// billNum: entity.BillNum,
// settleBillNum: entity.SettleBillNum,
// state: SettleBillState.客户已收票,
// invGroupNum: entity.InvGroupNum,
// site: entity.Site
// );
// var bbacDetail = new List<BBAC_PD_DETAIL>();
// foreach (var itm in entityDetail) var bbacmainlist = new List<PUB_PD>();
// { foreach (var itm in invList)
// bbacDetail.Add( {
// new BBAC_PD_DETAIL( var pub = new PUB_PD(
// guid: itm.Id, guid: itm.Id,
// keyCode: itm.KeyCode, version: int.Parse(DateTime.Now.ToString("yyyyMM")),
// version: itm.Version, billNum: itm.InvbillNum,
// billNum: itm.BillNum, settleBillNum: itm.InvGroupNum,
// lU: itm.LU, state: SettleBillState.,
// rELU: string.Empty, invGroupNum: itm.InvGroupNum,
// pN: itm.PN, site: string.Empty
// rEPN: string.Empty, );
// site: itm.Site, bbacmainlist.Add(pub);
// qty: itm.Qty,
// price: itm.Price,
// invGroupNum: itm.InvGroupNum,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// extend1: string.Empty,
// extend2: string.Empty,
// extend3: string.Empty,
// extend4: string.Empty
// ));
// await _repository.DbContext.BulkInsertAsync(new List<BBAC_PD>() { bbac });
// await _repository.DbContext.BulkInsertAsync(bbacDetail);
// return true;
// }
//} }
//else if (inv.BusinessType == EnumBusinessType.JisHBPO) var bbacDetail = new List<PUB_PD_DETAIL>();
//{ foreach (var itm in entityList)
// var entity = await _hbpoMng.GetMainAsync(inv.InvGroupNum); {
// if (entity != null) bbacDetail.Add(
// { new PUB_PD_DETAIL(
guid: itm.Id,
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.Empty,
pN: itm.PN,
rEPN: string.Empty,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType:itm.BusinessType,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
await _repository.DbContext.BulkInsertAsync(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
// var entityDetail = await _hbpoMng.GetDetalListAsync(inv.InvGroupNum); }
// if (entityDetail != null && entityDetail.Count() > 0)
// {
// var hbpo = new HBPO_PD(
// guid: entity.Id,
// version: entity.Version,
// billNum: entity.BillNum,
// settleBillNum: entity.SettleBillNum,
// state: SettleBillState.客户已收票,
// invGroupNum: entity.InvGroupNum,
// site: entity.Site
// );
// var hbpoDetail = new List<HBPO_PD_DETAIL>();
// foreach (var itm in entityDetail)
// {
// hbpoDetail.Add(
// new HBPO_PD_DETAIL(
// guid: itm.Id,
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.BillNum,
// lU: itm.LU,
// rELU: string.Empty,
// pN: itm.PN,
// rEPN: string.Empty,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// invGroupNum: itm.InvGroupNum,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// extend1: string.Empty,
// extend2: string.Empty,
// extend3: string.Empty,
// extend4: string.Empty
// ));
// }
// await _repository.DbContext.BulkInsertAsync(new List<HBPO_PD>() { hbpo });
// await _repository.DbContext.BulkInsertAsync(hbpoDetail);
// return true;
// }
// }
//}
//else
//{
// var entity = await _pubMng.GetMainAsync(inv.InvGroupNum);
// if (entity != null)
// {
// var entityDetail = await _pubMng.GetDetalListAsync(inv.InvGroupNum);
// if (entityDetail != null && entityDetail.Count() > 0)
// {
// var pub = new PUB_PD(
// guid: entity.Id,
// version: entity.Version,
// billNum: entity.BillNum,
// settleBillNum: entity.SettleBillNum,
// state: SettleBillState.客户已收票,
// invGroupNum: entity.InvGroupNum,
// site: entity.Site
// );
// var pubDetail = new List<PUB_PD_DETAIL>();
// foreach (var itm in entityDetail)
// {
// pubDetail.Add(
// new PUB_PD_DETAIL(
// guid: itm.Id,
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.BillNum,
// lU: itm.LU,
// rELU: string.Empty,
// pN: itm.PN,
// rEPN: string.Empty,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// invGroupNum: itm.InvGroupNum,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// extend1: string.Empty,
// extend2: string.Empty,
// extend3: string.Empty,
// extend4: string.Empty,
// businessType: itm.BusinessType
// ));
// }
// await _repository.DbContext.BulkInsertAsync(new List<PUB_PD>() { pub });
// await _repository.DbContext.BulkInsertAsync(pubDetail);
// return true;
// }
// }
//}
return false; return false;
} }
public virtual async Task<bool> Reject(INVOICE_GRP p_entity) public virtual async Task<bool> Reject(INVOICE_GRP p_entity)
@ -762,7 +961,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
select itm2; select itm2;
foreach (var itm in query) foreach (var itm in query)
{ {
itm.BillNum = key; itm.InvbillNum = key;
salist.Add(itm); salist.Add(itm);
} }
if (!string.IsNullOrEmpty(p_parentInvBillNum)) if (!string.IsNullOrEmpty(p_parentInvBillNum))
@ -989,10 +1188,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
select itm2; select itm2;
foreach (var itm in query) foreach (var itm in query)
{ {
itm.BillNum = key; itm.InvbillNum = key;
salist.Add(itm); salist.Add(itm);
} }
if (!string.IsNullOrEmpty(p_parentInvBillNum)) if (!string.IsNullOrEmpty(p_parentInvBillNum))
{ {
@ -1177,7 +1374,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList(); var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in invdetails) foreach (var detail in invdetails)
{ {
detail.BillNum = key; detail.InvbillNum = key;
salist.Add(detail); salist.Add(detail);
} }
if (!string.IsNullOrEmpty(p_parentInvBillNum)) if (!string.IsNullOrEmpty(p_parentInvBillNum))
@ -1351,12 +1548,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false; return false;
} }
foreach (var adj in p_adjlist) //foreach (var adj in p_adjlist)
{ //{
adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息 // adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息
} //}
_repository.DbContext.BulkUpdate(p_adjlist); //_repository.DbContext.BulkUpdate(p_adjlist);
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv }); _repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv });
return true; return true;
@ -1408,7 +1605,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
//{ //{
// adj.InvBillNum = string.Join(",", invlist); // adj.InvBillNum = string.Join(",", invlist);
//} //}
_repository.DbContext.BulkUpdate(p_adjlist); //_repository.DbContext.BulkUpdate(p_adjlist);
return true; return true;
} }
return false; return false;

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs

@ -256,6 +256,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <summary>
/// 通过发票号获取结算数据
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<PUB_CAN_SA_DETAIL>> GetDetailByInbillNumAsync(List<string> p_invs)
{
return await _detailRepository.Where(p => p_invs.Contains(p.BillNum)).ToListAsync();
}
} }

54
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -107,6 +107,9 @@ namespace Win.Sfs.SettleAccount
builder.ConfigurePUB_ADJ_DETAIL(options); builder.ConfigurePUB_ADJ_DETAIL(options);
builder.ConfigureBBAC_ADJ_DETAIL(options); builder.ConfigureBBAC_ADJ_DETAIL(options);
builder.ConfigureHBPO_ADJ_DETAIL(options); builder.ConfigureHBPO_ADJ_DETAIL(options);
builder.ConfigureBBAC_PD(options);
builder.ConfigureHBPO_PD(options);
builder.ConfigurePUB_PD(options);
//大众发票导入 //大众发票导入
//builder.ConfigureInvoice(options); //builder.ConfigureInvoice(options);
//builder.ConfigureInvoiceVersion(options); //builder.ConfigureInvoiceVersion(options);
@ -1209,6 +1212,57 @@ namespace Win.Sfs.SettleAccount
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
}); });
} }
private static void ConfigureBBAC_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<BBAC_PD>(b =>
{
b.ToTable($"{options.TablePrefix}_BBAC_PD", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.BillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigureHBPO_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<HBPO_PD>(b =>
{
b.ToTable($"{options.TablePrefix}_HBPO_PD", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.BillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigurePUB_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<PUB_PD>(b =>
{
b.ToTable($"{options.TablePrefix}_PUB_PD", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.BillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {

Loading…
Cancel
Save