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.
60 lines
2.1 KiB
60 lines
2.1 KiB
using AutoMapper;
|
|
using Kean.Domain.Task.Commands;
|
|
using Kean.Domain.Task.Events;
|
|
using Kean.Domain.Task.Repositories;
|
|
using Kean.Domain.Task.SharedServices.Proxies;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Threading;
|
|
|
|
namespace Kean.Domain.Task.CommandHandlers
|
|
{
|
|
/// <summary>
|
|
/// 任务取消命令处理程序
|
|
/// </summary>
|
|
public sealed class ReuploadTaskCommandHandler : CommandHandler<ReuploadTaskCommand>
|
|
{
|
|
private readonly ICommandBus _commandBus; // 命令总线
|
|
//private readonly IMapper _mapper; // 模型映射
|
|
private readonly ITaskRepository _taskRepository; // 任务仓库
|
|
//private readonly IWarehouseRepository _warehouseRepository; // 库房仓库
|
|
private readonly StockProxy _stockProxy; // 库房仓库
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public ReuploadTaskCommandHandler(
|
|
ICommandBus commandBus,
|
|
//IMapper mapper,
|
|
StockProxy stockProxy,
|
|
//IWarehouseRepository warehouseRepository,
|
|
ITaskRepository taskRepository)
|
|
{
|
|
_commandBus = commandBus;
|
|
//_mapper = mapper;
|
|
_stockProxy = stockProxy;
|
|
//_warehouseRepository = warehouseRepository;
|
|
_taskRepository = taskRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理程序
|
|
/// </summary>
|
|
public override async System.Threading.Tasks.Task Handle(ReuploadTaskCommand command, CancellationToken cancellationToken)
|
|
{
|
|
if (command.ValidationResult.IsValid)
|
|
{
|
|
var task = await _taskRepository.GetTask(command.Id);
|
|
if (task != null)
|
|
{
|
|
Output(nameof(command.Message),await _stockProxy.Reupload(task.Type.ToString(),task.Barcode, task.RequestNo, "2"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
await _commandBus.Notify(command.ValidationResult,
|
|
cancellationToken: cancellationToken);
|
|
}
|
|
}
|
|
}
|
|
}
|