12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- 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
- {
- /// <summary>
- /// AGV相关接口控制器
- /// </summary>
- public static class WmsApi
- {
- private static string _WMSUrl = null!;
- private static string _wareHouseId = null!;
- /// <summary>
- /// WMS URL
- /// </summary>
- public static string WMSUrl
- {
- get
- {
- _WMSUrl ??= RedisHub.Default.Check("WMSUrl");
- if (string.IsNullOrEmpty(_WMSUrl))
- {
- throw new KnownException($"请在Redis配置WMSUrl", LogLevelEnum.High);
- }
- return _WMSUrl;
- }
- }
- /// <summary>
- /// 仓库编号
- /// </summary>
- public static string wareHouseId
- {
- get
- {
- _wareHouseId ??= RedisHub.Default.Check("wareHouseId");
- if (string.IsNullOrEmpty(_wareHouseId))
- {
- throw new KnownException($"请在Redis配置wareHouseId", LogLevelEnum.High);
- }
- return _wareHouseId;
- }
- }
- /// <summary>
- /// 分配货位
- /// </summary>
- /// <param name="wcsTaskNum">WMS任务ID</param>
- /// <param name="tunnel">巷道</param>
- /// <param name="device">设备号</param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public static I_WCS_GetWareCellResponse GetLocalIn(int wcsTaskNum, string tunnel, string device)
- {
- var res = APICaller.CallApi2<I_WCS_GetWareCellResponse>(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;
- }
- /// <summary>
- /// 向WMS获取入库任务 一次单卷
- /// </summary>
- /// <param name="barcode">产品条码</param>
- /// <param name="devCode">设备条码</param>
- /// <param name="getTunnel"></param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public static I_WCS_GetInTaskResponse I_WCS_GetInTask(string barcode, string devCode, bool getTunnel = false)
- {
- var res = APICaller.CallApi<I_WCS_GetInTaskResponse>(WMSUrl + "/api/Task/I_WCS_GetInTask", new List<I_WCS_GetInTaskRequest>()
- {
- 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;
- }
- }
- }
|