平安校园
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

62 行
3.0 KiB

  1. namespace SafeCampus.Application.Services.Business.AttendanceService;
  2. public class AttendanceService:DbRepository<Attendance>, IAttendanceService
  3. {
  4. public async Task<bool> Add(AttendanceDto input)
  5. {
  6. var model = input.Adapt<Attendance>();
  7. //if (string.IsNullOrEmpty(model.PersonId))
  8. //{
  9. // if (await IsAnyAsync(x => x.TaskId == model.TaskId && x.PersonId == model.PersonId && x.PersonSetId == model.PersonSetId))
  10. // {
  11. // //该批次点名任务已经出现过这个人,不在重复添加
  12. // return true;
  13. // }
  14. //}
  15. //else
  16. //{
  17. // if (await IsAnyAsync(x => x.TaskId == model.TaskId && x.TrackId == model.TrackId))
  18. // {
  19. // //没有匹配到人员,但是所属同一跟踪id
  20. // //该批次点名任务已经出现过这个人,不在重复添加
  21. // return true;
  22. // }
  23. //}
  24. await InsertAsync(model);
  25. return true;
  26. }
  27. public async Task<SqlSugarPagedList<AttendanceList>> GetPageList(AttendanceSearch search)
  28. {
  29. var query = Context.Queryable<Attendance>()
  30. //.Includes(x => x.CameraInfoItem)
  31. .WhereIF(search.IsAuto.HasValue, x => x.IsAuto == search.IsAuto)
  32. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  33. .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
  34. .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
  35. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  36. .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
  37. .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
  38. var list = await query.OrderByDescending(x => x.Tick)
  39. .ToPagedListAsyncMapster<Attendance, AttendanceList>(search.PageNum, search.PageSize);
  40. return list;
  41. }
  42. public async Task<List<AttendanceList>> GetNoPageList(AttendanceSearch search)
  43. {
  44. var query = Context.Queryable<Attendance>()
  45. //.Includes(x => x.CameraInfoItem)
  46. .WhereIF(search.IsAuto.HasValue, x => x.IsAuto == search.IsAuto)
  47. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  48. .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
  49. .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
  50. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  51. .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
  52. .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
  53. var list = await query.OrderByDescending(x => x.Tick)
  54. .ToListAsync();
  55. return list.Adapt<List<AttendanceList>>();
  56. }
  57. }