using ServiceCenter.Redis;
using ServiceCenter.WebApi;
using WCS.WorkEngineering.WebApi.Models.WMS.Request;
using WCS.WorkEngineering.WebApi.Models.WMS.Response;
using WCS.WorkEngineering.Worlds.Logs;
namespace WCS.WorkEngineering.WebApi.Controllers
{
///
/// AGV相关接口控制器
///
public static class WmsApi
{
private static string _WMSUrl = null!;
private static string _wareHouseId = null!;
///
/// WMS URL
///
public static string WMSUrl
{
get
{
_WMSUrl ??= RedisHub.Default.Check("WMSUrl");
if (string.IsNullOrEmpty(_WMSUrl))
{
throw new KnownException($"请在Redis配置WMSUrl", LogLevelEnum.High);
}
return _WMSUrl;
}
}
///
/// 仓库编号
///
public static string wareHouseId
{
get
{
_wareHouseId ??= RedisHub.Default.Check("wareHouseId");
if (string.IsNullOrEmpty(_wareHouseId))
{
throw new KnownException($"请在Redis配置wareHouseId", LogLevelEnum.High);
}
return _wareHouseId;
}
}
///
/// 分配货位
///
/// WMS任务ID
/// 巷道
/// 设备号
///
///
public static I_WCS_GetWareCellResponse GetLocalIn(int wcsTaskNum, string tunnel, string device)
{
var res = APICaller.CallApi2(WMSUrl + "/api/Task/I_WCS_GetWareCell", new I_WCS_GetWareCellRequest
{
PickUpEquipmentNo = device,
TunnelNum = tunnel.Last().ToString(),
WCSTaskNum = wcsTaskNum.ToString(),
});
if (!res.ResType)
{
throw new KnownException(res.ResMessage, LogLevelEnum.High);
}
return res;
}
///
/// 向WMS获取入库任务 一次单卷
///
/// 产品条码
/// 设备条码
///
///
///
public static I_WCS_GetInTaskResponse I_WCS_GetInTask(string barcode, string devCode, bool getTunnel = false)
{
var res = APICaller.CallApi(WMSUrl + "/api/Task/I_WCS_GetInTask", new List()
{
new I_WCS_GetInTaskRequest(){
ContainerBarCode = barcode,
WareHouseId = wareHouseId,
EquipmentNo = devCode,
Memo1 = getTunnel ? "1" : "" //1:分巷道 2:分货位
}
});
if (!res.ResType) throw new KnownException(res.ResMessage, LogLevelEnum.High);
return res;
}
}
}