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

133 lines
4.5 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.AttendanceService;
  6. namespace SafeCampus.Web.Core.Controllers.Application.Business;
  7. /// <summary>
  8. /// 考勤事件管理接口
  9. /// </summary>
  10. [Route("/business/[controller]")]
  11. [ApiDescriptionSettings(ApiGroupConsts.SYSTEM_Business, Order = 94,Tag = "考勤事件管理")]
  12. public class AttendanceApi : IDynamicApiController
  13. {
  14. private readonly IAttendanceService _attendanceService;
  15. private readonly IDeepelephManager _deepelephManager;
  16. public AttendanceApi(IDeepelephManager deepelephManager, IAttendanceService attendanceService)
  17. {
  18. _deepelephManager = deepelephManager;
  19. _attendanceService = attendanceService;
  20. }
  21. /// <summary>
  22. /// 考勤查询
  23. /// </summary>
  24. /// <param name="search">查询参数</param>
  25. /// <returns></returns>
  26. [Obsolete]
  27. public async Task<dynamic> GetPassengerFlow(ClassRoomCallTaskSearchRequest search)
  28. {
  29. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  30. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/attendance/data/query"
  31. .SetBody(new
  32. {
  33. token = _deepelephManager.GetToken(),
  34. tenantCode = appSettings.TenantCode,
  35. poiId = appSettings.PoiId,
  36. startTime = new DateTimeOffset(search.startTime).ToUnixTimeMilliseconds(),
  37. endTime = new DateTimeOffset(search.endTime).ToUnixTimeMilliseconds(),
  38. cameraId = search.cameraId,
  39. pageIndex = search.PageNum,
  40. pageSize = search.PageSize,
  41. })
  42. .SetContentType("application/json")
  43. .PostAsAsync<string>();
  44. var model = JsonConvert.DeserializeObject<JObject>(str);
  45. if (!(bool)model["success"]) throw Oops.Oh(model["message"].ToString());
  46. if (model["data"] != null)
  47. {
  48. return new
  49. {
  50. pageNum = search.PageNum,
  51. pageSize = model["data"]["size"],
  52. total = model["data"]["total"],
  53. pages = model["data"]["pages"],
  54. list = model["data"]["items"]
  55. };
  56. }
  57. return new
  58. {
  59. pageNum = search.PageNum,
  60. pageSize = 0,
  61. total = 0,
  62. pages = 0,
  63. list = new List<string>()
  64. };
  65. }
  66. /// <summary>
  67. /// 添加考勤记录
  68. /// </summary>
  69. /// <param name="input"></param>
  70. /// <returns></returns>
  71. public async Task<bool> Add(List<AttendanceAddInput> input)
  72. {
  73. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  74. foreach (var attendanceAddInput in input)
  75. {
  76. var vm = new AttendanceDto
  77. {
  78. CreateTime = DateTime.Now,
  79. TenantCode = appSettings.TenantCode,
  80. FaceScore = 100,
  81. IsAuto = false,
  82. PersonSetId = attendanceAddInput.PersonSetId,
  83. PersonId = attendanceAddInput.PersonId,
  84. PoiId = appSettings.PoiId,
  85. Tick = attendanceAddInput.Tick,
  86. Similarity = 100,
  87. EventId = "",
  88. CameraId = "",
  89. Extend = "",
  90. TrackId = "",
  91. SnapshotUrl = "",
  92. SnapshotData = "",
  93. Rects = ""
  94. };
  95. await _attendanceService.Add(vm);
  96. }
  97. return true;
  98. }
  99. /// <summary>
  100. /// 分页获取考勤列表
  101. /// </summary>
  102. /// <param name="search"></param>
  103. /// <returns></returns>
  104. public async Task<SqlSugarPagedList<AttendanceList>> GetPageList(AttendanceSearch search)
  105. {
  106. return await _attendanceService.GetPageList(search);
  107. }
  108. /// <summary>
  109. /// 不分页获取考勤列表
  110. /// </summary>
  111. /// <param name="search"></param>
  112. /// <returns></returns>
  113. public async Task<List<AttendanceList>> GetNoPageList(AttendanceSearch search)
  114. {
  115. return await _attendanceService.GetNoPageList(search);
  116. }
  117. /// <summary>
  118. /// 根据宿舍楼id获取出入记录
  119. /// </summary>
  120. /// <param name="search"></param>
  121. /// <returns></returns>
  122. public async Task<SqlSugarPagedList<AttendanceList>> GetPageListByBuild(BuildAttendanceSearch search)
  123. {
  124. return await _attendanceService.GetPageListByBuild(search);
  125. }
  126. }