This commit is contained in:
cheche
2024-03-11 17:48:47 +08:00
parent fff0928a86
commit 90e5728fd3
3 changed files with 59 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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);
}
}