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 { /// /// 扫描输入命令处理程序 /// public sealed class ScanStationCommandHandler : CommandHandler { private readonly IWcsRepository _wcsRepository; // 控制仓库 /// /// 依赖注入 /// public ScanStationCommandHandler( IWcsRepository wcsRepository) { _wcsRepository = wcsRepository; } /// /// 处理程序 /// public override async Task Handle(ScanStationCommand command, CancellationToken cancellationToken) { var queue = new Queue(); 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); } } }