|
@ -10,6 +10,8 @@ using Win.Sfs.Shared.RepositoryBase; |
|
|
using Win.Sfs.SettleAccount.Bases; |
|
|
using Win.Sfs.SettleAccount.Bases; |
|
|
using EFCore.BulkExtensions; |
|
|
using EFCore.BulkExtensions; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
|
|
|
using System.Security.Cryptography; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Bases.DomainServices; |
|
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
@ -27,6 +29,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _repository; |
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _repository; |
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _detailRepository; |
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _detailRepository; |
|
|
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _notRepository; |
|
|
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _notRepository; |
|
|
|
|
|
private readonly BaseDomainService _service; |
|
|
|
|
|
|
|
|
public PUB_NOT_SA_MNG() |
|
|
public PUB_NOT_SA_MNG() |
|
|
{ |
|
|
{ |
|
@ -36,50 +39,129 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
( |
|
|
( |
|
|
INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, |
|
|
INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, |
|
|
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, |
|
|
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, |
|
|
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> notRepository |
|
|
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> notRepository, |
|
|
|
|
|
BaseDomainService service |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
|
|
|
_service = service; |
|
|
_repository = repository; |
|
|
_repository = repository; |
|
|
_detailRepository = detailRepository; |
|
|
_detailRepository = detailRepository; |
|
|
_notRepository = notRepository; |
|
|
_notRepository = notRepository; |
|
|
} |
|
|
} |
|
|
public virtual async Task<bool> GenerateSettlementOrder(List<PUB_NOT_SA_DETAIL> p_list) |
|
|
public virtual async Task<List<string>> GenerateSettlementOrder(List<PUB_NOT_SA_DETAIL> p_list) |
|
|
{ |
|
|
{ |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
List<string> errors = new List<string>(); |
|
|
var _entity = new PUB_CAN_SA(); |
|
|
var query = p_list.Select(p => p.BusinessType).Distinct(); |
|
|
_entity.BillNum = billNumber; |
|
|
foreach (var itm in query.ToList()) |
|
|
_entity.InvGroupNum = billNumber; |
|
|
|
|
|
_entity.Version = DateTime.Now.Year + DateTime.Now.Month; |
|
|
|
|
|
_entity.State = SettleBillState.未结状态; |
|
|
|
|
|
_entity.SettleBillNum = string.Empty; |
|
|
|
|
|
var _entityList = new List<PUB_CAN_SA_DETAIL>(); |
|
|
|
|
|
foreach (var itm in p_list) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var _detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
errors.Add("选择项有不在同一业务的数据!"); |
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
keyCode: itm.KeyCode, |
|
|
} |
|
|
version: itm.Version, |
|
|
if (errors.Count > 0) |
|
|
billNum: billNumber, |
|
|
{ |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
return errors; |
|
|
lU: itm.LU, |
|
|
} |
|
|
pN: itm.PN, |
|
|
|
|
|
site: itm.Site, |
|
|
var first= p_list.FirstOrDefault(); |
|
|
qty: itm.Qty, |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO |
|
|
price: itm.Price, |
|
|
|| first.BusinessType == EnumBusinessType.BeiJian |
|
|
businessType: itm.BusinessType, |
|
|
) |
|
|
settleDate: itm.SettleDate, |
|
|
{ |
|
|
groupNum: itm.GroupNum, |
|
|
var ls = p_list.Select(p => p.GroupNum).Distinct().ToList(); |
|
|
invGroupNum: billNumber, |
|
|
var notlist = _notRepository.Where(p => ls.Contains(p.GroupNum)).ToList();//JIT_ASN整发
|
|
|
invbillnum: string.Empty, |
|
|
var priceErrors = await _service.CheckPriceList(notlist); |
|
|
partcode:itm.PartCode |
|
|
if (priceErrors.Count > 0) |
|
|
); |
|
|
{ |
|
|
|
|
|
foreach (var itm in priceErrors) |
|
|
|
|
|
{ |
|
|
|
|
|
errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
return errors; |
|
|
|
|
|
} |
|
|
|
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
|
|
var _entity = new PUB_CAN_SA(); |
|
|
|
|
|
_entity.BillNum = billNumber; |
|
|
|
|
|
_entity.InvGroupNum = billNumber; |
|
|
|
|
|
_entity.Version = DateTime.Now.Year + DateTime.Now.Month; |
|
|
|
|
|
_entity.State = SettleBillState.未结状态; |
|
|
|
|
|
_entity.SettleBillNum = string.Empty; |
|
|
|
|
|
var _entityList = new List<PUB_CAN_SA_DETAIL>(); |
|
|
|
|
|
foreach (var itm in notlist) |
|
|
|
|
|
{ |
|
|
|
|
|
var _detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
keyCode: itm.KeyCode, |
|
|
|
|
|
version: itm.Version, |
|
|
|
|
|
billNum: billNumber, |
|
|
|
|
|
settleBillNum: itm.SettleBillNum, |
|
|
|
|
|
lU: itm.LU, |
|
|
|
|
|
pN: itm.PN, |
|
|
|
|
|
site: itm.Site, |
|
|
|
|
|
qty: itm.Qty, |
|
|
|
|
|
price: itm.Price, |
|
|
|
|
|
businessType: itm.BusinessType, |
|
|
|
|
|
settleDate: itm.SettleDate, |
|
|
|
|
|
groupNum: itm.GroupNum, |
|
|
|
|
|
invGroupNum: billNumber, |
|
|
|
|
|
invbillnum: string.Empty, |
|
|
|
|
|
partcode: itm.PartCode |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
_entityList.Add(_detailEntity); |
|
|
|
|
|
} |
|
|
|
|
|
await _notRepository.DbContext.BulkDeleteAsync(p_list); |
|
|
|
|
|
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { _entity }); |
|
|
|
|
|
await _repository.DbContext.BulkInsertAsync(_entityList); |
|
|
|
|
|
|
|
|
_entityList.Add(_detailEntity); |
|
|
|
|
|
} |
|
|
} |
|
|
await _notRepository.DbContext.BulkDeleteAsync(p_list); |
|
|
else |
|
|
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { _entity }); |
|
|
{ |
|
|
await _repository.DbContext.BulkInsertAsync(_entityList); |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
return true; |
|
|
var _entity = new PUB_CAN_SA(); |
|
|
|
|
|
_entity.BillNum = billNumber; |
|
|
|
|
|
_entity.InvGroupNum = billNumber; |
|
|
|
|
|
_entity.Version = DateTime.Now.Year + DateTime.Now.Month; |
|
|
|
|
|
_entity.State = SettleBillState.未结状态; |
|
|
|
|
|
_entity.SettleBillNum = string.Empty; |
|
|
|
|
|
var _entityList = new List<PUB_CAN_SA_DETAIL>(); |
|
|
|
|
|
foreach (var itm in p_list) |
|
|
|
|
|
{ |
|
|
|
|
|
var _detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
keyCode: itm.KeyCode, |
|
|
|
|
|
version: itm.Version, |
|
|
|
|
|
billNum: billNumber, |
|
|
|
|
|
settleBillNum: itm.SettleBillNum, |
|
|
|
|
|
lU: itm.LU, |
|
|
|
|
|
pN: itm.PN, |
|
|
|
|
|
site: itm.Site, |
|
|
|
|
|
qty: itm.Qty, |
|
|
|
|
|
price: itm.Price, |
|
|
|
|
|
businessType: itm.BusinessType, |
|
|
|
|
|
settleDate: itm.SettleDate, |
|
|
|
|
|
groupNum: itm.GroupNum, |
|
|
|
|
|
invGroupNum: billNumber, |
|
|
|
|
|
invbillnum: string.Empty, |
|
|
|
|
|
partcode: itm.PartCode |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
_entityList.Add(_detailEntity); |
|
|
|
|
|
} |
|
|
|
|
|
await _notRepository.DbContext.BulkDeleteAsync(p_list); |
|
|
|
|
|
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { _entity }); |
|
|
|
|
|
await _repository.DbContext.BulkInsertAsync(_entityList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return errors; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|