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.
162 lines
5.1 KiB
162 lines
5.1 KiB
using Kean.Application.Command.Interfaces;
|
|
using Kean.Application.Command.ViewModels;
|
|
using Kean.Domain;
|
|
using Kean.Domain.Stock.Commands;
|
|
using Orleans;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kean.Application.Command.Implements
|
|
{
|
|
/// <summary>
|
|
/// 库存交互颗粒
|
|
/// </summary>
|
|
internal class StockGrain : Grain, IStockGrain
|
|
{
|
|
private readonly ICommandBus _bus; // 命令总线
|
|
private readonly INotification _notifications; // 总线通知
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public StockGrain(
|
|
ICommandBus bus,
|
|
INotification notifications)
|
|
{
|
|
_bus = bus;
|
|
_notifications = notifications;
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.Inbound 方法
|
|
*/
|
|
public async Task<Failure> Inbound(InboundCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.Outbound 方法
|
|
*/
|
|
public async Task<Failure> Outbound(OutboundCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.Update 方法
|
|
*/
|
|
public async Task<Failure> Update(UpdateCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.Combine 方法
|
|
*/
|
|
public async Task<Failure> Combine(CombineCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.Inventory 方法
|
|
*/
|
|
public async Task<Failure> Inventory(InventoryCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
////////////////////////////////////////////////
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.ScanInbound 方法
|
|
*/
|
|
public async Task<(string Device, Failure Failure)> ScanInbound(ScanInboundCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Tag, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.PalletIn 方法
|
|
*/
|
|
public async Task<Failure> PalletIn(PalletInCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.PreScanInbound 方法
|
|
*/
|
|
public async Task<(string Device, Failure Failure)> PreScanInbound(PreScanInboundCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Source, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.RecordInterface 方法
|
|
*/
|
|
public async Task<Failure> RecordInterface(InterfaceRecordCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.SetRollResult 方法
|
|
*/
|
|
public async Task<Failure> SetRollResult(SetRollResultCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.PreScanInbound 方法
|
|
*/
|
|
public async Task<(int barcodeCount, Failure Failure)> PreSetQcStatus(PreSetQcStatusCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.BarcodeCount, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.ChangeStorageProperty 方法
|
|
*/
|
|
public async Task<Failure> ChangeStorageProperty(ChangeStoragePropertyCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IStockGrain.BatchReFeedback 方法
|
|
*/
|
|
public async Task<Failure> BatchReFeedback(BatchReFeedbackCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
}
|