BaseWareCellController.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Microsoft.AspNetCore.Mvc;
  2. using Newtonsoft.Json;
  3. using wms.sqlsugar.model.pt;
  4. using WMS.BZModels;
  5. using WMS.BZModels.Dto.PT.WareCellDtos;
  6. using WMS.BZModels.Dto.PT.TaskDtos;
  7. using WMS.BZUtil;
  8. using WMS.Core;
  9. using WMS.Info;
  10. using WMS.Util;
  11. using WMS.BZServices.PT;
  12. namespace WMS.BZWeb.Areas.PTManager.Controllers
  13. {
  14. [Area("PTManager")]
  15. public class BaseWareCellController : MvcControllerBase
  16. {
  17. private readonly WareCellService _wareCellService;
  18. public BaseWareCellController(WareCellService wareCellService)
  19. {
  20. _wareCellService = wareCellService;
  21. }
  22. public IActionResult Index()
  23. {
  24. return View();
  25. }
  26. public ActionResult Form()
  27. {
  28. return View();
  29. }
  30. public ActionResult GetPageList(string pagination, string queryJson)
  31. {
  32. Pagination paginationobj = InitPagination(pagination);
  33. var query = new WarecellListQueryDto();
  34. if (!string.IsNullOrEmpty(queryJson))
  35. {
  36. query = JsonConvert.DeserializeObject<WarecellListQueryDto>(queryJson);
  37. }
  38. var lists = _wareCellService.GetPageList(paginationobj, query ?? new WarecellListQueryDto());
  39. var jsonData = new
  40. {
  41. rows = lists.Result,
  42. total = lists.TotalPage,
  43. page = lists.PageIndex,
  44. records = lists.TotalNum
  45. };
  46. return Success(jsonData);
  47. }
  48. [HttpPost]
  49. public ActionResult EnableWareCells(string ids)
  50. {
  51. if (string.IsNullOrEmpty(ids))
  52. {
  53. return Fail("没有选择货位!");
  54. }
  55. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  56. var userid = WebUtil.GetItem("userId");
  57. _wareCellService.ChangeWareCells(lists, LocationStop.LocationInvoke, userid?.ToString());
  58. return Success("保存成功!");
  59. }
  60. [HttpPost]
  61. public ActionResult DisableWareCells(string ids)
  62. {
  63. if (string.IsNullOrEmpty(ids))
  64. {
  65. return Fail("没有选择货位!");
  66. }
  67. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  68. var userid = WebUtil.GetItem("userId");
  69. _wareCellService.ChangeWareCells(lists, LocationStop.LocationStopped, userid?.ToString());
  70. return Success("保存成功!");
  71. }
  72. [HttpPost]
  73. public ActionResult SaveForm(string keyValue, BaseWarecell Data)
  74. {
  75. LoginUserInfo LoginUser = GetLoginUser();
  76. _wareCellService.Save(LoginUser, keyValue, Data);
  77. return Success("保存成功。");
  78. }
  79. [HttpPost]
  80. public ActionResult Delete(string keyValue)
  81. {
  82. _wareCellService.Delete(keyValue);
  83. return Success("删除成功。");
  84. }
  85. }
  86. }