6 changed files with 131 additions and 25 deletions
@ -0,0 +1,17 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
https://go.microsoft.com/fwlink/?LinkID=208121. |
||||
|
--> |
||||
|
<Project> |
||||
|
<PropertyGroup> |
||||
|
<DeleteExistingFiles>false</DeleteExistingFiles> |
||||
|
<ExcludeApp_Data>false</ExcludeApp_Data> |
||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish> |
||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> |
||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform> |
||||
|
<PublishProvider>FileSystem</PublishProvider> |
||||
|
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl> |
||||
|
<WebPublishMethod>FileSystem</WebPublishMethod> |
||||
|
<_TargetId>Folder</_TargetId> |
||||
|
</PropertyGroup> |
||||
|
</Project> |
@ -0,0 +1,105 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.EventBus; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.Event; |
||||
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
||||
|
using Win_in.Sfs.Wms.Store.Event.Transaction; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event.Transactions; |
||||
|
|
||||
|
public class MesNoteEventHandler |
||||
|
: StoreInventoryEventHandlerBase |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<MesNote>> |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<MesNote>>> |
||||
|
{ |
||||
|
|
||||
|
private const EnumTransType TransType = EnumTransType.Scrap; |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<MesNote> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
await AddTransactionsAsync(new List<MesNote>() { entity }).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<MesNote>> eventData) |
||||
|
{ |
||||
|
var entities = eventData.Entity; |
||||
|
await AddTransactionsAsync(entities).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
#region 私有
|
||||
|
|
||||
|
private async Task AddTransactionsAsync(List<MesNote> MesNotes) |
||||
|
{ |
||||
|
|
||||
|
//如果WMS管理报废库,生成库存转移
|
||||
|
if (await SettingManager.IsTrueAsync(StoreSettings.Common.EnableScrapLocation).ConfigureAwait(false)) |
||||
|
{ |
||||
|
var transferLogs = new List<TransferLogEditInput>(); |
||||
|
foreach (var MesNote in MesNotes) |
||||
|
{ |
||||
|
transferLogs.AddRange(BuildTransferLogs(MesNote)); |
||||
|
} |
||||
|
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
var transactions = new List<TransactionEditInput>(); |
||||
|
foreach (var MesNote in MesNotes) |
||||
|
{ |
||||
|
transactions.AddRange(BuildTransactions(MesNote)); |
||||
|
} |
||||
|
|
||||
|
await TransactionAppService.AddManyAsync(transactions).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private List<TransferLogEditInput> BuildTransferLogs(MesNote MesNote) |
||||
|
{ |
||||
|
var transferLogs = new List<TransferLogEditInput>(); |
||||
|
foreach (var detail in MesNote.Details.Where(detail => detail.Qty != 0)) |
||||
|
{ |
||||
|
var transferLog = ObjectMapper.Map<MesNoteDetail, TransferLogEditInput>(detail); |
||||
|
|
||||
|
transferLog.TransType = TransType; |
||||
|
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(MesNote.Type); |
||||
|
transferLog.Worker = MesNote.Worker; |
||||
|
transferLog.DocNumber = MesNote.Number; |
||||
|
transferLog.JobNumber = MesNote.JobNumber; |
||||
|
|
||||
|
transferLogs.Add(transferLog); |
||||
|
} |
||||
|
|
||||
|
return transferLogs; |
||||
|
} |
||||
|
|
||||
|
private List<TransactionEditInput> BuildTransactions(MesNote deliverNote) |
||||
|
{ |
||||
|
var transactions = new List<TransactionEditInput>(); |
||||
|
|
||||
|
foreach (var detail in deliverNote.Details) |
||||
|
{ |
||||
|
var transaction = ObjectMapper.Map<MesNoteDetail, TransactionEditInput>(detail); |
||||
|
|
||||
|
transaction.TransType = TransType; |
||||
|
transaction.TransInOut = EnumTransInOut.Out; |
||||
|
transaction.Worker = deliverNote.Worker; |
||||
|
transaction.DocNumber = deliverNote.Number; |
||||
|
transaction.JobNumber = deliverNote.JobNumber; |
||||
|
|
||||
|
transactions.Add(transaction); |
||||
|
} |
||||
|
|
||||
|
return transactions; |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
Loading…
Reference in new issue