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

85 lines
3.0 KiB

using AutoMapper;
using Kean.Domain.Task.Commands;
using Kean.Domain.Task.Enums;
using Kean.Domain.Task.Events;
using Kean.Domain.Task.Repositories;
using Kean.Domain.Task.SharedServices.Proxies;
using MediatR;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading;
namespace Kean.Domain.Task.EventHandlers
{
/// <summary>
/// 任务完成命令成功时,处理后续
/// </summary>
[EventHandlerIndex(8)]
public sealed class CompleteSuccessEventHandler_Bypass : EventHandler<CompleteSuccessEvent>
{
private readonly ICommandBus _commandBus; // 命令总线
private readonly INotification _notifications; // 总线通知
private readonly IMapper _mapper; // 模型映射
private readonly ITaskRepository _taskRepository; // 任务仓库
private readonly IWarehouseRepository _warehouseRepository; // 库房仓库
private readonly StockProxy _stockProxy; // 仓储域
private readonly ILogger<CompleteSuccessEventHandler_Follow> _logger; // 日志
/// <summary>
/// 依赖注入
/// </summary>
public CompleteSuccessEventHandler_Bypass(
ICommandBus commandBus,
INotification notifications,
IMapper mapper,
ITaskRepository taskRepository,
IWarehouseRepository warehouseRepository,
ILogger<CompleteSuccessEventHandler_Follow> logger,
StockProxy stockProxy)
{
_commandBus = commandBus;
_notifications = notifications;
_mapper = mapper;
_taskRepository = taskRepository;
_warehouseRepository = warehouseRepository;
_stockProxy = stockProxy;
_logger = logger;
}
/// <summary>
/// 处理程序
/// </summary>
public override async System.Threading.Tasks.Task Handle(CompleteSuccessEvent @event, CancellationToken cancellationToken)
{
if (@event.Barcode.Substring(2,1) == "G" && @event.Type == TaskType.Outfeed)
{
if (await _taskRepository.HasAGVInput())
{
//查找22009 是否有出库托盘
var stockBarcode = await _taskRepository.GetStockbarcode(22009);
if (stockBarcode != null)
{
await _taskRepository.DeleteTask(@event.Id);
BypassHithumCommand command = new BypassHithumCommand();
command.Barcode = stockBarcode;
command.Original = "device:22009";
await _commandBus.Execute(command);
}
//删除AGV出库申请
if (_notifications.Any())
{
}
else
{
await _taskRepository.RemoveAGVInput();
}
}
}
}
}
}