fix 补充设备分组
This commit is contained in:
@@ -44,8 +44,38 @@ public class GetDataPermissionService : IGetDataPermissions, ISingletonDependenc
|
|||||||
.GetProperties()
|
.GetProperties()
|
||||||
.FirstOrDefault(x => x.IsDefined(typeof(DeviceCodeAttribute), false));
|
.FirstOrDefault(x => x.IsDefined(typeof(DeviceCodeAttribute), false));
|
||||||
|
|
||||||
|
var deviceGroupCodeProperty = typeof(T)
|
||||||
|
.GetProperties()
|
||||||
|
.FirstOrDefault(x => x.IsDefined(typeof(DeviceGroupCodeAttribute), false));
|
||||||
|
|
||||||
|
|
||||||
var deviceCodes = new List<Guid>();
|
var deviceCodes = new List<Guid>();
|
||||||
|
|
||||||
|
//先计算分组权限下的设备
|
||||||
|
var deviceGroupCodes = userDataPermissions.Where(x => x.UniqueType == DataPermissionAssignmentEnumType.Group).Select(x => x.UniqueValue).ToList();
|
||||||
|
if (deviceGroupCodes.Any())
|
||||||
|
{
|
||||||
|
var data = db.Queryable<DeviceGroupEntity>().ToList();
|
||||||
|
|
||||||
|
var myCodes = new List<Guid>();
|
||||||
|
foreach (Guid deviceGroupCode in deviceGroupCodes)
|
||||||
|
{
|
||||||
|
myCodes.AddRange(RecursionHelper.HandlerDeviceGroupNextCodes(deviceGroupCode, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
myCodes = myCodes.Distinct().ToList();
|
||||||
|
|
||||||
|
if (deviceCodeProperty != null)
|
||||||
|
{
|
||||||
|
deviceCodes = db.Queryable<DeviceGroupRelationshipEntity>().Where(x => myCodes.Contains(x.GroupCode)).Select(x => x.DeviceCode).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceGroupCodeProperty != null)
|
||||||
|
{
|
||||||
|
dict.Add(deviceGroupCodeProperty.Name, deviceGroupCodes);
|
||||||
|
}
|
||||||
|
|
||||||
if (deviceCodeProperty != null)
|
if (deviceCodeProperty != null)
|
||||||
{
|
{
|
||||||
var currentDeviceCodes = userDataPermissions.Where(x => x.UniqueType == DataPermissionAssignmentEnumType.Device).Select(x => x.UniqueValue).ToList();
|
var currentDeviceCodes = userDataPermissions.Where(x => x.UniqueType == DataPermissionAssignmentEnumType.Device).Select(x => x.UniqueValue).ToList();
|
||||||
|
|||||||
27
Src/Dlhis.ScheduledTask/RecursionHelper.cs
Normal file
27
Src/Dlhis.ScheduledTask/RecursionHelper.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Dlhis.Entity.Basic.Entity;
|
||||||
|
using Dlhis.Entity.Device.Entities;
|
||||||
|
|
||||||
|
namespace Dlhis.ScheduledTask;
|
||||||
|
|
||||||
|
public static class RecursionHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
public static List<Guid> HandlerDeviceGroupNextCodes(Guid current, List<DeviceGroupEntity> data)
|
||||||
|
{
|
||||||
|
var result = new List<Guid> { current };
|
||||||
|
|
||||||
|
InternalHandlerCodes(current, data, result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
static void InternalHandlerCodes(Guid internalCurrent, List<DeviceGroupEntity> internalData, List<Guid> internalResult)
|
||||||
|
{
|
||||||
|
var next = internalData.Where(x => x.PCode == internalCurrent);
|
||||||
|
foreach (var item in next)
|
||||||
|
{
|
||||||
|
internalResult.Add(item.Code);
|
||||||
|
InternalHandlerCodes(item.Code, internalData, internalResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user