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

56 lines
1.6 KiB

using Kean.Domain.Stock.Enums;
using Kean.Domain.Stock.Repositories;
using Kean.Domain.Stock.SharedServices.Proxies;
using System.Linq;
using System.Threading.Tasks;
namespace Kean.Domain.Stock.Strategies
{
/// <summary>
/// 默认状态判定策略
/// </summary>
public sealed class StateStrategy_Default : StateStrategy
{
private readonly IStockRepository _stockRepository; // 存储仓库
private readonly MaterialProxy _materialProxy;
/// <summary>
/// 依赖注入
/// </summary>
public StateStrategy_Default(
IStockRepository stockRepository,
MaterialProxy materialProxy)
{
_stockRepository = stockRepository;
_materialProxy = materialProxy;
}
/*
* 实现 Kean.Domain.Stock.Strategies.StateStrategy.GetState 方法
*/
public override async Task<CellState> GetState(string barcode)
{
var stock = await _stockRepository.GetStock(barcode);
if (stock == null)
{
return CellState.Empty;
}
if (stock.Full == true)
{
return CellState.Full;
}
else
{
if (await _materialProxy.IsPallet(stock.Lines.Any() ? stock.Lines.First().Material : 0))
{
return CellState.Pallet;
}
else
{
return CellState.Have;
}
}
}
}
}