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.
63 lines
2.2 KiB
63 lines
2.2 KiB
3 months ago
|
using Kean.Domain.Task.Commands;
|
||
|
using Kean.Domain.Task.Models;
|
||
|
using Kean.Domain.Task.Repositories;
|
||
|
using Kean.Domain.Task.SharedServices.Proxies;
|
||
|
using Kean.Infrastructure.Configuration;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace Kean.Domain.Task.Strategies
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 简单避让策略
|
||
|
/// </summary>
|
||
|
public sealed class AvertStrategy_Simple : AvertStrategy
|
||
|
{
|
||
|
private readonly IWarehouseRepository _warehouseRepository; // 库房仓库
|
||
|
private readonly BarcodeInterpreter _barcodeInterpreter; // 条码解释器
|
||
|
private readonly StockProxy _stockProxy; // 仓储域代理
|
||
|
|
||
|
/// <summary>
|
||
|
/// 依赖注入
|
||
|
/// </summary>
|
||
|
public AvertStrategy_Simple(
|
||
|
IWarehouseRepository warehouseRepository,
|
||
|
BarcodeInterpreter barcodeInterpreter,
|
||
|
StockProxy stockProxy)
|
||
|
{
|
||
|
_warehouseRepository = warehouseRepository;
|
||
|
_barcodeInterpreter = barcodeInterpreter;
|
||
|
_stockProxy = stockProxy;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* 实现 Kean.Domain.Task.Strategies.AvertStrategy.AutoCommand 方法
|
||
|
*/
|
||
|
public override async Task<TransferCommand> AutoCommand(Cell cell)
|
||
|
{
|
||
|
var barcode = await _stockProxy.GetBarcode(cell.Id);
|
||
|
if (barcode == null)
|
||
|
{
|
||
|
return new();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
var spec = await _stockProxy.GetSpec(barcode) ?? cell.Spec;
|
||
|
var pallet = await _barcodeInterpreter.Interpret(barcode);
|
||
|
var goodsid = await _stockProxy.GetStorageMaterial(barcode);
|
||
|
var destination = (await _warehouseRepository.GetFreeCell(cell.Laneway, spec, pallet, goodsid))
|
||
|
.OrderByDescending(c => c.Deep)
|
||
|
.ThenBy(r=>r.Row)
|
||
|
.ThenBy(r=>r.Column)
|
||
|
.FirstOrDefault();
|
||
|
return new()
|
||
|
{
|
||
|
Barcode = barcode,
|
||
|
Destination = destination,
|
||
|
Warehouse = destination == null ? 0 : destination.Warehouse
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|