终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

105 lines
3.2 KiB

  1. using BPASmartClient.AGV;
  2. using BPASmartClient.AGV.Feedback;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.AspNetCore.SignalR;
  5. using Newtonsoft.Json;
  6. using System.Diagnostics;
  7. using System.Text;
  8. namespace BPASmartClient.AgvApi.Controllers
  9. {
  10. [ApiController]
  11. [Route("apicallback/quicktron/[Controller]")]
  12. public class robotjobController : ControllerBase
  13. {
  14. /// <summary>
  15. /// 搬运任务状态上报
  16. /// </summary>
  17. /// <param name="sign"></param>
  18. /// <returns></returns>
  19. [HttpPost("report")]
  20. public async Task<string> report()
  21. {
  22. //if (sign != null)
  23. //{
  24. try
  25. {
  26. using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
  27. {
  28. string body = await reader.ReadToEndAsync();
  29. var res = JsonConvert.DeserializeObject<TaskData>(body);
  30. var r = res.body.@event;
  31. if (r != null)
  32. {
  33. await Factory.GetInstance.SendReport(r);
  34. return "Report SUCCESS";
  35. }
  36. }
  37. }
  38. catch (Exception ex)
  39. {
  40. return ex.ToString();
  41. }
  42. //var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign);
  43. // if (res != null)
  44. // {
  45. // Factory.GetInstance.SendReport(res);
  46. // return "SUCCESS";
  47. // }
  48. //}
  49. //}
  50. return "Error";
  51. }
  52. /// <summary>
  53. /// AGV上下料交互请求接口
  54. /// </summary>
  55. /// <param name="sign"></param>
  56. /// <returns></returns>
  57. [HttpPost("upstreamrequest")]
  58. public async Task<string> upstreamrequest()
  59. {
  60. //if (sign != null)
  61. //{
  62. try
  63. {
  64. using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
  65. {
  66. string body = await reader.ReadToEndAsync();
  67. var res = JsonConvert.DeserializeObject<LoadRequest>(body);
  68. var r = res.body.@event;
  69. if (r != null)
  70. {
  71. await Factory.GetInstance.SendUpstreamrequest(r);
  72. //return "UpStream SUCCESS";
  73. return JsonConvert.SerializeObject(new HttpResponseModel() { header = new HttpResponseHeaderModel { requestId = res.header.requestId,timestamp=DateTime.Now.ToString(),version="2.7" } ,body = new HttpResponseBodyModel() { success = true, code = "SUCCESS", message = "", data = null } });
  74. }
  75. }
  76. //var res = JsonConvert.DeserializeObject<Upstreamrequest>(sign);
  77. //if (res != null)
  78. //{
  79. // Factory.GetInstance.SendUpstreamrequest(res);
  80. // return "SUCCESS";
  81. //}
  82. }
  83. catch (Exception ex)
  84. {
  85. return ex.ToString();
  86. }
  87. //}
  88. return "Error";
  89. }
  90. }
  91. }