using Kean.Domain.Stock.Commands; using Kean.Domain.Stock.Repositories; using System; using System.Threading.Tasks; namespace Kean.Domain.Stock.SharedServices { /// /// 出库 /// public sealed class OutboundForPallet { private readonly ICommandBus _commandBus; private readonly IStockRepository _stockRepository; // 存储仓库 private readonly IWarehouseRepository _warehouseRepository; /// /// 依赖注入 /// public OutboundForPallet(ICommandBus commandBus, IWarehouseRepository warehouseRepository, IStockRepository stockRepository) { _commandBus = commandBus; _stockRepository = stockRepository; _warehouseRepository = warehouseRepository; } /// /// 处理程序 /// /// 托盘条码 /// 操作者 /// 标签 public async Task Handler( string barcode, int @operator, string tag) { bool bPallet = false; var storage = await _stockRepository.GetStock(barcode); foreach (var r in storage.Lines) { bPallet = await _stockRepository.IsPallet(r.Material); break; } var vCell = await _warehouseRepository.IsCell(storage.Cell); bool bCell = vCell.HasValue ? vCell.Value : false; //900取消 判断是否是空托盘,并且是入库任务取消。 空托盘的出库取消:在立库货位不能删除库存,库存在暂存区的可以删除库存 if (bPallet && !bCell) { await _commandBus.Execute(new OutboundCommand { Barcode = barcode, Operator = @operator, Tag = tag }); } } } }