BarcodeTraceController.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.Data.SqlClient;
  10. using System.Data;
  11. namespace Procurement.Controllers
  12. {
  13. [Produces("application/json")]
  14. [Route("api/wms/[controller]")]
  15. public class BarcodeTraceController : AbpController
  16. {
  17. private readonly ISqlRepository _repository;
  18. public BarcodeTraceController(ISqlRepository sqlRepository)
  19. {
  20. _repository = sqlRepository;
  21. }
  22. [HttpGet]
  23. public async Task<IActionResult> Get(string domain, string barcode)
  24. {
  25. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  26. string subMsg = "";
  27. dynamic items = null;
  28. try
  29. {
  30. SqlParameter[] parameters = {
  31. new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
  32. new SqlParameter { ParameterName = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar},
  33. };
  34. items = await _repository.GetListByProcAsync("pr_WMS_GetBarcodeTraceList", parameters);
  35. }
  36. catch (Exception ex)
  37. {
  38. subMsg = ex.Message;
  39. code = ResultCode.Fail;
  40. subCode = ResultCode.Fail;
  41. }
  42. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  43. return Ok(result);
  44. }
  45. [Route("hist")]
  46. [HttpGet]
  47. public async Task<IActionResult> Hist(string domain, string type, string barcode = "", int recid = 0)
  48. {
  49. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  50. string subMsg = "";
  51. dynamic items = null;
  52. try
  53. {
  54. SqlParameter[] parameters = {
  55. new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
  56. new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar},
  57. new SqlParameter { ParameterName = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar},
  58. new SqlParameter { ParameterName = "@RecID", Value = recid,SqlDbType=SqlDbType.BigInt},
  59. };
  60. items = await _repository.GetListByProcAsync("pr_WMS_GetBarcodeTransHistList", parameters);
  61. }
  62. catch (Exception ex)
  63. {
  64. subMsg = ex.Message;
  65. code = ResultCode.Fail;
  66. subCode = ResultCode.Fail;
  67. }
  68. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  69. return Ok(result);
  70. }
  71. [Route("single")]
  72. [HttpGet]
  73. public async Task<IActionResult> SingleBarCode(string domain, string barcode, bool isapp = false)
  74. {
  75. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  76. string subMsg = "";
  77. dynamic items = null;
  78. try
  79. {
  80. SqlParameter[] parameters = {
  81. new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
  82. new SqlParameter { ParameterName = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar},
  83. new SqlParameter { ParameterName = "@IsApp", Value = isapp,SqlDbType=SqlDbType.Int},
  84. };
  85. items = await _repository.GetListByProcAsync("pr_SFM_SingleLabelBarcodeTrackHist", parameters);
  86. }
  87. catch (Exception ex)
  88. {
  89. subMsg = ex.Message;
  90. code = ResultCode.Fail;
  91. subCode = ResultCode.Fail;
  92. }
  93. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  94. return Ok(result);
  95. }
  96. }
  97. }