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

88 lines
2.8 KiB

  1. using SafeCampus.Application.Services.Business.CameraInfoService;
  2. using System.Collections.Generic;
  3. namespace SafeCampus.Web.Core.Controllers.Application.Business;
  4. /// <summary>
  5. /// 摄像头管理接口
  6. /// </summary>
  7. [ApiDescriptionSettings(ApiGroupConsts.SYSTEM_Business, Order = 91, Tag = "摄像头管理")]
  8. [Route("/business/cameraInfo")]
  9. [RolePermission]
  10. public class CameraInfoController
  11. {
  12. private readonly ICameraInfoService _cameraInfoService;
  13. public CameraInfoController(ICameraInfoService cameraInfoService)
  14. {
  15. _cameraInfoService = cameraInfoService;
  16. }
  17. /// <summary>
  18. /// 数据同步
  19. /// </summary>
  20. /// <returns></returns>
  21. public async Task<bool> DataSync()
  22. {
  23. return await _cameraInfoService.DataSync();
  24. }
  25. /// <summary>
  26. /// 获取摄像头列表
  27. /// </summary>
  28. /// <param name="search"></param>
  29. /// <returns></returns>
  30. public async Task<SqlSugarPagedList<CameraInfoDto>> GetPageList(CameraSearch search)
  31. {
  32. return await _cameraInfoService.GetPageList(search);
  33. }
  34. /// <summary>
  35. /// 批量给摄像头设置分组
  36. /// </summary>
  37. /// <param name="input"></param>
  38. /// <returns></returns>
  39. public async Task<bool> BatchSetGroup(SetGroupInput input)
  40. {
  41. return await _cameraInfoService.BatchSetGroup(input);
  42. }
  43. /// <summary>
  44. /// 根据分组批量设置推送人
  45. /// </summary>
  46. /// <param name="input"></param>
  47. /// <returns></returns>
  48. public async Task<bool> BatchSetPushPersonByGroup(SetPushPersonGroupInput input)
  49. {
  50. return await _cameraInfoService.BatchSetPushPersonByGroup(input);
  51. }
  52. /// <summary>
  53. /// 对摄像头批量设置推送人
  54. /// </summary>
  55. /// <param name="input"></param>
  56. /// <returns></returns>
  57. public async Task<bool> BatchSetPushPerson(SetPushPersonInput input)
  58. {
  59. return await _cameraInfoService.BatchSetPushPerson(input);
  60. }
  61. /// <summary>
  62. /// 根据预警分组设置推送人
  63. /// </summary>
  64. /// <param name="input"></param>
  65. /// <returns></returns>
  66. public async Task<bool> BatchSetPushPersonByWarn(SetPushPersonWarnInput input)
  67. {
  68. return await _cameraInfoService.BatchSetPushPersonByWarn(input);
  69. }
  70. /// <summary>
  71. /// 设备状态统计API
  72. /// </summary>
  73. /// <returns></returns>
  74. public async Task<dynamic> GetCameraStatistic()
  75. {
  76. var list = await _cameraInfoService.GetPageList(new CameraSearch{PageNum = 1,PageSize = 1000});
  77. var numbers = new Dictionary<bool, string> { {true, "在线" }, { false, "离线" } };
  78. var statistics = numbers.Select(x => new
  79. {
  80. Name = x.Value,
  81. Count = list.List.Count(xx => xx.DeviceStatus)
  82. }).ToList();
  83. return statistics;
  84. }
  85. }