山东雷驰
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

55 lines
1.8 KiB

using Kean.Domain.Wcs.Events;
using Kean.Domain.Wcs.Repositories;
using Kean.Domain.Wcs.SharedServices.Proxies;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Kean.Domain.Wcs.EventHandlers
{
/// <summary>
/// 接受输入成功时,处理类型 5:回退
/// </summary>
public sealed class AcceptInputSuccessEventHandler_5 : EventHandler<AcceptInputSuccessEvent>
{
private readonly IWcsRepository _wcsRepository; // 控制仓库
/// <summary>
/// 依赖注入
/// </summary>
public AcceptInputSuccessEventHandler_5(
IWcsRepository wcsRepository)
{
_wcsRepository = wcsRepository;
}
/// <summary>
/// 处理程序
/// </summary>
public override async Task Handle(AcceptInputSuccessEvent @event, CancellationToken cancellationToken)
{
if (@event.Function == "5")
{
var endDevice = await _wcsRepository.GetPassBackEndDevice(@event.Device, @event.Barcode.Substring(0,5));
if (!string.IsNullOrEmpty(endDevice))
{
await _wcsRepository.CreateOutput(new Models.Output
{
Warehouse = @event.Warehouse,
Function = 4,
Barcode = @event.Barcode,
Original = @event.Device,
Destination = endDevice,
State = 0,
Timestamp = DateTime.Now,
PreState = 0,
Message = @event.Parameters,
Operator = "-1"
});
}
}
}
}
}