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.
76 lines
2.4 KiB
76 lines
2.4 KiB
using Kean.Domain.Task.Commands;
|
|
using Kean.Domain.Task.Repositories;
|
|
using Kean.Domain.Task.SharedServices.Proxies;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
|
|
namespace Kean.Domain.Task.SharedServices
|
|
{
|
|
/// <summary>
|
|
/// 申请空托盘出库
|
|
/// </summary>
|
|
public sealed class ApplyOut
|
|
{
|
|
private readonly ICommandBus _commandBus;
|
|
private readonly IWarehouseRepository _warehouseRepository; // 库房仓库
|
|
private readonly MaterialProxy _materialProxy; // 物料服务
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public ApplyOut(ICommandBus commandBus,
|
|
MaterialProxy materialProxy,
|
|
IWarehouseRepository warehouseRepository)
|
|
{
|
|
_commandBus = commandBus;
|
|
_materialProxy = materialProxy;
|
|
_warehouseRepository = warehouseRepository;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 处理程序
|
|
/// </summary>
|
|
public async System.Threading.Tasks.Task Handler(
|
|
string warehouseCode,
|
|
string deviceCode,
|
|
string barcode,
|
|
string tag,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
Models.Station strion = await _warehouseRepository.GetStationByDevice(deviceCode, Convert.ToInt32(warehouseCode));
|
|
|
|
List<int> lsGoods = new List<int>();
|
|
var sGoods = await _materialProxy.GetMaterial(null, strion.Pallet.First(), false);
|
|
Models.Material goods = JsonConvert.DeserializeObject<Models.Material>(sGoods);
|
|
if (goods == null)
|
|
{
|
|
await _commandBus.Notify(nameof(deviceCode), $"未找到站台({deviceCode})对应的托盘类型信息,请联系管理员", deviceCode, cancellationToken: cancellationToken);
|
|
return;
|
|
}
|
|
lsGoods.Add(goods.Id);
|
|
|
|
await _commandBus.Execute(new ApplyOutCommand
|
|
{
|
|
Warehouse = strion.Warehouse,
|
|
//RequestNo = requestNo,
|
|
Operator = -1,
|
|
Tag = tag,
|
|
Destination = $"device:{deviceCode}",
|
|
Priority = 0,
|
|
Manual = false,
|
|
Transaction = "PalletOut",
|
|
Materials = lsGoods,
|
|
Qty = 1,
|
|
Qc ="ok",
|
|
enable = true,
|
|
IsLocal="1"
|
|
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|