|
|
@ -1,12 +1,15 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Security.Policy; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using Win.Sfs.SettleAccount.Bases; |
|
|
|
using Win.Sfs.SettleAccount.Bases.DomainServices; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
@ -26,6 +29,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _detailRepository; |
|
|
|
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _notRepository; |
|
|
|
private readonly BaseDomainService _service; |
|
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
|
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository; |
|
|
|
|
|
|
|
|
|
|
|
public PUB_NOT_SA_MNG() |
|
|
|
{ |
|
|
@ -36,9 +42,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, |
|
|
|
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, |
|
|
|
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> notRepository, |
|
|
|
BaseDomainService service |
|
|
|
BaseDomainService service, |
|
|
|
INormalEfCoreRepository<PriceList, Guid> priceRepository, |
|
|
|
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository |
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
|
{ |
|
|
|
_priceRepository = priceRepository; |
|
|
|
_pricebjRepository = pricebjRepository; |
|
|
|
_service = service; |
|
|
|
_repository = repository; |
|
|
|
_detailRepository = detailRepository; |
|
|
@ -49,7 +61,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
var first= p_list.FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var site = first.Site; |
|
|
|
|
|
|
|
|
|
|
|
List<string> errors = new List<string>(); |
|
|
@ -65,6 +77,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
return errors; |
|
|
|
} |
|
|
|
} |
|
|
|
List<PriceList> priceList = new List<PriceList>(); |
|
|
|
if (first.BusinessType == EnumBusinessType.BeiJian) |
|
|
|
{ |
|
|
|
var priceListbj = _pricebjRepository.Where(p => p.IsCancel == false).ToList(); //价格单
|
|
|
|
foreach (var itm in priceListbj) |
|
|
|
{ |
|
|
|
priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price}); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
priceList = _priceRepository.Where(p => p.IsCancel == false && p.ClientCode==site).ToList();//价格单
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC |
|
|
@ -95,6 +122,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
{ |
|
|
|
return errors; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var _entity = new PUB_CAN_SA(); |
|
|
|
_entity.SetId(Guid.NewGuid()); |
|
|
@ -104,35 +134,81 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
_entity.State = SettleBillState.未结状态; |
|
|
|
_entity.SettleBillNum = string.Empty; |
|
|
|
_entity.BusinessType = first.BusinessType; |
|
|
|
_entity.Site = first.Site; |
|
|
|
_entity.Site = site; |
|
|
|
// var pricelist = _priceRepository.Where(p => p.ClientCode == site && p.IsCancel == false).ToList();
|
|
|
|
|
|
|
|
var _entityList = new List<PUB_CAN_SA_DETAIL>(); |
|
|
|
foreach (var itm in notlist) |
|
|
|
if (first.BusinessType == EnumBusinessType.BeiJian) |
|
|
|
{ |
|
|
|
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, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
_detailEntity.IndexNum = itm.IndexNum; |
|
|
|
_detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
//var bjdetailList = new List<PUB_CAN_SA_DETAIL>();
|
|
|
|
|
|
|
|
_entityList.Add(_detailEntity); |
|
|
|
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, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
_detailEntity.IndexNum = itm.IndexNum; |
|
|
|
_detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
_detailEntity.Price = priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == first.Site).Price; |
|
|
|
_detailEntity.SetProperty("DeliveryNumber", itm.GetProperty("DeliveryNumber", ""));//交货号
|
|
|
|
_detailEntity.SetProperty("InvoiceNumber", itm.GetProperty("InvoiceNumber", ""));//发票号
|
|
|
|
_detailEntity.SetProperty("VendorCode", itm.GetProperty("VendorCode", ""));//供应商代码
|
|
|
|
_detailEntity.SetProperty("VendorName", itm.GetProperty("VendorName", ""));//供应商名称
|
|
|
|
_detailEntity.SetProperty("PO", itm.GetProperty("PO", "")); |
|
|
|
_detailEntity.SetProperty("DeliveryIndexNumber", itm.GetProperty("DeliveryIndexNumber", ""));//交付索引号
|
|
|
|
_detailEntity.SetProperty("PartName", itm.GetProperty("PartName", ""));//零件名称
|
|
|
|
_detailEntity.SetProperty("PartGroup", itm.GetProperty("CommodityGroup", "")); |
|
|
|
// _detailEntity.ExtraProperties = itm.ExtraProperties;
|
|
|
|
_entityList.Add(_detailEntity); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
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: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == first.Site).Price, |
|
|
|
businessType: itm.BusinessType, |
|
|
|
settleDate: itm.SettleDate, |
|
|
|
groupNum: itm.GroupNum, |
|
|
|
invGroupNum: billNumber, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm.PartCode, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
_detailEntity.IndexNum = itm.IndexNum; |
|
|
|
_detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
_entityList.Add(_detailEntity); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await _repository.DbContext.BulkDeleteAsync(p_list).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { _entity }).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkInsertAsync(_entityList).ConfigureAwait(false); |
|
|
@ -164,8 +240,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
pN: itm.PN, |
|
|
|
site: itm.Site, |
|
|
|
qty: itm.Qty, |
|
|
|
price: itm.Price, |
|
|
|
businessType: itm.BusinessType, |
|
|
|
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == first.Site).Price, |
|
|
|
businessType: itm.BusinessType, |
|
|
|
settleDate: itm.SettleDate, |
|
|
|
groupNum: itm.GroupNum, |
|
|
|
invGroupNum: billNumber, |
|
|
|