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.Database; 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 { /// /// 命令处理程序 /// public sealed class BatchReFeedbackCommandHandler : CommandHandler { private readonly ICommandBus _commandBus; // 命令总线 private readonly IStockRepository _stockRepository; // 存储仓库 private readonly INotification _notifications; // 总线通知 private readonly Kean.Infrastructure.Soap.Hithium.WmsAPIService _wmsService; // 海辰WMS /// /// 依赖注入 /// public BatchReFeedbackCommandHandler( ICommandBus commandBus, IStockRepository stockRepository, Kean.Infrastructure.Soap.Hithium.WmsAPIService wmsService, INotification notifications) { _commandBus = commandBus; _stockRepository = stockRepository; _notifications = notifications; _wmsService = wmsService; } /// /// 处理程序 /// public override async Task Handle(BatchReFeedbackCommand command, CancellationToken cancellationToken) { foreach (int id in command.idList) { ErrorFeedback errorFeedback = await _stockRepository.GetErrFeedback(id); if (errorFeedback != null && errorFeedback.RESULT != "0") { if (errorFeedback.METHOD == "INVENTORY") { await _wmsService.FeedbackIn(errorFeedback.METHOD, errorFeedback.PARAM_IN, errorFeedback.BARCODE, errorFeedback.REQUEST_NO, errorFeedback.FEEDBACK_STATUS); } else if (errorFeedback.METHOD == "OUTBOUND") { await _wmsService.FeedbackOut(errorFeedback.METHOD, errorFeedback.PARAM_IN, errorFeedback.BARCODE, errorFeedback.REQUEST_NO, errorFeedback.FEEDBACK_STATUS); } else { } } } } } }