平安校园
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.
 
 
 
 
 
 

96 lines
3.6 KiB

  1. using MoYu.FriendlyException;
  2. using MoYu.RemoteRequest.Extensions;
  3. using Newtonsoft.Json.Linq;
  4. using SafeCampus.Application.Manager.DeepelephManager;
  5. using SafeCampus.Application.Services.Business.PassengerFlowService;
  6. using SafeCampus.Application.Services.Business.PassengerFlowService.Dto;
  7. namespace SafeCampus.Web.Core.Controllers.Application.Business;
  8. /// <summary>
  9. /// 客流查询接口
  10. /// </summary>
  11. [Route("/business/[controller]")]
  12. [ApiDescriptionSettings(ApiGroupConsts.SYSTEM_Business, Order = 96,Tag = " 客流查询")]
  13. public class PassengerFlowApi : IDynamicApiController
  14. {
  15. private readonly IDeepelephManager _deepelephManager;
  16. private readonly IPassengerFlowService _passengerFlowService;
  17. public PassengerFlowApi(IDeepelephManager deepelephManager, IPassengerFlowService passengerFlowService)
  18. {
  19. _deepelephManager = deepelephManager;
  20. _passengerFlowService = passengerFlowService;
  21. }
  22. /// <summary>
  23. /// 添加客流查询任务
  24. /// </summary>
  25. /// <param name="input">添加参数</param>
  26. /// <returns></returns>
  27. public async Task<bool> Add(PassengerFlowDto input)
  28. {
  29. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  30. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/passenger-flow/enter/search"
  31. .SetBody(new
  32. {
  33. token = _deepelephManager.GetToken(),
  34. tenantCode = appSettings.TenantCode,
  35. poiId = appSettings.PoiId,
  36. startTime = new DateTimeOffset(input.StartTime).ToUnixTimeMilliseconds(),
  37. endTime = new DateTimeOffset(input.EndTime).ToUnixTimeMilliseconds(),
  38. cameraId=input.CameraIds,
  39. split = input.Split ? "HOUR" : "DAY",
  40. })
  41. .SetContentType("application/json")
  42. .PostAsAsync<string>();
  43. var model = JsonConvert.DeserializeObject<JObject>(str);
  44. if ((bool)model["success"])
  45. {
  46. input.Total = (int)model["data"]["total"];
  47. input.ExtJson = model["data"]["data"].ToString();
  48. await _passengerFlowService.Add(input);
  49. return true;
  50. }
  51. throw Oops.Oh(model["message"].ToString());
  52. }
  53. /// <summary>
  54. /// 分页查询列表
  55. /// </summary>
  56. /// <param name="search"></param>
  57. /// <returns></returns>
  58. public async Task<SqlSugarPagedList<PassengerFlowList>> GetPageList(PassengerFlowSearch search)
  59. {
  60. return await _passengerFlowService.GetPageList(search);
  61. }
  62. /// <summary>
  63. /// 客流查询
  64. /// </summary>
  65. /// <param name="search">查询参数</param>
  66. /// <returns></returns>
  67. [Obsolete]
  68. public async Task<dynamic> PostPassengerFlow(PassengerFlowDto search)
  69. {
  70. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  71. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/passenger-flow/enter/search"
  72. .SetBody(new
  73. {
  74. token = _deepelephManager.GetToken(),
  75. tenantCode = appSettings.TenantCode,
  76. poiId = appSettings.PoiId,
  77. startTime = new DateTimeOffset(search.StartTime).ToUnixTimeMilliseconds(),
  78. endTime = new DateTimeOffset(search.EndTime).ToUnixTimeMilliseconds(),
  79. cameraId=search.CameraIds,
  80. split = search.Split ? "HOUR" : "DAY",
  81. })
  82. .SetContentType("application/json")
  83. .PostAsAsync<string>();
  84. var model = JsonConvert.DeserializeObject<JObject>(str);
  85. if ((bool)model["success"])
  86. {
  87. return model["data"];
  88. }
  89. throw Oops.Oh(model["message"].ToString());
  90. }
  91. }