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

163 lines
5.1 KiB

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