43 changed files with 790 additions and 223 deletions
@ -0,0 +1,35 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Win_in.Sfs.Shared.Domain.Shared; |
|||
|
|||
public enum EnumInjectionModelStatus |
|||
{ |
|||
/// <summary>
|
|||
/// 有更新
|
|||
/// </summary>
|
|||
[Display(Name = "有更新")] |
|||
Updated = 10, |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 执行中
|
|||
/// </summary>
|
|||
[Display(Name = "执行中")] |
|||
Handling = 5, |
|||
/// <summary>
|
|||
/// 部分完成
|
|||
/// </summary>
|
|||
[Display(Name = "已过时")] |
|||
Deprecated = 11, |
|||
/// <summary>
|
|||
/// 已完成
|
|||
/// </summary>
|
|||
[Display(Name = "已完成")] |
|||
Completed = 6, |
|||
|
|||
/// <summary>
|
|||
/// 新增
|
|||
/// </summary>
|
|||
[Display(Name = "新增")] |
|||
New = 1 |
|||
} |
@ -0,0 +1,166 @@ |
|||
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.Basedata.Application.Contracts; |
|||
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.Event.Transaction; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Event.Transactions; |
|||
|
|||
public class ThirdLocationNoteEventHandler |
|||
: StoreInventoryEventHandlerBase |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<ThirdLocationNote>> |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<List<ThirdLocationNote>>> |
|||
, ILocalEventHandler<SfsConfirmedEntityEventData<ThirdLocationNote>> |
|||
{ |
|||
private const EnumTransType TransType = EnumTransType.TransferLib; |
|||
|
|||
private readonly ILocationAppService _locationAppService; |
|||
private readonly IThirdLocationRequestManager _thirdLocationRequestManager; |
|||
|
|||
public ThirdLocationNoteEventHandler(ILocationAppService locationAppService |
|||
, IThirdLocationRequestManager thirdLocationRequestManager) |
|||
{ |
|||
_locationAppService = locationAppService; |
|||
_thirdLocationRequestManager = thirdLocationRequestManager; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ThirdLocationNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
var route = EnumTransferRoute.OnTheWayToDestination; |
|||
|
|||
transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false)); |
|||
|
|||
|
|||
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|||
|
|||
if (!string.IsNullOrEmpty(entity.RequestNumber)) |
|||
{ |
|||
var thirdLocationRequest = await _thirdLocationRequestManager.GetByNumberAsync(entity.RequestNumber).ConfigureAwait(false); |
|||
await _thirdLocationRequestManager.CompleteAsync(thirdLocationRequest).ConfigureAwait(false); |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<ThirdLocationNote>> eventData) |
|||
{ |
|||
var entities = eventData.Entity; |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
//如果要做库存事务汇总,可以修改此处
|
|||
foreach (var thirdLocationNote in entities) |
|||
{ |
|||
var route = EnumTransferRoute.OnTheWayToDestination; |
|||
|
|||
transferLogs.AddRange(await BuildTransferLogsAsync(thirdLocationNote, route).ConfigureAwait(false)); |
|||
} |
|||
|
|||
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
|
|||
public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<ThirdLocationNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
|
|||
var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false); |
|||
await AddTransferLogsAsync(inputList).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList) |
|||
{ |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
|
|||
transferLogs.AddRange(inputList); |
|||
|
|||
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|||
|
|||
} |
|||
|
|||
private async Task<List<TransferLogEditInput>> BuildTransferLogsAsync(ThirdLocationNote thirdLocationNote, EnumTransferRoute route) |
|||
{ |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
foreach (var detail in thirdLocationNote.Details.Where(detail => detail.Qty != 0)) |
|||
{ |
|||
var transferLog = ObjectMapper.Map<ThirdLocationNoteDetail, TransferLogEditInput>(detail); |
|||
|
|||
LocationDTO fromLocationDTO = null; |
|||
LocationDTO toLocationDTO = null; |
|||
|
|||
if (thirdLocationNote.UseOnTheWayLocation) |
|||
{ |
|||
var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|||
switch (route) |
|||
{ |
|||
case EnumTransferRoute.SourceToOnTheWay: |
|||
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|||
|
|||
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|||
break; |
|||
case EnumTransferRoute.OnTheWayToDestination: |
|||
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|||
|
|||
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|||
|
|||
await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false); |
|||
break; |
|||
case EnumTransferRoute.SourceToDestination: |
|||
default: |
|||
throw new ArgumentOutOfRangeException(nameof(route), route, null); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|||
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|||
} |
|||
|
|||
transferLog.FromLocationCode = fromLocationDTO.Code; |
|||
transferLog.FromLocationArea = fromLocationDTO.AreaCode; |
|||
transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; |
|||
transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; |
|||
|
|||
transferLog.ToLocationCode = toLocationDTO.Code; |
|||
transferLog.ToLocationArea = toLocationDTO.AreaCode; |
|||
transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; |
|||
transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; |
|||
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(thirdLocationNote.RequestType); |
|||
transferLog.TransType = TransType; |
|||
transferLog.DocNumber = thirdLocationNote.Number; |
|||
transferLog.JobNumber = thirdLocationNote.JobNumber; |
|||
|
|||
transferLog.FromPackingCode = ""; |
|||
transferLog.FromLot = ""; |
|||
transferLog.ToPackingCode = ""; |
|||
transferLog.ToLot = ""; |
|||
transferLog.FromStatus = EnumInventoryStatus.OK; |
|||
transferLog.ToStatus = EnumInventoryStatus.OK; |
|||
|
|||
transferLogs.Add(transferLog); |
|||
} |
|||
|
|||
return transferLogs; |
|||
} |
|||
|
|||
private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput) |
|||
{ |
|||
transferLogCreateInput.ToPackingCode = ""; |
|||
transferLogCreateInput.ToLot = ""; |
|||
transferLogCreateInput.ToContainerCode = ""; |
|||
|
|||
transferLogCreateInput.FromPackingCode = ""; |
|||
transferLogCreateInput.FromLot = ""; |
|||
transferLogCreateInput.FromContainerCode = ""; |
|||
|
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue