山东雷驰
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.

78 lines
2.7 KiB

3 months ago
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
{
/// <summary>
/// 接受输入成功时,处理类型 3:空托盘上架申请
/// </summary>
public sealed class AcceptInputSuccessEventHandler_3 : EventHandler<AcceptInputSuccessEvent>
{
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; // 命令总线
/// <summary>
/// 依赖注入
/// </summary>
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;
}
/// <summary>
/// 处理程序
/// </summary>
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);
}
}
}
}
}