using Kean.Domain.Wcs.Events; using Kean.Domain.Wcs.Models; 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 { /// /// 接受输入成功时,处理类型 3:空托盘上架申请 /// public sealed class AcceptInputSuccessEventHandler_3 : EventHandler { private readonly StockProxy _stockProxy; private readonly INotification _notification; // private readonly IWcsRepository _wcsRepository; // 控制仓库 private readonly Kean.Infrastructure.Soap.LED.LedService _ledService; private readonly TaskProxy _taskProxy; // 任务代理 private readonly ICommandBus _commandBus; // 命令总线 /// /// 依赖注入 /// public AcceptInputSuccessEventHandler_3( StockProxy stockProxy, IWcsRepository wcsRepository, Kean.Infrastructure.Soap.LED.LedService ledService, TaskProxy taskProxy, ICommandBus commandBus, INotification notification) { _stockProxy = stockProxy; _wcsRepository = wcsRepository; _ledService = ledService; _notification = notification; _taskProxy = taskProxy; _commandBus = commandBus; } /// /// 处理程序 /// public override async Task Handle(AcceptInputSuccessEvent @event, CancellationToken cancellationToken) { // 车身29101 AGV无空托盘 申请出库 if (@event.Function == "3") { //查找22009 是否有出库托盘 var stockBarcode = await _wcsRepository.GetStockbarcode(22009); if (stockBarcode != null) { await _taskProxy.BypassHithum( stockBarcode, $"device:22009"); } //变更状态为3 等待下架任务完成,再输送 else { @event.Fallback(new Models.Input { Para02 = "未找到22009缓存区库存,等待出库任务" }); Input input = new Input(); input.Function = "3"; input.Device = @event.Device; input.State = 3; await _wcsRepository.CreateInputForShenAgvOut(input); } } } } }