fix 处理设备分组优化
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Dlhis.DataPermission.Model;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
@@ -52,20 +53,24 @@ public class GetDataPermissionService : IGetDataPermissions, ISingletonDependenc
|
||||
|
||||
//先计算分组权限下的设备
|
||||
var deviceGroupCodes = userDataPermissions.Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Group).Select(x => x.UniqueValue).ToList();
|
||||
if (deviceGroupCodes.Any() && deviceCodeProperty != null)
|
||||
if (deviceGroupCodes.Any())
|
||||
{
|
||||
var data = db.Queryable<DeviceGroupEntity>().ToList();
|
||||
//开始递归处理
|
||||
var tops = data.Where(x => !x.PCode.HasValue).ToList();
|
||||
tops.ForEach(x => { DeviceGroupRecursionGetNext(x, data, deviceGroupCodes, deviceGroupCodes.Contains(x.Code)); });
|
||||
deviceGroupCodes = deviceGroupCodes.Distinct().ToList();
|
||||
|
||||
if (deviceCodeProperty != null)
|
||||
{
|
||||
deviceCodes = db.Queryable<DeviceGroupRelationshipEntity>().Where(x => deviceGroupCodes.Contains(x.GroupCode)).Select(x => x.DeviceCode).ToList();
|
||||
}
|
||||
|
||||
if (deviceGroupCodeProperty != null && deviceGroupCodes.Any())
|
||||
if (deviceGroupCodeProperty != null)
|
||||
{
|
||||
dict.Add(deviceGroupCodeProperty.Name, deviceGroupCodes);
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceCodeProperty != null)
|
||||
{
|
||||
|
||||
@@ -43,11 +43,12 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
.Select<DeviceGroupTreeResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
var others = await _dbContext.Queryable<DeviceGroupEntity>()
|
||||
var others = await _dbContext.Client.Queryable<DeviceGroupEntity>()
|
||||
.Where(x => x.Type == type)
|
||||
.Where(x => x.Name == "*共用区域" || x.Name == "*非共用区域" || x.Name == "*通用考勤设备组" || x.Name == "*专用考勤设备组")
|
||||
.Select<DeviceGroupTreeResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
deviceGroups.AddRange(others);
|
||||
|
||||
var tops = deviceGroups.Where(x => !x.PCode.HasValue).ToList();
|
||||
@@ -167,7 +168,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<DeviceGroupEntity> CheckPCodeAsync(DeviceGroupSaveRequest request)
|
||||
private async Task CheckPCodeAsync(DeviceGroupSaveRequest request)
|
||||
{
|
||||
var pGrp = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Code == request.PCode).FirstAsync();
|
||||
if (pGrp != null)
|
||||
@@ -178,7 +179,6 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
}
|
||||
|
||||
(pGrp != null && pGrp.Type != request.Type).ThrowIfTrue("分组类型必须与上级类型保持一致");
|
||||
return pGrp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes;
|
||||
|
||||
namespace Dlhis.Basic.DataPermissions;
|
||||
namespace Dlhis.DataPermission.Model;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class DeviceCodeAttribute : BaseDataPermissionAttribute
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes;
|
||||
|
||||
namespace Dlhis.Basic.DataPermissions;
|
||||
namespace Dlhis.DataPermission.Model;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class DeviceGroupCodeAttribute : BaseDataPermissionAttribute
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Dlhis.Basic.DataPermissions;
|
||||
using Dlhis.DataPermission.Model;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||
|
||||
Reference in New Issue
Block a user