MobileTaskController.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 MobileTaskController : AbpController
  17. {
  18. private readonly ISqlRepository _repository;
  19. public MobileTaskController(ISqlRepository sqlRepository)
  20. {
  21. _repository = sqlRepository;
  22. }
  23. [HttpGet]
  24. public async Task<IActionResult> Get(string typeid = "Wms", string userno = "", int page = 0)
  25. {
  26. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  27. string subMsg = "";
  28. dynamic items = null;
  29. try
  30. {
  31. SqlParameter[] parameters = {
  32. new SqlParameter { ParameterName = "@TypeID", Value = typeid,SqlDbType=SqlDbType.VarChar},
  33. new SqlParameter { ParameterName = "@UserNo", Value = userno,SqlDbType=SqlDbType.VarChar},
  34. new SqlParameter { ParameterName = "@Page", Value = page,SqlDbType=SqlDbType.Int},
  35. };
  36. items = await _repository.GetListByProcAsync("pr_WMS_BPM_GetMobileTaskList", 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. [HttpPost]
  48. public async Task<IActionResult> Post([FromBody] JsonElement jsonElement)
  49. {
  50. if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
  51. {
  52. return BadRequest();
  53. }
  54. ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
  55. string subMsg = "";
  56. try
  57. {
  58. string proc = "pr_WMS_BPM_DelMobileTask";
  59. SqlParameter[] sqlParams = SqlHelper.CreateSqlParameters(jsonElement);
  60. var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
  61. subMsg = resultData.msg;
  62. if (resultData.isSuccess)
  63. {
  64. code = ResultCode.Success;
  65. subCode = ResultCode.Success;
  66. }
  67. }
  68. catch (Exception ex)
  69. {
  70. subMsg = ex.Message;
  71. code = ResultCode.Fail;
  72. subCode = ResultCode.Fail;
  73. }
  74. ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
  75. return Ok(result);
  76. }
  77. }
  78. }