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

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