|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using Dm;
-
- namespace SafeCampus.Application.Services.Business.ClassRoomCallService;
-
- public class ClassRoomCallService : DbRepository<ClassRoomCall>, IClassRoomCallService
- {
- public async Task<bool> Add(ClassRoomCallDto input)
- {
- var model = input.Adapt<ClassRoomCall>();
- if (string.IsNullOrEmpty(model.PersonId))
- {
- if (await IsAnyAsync(x => x.TaskId == model.TaskId && x.PersonId == model.PersonId && x.PersonSetId == model.PersonSetId))
- {
- //该批次点名任务已经出现过这个人,不在重复添加
- return true;
- }
- }
- else
- {
- if (await IsAnyAsync(x=>x.TaskId==model.TaskId&&x.TrackId==model.TrackId))
- {
- //没有匹配到人员,但是所属同一跟踪id
- //该批次点名任务已经出现过这个人,不在重复添加
- return true;
- }
- }
- await InsertAsync(model);
- return true;
- }
-
- public async Task<bool> Update(ClassRoomCallUpdate input)
- {
- var model = await GetFirstAsync(p => p.Id == input.Id);
- if (model == null)
- {
- throw Oops.Oh("信息不存在");
- }
- //var res = input.Adapt(model);
- model.PersonSetId = input.PersonSetId;
- model.PersonId = input.PersonId;
- await Context.Updateable(model)
- .UpdateColumns(x => new
- {
- x.PersonSetId,
- x.PersonId
- })
- .ExecuteCommandAsync();
- //await UpdateAsync(model);
- return true;
- }
-
- public async Task<bool> Remove(long id)
- {
- var model = await GetFirstAsync(x => x.Id == id);
- if (model == null)
- {
- throw Oops.Oh("信息不存在");
- }
- await DeleteAsync(model);
- return true;
- }
-
- public async Task<SqlSugarPagedList<ClassRoomCallList>> GetPageList(ClassRoomCallSearch search)
- {
- var query = Context.Queryable<ClassRoomCall>()
- .Includes(x => x.CameraInfoItem)
- .WhereIF(!string.IsNullOrEmpty(search.AlarmType), x => x.AlarmType == search.AlarmType)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
- .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
- .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
- .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
- .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
-
- var list = await query.OrderByDescending(x => x.Tick)
- .ToPagedListAsyncMapster<ClassRoomCall, ClassRoomCallList>(search.PageNum, search.PageSize);
- return list;
- }
-
- public async Task<List<ClassRoomCallList>> GetNoPageList(ClassRoomCallSearch search)
- {
- var query = Context.Queryable<ClassRoomCall>()
- .Includes(x => x.CameraInfoItem)
- .WhereIF(!string.IsNullOrEmpty(search.AlarmType), x => x.AlarmType == search.AlarmType)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
- .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
- .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
- .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
- .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
-
- var list = await query.OrderByDescending(x => x.Tick)
- .ToListAsync();
- return list.Adapt<List<ClassRoomCallList>>();
- }
- }
|