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.
111 lines
4.7 KiB
111 lines
4.7 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.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 SendOutToHiWMSCommandHandler : CommandHandler<SendOutToHiWMSCommand>
|
||
|
{
|
||
|
private readonly ILogger<SendOutToHiWMSCommandHandler> _logger; // 日志
|
||
|
private readonly Kean.Infrastructure.Soap.Hithium.WmsAPIService _wmsService; // 海辰WMS
|
||
|
private readonly ICommandBus _commandBus; // 命令总线
|
||
|
private readonly TaskProxy _taskProxy; // 任务域
|
||
|
private readonly IStockRepository _stockRepository; // 存储仓库
|
||
|
private readonly MessageProxy _messageProxy; // 仓储域
|
||
|
private readonly INotification _notifications; // 总线通知
|
||
|
|
||
|
/// <summary>
|
||
|
/// 依赖注入
|
||
|
/// </summary>
|
||
|
public SendOutToHiWMSCommandHandler(
|
||
|
ILogger<SendOutToHiWMSCommandHandler> logger,
|
||
|
Kean.Infrastructure.Soap.Hithium.WmsAPIService wmsService,
|
||
|
ICommandBus commandBus,
|
||
|
IStockRepository stockRepository,
|
||
|
MessageProxy messageProxy,
|
||
|
INotification notifications,
|
||
|
TaskProxy taskProxy)
|
||
|
{
|
||
|
_logger = logger;
|
||
|
_wmsService = wmsService;
|
||
|
_commandBus = commandBus;
|
||
|
_taskProxy = taskProxy;
|
||
|
_messageProxy = messageProxy;
|
||
|
_stockRepository = stockRepository;
|
||
|
_notifications = notifications;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 处理程序
|
||
|
/// </summary>
|
||
|
public override async Task Handle(SendOutToHiWMSCommand command, CancellationToken cancellationToken)
|
||
|
{
|
||
|
if (command.ValidationResult.IsValid)
|
||
|
{
|
||
|
bool bFeedback = false;
|
||
|
if (string.IsNullOrEmpty(command.RequestNo))
|
||
|
{
|
||
|
bFeedback = false;
|
||
|
}
|
||
|
|
||
|
if (bFeedback)
|
||
|
{
|
||
|
Feedback feedback = new Feedback();
|
||
|
feedback.requestNo = command.RequestNo;
|
||
|
feedback.barcode = command.Barcode;
|
||
|
feedback.feedbackStatus = command.FeedbackStatus;
|
||
|
feedback.message = command.Message;
|
||
|
//@=@ W1固定值 postUser
|
||
|
feedback.postUser = "ASRS";
|
||
|
|
||
|
//var sResult = string.Empty;
|
||
|
if (command.Transaction == "Infeed" || command.Transaction == "Bypass")
|
||
|
{
|
||
|
//sResult = await _wmsService.FeedbackIn("FeedbackIn", JsonConvert.SerializeObject(feedback, Formatting.Indented), command.Barcode, command.RequestNo);
|
||
|
_= _wmsService.FeedbackIn("INVENTORY", JsonConvert.SerializeObject(feedback, Formatting.Indented), command.Barcode, command.RequestNo, command.FeedbackStatus);
|
||
|
}
|
||
|
if (command.Transaction == "ApplyOut" || command.Transaction == "Outfeed")
|
||
|
{
|
||
|
//sResult = await _wmsService.FeedbackOut("FeedbackOut", JsonConvert.SerializeObject(feedback, Formatting.Indented), command.Barcode, command.RequestNo);
|
||
|
_= _wmsService.FeedbackOut("OUTBOUND", JsonConvert.SerializeObject(feedback, Formatting.Indented), command.Barcode, command.RequestNo, command.FeedbackStatus);
|
||
|
}
|
||
|
|
||
|
//Kean.Infrastructure.Soap.Hithium.Models.Result result = JsonConvert.DeserializeObject<Kean.Infrastructure.Soap.Hithium.Models.Result>(sResult);
|
||
|
|
||
|
//if (result.code == "0")
|
||
|
//{
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// //await _taskProxy.SetErrorStateForDir(command.Barcode, "WmsResultFail", result.ReturnMsg);
|
||
|
// //await _commandBus.Notify("TaskState", $"膜卷号({r.Bill})出库过账失败,原因:{result.ReturnMsg}", "WmsResultFail",
|
||
|
// // cancellationToken: cancellationToken);
|
||
|
// //return;
|
||
|
//}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
await _commandBus.Notify(command.ValidationResult,
|
||
|
cancellationToken: cancellationToken);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|