using AutoMapper;
using Kean.Domain.Stock.Commands;
using Kean.Domain.Stock.Models;
using Kean.Domain.Stock.Repositories;
using Kean.Domain.Stock.SharedServices.Proxies;
using Kean.Infrastructure.Soap.Hithium.Models;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Kean.Domain.Stock.CommandHandlers
{
    /// <summary>
    /// 命令处理程序
    /// </summary>
    public sealed class SendAGVCommandHandler : CommandHandler<SendAGVCommand>
    {
        private readonly ICommandBus _commandBus; // 命令总线
        //private readonly Kean.Infrastructure.Soap.Hithium.AgvAddjobAPIService _agvAddjobService; // AGV
        private readonly TaskProxy _taskProxy; // 任务域
        private readonly IStockRepository _stockRepository; // 存储仓库
        private readonly MaterialProxy _materialProxy; // 物料服务

        /// <summary>
        /// 依赖注入
        /// </summary>
        public SendAGVCommandHandler(
            ICommandBus commandBus,
            //Kean.Infrastructure.Soap.Hithium.AgvAddjobAPIService agvAddjobService,
            IStockRepository stockRepository,
            MaterialProxy materialProxy,
            TaskProxy taskProxy)
        {
            _commandBus = commandBus;
            //_agvAddjobService = agvAddjobService;
            _taskProxy = taskProxy;
            _stockRepository = stockRepository;
            _materialProxy = materialProxy;
        }

        /// <summary>
        /// 处理程序
        /// </summary>
        public override async Task Handle(SendAGVCommand command, CancellationToken cancellationToken)
        {
            if (command.ValidationResult.IsValid)
            {
            }
            else
            {
                await _commandBus.Notify(command.ValidationResult,
                    cancellationToken: cancellationToken);
            }
        }
    }
}