InventoryCycleController.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. namespace Procurement.Controllers
  11. {
  12. [Produces("application/json")]
  13. [Route("api/wms/[controller]")]
  14. public class InventoryCycleController : AbpController
  15. {
  16. private readonly ISqlRepository _repository;
  17. public InventoryCycleController(ISqlRepository sqlRepository)
  18. {
  19. _repository = sqlRepository;
  20. }
  21. /// <summary>
  22. /// 查找货架下未扫到的N状态标签
  23. /// </summary>
  24. /// <returns></returns>
  25. [Route("batch")]
  26. [HttpGet]
  27. public async Task<IActionResult> Get(string domain, string strDetails1)
  28. {
  29. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  30. string subMsg = "";
  31. dynamic items = null;
  32. try
  33. {
  34. SqlParameterViewModel[] parameters = {
  35. new SqlParameterViewModel { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbTypes.VarChar},
  36. new SqlParameterViewModel { ParameterName = "@Details", Value = strDetails1,SqlDbType=SqlDbTypes.VarChar}
  37. };
  38. items = await _repository.GetListByProcAsync("pr_WMS_GetInventoryCycleBatch", parameters);
  39. }
  40. catch (Exception ex)
  41. {
  42. subMsg = ex.Message;
  43. code = ResultCode.Fail;
  44. subCode = ResultCode.Fail;
  45. }
  46. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  47. return Ok(result);
  48. }
  49. /// <summary>
  50. /// 保存
  51. /// </summary>
  52. /// <returns></returns>
  53. [HttpPost]
  54. public async Task<IActionResult> Post([FromBody] JsonElement jsonElement)
  55. {
  56. if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
  57. {
  58. return BadRequest();
  59. }
  60. ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
  61. string subMsg = "";
  62. try
  63. {
  64. string proc = "pr_WMS_SaveInventoryCycle";
  65. SqlParameterViewModel[] sqlParams = await SqlHelper.CreateSqlParameters(_repository, proc, jsonElement);
  66. var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
  67. subMsg = resultData.msg;
  68. if (resultData.isSuccess)
  69. {
  70. code = ResultCode.Success;
  71. subCode = ResultCode.Success;
  72. }
  73. }
  74. catch (Exception ex)
  75. {
  76. subMsg = ex.Message;
  77. code = ResultCode.Fail;
  78. subCode = ResultCode.Fail;
  79. }
  80. ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
  81. return Ok(result);
  82. }
  83. }
  84. }