|
|
@ -1,7 +1,9 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.EventBus; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
|
using Win_in.Sfs.Shared.Event; |
|
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
@ -17,6 +19,14 @@ public class ProductReceiptNoteEventHandler |
|
|
|
{ |
|
|
|
private const EnumTransInOut TransInOut = EnumTransInOut.In; |
|
|
|
private const EnumTransType TransType = EnumTransType.ProductReceipt; |
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
|
|
|
|
public ProductReceiptNoteEventHandler(IItemBasicAppService itemBasicAppService, ILocationAppService locationAppService) |
|
|
|
{ |
|
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
} |
|
|
|
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ProductReceiptNote> eventData) |
|
|
@ -30,7 +40,7 @@ public class ProductReceiptNoteEventHandler |
|
|
|
{ |
|
|
|
var inboundTransactions = new List<TransactionEditInput>(); |
|
|
|
|
|
|
|
inboundTransactions.AddRange(BuildTransactions(productReceiptNote)); |
|
|
|
inboundTransactions.AddRange(await BuildTransactions(productReceiptNote)); |
|
|
|
|
|
|
|
await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); |
|
|
|
|
|
|
@ -51,13 +61,13 @@ public class ProductReceiptNoteEventHandler |
|
|
|
//如果要做库存事务汇总,可以修改此处
|
|
|
|
foreach (var productReceiptNote in productReceiptNotes) |
|
|
|
{ |
|
|
|
inboundTransactions.AddRange(BuildTransactions(productReceiptNote)); |
|
|
|
inboundTransactions.AddRange(await BuildTransactions(productReceiptNote)); |
|
|
|
} |
|
|
|
|
|
|
|
await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
private List<TransactionEditInput> BuildTransactions(ProductReceiptNote productReceiptNote) |
|
|
|
private async Task<List<TransactionEditInput>> BuildTransactions(ProductReceiptNote productReceiptNote) |
|
|
|
{ |
|
|
|
var transactionCreateInputs = new List<TransactionEditInput>(); |
|
|
|
//构造库存入库创建Input
|
|
|
@ -65,6 +75,21 @@ public class ProductReceiptNoteEventHandler |
|
|
|
{ |
|
|
|
var transaction = ObjectMapper.Map<ProductReceiptNoteDetail, TransactionEditInput>(detail); |
|
|
|
|
|
|
|
var itemBasicDto= await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
; |
|
|
|
detail.ItemDesc1 = itemBasicDto.Desc1; |
|
|
|
detail.ItemDesc2 = itemBasicDto.Desc2; |
|
|
|
detail.ItemName=itemBasicDto.Name; |
|
|
|
detail.StdPackQty=itemBasicDto.StdPackQty; |
|
|
|
|
|
|
|
var erpLocationDtos= await _locationAppService.GetListByTypesAndErpCodeAsync(new List<EnumLocationType> { EnumLocationType.WIP }, |
|
|
|
detail.LocationErpCode).ConfigureAwait(false); |
|
|
|
var erpLocationDto = erpLocationDtos.First(); |
|
|
|
detail.LocationArea = erpLocationDto.Code; |
|
|
|
detail.LocationGroup = erpLocationDto.LocationGroupCode; |
|
|
|
detail.LocationErpCode= erpLocationDto.Code; |
|
|
|
detail.LocationCode= erpLocationDto.Code; |
|
|
|
|
|
|
|
transaction.TransType = TransType; |
|
|
|
transaction.TransInOut = TransInOut; |
|
|
|
transaction.WarehouseCode = productReceiptNote.WarehouseCode; |
|
|
|