fix 查询人员权限
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Dtos;
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
@@ -118,27 +119,39 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<Pagination<DevicePageResponse>> GetAssignDeviceCodesAsync(DeviceAssRequest request)
|
||||
public async Task<Pagination<GainfoDevicePermissionResponse>> GetAssignDeviceCodesAsync(DeviceAssRequest request)
|
||||
{
|
||||
var ids = await _devicePermissionAnalyzeService.GetAssignDeviceCodesAsync(request.UserNo);
|
||||
var result = await _devicePermissionAnalyzeService.GetUserAssignDeviceCodesWithTypeInTenantAsync(new List<string> { request.UserNo });
|
||||
var permissions = result[request.UserNo].ToList();
|
||||
|
||||
var codes = permissions.SelectMany(x => x.AssignTypes.SelectMany(p => p.Codes)).Distinct().ToList();
|
||||
|
||||
var page = await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||
.LeftJoin<DeviceRegistryEntity>((d, dt, dr) => d.UniqueNo == dr.DeviceUniqueNo)
|
||||
.LeftJoin<BusinessPlaceEntity>((d, dt, dr, bp) => dr.BusinessPlaceCode == bp.Code)
|
||||
.LeftJoin<DeviceRegistryEntity>((d, dr) => d.UniqueNo == dr.DeviceUniqueNo)
|
||||
.WhereIF(request.DeviceType.HasValue, d => d.Type == request.DeviceType)
|
||||
.Where(d => ids.Contains(d.Code))
|
||||
.Select((d, dt, dr, bp) => new DevicePageResponse
|
||||
{
|
||||
FuncsStr = d.Funcs.ToString(),
|
||||
Brand = dt.Brand,
|
||||
Type = d.Type,
|
||||
BusinessPlaceCode = bp.Code,
|
||||
BusinessPlaceName = bp.Name,
|
||||
LastHeartbeatTime = dr.LastHeartbeatTime
|
||||
}, true)
|
||||
.Where(d => codes.Contains(d.Code))
|
||||
.Select((d, dr) => new GainfoDevicePermissionResponse { Factory = d.TenantId }, true)
|
||||
.ToPageListAsync(request);
|
||||
|
||||
page.Data.ForEach(item =>
|
||||
{
|
||||
var permission = permissions.First(x => x.Tenant == item.Factory);
|
||||
|
||||
item.Source = new DevicePermissionSourceDto
|
||||
{
|
||||
Factory = item.Factory,
|
||||
Types = permission.AssignTypes.Where(x => x.Codes.Any(p => p == item.Code)).Select(x => new DevicePermissionSourceTypeDto
|
||||
{
|
||||
AssignType = x.AssignType,
|
||||
AssignValue = x.AssignValue,
|
||||
UniqueType = x.UniqueType,
|
||||
Codes = x.UniqueType == DeviceAssignmentTypeEnumType.Device
|
||||
? x.Codes.Where(p => p == item.Code)
|
||||
: x.Codes.Take(1)
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user