From d27aa2e007048fe2997b63c397ad1c59aeb2ad6d Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 22 Jul 2024 15:38:27 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=9F=A5=E8=AF=A2json=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/DevicePermissionService.cs | 2 +- .../Implements/DeviceTimePeriodService.cs | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) 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; } }