InvSearchController.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 InvSearchController : AbpController
  15. {
  16. private readonly ISqlRepository _repository;
  17. public InvSearchController(ISqlRepository sqlRepository)
  18. {
  19. _repository = sqlRepository;
  20. }
  21. [HttpGet]
  22. public async Task<IActionResult> Get(string domain, string location = "", string shelf = "", string itemnum = "", int page = 1)
  23. {
  24. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  25. string subMsg = "";
  26. dynamic items = null;
  27. try
  28. {
  29. SqlParameterViewModel[] parameters = {
  30. new SqlParameterViewModel { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbTypes.VarChar},
  31. new SqlParameterViewModel { ParameterName = "@Location", Value = location,SqlDbType=SqlDbTypes.VarChar},
  32. new SqlParameterViewModel { ParameterName = "@Shelf", Value = shelf,SqlDbType=SqlDbTypes.VarChar},
  33. new SqlParameterViewModel { ParameterName = "@ItemNum", Value = itemnum,SqlDbType=SqlDbTypes.VarChar},
  34. new SqlParameterViewModel { ParameterName = "@Page", Value = page,SqlDbType=SqlDbTypes.Int16},
  35. };
  36. items = await _repository.GetListByProcAsync("pr_WMS_GetInvSearchList", parameters);
  37. }
  38. catch (Exception ex)
  39. {
  40. subMsg = ex.Message;
  41. code = ResultCode.Fail;
  42. subCode = ResultCode.Fail;
  43. }
  44. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  45. return Ok(result);
  46. }
  47. [Route("fifo")]
  48. [HttpGet]
  49. public async Task<IActionResult> FIFO(string domain, string location = "", string itemnum = "")
  50. {
  51. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  52. string subMsg = "";
  53. dynamic items = null;
  54. try
  55. {
  56. SqlParameterViewModel[] parameters = {
  57. new SqlParameterViewModel { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbTypes.VarChar},
  58. new SqlParameterViewModel { ParameterName = "@Location", Value = location,SqlDbType=SqlDbTypes.VarChar},
  59. new SqlParameterViewModel { ParameterName = "@ItemNum", Value = itemnum,SqlDbType=SqlDbTypes.VarChar},
  60. };
  61. items = await _repository.GetSingleListByProcAsync("pr_WMS_GetInvFIFOList", parameters);
  62. }
  63. catch (Exception ex)
  64. {
  65. subMsg = ex.Message;
  66. code = ResultCode.Fail;
  67. subCode = ResultCode.Fail;
  68. }
  69. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  70. return Ok(result);
  71. }
  72. }
  73. }