diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index 40c04983..330090d3 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -116,11 +116,11 @@ public class DevicePermissionService : IDevicePermissionService public async Task AssignDeviceToDepartmentAsync(string currentTenantId, bool isAll, List deviceCodes, DevicePermissionSaveRequest request) { - request.AssignValue = request.TenantId + ":" + request.AssignValue; + var departmentValue = request.TenantId + ":" + request.AssignValue; var p = await _dbContext.Queryable() .Where(x => x.AssignType == AssignTypeEnumType.Department) - .Where(x => x.AssignValue == request.AssignValue) + .Where(x => x.AssignValue == departmentValue) .Where(x => x.UniqueType == request.UniqueType) .WhereIF(!isAll, x => deviceCodes.Contains(x.UniqueValue)) .Where(x => x.Type == request.Type) @@ -209,7 +209,7 @@ public class DevicePermissionService : IDevicePermissionService }).ToList()); } - foreach (var items in tasks.Chunk(500)) + foreach (var items in tasks.Where(x => x.Type == DeviceTaskEnumType.Add).Chunk(500)) { await _dbContext.InsertAsync(items.ToList()); } @@ -224,11 +224,11 @@ public class DevicePermissionService : IDevicePermissionService public async Task AssignDeviceGroupToDepartmentAsync(string currentTenantId, DevicePermissionSaveRequest request) { - request.AssignValue = request.TenantId + ":" + request.AssignValue; + var departmentValue = request.TenantId + ":" + request.AssignValue; var groupData = await _dbContext.Queryable() .Where(x => x.AssignType == AssignTypeEnumType.Department) - .Where(x => x.AssignValue == request.AssignValue) + .Where(x => x.AssignValue == departmentValue) .Where(x => x.UniqueType == request.UniqueType) .Where(x => x.Type == request.Type) .Where(x => x.TenantId == currentTenantId) @@ -307,7 +307,7 @@ public class DevicePermissionService : IDevicePermissionService }).ToList()); } - foreach (var items in tasks.Chunk(500)) + foreach (var items in tasks.Where(x => x.Type == DeviceTaskEnumType.Add).Chunk(500)) { await _dbContext.InsertAsync(items.ToList()); } @@ -423,7 +423,7 @@ public class DevicePermissionService : IDevicePermissionService }).ToList()); } - foreach (var items in tasks.Chunk(500)) + foreach (var items in tasks.Where(x => x.Type == DeviceTaskEnumType.Add).Chunk(500)) { await _dbContext.InsertAsync(items.ToList()); } @@ -512,7 +512,7 @@ public class DevicePermissionService : IDevicePermissionService }).ToList()); } - foreach (var items in tasks.Chunk(500)) + foreach (var items in tasks.Where(x => x.Type == DeviceTaskEnumType.Add).Chunk(500)) { await _dbContext.InsertAsync(items.ToList()); }