IwmsApi.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using ServiceCenter.Extensions;
  2. using ServiceCenter.Logs;
  3. using ServiceCenter.Redis;
  4. using ServiceCenter.WebApi;
  5. using WCS.WorkEngineering.WebApi.Models.AGV;
  6. using WCS.WorkEngineering.WebApi.Models.AGV.Request;
  7. using WCS.WorkEngineering.WebApi.Models.AGV.Response;
  8. namespace WCS.WorkEngineering.WebApi.Controllers
  9. {
  10. public class IwmsApi
  11. {
  12. private static string _IwmsUrl = null!;
  13. /// <summary>
  14. /// AGV地址
  15. /// </summary>
  16. public static string IwmsUrl
  17. {
  18. get
  19. {
  20. _IwmsUrl ??= RedisHub.Default.Check("IwmsUrl");
  21. if (string.IsNullOrEmpty(_IwmsUrl))
  22. {
  23. throw new KnownException($"请在Redis配置IwmsUrl", LogLevelEnum.High);
  24. }
  25. return _IwmsUrl;
  26. }
  27. }
  28. /// <summary>
  29. /// 满轮出库
  30. /// </summary>
  31. /// <param name="matCode">物料编号</param>
  32. /// <param name="wbCode">取货点位置</param>
  33. /// <param name="taskNo">任务号</param>
  34. /// <param name="rfid">RFID</param>
  35. /// <param name="matNo">材料号</param>
  36. /// <param name="isSurplus">改手盘标记</param>
  37. /// <param name="isRework">返工标记</param>
  38. /// <param name="matFast">快投标记</param>
  39. /// <param name="gradeCode">质量等级</param>
  40. /// <param name="wetIntoBinCode">仓位号</param>
  41. /// <returns></returns>
  42. public static zhongTianIntoStockResponse 满轮出库(string matCode, string wbCode, string taskNo, string rfid, string matNo, bool isSurplus, bool isRework, bool matFast, string gradeCode, string wetIntoBinCode)
  43. {
  44. var zhongTian = new zhongTianIntoStockRequest()
  45. {
  46. matCode = matCode,
  47. wbCode = wbCode,
  48. inSpoolFull = "1",
  49. getOutEmpty = false,
  50. wetIntoReturn = false,
  51. isSurplus = isSurplus == false ? "0" : "1",
  52. isRework = isRework == false ? "0" : "1",
  53. spoolNo = rfid,
  54. gradeCode = gradeCode,
  55. matFast = matFast == false ? "0" : "1",
  56. matNo = matNo,
  57. orderProcessLenOut = "0",
  58. taskNo = $"RK{taskNo}",
  59. returnDesc = "",
  60. lockFlag = "0",
  61. };
  62. if (wetIntoBinCode.Length == 14)
  63. {
  64. zhongTian.wetInto = true;
  65. zhongTian.wetIntoBinCode = wetIntoBinCode;
  66. zhongTian.wetIntoSpec = false;
  67. zhongTian.wetSpecWbCode = "";
  68. }
  69. else
  70. {
  71. zhongTian.wetInto = false;
  72. zhongTian.wetIntoBinCode = "";
  73. zhongTian.wetIntoSpec = true;
  74. zhongTian.wetSpecWbCode = wetIntoBinCode;
  75. }
  76. return zhongTianIntoStock(zhongTian);
  77. //return zhongTianOutStock(new zhongTianOutStockRequest()
  78. //{
  79. // matCode = matCode,
  80. // workAreaCode = wbCode,
  81. // outSpoolFull = "1"
  82. //});
  83. }
  84. public static zhongTianOutStockResponse 空轮回库(string matCode, string wbCode, bool isSurplus, bool isRework, int taskNo, string RFID)
  85. {
  86. return zhongTianOutStock(new zhongTianOutStockRequest()
  87. {
  88. matCode = matCode,
  89. workAreaCode = wbCode,
  90. outSpoolFull = "0",
  91. intoEmpty = false,
  92. wetOut = "",
  93. wetOutReturn = true,
  94. spoolNo = RFID,
  95. isSurplus = isSurplus == false ? "0" : "1",
  96. isRework = isRework == false ? "0" : "1",
  97. reqCode = Guid.NewGuid().ToString().Replace("-", ""),
  98. taskNo = $"CK{wbCode}{taskNo}"
  99. });
  100. }
  101. public static zhongTianIntoStockResponse zhongTianIntoStock(zhongTianIntoStockRequest req)
  102. {
  103. var res = APICaller.CallApi2<zhongTianIntoStockResponse>(IwmsUrl + "/databus/publish/zhongTianIntoStock", req);
  104. if (res.code != AgvResponseCode.Success)
  105. {
  106. throw new KnownException(res.message, LogLevelEnum.High);
  107. }
  108. return res;
  109. }
  110. public static zhongTianOutStockResponse zhongTianOutStock(zhongTianOutStockRequest req)
  111. {
  112. var res = APICaller.CallApi2<zhongTianOutStockResponse>(IwmsUrl + "/databus/publish/zhongTianOutStock", req);
  113. if (res.code != AgvResponseCode.Success)
  114. {
  115. throw new KnownException(res.message, LogLevelEnum.High);
  116. }
  117. return res;
  118. }
  119. }
  120. }