fix 中文描述转换
This commit is contained in:
@@ -24,4 +24,6 @@ public class DevicePermissionSourceTypeDto
|
|||||||
public DeviceAssignmentTypeEnumType UniqueType { get; set; }
|
public DeviceAssignmentTypeEnumType UniqueType { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Guid> Codes { get; set; }
|
public IEnumerable<Guid> Codes { get; set; }
|
||||||
|
|
||||||
|
public string CodeDesc { get; set; }
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,12 @@ public class GainfoDevicePermissionResponse
|
|||||||
/// 心跳间隔
|
/// 心跳间隔
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int HeartbeatInterval { get; set; }
|
public int HeartbeatInterval { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部署点
|
||||||
|
/// </summary>
|
||||||
|
public string DeployPlace { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备机功能类型
|
/// 设备机功能类型
|
||||||
|
|||||||
@@ -133,6 +133,15 @@ public class GainfoPermissionService : IGainfoPermissionService
|
|||||||
.Select((d, dr) => new GainfoDevicePermissionResponse { Factory = d.TenantId }, true)
|
.Select((d, dr) => new GainfoDevicePermissionResponse { Factory = d.TenantId }, true)
|
||||||
.ToPageListAsync(request);
|
.ToPageListAsync(request);
|
||||||
|
|
||||||
|
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>().Select(x => new { x.Code, x.Name }).ToListAsync();
|
||||||
|
var departments = permissions.Any(x => x.AssignTypes.Any(p => p.AssignType == AssignTypeEnumType.Department))
|
||||||
|
? await _dbContext.Queryable<DepartmentEntity>().Select(x => new { x.No, x.Name }).ToListAsync()
|
||||||
|
: new[] { new { No = string.Empty, Name = string.Empty } }.ToList();
|
||||||
|
|
||||||
|
var userGroups = permissions.Any(x => x.AssignTypes.Any(p => p.AssignType == AssignTypeEnumType.Group))
|
||||||
|
? await _dbContext.Queryable<GainfoGroupEntity>().Select(x => new { x.Code, x.Name }).ToListAsync()
|
||||||
|
: new[] { new { Code = Guid.Empty, Name = string.Empty } }.ToList();
|
||||||
|
|
||||||
page.Data.ForEach(item =>
|
page.Data.ForEach(item =>
|
||||||
{
|
{
|
||||||
var permission = permissions.First(x => x.Tenant == item.Factory);
|
var permission = permissions.First(x => x.Tenant == item.Factory);
|
||||||
@@ -140,14 +149,35 @@ public class GainfoPermissionService : IGainfoPermissionService
|
|||||||
item.Source = new DevicePermissionSourceDto
|
item.Source = new DevicePermissionSourceDto
|
||||||
{
|
{
|
||||||
Factory = item.Factory,
|
Factory = item.Factory,
|
||||||
Types = permission.AssignTypes.Where(x => x.Codes.Any(p => p == item.Code)).Select(x => new DevicePermissionSourceTypeDto
|
Types = permission.AssignTypes.Where(x => x.Codes.Any(p => p == item.Code)).Select(x =>
|
||||||
{
|
{
|
||||||
AssignType = x.AssignType,
|
var codeDesc = x.UniqueType == DeviceAssignmentTypeEnumType.Device
|
||||||
AssignValue = x.AssignValue,
|
? item.DeployPlace
|
||||||
UniqueType = x.UniqueType,
|
: deviceGroups.First(p => p.Code == x.Codes.First()).Name;
|
||||||
Codes = x.UniqueType == DeviceAssignmentTypeEnumType.Device
|
|
||||||
? x.Codes.Where(p => p == item.Code)
|
var currentAssignValue = x.AssignValue;
|
||||||
: x.Codes.Take(1)
|
if (x.AssignType == AssignTypeEnumType.Department)
|
||||||
|
{
|
||||||
|
currentAssignValue = departments.First(p => p.No == x.AssignValue.Split(":")[1]).Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x.AssignType == AssignTypeEnumType.Group)
|
||||||
|
{
|
||||||
|
currentAssignValue = userGroups.First(p => p.Code == Guid.Parse(currentAssignValue)).Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
var r = new DevicePermissionSourceTypeDto
|
||||||
|
{
|
||||||
|
AssignType = x.AssignType,
|
||||||
|
AssignValue = currentAssignValue,
|
||||||
|
UniqueType = x.UniqueType,
|
||||||
|
Codes = x.UniqueType == DeviceAssignmentTypeEnumType.Device
|
||||||
|
? x.Codes.Where(p => p == item.Code)
|
||||||
|
: x.Codes.Take(1),
|
||||||
|
CodeDesc = codeDesc
|
||||||
|
};
|
||||||
|
|
||||||
|
return r;
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user