QueryCellController.cs 5.1 KB

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