feat aa
This commit is contained in:
@@ -28,4 +28,15 @@ public class GainfoPermissionsController : ControllerBase
|
||||
{
|
||||
return await _gainfoPermissions.GetPlaceByGainfoAsync(userNo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据档案号 设备组查询设备
|
||||
/// </summary>
|
||||
/// <param name="userNo"></param>
|
||||
/// <param name="deviceGroupCode"></param>
|
||||
/// <returns></returns>
|
||||
public async Task GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode)
|
||||
{
|
||||
return await _gainfoPermissions.GetDevicesUnderGroupByUserNoAsync(userNo,deviceGroupCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ public interface IGainfoPermissions : IScopeDependency
|
||||
{
|
||||
Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(string userNo);
|
||||
|
||||
//Task GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode);
|
||||
Task GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dm.filter.rw;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
@@ -47,6 +50,50 @@ public class GainfoPermissions : IGainfoPermissions
|
||||
})
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode)
|
||||
{;
|
||||
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>().ToListAsync();
|
||||
|
||||
var currentGroup = deviceGroups.Where(x => x.Code.ToString() == deviceGroupCode).First();
|
||||
|
||||
var groups = new List<Guid>();
|
||||
if(!currentGroup.PCode.HasValue)
|
||||
{
|
||||
RecursionGetNext(currentGroup, deviceGroups, groups);
|
||||
}
|
||||
else
|
||||
{
|
||||
groups.Add((Guid)currentGroup.PCode);
|
||||
}
|
||||
|
||||
var gs = await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => groups.Contains(x.UniqueValue))
|
||||
.Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Group)
|
||||
.Where(x => x.AssignType == AssignTypeEnumType.User)
|
||||
.Where(x => x.AssignValue == userNo)
|
||||
.Select(x => x.UniqueValue)
|
||||
.ToListAsync();
|
||||
|
||||
var lst = new List<Guid>();
|
||||
foreach (var gcode in gs)
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||
.Where(x => x.GroupCode == gcode)
|
||||
.Select(x => x.DeviceCode)
|
||||
.ToListAsync();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void RecursionGetNext(DeviceGroupEntity current, List<DeviceGroupEntity> deviceGroups,List<Guid> res)
|
||||
{
|
||||
var next = deviceGroups.Where(x => x.PCode == current.Code).ToList();
|
||||
foreach (var item in next)
|
||||
{
|
||||
RecursionGetNext(item, deviceGroups,res);
|
||||
}
|
||||
res.Add(current.Code);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user