Browse Source

[CI SKIP]-[168]添加已扣减发票提交到QAD接口

master
mahao 1 year ago
parent
commit
497986de62
  1. 43
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  2. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  3. 132
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  4. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

43
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -136,23 +136,50 @@ namespace Win.Sfs.SettleAccount.Bases
[UnitOfWork(false)]
public virtual async Task<string> ApprovalPassed(List<string> p_list)
{
return await InvokePD(p_list, _service, false);
return await InvokePD(p_list, _service);
}
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<string> RejectAsync(List<string> p_list)
{
return await InvokePD(p_list, _service, true);
return await InvokePD(p_list, _service);
}
/// <summary>
/// 调用扣减
/// </summary>
/// <param name="p_list"></param>
/// <param name="p_service"></param>
/// <param name="isback"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false)
{
var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
var states= invlist.Select(p => p.State).Distinct().ToList();
if (states.Count > 1)
{
throw new UserFriendlyException($"发票不是同一状态", "400");
}
var first = invlist.FirstOrDefault();//发票状态
if(first.State != SettleBillState. && first.State != SettleBillState.)
{
throw new UserFriendlyException($"当前发票状态不是【客户已收票】或【已扣减状态】不能进行出库扣减或撤销扣减操作", "400");
}
if (first.State == SettleBillState.)
{
isback = false;
}
if(first.State==SettleBillState.)
{
isback = true;
}
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
var first=detailist.FirstOrDefault();
var first1=detailist.FirstOrDefault();
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
customConditionList.Add(new CustomCondition() { Name = "Type", Value =first.BusinessType.ToString() });
customConditionList.Add(new CustomCondition() { Name = "Type", Value =first1.BusinessType.ToString() });
if (isback == false)
{
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
@ -161,7 +188,6 @@ namespace Win.Sfs.SettleAccount.Bases
{
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "in" });
}
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var lst=new List<TEntity>();
if (isback == false)
@ -172,8 +198,6 @@ namespace Win.Sfs.SettleAccount.Bases
{
lst = ls.Where(p => (p.State == SettleBillState.|| p.State == SettleBillState.)).ToList();
}
if (lst.Count() > 0)
{
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
@ -190,8 +214,7 @@ namespace Win.Sfs.SettleAccount.Bases
}
}
await _repository.DbContext.BulkUpdateAsync(ls);
var _taskid = await p_service.ExportEnqueueAsync($"{first.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
var _taskid = await p_service.ExportEnqueueAsync($"{first1.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
{
});

25
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -353,8 +353,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public virtual async Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input)
{
INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO();
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum");
if( condition==null )
{
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
}
var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);
var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
var first = invs.FirstOrDefault();
@ -607,6 +615,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList();
return entity;
}
[HttpPost]
public virtual async Task<string> ExportAsync(INVOICE_GRP_REQ_DTO input)
{
@ -654,7 +668,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
IExporter _csv = new CsvExporter();
ExcelExporter _excel = new ExcelExporter();
// var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false);
var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum");
if (condition == null)
{
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
}
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var first = entities.FirstOrDefault();
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities);
var invdetail = await DetailQueryAsync(input).ConfigureAwait(false);

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

@ -199,97 +199,109 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
var _first = p_ls.FirstOrDefault();
bool issucess = true;
using (var transaction = _dbcontext.Database.BeginTransaction())
{
try
using (var transaction = _dbcontext.Database.BeginTransaction())
{
// 执行批量数据操作
if (ls != null && ls.Count > 0)
try
{
var messagelist = new List<VmiMessage>();
foreach (var item in ls)
// 执行批量数据操作
if (ls != null && ls.Count > 0)
{
var message = new VmiMessage
var messagelist = new List<VmiMessage>();
foreach (var item in ls)
{
Message = System.Text.Json.JsonSerializer.Serialize(item),
};
messagelist.Add(message);
}
_dbcontext.BulkInsert(messagelist);
_dbcontext.BulkInsert(ls, new BulkConfig() { });
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)
var message = new VmiMessage
{
Message = System.Text.Json.JsonSerializer.Serialize(item),
};
messagelist.Add(message);
}
_dbcontext.BulkInsert(messagelist);
_dbcontext.BulkInsert(ls, new BulkConfig() { });
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();//同步数据的发票号
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();//扣减单内容
var pdinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (pdList.Count > 0)
{
if (flag == true)
{
item.State = SettleBillState.;
foreach (var item in pdList)
{
item.State = SettleBillState.;
}
foreach (var item in pdinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(pdList);
_dbcontext.BulkUpdate(pdinvList);
}
else
{
item.State = SettleBillState.;
_dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
}
}
_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)
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
var bbacinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (bbacList.Count > 0)
{
if (flag == true)
{
item.State = SettleBillState.;
foreach (var item in bbacList)
{
item.State = SettleBillState.;
}
foreach (var item in bbacinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(bbacList);
_dbcontext.BulkUpdate(bbacinvList);
}
else
{
item.State = SettleBillState.;
_dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
}
}
_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)
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
var hbpoinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();//发票
if (hbpoList.Count > 0)
{
if (flag == true)
{
item.State = SettleBillState.;
foreach (var item in bbacList)
{
item.State = SettleBillState.;
}
foreach (var item in bbacinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(bbacList);
_dbcontext.BulkUpdate(bbacinvList);
}
else
{
item.State = SettleBillState.;
_dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
}
}
_dbcontext.BulkUpdate(hbpoList);
}
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (invoiceList.Count > 0)
{
foreach (var item in invoiceList)
{
if (flag == true)
{
item.State = SettleBillState.;
}
}
_dbcontext.BulkUpdate(invoiceList);
}
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
issucess = false;
// 回滚事务
transaction.Rollback();
}
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
issucess = false;
// 回滚事务
transaction.Rollback();
}
}
if (issucess ==false)
{
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();

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

@ -1154,10 +1154,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
invoiceBillState: InvoiceBillState.,
tax: 0.13m,
parent: p_parentInvBillNum,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: readAmt
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: readAmt
);
invbill.ClientCode = clientCode;
invbill.Site = dtos.FirstOrDefault().Site;
@ -1393,7 +1393,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0.13m,
parent: string.Empty,
parent: !string.IsNullOrEmpty(p_parentInvBillNum)?p_parentInvBillNum:string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
@ -1963,7 +1963,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0.13m,
parent: string.Empty,
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
@ -2027,7 +2027,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
if (!string.IsNullOrEmpty(p_OldInvBillNum))
{
var inv = await GetInvoiceAsync(p_OldInvBillNum).ConfigureAwait(false);
var inv = await GetInvoiceAsync(p_OldInvBillNum).ConfigureAwait(false);//获取旧发票
if (inv == null)
{
@ -2283,7 +2283,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0.13m,
parent: string.Empty,
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,

Loading…
Cancel
Save