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.
123 lines
4.5 KiB
123 lines
4.5 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 Kean.Infrastructure.Soap.LED;
|
||
|
using Newtonsoft.Json;
|
||
|
using System;
|
||
|
using System.Linq;
|
||
|
using System.Threading;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace Kean.Domain.Wcs.EventHandlers
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 接受输入成功时,处理类型 2:车身出口(29101)AGV 回空托盘
|
||
|
/// </summary>
|
||
|
public sealed class AcceptInputSuccessEventHandler_2 : EventHandler<AcceptInputSuccessEvent>
|
||
|
{
|
||
|
private readonly StockProxy _stockProxy;
|
||
|
private readonly TaskProxy _taskProxy; // 任务代理
|
||
|
private readonly INotification _notification; //
|
||
|
private readonly Kean.Infrastructure.Soap.LED.LedService _ledService;
|
||
|
private readonly IWcsRepository _wcsRepository; // 控制仓库
|
||
|
private readonly ICommandBus _commandBus; // 命令总线
|
||
|
|
||
|
/// <summary>
|
||
|
/// 依赖注入
|
||
|
/// </summary>
|
||
|
public AcceptInputSuccessEventHandler_2(
|
||
|
StockProxy stockProxy,
|
||
|
TaskProxy taskProxy,
|
||
|
IWcsRepository wcsRepository,
|
||
|
ICommandBus commandBus,
|
||
|
Kean.Infrastructure.Soap.LED.LedService ledService,
|
||
|
INotification notification)
|
||
|
{
|
||
|
_stockProxy = stockProxy;
|
||
|
_taskProxy = taskProxy;
|
||
|
_ledService = ledService;
|
||
|
_notification = notification;
|
||
|
_wcsRepository = wcsRepository;
|
||
|
_commandBus = commandBus;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 处理程序
|
||
|
/// </summary>
|
||
|
public override async Task Handle(AcceptInputSuccessEvent @event, CancellationToken cancellationToken)
|
||
|
{
|
||
|
if (@event.Function == "2")
|
||
|
{
|
||
|
string line1 = $"{@event.Barcode}空托入库通过";
|
||
|
string line2 = " ";
|
||
|
|
||
|
@event.Barcode = "LCG" + System.DateTime.Now.ToString("yyyy-MM-ddHH:mm:ss.fff").Replace("-", "").Replace(":", "").Replace(".", "");
|
||
|
await _stockProxy.PalletIn(
|
||
|
@event.Barcode,
|
||
|
int.Parse(@event.Device),
|
||
|
//@=@ 固定值 车身空托盘
|
||
|
5,
|
||
|
-1,
|
||
|
string.Empty);
|
||
|
|
||
|
if (_notification.Any())
|
||
|
{
|
||
|
line1 = $"{@event.Barcode}空托入库失败";
|
||
|
line2 = $"{_notification.FirstOrDefault().ErrorMessage}";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
await _taskProxy.Infeed(
|
||
|
1,
|
||
|
@event.Barcode,
|
||
|
int.TryParse(@event.Parameters, out var p) ? p : null,
|
||
|
$"device:{@event.Device}",
|
||
|
null,
|
||
|
null,
|
||
|
-1,
|
||
|
null,
|
||
|
null,
|
||
|
@event.Parameters);
|
||
|
|
||
|
if (_notification.Any())
|
||
|
{
|
||
|
line1 = $"{@event.Barcode}空托入库失败";
|
||
|
line2 = $"{_notification.FirstOrDefault().ErrorMessage}";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//查找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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//LED提示
|
||
|
await _ledService.Invoke(@event.Device, line1, line2);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|