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.
32 lines
1.2 KiB
32 lines
1.2 KiB
using Kean.Domain.Task.Models;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kean.Domain.Task.Strategies
|
|
{
|
|
/// <summary>
|
|
/// 上架策略上下文
|
|
/// </summary>
|
|
public sealed class InfeedContext<T> where T : InfeedStrategy
|
|
{
|
|
private readonly T _strategy; // 策略实例
|
|
|
|
/// <summary>
|
|
/// 初始化 Kean.Domain.Task.Strategies.InfeedContext 类的新实例
|
|
/// </summary>
|
|
public InfeedContext(IServiceProvider serviceProvider) =>
|
|
_strategy = Activator.CreateInstance(typeof(T),
|
|
typeof(T).GetConstructors().First().GetParameters().Select(p => serviceProvider.GetService(p.ParameterType)).ToArray()) as T;
|
|
|
|
/// <summary>
|
|
/// 获取自动分配的目标货位
|
|
/// </summary>
|
|
/// <param name="pallet">托盘类型</param>
|
|
/// <param name="original">任务起始位置</param>
|
|
/// <param name="spec">负载规格</param>
|
|
/// <returns>自动分配的目标货位</returns>
|
|
public Task<Cell> AutoDestination(string pallet, Station original, int? spec, int? goodsid) =>
|
|
_strategy.AutoDestination(pallet, original, spec,goodsid);
|
|
}
|
|
}
|