diff --git a/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs
index a286e912..cfb31653 100644
--- a/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs
+++ b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs
@@ -18,11 +18,11 @@ public class AppointmentAreasController : ControllerBase
{
private readonly IAppointmentAreaService _appointmentAreaService;
- public AppointmentAreasController(IAppointmentAreaService appointmentAreaService )
+ public AppointmentAreasController(IAppointmentAreaService appointmentAreaService)
{
_appointmentAreaService = appointmentAreaService;
}
-
+
///
/// 保存
///
@@ -55,4 +55,16 @@ public class AppointmentAreasController : ControllerBase
{
await _appointmentAreaService.AssignAsync(request);
}
-}
+
+ ///
+ /// 获取当前分配
+ ///
+ ///
+ ///
+ [HttpGet("assignments")]
+ [Transactional]
+ public async Task> GetAssignmentsAsync(string customCode)
+ {
+ return await _appointmentAreaService.GetAssignmentsAsync(customCode);
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs
index aec22aaf..112cf6b8 100644
--- a/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs
@@ -11,7 +11,7 @@ public class AppointmentAreaAssignRequest
public string CustomCode { get; set; }
///
- /// 分组
+ /// 设备分组
///
- public List DeviceCodes { get; set; }
+ public List DeviceGroupCodes { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs
index 90fb0727..b416599f 100644
--- a/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs
+++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs
@@ -26,4 +26,11 @@ public interface IAppointmentAreaService : IScopeDependency
///
///
Task AssignAsync(AppointmentAreaAssignRequest request);
+
+ ///
+ /// 获取分配
+ ///
+ ///
+ ///
+ Task> GetAssignmentsAsync(string customCode);
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs
index 74e36c98..d6778125 100644
--- a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs
+++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs
@@ -54,6 +54,12 @@ public class AppointmentAreaService : IAppointmentAreaService
(await _dbContext.Queryable().Where(x => x.CustomCode == request.CustomCode).AnyAsync())
.ThrowIfFalse("区域不存在");
+ (await _dbContext.Queryable()
+ .Where(x => request.DeviceGroupCodes.Contains(x.Code))
+ .Where(x => x.AsAppointment == false)
+ .AnyAsync())
+ .ThrowIfTrue("存在非可设置访客预约的分组");
+
var userBeforePermissions = await GetMyPermissionsAsync(request.CustomCode);
var userNos = userBeforePermissions.Select(x => x.Key).ToList();
@@ -63,10 +69,10 @@ public class AppointmentAreaService : IAppointmentAreaService
.ExecuteCommandAsync();
//添加当前区域的设置
- var data = request.DeviceCodes.Select(x => new AppointmentAreaAssignmentEntity
+ var data = request.DeviceGroupCodes.Select(x => new AppointmentAreaAssignmentEntity
{
CustomCode = request.CustomCode,
- DeviceCode = x
+ DeviceGroupCode = x
}).ToList();
await _dbContext.InsertAsync(data);
@@ -122,6 +128,14 @@ public class AppointmentAreaService : IAppointmentAreaService
await _dbContext.InsertAsync(tasks);
}
+ ///
+ public async Task> GetAssignmentsAsync(string customCode)
+ {
+ return await _dbContext.Queryable()
+ .Where(x => x.CustomCode == customCode).Select(x => x.DeviceGroupCode)
+ .ToListAsync();
+ }
+
//********************************************************* help methods ***************************************************************
@@ -167,9 +181,15 @@ public class AppointmentAreaService : IAppointmentAreaService
var userBeforePermissions = new Dictionary>(userAreaCodes.Count);
foreach ((string currentUserNo, IEnumerable currentUseAreaCode) in userAreaCodes)
{
- var deviceCodes = await _dbContext.Queryable()
+ var deviceGroupCodes = await _dbContext.Queryable()
.Where(x => currentUseAreaCode.Contains(x.CustomCode))
+ .Select(x => x.DeviceGroupCode)
+ .ToListAsync();
+
+ var deviceCodes = await _dbContext.Queryable()
+ .Where(x => deviceGroupCodes.Contains(x.GroupCode))
.Select(x => x.DeviceCode)
+ .Distinct()
.ToListAsync();
userBeforePermissions.Add(currentUserNo, deviceCodes);
diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs
index ab32b99e..dc33b6a2 100644
--- a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs
+++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs
@@ -53,12 +53,13 @@ public class AppointmentService : IAppointmentService
var areaCodes = GetValidAreaCodes(detail);
var existsAreaCodes = await _dbContext.Queryable().Where(x => areaCodes.Contains(x.CustomCode)).Select(x => x.CustomCode).ToListAsync();
- //当前分配的设备codes
- var deviceCodes = await _dbContext.Queryable()
+ //当前分配的设备组code
+ var deviceGroupCodes = await _dbContext.Queryable()
.Where(x => existsAreaCodes.Contains(x.CustomCode))
- .Select(x => x.DeviceCode)
+ .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 => new { x.UniqueNo, x.TenantId }).ToListAsync();
await _dbContext.InsertAsync(deviceUniqueNos.Select(x => new DeviceTaskEntity
diff --git a/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs
index 82dc7a05..0d9ac1eb 100644
--- a/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs
+++ b/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs
@@ -19,8 +19,8 @@ public class AppointmentAreaAssignmentEntity : SugarBaseEntity, ITenantId
///
/// 设备code
///
- [SugarColumn(IsNullable = false, ColumnDescription = "设备code")]
- public Guid DeviceCode { get; set; }
+ [SugarColumn(IsNullable = false, ColumnDescription = "设备组Code")]
+ public Guid DeviceGroupCode { get; set; }
[SugarColumn]