BillBomSetController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using Mapster;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Newtonsoft.Json;
  4. using wms.sqlsugar.model.fj;
  5. using WMS.BZModels;
  6. using WMS.BZModels.Dto.FJ.BillBom;
  7. using WMS.BZServices.FJ;
  8. using WMS.Info;
  9. using WMS.Util;
  10. namespace WMS.BZWeb.Areas.FJManager.Controllers
  11. {
  12. [Area("FJManager")]
  13. public class BillBomSetController : MvcControllerBase
  14. {
  15. private readonly BillBomSetService _billBomSetService;
  16. public BillBomSetController(BillBomSetService billBomSetService)
  17. {
  18. _billBomSetService = billBomSetService;
  19. }
  20. #region 视图功能
  21. public IActionResult Index()
  22. {
  23. return View();
  24. }
  25. public IActionResult DFM09()
  26. {
  27. return View();
  28. }
  29. public IActionResult DFM1509()
  30. {
  31. return View();
  32. }
  33. public IActionResult DOF2()
  34. {
  35. return View();
  36. }
  37. public IActionResult DOF4()
  38. {
  39. return View();
  40. }
  41. public IActionResult DFM6()
  42. {
  43. return View();
  44. }
  45. public IActionResult Exception()
  46. {
  47. return View();
  48. }
  49. public IActionResult DFMAll()
  50. {
  51. return View();
  52. }
  53. #endregion
  54. public ActionResult GetPageList(string pagination, string queryJson)
  55. {
  56. Pagination paginationobj = InitPagination(pagination);
  57. var query = new BillBomsetgrpQueryDto();
  58. if (!string.IsNullOrEmpty(queryJson))
  59. {
  60. query = JsonConvert.DeserializeObject<BillBomsetgrpQueryDto>(queryJson);
  61. }
  62. var lists = _billBomSetService.GetPageList(paginationobj, query ?? new BillBomsetgrpQueryDto());
  63. var jsonData = new
  64. {
  65. rows = lists.Result,
  66. total = lists.TotalPage,
  67. page = lists.PageIndex,
  68. records = lists.TotalNum
  69. };
  70. return Success(jsonData);
  71. }
  72. public ActionResult GetBillBomSetInfoItem(string bomSetHdrId)
  73. {
  74. if (string.IsNullOrWhiteSpace(bomSetHdrId))
  75. {
  76. return Fail("跺型Id不能为空");
  77. }
  78. if (!long.TryParse(bomSetHdrId, out var id))
  79. {
  80. return Fail("跺型Id不能为空");
  81. }
  82. var list = _billBomSetService.GetBillBomsetinfoItem(id);
  83. return Success(list);
  84. }
  85. public ActionResult GetBillBomsetinfo(string id)
  86. {
  87. if (string.IsNullOrWhiteSpace(id))
  88. {
  89. return Fail("跺型Id不能为空");
  90. }
  91. if (!long.TryParse(id, out var bomsetid))
  92. {
  93. return Fail("跺型Id不能为空");
  94. }
  95. var dto = _billBomSetService.GetBillBomsetinfo(bomsetid);
  96. return Success(dto);
  97. }
  98. public ActionResult GetSelectCodeListByType(string typenum)
  99. {
  100. var list = _billBomSetService.GetSelectCodeListByType(typenum);
  101. return Success(list);
  102. }
  103. [HttpPost]
  104. public ActionResult Save09Form(string keyValue, BillBomsetDto Data)
  105. {
  106. LoginUserInfo LoginUser = GetLoginUser();
  107. _billBomSetService.Save09(LoginUser, keyValue, Data.Adapt<BillBomsetgrp>(), Data.Bomsetinfos.Adapt<List<BillBomsetinfo>>());
  108. return Success("保存成功。");
  109. }
  110. [HttpPost]
  111. public ActionResult SaveForm(string keyValue, BillBomsetDto Data)
  112. {
  113. LoginUserInfo LoginUser = GetLoginUser();
  114. _billBomSetService.Save(LoginUser, keyValue, Data.Adapt<BillBomsetgrp>(), Data.Bomsetinfos.Adapt<List<BillBomsetinfo>>());
  115. return Success("保存成功。");
  116. }
  117. [HttpPost]
  118. public ActionResult SaveExceptionForm(string keyValue, BillBomsetDto Data)
  119. {
  120. LoginUserInfo LoginUser = GetLoginUser();
  121. _billBomSetService.SaveException(LoginUser, keyValue, Data.Adapt<BillBomsetgrp>(), Data.Bomsetinfos.Adapt<List<BillBomsetinfo>>());
  122. return Success("保存成功。");
  123. }
  124. [HttpPost]
  125. public ActionResult Delete(string keyValue)
  126. {
  127. if (string.IsNullOrWhiteSpace(keyValue))
  128. {
  129. return Fail("跺型Id不能为空");
  130. }
  131. if (!long.TryParse(keyValue, out var id))
  132. {
  133. return Fail("跺型Id不能为空");
  134. }
  135. _billBomSetService.Delete(id);
  136. return Success("删除成功。");
  137. }
  138. [HttpPost]
  139. public ActionResult Deletes(string[] keyValue)
  140. {
  141. if (keyValue == null || keyValue.Length == 0)
  142. {
  143. return Fail("跺型Id不能为空");
  144. }
  145. var userid = WebUtil.GetItem("userId");
  146. _billBomSetService.Deletes(keyValue, userid?.ToString());
  147. return Success("删除成功。");
  148. }
  149. [HttpPost]
  150. public ActionResult Enables(string ids)
  151. {
  152. if (string.IsNullOrEmpty(ids))
  153. {
  154. return Fail("没有选择跺型!");
  155. }
  156. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  157. var userid = WebUtil.GetItem("userId");
  158. _billBomSetService.ChangeEnableds(lists, LocationStop.LocationInvoke, userid?.ToString());
  159. return Success("保存成功!");
  160. }
  161. [HttpPost]
  162. public ActionResult Disables(string ids)
  163. {
  164. if (string.IsNullOrEmpty(ids))
  165. {
  166. return Fail("没有选择跺型!");
  167. }
  168. var lists = JsonConvert.DeserializeObject<List<string>>(ids);
  169. var userid = WebUtil.GetItem("userId");
  170. _billBomSetService.ChangeEnableds(lists, LocationStop.LocationStopped, userid?.ToString());
  171. return Success("保存成功!");
  172. }
  173. }
  174. }