BaseWareCellController.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using Microsoft.AspNetCore.Mvc;
  2. using Newtonsoft.Json;
  3. using wms.sqlsugar.model.fj;
  4. using WMS.BZModels;
  5. using WMS.BZModels.Dto.FJ.WareCellDtos;
  6. using WMS.BZServices.FJ;
  7. using WMS.Info;
  8. using WMS.Util;
  9. namespace WMS.BZWeb.Areas.FJManager.Controllers
  10. {
  11. [Area("FJManager")]
  12. public class BaseWareCellController : MvcControllerBase
  13. {
  14. private readonly WareCellService _wareCellService;
  15. public BaseWareCellController(WareCellService wareCellService)
  16. {
  17. _wareCellService = wareCellService;
  18. }
  19. public IActionResult Index()
  20. {
  21. return View();
  22. }
  23. public ActionResult Form()
  24. {
  25. return View();
  26. }
  27. public ActionResult SizeForm()
  28. {
  29. return View();
  30. }
  31. public ActionResult GetPageList(string pagination, string queryJson)
  32. {
  33. Pagination paginationobj = InitPagination(pagination);
  34. var query = new WarecellListQueryDto();
  35. if (!string.IsNullOrEmpty(queryJson))
  36. {
  37. query = JsonConvert.DeserializeObject<WarecellListQueryDto>(queryJson);
  38. }
  39. var lists = _wareCellService.GetPageList(paginationobj, query ?? new WarecellListQueryDto());
  40. var jsonData = new
  41. {
  42. rows = lists.Result,
  43. total = lists.TotalPage,
  44. page = lists.PageIndex,
  45. records = lists.TotalNum
  46. };
  47. return Success(jsonData);
  48. }
  49. public ActionResult GetListsByGroupID(string groupId)
  50. {
  51. if (string.IsNullOrEmpty(groupId))
  52. {
  53. return Fail("编号不能为空");
  54. }
  55. var list = _wareCellService.GetListsByGroupID(Convert.ToInt64(groupId));
  56. return Success(list);
  57. }
  58. [HttpPost]
  59. public ActionResult EnableWareCells(string ids)
  60. {
  61. if (string.IsNullOrEmpty(ids))
  62. {
  63. return Fail("没有选择货位!");
  64. }
  65. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  66. var userid = WebUtil.GetItem("userId");
  67. _wareCellService.ChangeWareCells(lists, LocationStop.LocationInvoke, userid?.ToString());
  68. return Success("保存成功!");
  69. }
  70. [HttpPost]
  71. public ActionResult DisableWareCells(string ids)
  72. {
  73. if (string.IsNullOrEmpty(ids))
  74. {
  75. return Fail("没有选择货位!");
  76. }
  77. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  78. var userid = WebUtil.GetItem("userId");
  79. _wareCellService.ChangeWareCells(lists, LocationStop.LocationStopped, userid?.ToString());
  80. return Success("保存成功!");
  81. }
  82. [HttpPost]
  83. public ActionResult SaveForm(string keyValue, BaseWarecell Data)
  84. {
  85. if (!long.TryParse(keyValue, out var _keyvalue))
  86. {
  87. return Fail("货位编号错误!");
  88. }
  89. LoginUserInfo LoginUser = GetLoginUser();
  90. _wareCellService.Save(LoginUser, _keyvalue, Data);
  91. return Success("保存成功。");
  92. }
  93. [HttpPost]
  94. public ActionResult Delete(string keyValue)
  95. {
  96. _wareCellService.Delete(keyValue);
  97. return Success("删除成功。");
  98. }
  99. [HttpPost]
  100. public ActionResult UpdateCellState(string CellCode, string Status, string WarehouseId)
  101. {
  102. if (string.IsNullOrWhiteSpace(CellCode))
  103. {
  104. return Fail("货位不能为空!");
  105. }
  106. if (!int.TryParse(Status, out var status))
  107. {
  108. return Fail("货位状态值不对!");
  109. }
  110. if (!long.TryParse(WarehouseId, out var warehouID))
  111. {
  112. return Fail("仓库值不对!");
  113. }
  114. var userid = WebUtil.GetItem("userId");
  115. _wareCellService.UpdateCellState(CellCode, status, warehouID, userid?.ToString());
  116. return Success("保存成功。");
  117. }
  118. [HttpPost]
  119. public ActionResult UpdateSize(string ids, string size)
  120. {
  121. if (string.IsNullOrEmpty(ids))
  122. {
  123. return Fail("没有选择货位!");
  124. }
  125. if (string.IsNullOrEmpty(size))
  126. {
  127. return Fail("货位值不能为空!");
  128. }
  129. if (!int.TryParse(size, out var _size))
  130. {
  131. return Fail("货位值不正确!");
  132. }
  133. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  134. var userid = WebUtil.GetItem("userId");
  135. _wareCellService.UpdateSize(lists, userid?.ToString(), _size);
  136. return Success("修改成功!");
  137. }
  138. }
  139. }