QueryCellController.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using Microsoft.AspNetCore.Mvc;
  2. using Newtonsoft.Json;
  3. using WCS.Entity;
  4. using WMS.BZModels.Dto.PT.WareCellDtos;
  5. using WMS.BZServices.PT;
  6. using WMS.Info;
  7. namespace WMS.BZWeb.Areas.PTManager.Controllers
  8. {
  9. [Area("PTManager")]
  10. public class QueryCellController : MvcControllerBase
  11. {
  12. private readonly WareCellService _wareCellService ;
  13. public QueryCellController(WareCellService wareCellService)
  14. {
  15. _wareCellService = wareCellService;
  16. }
  17. #region 视图功能
  18. public IActionResult Index()
  19. {
  20. return View();
  21. }
  22. public IActionResult Form()
  23. {
  24. return View();
  25. }
  26. #endregion
  27. #region 获取数据
  28. [HttpPost]
  29. public ActionResult GetMaxLine(string houseNo)
  30. {
  31. var data = _wareCellService.GetMaxLine("pthouse");
  32. return Success("", data);
  33. }
  34. [HttpPost]
  35. public ActionResult GetLocViewList(string query)
  36. {
  37. var querydto = JsonConvert.DeserializeObject<WarecellQuery>(query);
  38. if (querydto == null || string.IsNullOrEmpty(querydto.SCRel))
  39. {
  40. return Success("", new StockLocationViewDto());
  41. }
  42. var list = _wareCellService.GetLocList(querydto);
  43. return Success("", list);
  44. }
  45. [HttpGet]
  46. public ActionResult GetSelectSRMNameList()
  47. {
  48. var list = _wareCellService.GetSelectSRMNameList();
  49. return Success(list);
  50. }
  51. [HttpPost]
  52. public ActionResult GetLocList(string houserNo, int line)
  53. {
  54. _wareCellService.GetLocList(new WarecellQuery { SCRel = "SRM01" });
  55. var data = _wareCellService.GetLocList(houserNo, line);
  56. var json = "[";
  57. int y = 0;
  58. int x = 0;
  59. foreach (WarecellDto entity in data)
  60. {
  61. if (entity.Layer > y)
  62. {
  63. y = entity.Layer;
  64. }
  65. if (entity.Col > x)
  66. {
  67. x = entity.Col;
  68. }
  69. var color = "";
  70. if (entity.IsStop == 1)
  71. {
  72. color = "#CCC";
  73. }
  74. else
  75. {
  76. if (entity.StateNum == 1)
  77. {
  78. color = "#4EEE94";
  79. }
  80. else if (entity.StateNum == 2)
  81. {
  82. color = "#191970";
  83. }
  84. else if (entity.StateNum == 3)
  85. {
  86. color = "#CD69C9";
  87. }
  88. else if (entity.StateNum == 4)
  89. {
  90. color = "#CD0000";
  91. }
  92. }
  93. double y1 = 0;
  94. double y2 = 0;
  95. if (entity.Depth == 2)
  96. {
  97. y1 = (entity.Layer + 0.6);
  98. y2 = (entity.Layer + 0.9);
  99. }
  100. else
  101. {
  102. y1 = entity.Layer + 0.1;
  103. y2 = entity.Layer + 0.4;
  104. }
  105. int result = 0;
  106. if (entity.IsStop != 1)
  107. {
  108. result = entity.StateNum.HasValue? entity.StateNum.Value:0;
  109. }
  110. json += "{";
  111. //json += @"name:'" + entity.F_WAREHOUSENO + "',fNo:'" + entity.F_NO + "',value:[" + y1 + "," + y2 + ","
  112. // + (entity.F_COL + 0.1) + "," + (entity.F_COL + 0.9) + "],itemStyle:{normal:{color:'" + color + "'}}},";
  113. json += @"name:'" + entity.WarehouseCode + "',fNo:'" + entity.Id +
  114. "',F_ISSTOP:" + entity.IsStop +
  115. ",F_STATENUM:" + entity.StateNum +
  116. ",F_COL:" + entity.Col + ",F_LAYER:" + entity.Layer + ",F_DEPTH:" + entity.Depth + ",STATE:'" + StateText(result) + "'" + ",F_CNTRGRPNO:'" + "'" +
  117. ",value:[" + y1 + "," + y2 + ","
  118. + (entity.Col + 0.1) + "," + (entity.Col + 0.9) + "],itemStyle:{normal:{color:'" + color + "'}}},";
  119. }
  120. json = json.TrimEnd(',') + "]";
  121. var retData = new
  122. {
  123. json,
  124. x,
  125. y
  126. };
  127. return Success("", retData);
  128. }
  129. private string StateText(int state)
  130. {
  131. var stateText = "";
  132. switch (state)
  133. {
  134. case 0:
  135. stateText = "停用";
  136. break;
  137. case 1:
  138. stateText = "空货位";
  139. break;
  140. case 2:
  141. stateText = "已存储";
  142. break;
  143. case 3:
  144. stateText = "入锁";
  145. break;
  146. case 4:
  147. stateText = "出锁";
  148. break;
  149. }
  150. return stateText;
  151. }
  152. #endregion
  153. }
  154. }