InventoryCycleController.cs 3.1 KB

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