平安校园
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ClassRoomCallService.cs 4.0 KiB

2 个月前
4 个月前
3 个月前
4 个月前
3 个月前
3 个月前
3 个月前
3 个月前
4 个月前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using Dm;
  2. namespace SafeCampus.Application.Services.Business.ClassRoomCallService;
  3. public class ClassRoomCallService : DbRepository<ClassRoomCall>, IClassRoomCallService
  4. {
  5. public async Task<bool> Add(ClassRoomCallDto input)
  6. {
  7. var model = input.Adapt<ClassRoomCall>();
  8. if (string.IsNullOrEmpty(model.PersonId))
  9. {
  10. if (await IsAnyAsync(x => x.TaskId == model.TaskId && x.PersonId == model.PersonId && x.PersonSetId == model.PersonSetId))
  11. {
  12. //该批次点名任务已经出现过这个人,不在重复添加
  13. return true;
  14. }
  15. }
  16. else
  17. {
  18. if (await IsAnyAsync(x=>x.TaskId==model.TaskId&&x.TrackId==model.TrackId))
  19. {
  20. //没有匹配到人员,但是所属同一跟踪id
  21. //该批次点名任务已经出现过这个人,不在重复添加
  22. return true;
  23. }
  24. }
  25. await InsertAsync(model);
  26. return true;
  27. }
  28. public async Task<bool> Update(ClassRoomCallUpdate input)
  29. {
  30. var model = await GetFirstAsync(p => p.Id == input.Id);
  31. if (model == null)
  32. {
  33. throw Oops.Oh("信息不存在");
  34. }
  35. //var res = input.Adapt(model);
  36. model.PersonSetId = input.PersonSetId;
  37. model.PersonId = input.PersonId;
  38. await Context.Updateable(model)
  39. .UpdateColumns(x => new
  40. {
  41. x.PersonSetId,
  42. x.PersonId
  43. })
  44. .ExecuteCommandAsync();
  45. //await UpdateAsync(model);
  46. return true;
  47. }
  48. public async Task<bool> Remove(long id)
  49. {
  50. var model = await GetFirstAsync(x => x.Id == id);
  51. if (model == null)
  52. {
  53. throw Oops.Oh("信息不存在");
  54. }
  55. await DeleteAsync(model);
  56. return true;
  57. }
  58. public async Task<SqlSugarPagedList<ClassRoomCallList>> GetPageList(ClassRoomCallSearch search)
  59. {
  60. var query = Context.Queryable<ClassRoomCall>()
  61. .Includes(x => x.CameraInfoItem)
  62. .WhereIF(!string.IsNullOrEmpty(search.AlarmType), x => x.AlarmType == search.AlarmType)
  63. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  64. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  65. .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
  66. .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
  67. .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
  68. .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
  69. .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
  70. var list = await query.OrderByDescending(x => x.Tick)
  71. .ToPagedListAsyncMapster<ClassRoomCall, ClassRoomCallList>(search.PageNum, search.PageSize);
  72. return list;
  73. }
  74. public async Task<List<ClassRoomCallList>> GetNoPageList(ClassRoomCallSearch search)
  75. {
  76. var query = Context.Queryable<ClassRoomCall>()
  77. .Includes(x => x.CameraInfoItem)
  78. .WhereIF(!string.IsNullOrEmpty(search.AlarmType), x => x.AlarmType == search.AlarmType)
  79. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  80. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  81. .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
  82. .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
  83. .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
  84. .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
  85. .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
  86. var list = await query.OrderByDescending(x => x.Tick)
  87. .ToListAsync();
  88. return list.Adapt<List<ClassRoomCallList>>();
  89. }
  90. }