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.
212 lines
6.7 KiB
212 lines
6.7 KiB
using Kean.Application.Command.Interfaces;
|
|
using Kean.Application.Command.ViewModels;
|
|
using Kean.Domain;
|
|
using Kean.Domain.Task.Commands;
|
|
using Orleans;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kean.Application.Command.Implements
|
|
{
|
|
/// <summary>
|
|
/// 库存交互颗粒
|
|
/// </summary>
|
|
internal class TaskGrain : Grain, ITaskGrain
|
|
{
|
|
private readonly ICommandBus _bus; // 命令总线
|
|
private readonly INotification _notifications; // 总线通知
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public TaskGrain(
|
|
ICommandBus bus,
|
|
INotification notifications)
|
|
{
|
|
_bus = bus;
|
|
_notifications = notifications;
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Infeed 方法
|
|
*/
|
|
public async Task<(int Id, Failure Failure)> Infeed(InfeedCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Id, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Outfeed 方法
|
|
*/
|
|
public async Task<(int Id, Failure Failure)> Outfeed(OutfeedCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Id, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Transfer 方法
|
|
*/
|
|
public async Task<(int Id, Failure Failure)> Transfer(TransferCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Id, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Bypass 方法
|
|
*/
|
|
public async Task<(int Id, Failure Failure)> Bypass(BypassCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Id, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Execute 方法
|
|
*/
|
|
public async Task<Failure> Execute(ExecuteCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Cancel 方法
|
|
*/
|
|
public async Task<Failure> Cancel(CancelCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Complete 方法
|
|
*/
|
|
public async Task<Failure> Complete(CompleteCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.Block 方法
|
|
*/
|
|
public async Task<Failure> Block(BlockCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
///////////////////////////////////////////////////
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.ApplyOut 方法
|
|
*/
|
|
public async Task<(int Id, Failure Failure)> ApplyOut(ApplyOutCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Id, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.PalletOut 方法
|
|
*/
|
|
public async Task<(int Id, Failure Failure)> PalletOut(PalletOutCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Id, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.PreApplyOut 方法
|
|
*/
|
|
public async Task<(string barcode, Failure failure)> PreApplyOut(PreApplyOutCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Barcode, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.ReuploadHiWMS 方法
|
|
*/
|
|
public async Task<Failure> ReuploadHiWMS(ReuploadTaskCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.SetRollTask 方法
|
|
*/
|
|
public async Task<Failure> SetRollTask(SetRollTaskCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.SetRollTask 方法
|
|
*/
|
|
public async Task<Failure> SetTaskState(SetTaskStateCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.CallDelete 方法
|
|
*/
|
|
public async Task<Failure> CallDelete(CallDeleteCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.SetPriority 方法
|
|
*/
|
|
public async Task<Failure> SetPriority(SetPriorityCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.CancelAgvApplyOut 方法
|
|
*/
|
|
public async Task<Failure> CancelAgvApplyOut(CancelAgvApplyOutCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.ITaskGrain.AutoPalletOut 方法
|
|
*/
|
|
public async Task<Failure> AutoPalletOut(AutoPalletOutCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
}
|