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.
158 lines
6.8 KiB
158 lines
6.8 KiB
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.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kean.Domain.Stock.CommandHandlers
|
|
{
|
|
/// <summary>
|
|
/// 命令处理程序
|
|
/// </summary>
|
|
public sealed class ReuploadHiWMSCommandHandler : CommandHandler<ReuploadHiWMSCommand>
|
|
{
|
|
private readonly ICommandBus _commandBus; // 命令总线
|
|
private readonly IStockRepository _stockRepository; // 存储仓库
|
|
private readonly TaskProxy _taskProxy; // 任务服务
|
|
private readonly Kean.Infrastructure.Soap.Hithium.WmsAPIService _wmsService; // 海辰WMS
|
|
private readonly ILogger<ReuploadHiWMSCommandHandler> _logger; // 日志
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public ReuploadHiWMSCommandHandler(
|
|
ICommandBus commandBus,
|
|
//INotification notifications,
|
|
//IMapper mapper,
|
|
TaskProxy taskProxy,
|
|
IWarehouseRepository warehouseRepository,
|
|
Kean.Infrastructure.Soap.Hithium.WmsAPIService wmsService,
|
|
ILogger<ReuploadHiWMSCommandHandler> logger,
|
|
IStockRepository stockRepository)
|
|
{
|
|
_commandBus = commandBus;
|
|
//_notifications = notifications;
|
|
//_mapper = mapper;
|
|
_taskProxy = taskProxy;
|
|
_wmsService = wmsService;
|
|
_logger = logger;
|
|
_stockRepository = stockRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理程序
|
|
/// </summary>
|
|
public override async Task Handle(ReuploadHiWMSCommand command, CancellationToken cancellationToken)
|
|
{
|
|
if (command.ValidationResult.IsValid)
|
|
{
|
|
//bool bFeedback = true;
|
|
//if (string.IsNullOrEmpty(command.RequestNo))
|
|
//{
|
|
// bFeedback = false;
|
|
//}
|
|
|
|
//var stockLines = await _stockRepository.GetLines(command.Barcode);
|
|
//if (stockLines == null)
|
|
//{
|
|
// await _commandBus.Notify(nameof(command.Barcode), $"托盘{command.Barcode}库存明细未找到", command.Barcode, cancellationToken: cancellationToken);
|
|
// return;
|
|
//}
|
|
|
|
//foreach (var r in stockLines)
|
|
//{
|
|
// //校验本地库存 1-本地 2-联机
|
|
// if (r.IsLocal == "1")
|
|
// {
|
|
// bFeedback = false;
|
|
// _logger.LogInformation($"上架后上传信息:托盘条码[{command.Barcode}],膜卷号[{r.Bill}],本地库存[{r.IsLocal}]不上传信息");
|
|
// break;
|
|
// }
|
|
|
|
//}
|
|
|
|
//if (bFeedback)
|
|
//{
|
|
// Feedback feedback = new Feedback();
|
|
// feedback.requestNo = command.RequestNo;
|
|
// feedback.barcode = command.Barcode;
|
|
// feedback.feedbackStatus = command.FeedbackStatus;
|
|
// feedback.message = command.Message;
|
|
// if (command.FeedbackStatus == "3")
|
|
// {
|
|
// feedback.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 (feedback.feedbackStatus == "2" && command.Transaction == "Infeed")
|
|
// {
|
|
// //if (result.code == "0")
|
|
// //{
|
|
// // foreach (var r in stockLines)
|
|
// // {
|
|
// // SetRollResultCommand commandSetRollResult = new SetRollResultCommand();
|
|
// // commandSetRollResult.BatchNo = r.Bill;
|
|
// // commandSetRollResult.Code = "0";
|
|
// // commandSetRollResult.Message = "";
|
|
// // commandSetRollResult.Operator = -4;
|
|
|
|
// // await _commandBus.Execute(commandSetRollResult, cancellationToken);
|
|
|
|
// // }
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // await _taskProxy.SetTaskState(0, command.Barcode, "UploadError", result.message, "Task");
|
|
// // Output(nameof(command.Message), result.message);
|
|
// // return;
|
|
// //}
|
|
|
|
|
|
// foreach (var r in stockLines)
|
|
// {
|
|
// SetRollResultCommand commandSetRollResult = new SetRollResultCommand();
|
|
// commandSetRollResult.BatchNo = r.Bill;
|
|
// commandSetRollResult.Code = "0";
|
|
// commandSetRollResult.Message = "";
|
|
// commandSetRollResult.Operator = -4;
|
|
|
|
// await _commandBus.Execute(commandSetRollResult, cancellationToken);
|
|
|
|
// }
|
|
|
|
// await _taskProxy.DeleteTask(command.Barcode);
|
|
// }
|
|
//}
|
|
|
|
}
|
|
else
|
|
{
|
|
await _commandBus.Notify(command.ValidationResult,
|
|
cancellationToken: cancellationToken);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|