BaseWareCellController.cs 4.8 KB

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