InvMoveController.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using Procurement.Enums;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Threading.Tasks;
  5. using Volo.Abp.AspNetCore.Mvc;
  6. using Procurement.EntityFrameworkCore.SqlRepositories;
  7. using Procurement.ViewModel;
  8. using Procurement.Helpers;
  9. using System.Text.Json;
  10. using System.Data.SqlClient;
  11. namespace Procurement.Controllers
  12. {
  13. [Produces("application/json")]
  14. [Route("api/wms/[controller]")]
  15. public class InvMoveController : AbpController
  16. {
  17. private readonly ISqlRepository _repository;
  18. public InvMoveController(ISqlRepository sqlRepository)
  19. {
  20. _repository = sqlRepository;
  21. }
  22. /// <summary>
  23. /// 悵湔痄踱扠ワ
  24. /// </summary>
  25. /// <returns></returns>
  26. [HttpPost]
  27. public async Task<IActionResult> Post([FromBody] JsonElement jsonElement)
  28. {
  29. if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
  30. {
  31. return BadRequest();
  32. }
  33. ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
  34. string subMsg = "";
  35. try
  36. {
  37. string proc = "pr_WMS_SaveInvMove";
  38. SqlParameter[] sqlParams = SqlHelper.CreateSqlParameters(jsonElement);
  39. var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
  40. subMsg = resultData.msg;
  41. if (resultData.isSuccess)
  42. {
  43. code = ResultCode.Success;
  44. subCode = ResultCode.Success;
  45. }
  46. }
  47. catch (Exception ex)
  48. {
  49. subMsg = ex.Message;
  50. code = ResultCode.Fail;
  51. subCode = ResultCode.Fail;
  52. }
  53. ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
  54. return Ok(result);
  55. }
  56. /// <summary>
  57. /// 悵湔偌等覃畢
  58. /// </summary>
  59. /// <returns></returns>
  60. [Route("bynbr")]
  61. [HttpPost]
  62. public async Task<IActionResult> InvMoveByNbr([FromBody] JsonElement jsonElement)
  63. {
  64. if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
  65. {
  66. return BadRequest();
  67. }
  68. ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
  69. string subMsg = "";
  70. try
  71. {
  72. string proc = "pr_WMS_SaveInvMoveByNbr";
  73. SqlParameter[] sqlParams = SqlHelper.CreateSqlParameters(jsonElement);
  74. var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
  75. subMsg = resultData.msg;
  76. if (resultData.isSuccess)
  77. {
  78. code = ResultCode.Success;
  79. subCode = ResultCode.Success;
  80. }
  81. }
  82. catch (Exception ex)
  83. {
  84. subMsg = ex.Message;
  85. code = ResultCode.Fail;
  86. subCode = ResultCode.Fail;
  87. }
  88. ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
  89. return Ok(result);
  90. }
  91. }
  92. }