diff --git a/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs index b3a8c9f6..8d9feb6a 100644 --- a/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs +++ b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs @@ -140,8 +140,8 @@ public class AppointmentsController : ControllerBase end = start.Date.AddDays(1).AddMilliseconds(-1); return await _appointmentService.GetSummaryAsync(factory, start, end); } - - + + /// /// 自动离职处理 /// @@ -152,4 +152,13 @@ public class AppointmentsController : ControllerBase { await _appointmentService.AutoResignAsync(); } + + [AllowAnonymous] + [IgnoreTenant] + [HttpGet("visitor-devices")] + public async Task> GetVisitorDevicesAsync(long detailId) + { + return await _appointmentService.GetVisitorDevicesAsync(detailId); + ; + } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs index d447469d..6ce15473 100644 --- a/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs +++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs @@ -72,4 +72,6 @@ public interface IAppointmentService : IScopeDependency /// /// Task AutoResignAsync(); + + Task> GetVisitorDevicesAsync(long detailId); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs index 6e09aaeb..ab458ec4 100644 --- a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs +++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs @@ -318,6 +318,28 @@ public class AppointmentService : IAppointmentService await GenerateDeviceTasksAsync(detail, true, DeviceTaskEnumType.Update, "访客手动上传照片"); } + public async Task> GetVisitorDevicesAsync(long detailId) + { + var detail = await _dbContext.Queryable().Where(x => x.Id == detailId).SingleAsync(); + detail.ThrowIfNull("数据不存在"); + + var areaCodes = GetValidAreaCodes(detail, false).ToList(); + if (areaCodes.IsEmpty()) return new List(); + + var existsAreaCodes = await _dbContext.Queryable().Where(x => areaCodes.Contains(x.CustomCode)).Select(x => x.CustomCode).ToListAsync(); + + //当前分配的设备组code + var deviceGroupCodes = await _dbContext.Queryable() + .Where(x => existsAreaCodes.Contains(x.CustomCode)) + .Select(x => x.DeviceGroupCode) + .ToListAsync(); + + var deviceCodes = await _dbContext.Queryable().Where(x => deviceGroupCodes.Contains(x.GroupCode)).Select(x => x.DeviceCode).ToListAsync(); + var deviceUniqueNos = await _dbContext.Queryable().Where(x => deviceCodes.Contains(x.Code)).Select(x => x.UniqueNo).ToListAsync(); + + return deviceUniqueNos; + } + /// public async Task AutoResignAsync() {