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

213 lines
6.7 KiB

3 months ago
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();
}
}
}