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

44 lines
1.3 KiB

3 months ago
using Kean.Domain.Wcs.Commands;
using Kean.Domain.Wcs.Models;
using Kean.Domain.Wcs.Repositories;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Kean.Domain.Wcs.CommandHandlers
{
/// <summary>
/// 扫描输入命令处理程序
/// </summary>
public sealed class ScanStationCommandHandler : CommandHandler<ScanStationCommand>
{
private readonly IWcsRepository _wcsRepository; // 控制仓库
/// <summary>
/// 依赖注入
/// </summary>
public ScanStationCommandHandler(
IWcsRepository wcsRepository)
{
_wcsRepository = wcsRepository;
}
/// <summary>
/// 处理程序
/// </summary>
public override async Task Handle(ScanStationCommand command, CancellationToken cancellationToken)
{
var queue = new Queue<StationModel>();
foreach (var item in await _wcsRepository.GetStationModels())
{
item.Warehouse = int.Parse(item.Device.Substring(0, 1)) % 2 == 0 ? "2" : "1";
item.Function = 7;
queue.Enqueue(item);
await _wcsRepository.LogOutput(item);
}
Output(nameof(command.UnsyncedStationModels), queue);
}
}
}