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

73 lines
2.6 KiB

3 months ago
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
{
/// <summary>
/// 命令处理程序
/// </summary>
public sealed class BatchReFeedbackCommandHandler : CommandHandler<BatchReFeedbackCommand>
{
private readonly ICommandBus _commandBus; // 命令总线
private readonly IStockRepository _stockRepository; // 存储仓库
private readonly INotification _notifications; // 总线通知
private readonly Kean.Infrastructure.Soap.Hithium.WmsAPIService _wmsService; // 海辰WMS
/// <summary>
/// 依赖注入
/// </summary>
public BatchReFeedbackCommandHandler(
ICommandBus commandBus,
IStockRepository stockRepository,
Kean.Infrastructure.Soap.Hithium.WmsAPIService wmsService,
INotification notifications)
{
_commandBus = commandBus;
_stockRepository = stockRepository;
_notifications = notifications;
_wmsService = wmsService;
}
/// <summary>
/// 处理程序
/// </summary>
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
{
}
}
}
}
}
}