WmsApi.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using ServiceCenter.WebApi;
  2. using WCS.WorkEngineering.WebApi.Models.WMS.Request;
  3. using WCS.WorkEngineering.WebApi.Models.WMS.Response;
  4. using WCS.WorkEngineering.Worlds.Logs;
  5. namespace WCS.WorkEngineering.WebApi.Controllers
  6. {
  7. /// <summary>
  8. /// AGV相关接口控制器
  9. /// </summary>
  10. public static class WmsApi
  11. {
  12. public static string WMSUrl = null!;
  13. public static string wareHouseId = null!;
  14. /// <summary>
  15. /// 分配货位
  16. /// </summary>
  17. /// <param name="wcsTaskNum">WMS任务ID</param>
  18. /// <param name="tunnel">巷道</param>
  19. /// <param name="device">设备号</param>
  20. /// <returns></returns>
  21. /// <exception cref="Exception"></exception>
  22. public static I_WCS_GetWareCellResponse GetLocalIn(int wcsTaskNum, string tunnel, string device)
  23. {
  24. var res = APICaller.CallApi2<I_WCS_GetWareCellResponse>(WMSUrl + "/api/Task/I_WCS_GetWareCell", new I_WCS_GetWareCellRequest
  25. {
  26. PickUpEquipmentNo = device,
  27. TunnelNum = tunnel.Last().ToString(),
  28. WCSTaskNum = wcsTaskNum.ToString(),
  29. });
  30. if (!res.ResType)
  31. {
  32. throw new KnownException(res.ResMessage, LogLevelEnum.High);
  33. }
  34. return res;
  35. }
  36. /// <summary>
  37. /// 向WMS获取入库任务 一次单卷
  38. /// </summary>
  39. /// <param name="barcode">产品条码</param>
  40. /// <param name="devCode">设备条码</param>
  41. /// <param name="getTunnel"></param>
  42. /// <returns></returns>
  43. /// <exception cref="Exception"></exception>
  44. public static I_WCS_GetInTaskResponse I_WCS_GetInTask(string barcode, string devCode, bool getTunnel = false)
  45. {
  46. var res = APICaller.CallApi<I_WCS_GetInTaskResponse>(WMSUrl + "/api/Task/I_WCS_GetInTask", new List<I_WCS_GetInTaskRequest>()
  47. {
  48. new I_WCS_GetInTaskRequest(){
  49. ContainerBarCode = barcode,
  50. WareHouseId = wareHouseId,
  51. EquipmentNo = devCode,
  52. Memo1 = getTunnel ? "1" : "" //1:分巷道 2:分货位
  53. }
  54. });
  55. if (!res.ResType) throw new KnownException(res.ResMessage, LogLevelEnum.High);
  56. return res;
  57. }
  58. }
  59. }