fix 通过设备查询人员详情
This commit is contained in:
@@ -78,6 +78,7 @@ public class DevicePermissionsController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("gainfos/page")]
|
||||
[CrossTenant]
|
||||
public async Task<Pagination<DeviceGainfoResponse>> GetGainfoPageByDeviceAsync([FromQuery] DeviceWithGainfoRequest request)
|
||||
{
|
||||
return await _devicePermissionService.GetGainfoPageByDeviceAsync(request);
|
||||
|
||||
@@ -364,6 +364,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
public async Task<Pagination<DeviceGainfoResponse>> GetGainfoPageByDeviceAsync(DeviceWithGainfoRequest request)
|
||||
{
|
||||
var device = await _dbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync();
|
||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
||||
|
||||
//当前设备的分组
|
||||
var groups = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||
@@ -394,7 +395,14 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
break;
|
||||
case AssignTypeEnumType.Department:
|
||||
{
|
||||
ids.AddRange(await _dbContext.Queryable<GainfoEntity>().Where(x => x.DepartmentNo == permission.AssignValue).Select(x => x.Id).ToListAsync());
|
||||
//递归向上获取 assignValue = department.No
|
||||
var arr = permission.AssignValue.Split(":");
|
||||
var tenantId = arr.First();
|
||||
var currentDepartmentNo = arr.Last();
|
||||
var departmentNos = new List<string> { currentDepartmentNo };
|
||||
DepartmentRecursionGetPNo(currentDepartmentNo, departments, departmentNos);
|
||||
|
||||
ids.AddRange(await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == tenantId && departmentNos.Contains(x.DepartmentNo)).Select(x => x.Id).ToListAsync());
|
||||
}
|
||||
break;
|
||||
case AssignTypeEnumType.Tenant:
|
||||
@@ -450,6 +458,16 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
});
|
||||
|
||||
return page;
|
||||
|
||||
void DepartmentRecursionGetPNo(string current, List<DepartmentEntity> data, List<string> result)
|
||||
{
|
||||
var p = data.FirstOrDefault(x => x.No == current)?.PNo;
|
||||
if (p.IsPresent())
|
||||
{
|
||||
result.Add(p);
|
||||
DepartmentRecursionGetPNo(p, data, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GenerateDeviceTasksAsync(string userNo, DeviceTaskEnumType taskType, DeviceTaskSourceEnumType source)
|
||||
|
||||
Reference in New Issue
Block a user