diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index 1de491b8..8d3fb5eb 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -119,7 +119,7 @@ public class DevicePermissionService : IDevicePermissionService public async Task> GetAssignmentsAsync(DeviceGetAssignmentsRequest request) { - var currentTenantId = request.TenantId ??= _currentUser.GetStringTenantId(); + var currentTenantId = request.AssignType == AssignTypeEnumType.Department ? request.TenantId : _currentUser.GetStringTenantId(); var role = _currentUser.GetRole(); var isAll = role is "admin" or "tenant-admin"; var deviceCodes = _myDataPermissionService.GetMyDeviceCodes(); diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceTimePeriodService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceTimePeriodService.cs index 1ab79451..aa8be63b 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceTimePeriodService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceTimePeriodService.cs @@ -87,7 +87,27 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService /// public async Task> GetListAsync(DeviceTimePeriodAssignEnumType assignType, Guid value) { - return await _dbContext.Queryable().Where(x => x.AssignType == assignType && x.Value == value).Select().ToListAsync(); + var data = await _dbContext.Queryable() + .Where(x => x.AssignType == assignType && x.Value == value) + .Select() + .ToListAsync(); + + var result = data.Adapt>(); + + var values = data.Select(x => x.Value); + var assignData = assignType == DeviceTimePeriodAssignEnumType.Device + ? await _dbContext.Queryable().Where(x => values.Contains(x.Code)).Select(x => new { x.Code, Name = x.DeployPlace }).ToListAsync() + : await _dbContext.Queryable().Where(x => values.Contains(x.Code)).Select(x => new { x.Code, x.Name }).ToListAsync(); + + var basicTypes = await _dbContext.Queryable().Where(x => x.Type == "timeperiod").ToListAsync(); + + result.ForEach(item => + { + item.Name = assignData.FirstOrDefault(x => x.Code == item.Value)?.Name; + item.CardTypeDesc = basicTypes.FirstOrDefault(x => x.Code == item.CardType.ToString())?.Display; + }); + + return result; } @@ -162,7 +182,7 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService Priority = 90, TenantId = device.TenantId }); - + break; } }