add 获取访客门禁设备权限

This commit is contained in:
2025-05-26 14:08:52 +08:00
parent ac88ae7a3b
commit 6528d29404
3 changed files with 35 additions and 2 deletions

View File

@@ -152,4 +152,13 @@ public class AppointmentsController : ControllerBase
{
await _appointmentService.AutoResignAsync();
}
[AllowAnonymous]
[IgnoreTenant]
[HttpGet("visitor-devices")]
public async Task<List<string>> GetVisitorDevicesAsync(long detailId)
{
return await _appointmentService.GetVisitorDevicesAsync(detailId);
;
}
}

View File

@@ -72,4 +72,6 @@ public interface IAppointmentService : IScopeDependency
/// </summary>
/// <returns></returns>
Task AutoResignAsync();
Task<List<string>> GetVisitorDevicesAsync(long detailId);
}

View File

@@ -318,6 +318,28 @@ public class AppointmentService : IAppointmentService
await GenerateDeviceTasksAsync(detail, true, DeviceTaskEnumType.Update, "访客手动上传照片");
}
public async Task<List<string>> GetVisitorDevicesAsync(long detailId)
{
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>().Where(x => x.Id == detailId).SingleAsync();
detail.ThrowIfNull("数据不存在");
var areaCodes = GetValidAreaCodes(detail, false).ToList();
if (areaCodes.IsEmpty()) return new List<string>();
var existsAreaCodes = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => areaCodes.Contains(x.CustomCode)).Select(x => x.CustomCode).ToListAsync();
//当前分配的设备组code
var deviceGroupCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
.Where(x => existsAreaCodes.Contains(x.CustomCode))
.Select(x => x.DeviceGroupCode)
.ToListAsync();
var deviceCodes = await _dbContext.Queryable<DeviceGroupRelationshipEntity>().Where(x => deviceGroupCodes.Contains(x.GroupCode)).Select(x => x.DeviceCode).ToListAsync();
var deviceUniqueNos = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceCodes.Contains(x.Code)).Select(x => x.UniqueNo).ToListAsync();
return deviceUniqueNos;
}
/// <inheritdoc />
public async Task AutoResignAsync()
{