BaseWareCellController.cs 5.0 KB

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