Merge branch 'development'
This commit is contained in:
@@ -305,7 +305,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
public async Task<List<Guid>> GetAssignDeviceCodesAsync(string userNo)
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().ToListAsync();
|
||||
var deviceRegistries = await _dbContext.Queryable<DeviceRegistryEntity>().ToListAsync();
|
||||
var deviceRegistries = await _dbContext.Queryable<DeviceRegistryEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.BusinessPlaceCode)).ToListAsync();
|
||||
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.No == userNo).SingleAsync();
|
||||
var gainfoGroups = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().ToListAsync();
|
||||
@@ -507,9 +507,9 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
)
|
||||
{
|
||||
var userNo = gainfo.No;
|
||||
var deviceCodes = new List<UserTenantDeviceCodeDto>();
|
||||
var deviceGroupCodes = new List<UserTenantDeviceCodeDto>();
|
||||
var placeCodes = new List<UserTenantDeviceCodeDto>();
|
||||
var deviceDtos = new List<UserTenantDeviceCodeDto>();
|
||||
var deviceGroupDtos = new List<UserTenantDeviceCodeDto>();
|
||||
var businessPlaceDtos = new List<UserTenantDeviceCodeDto>();
|
||||
|
||||
//获取人员的分组,跨基地
|
||||
var gainfoGroups = gainfoGroupRelationships.Where(x => x.UserNo == userNo).Select(x => x.GroupCode).ToList();
|
||||
@@ -519,9 +519,9 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
var gu = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Group, AssignTypeEnumType.User, userNo);
|
||||
var pu = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.BusinessPlace, AssignTypeEnumType.User, userNo);
|
||||
|
||||
deviceCodes.AddRange(du);
|
||||
deviceGroupCodes.AddRange(gu);
|
||||
placeCodes.AddRange(pu);
|
||||
deviceDtos.AddRange(du);
|
||||
deviceGroupDtos.AddRange(gu);
|
||||
businessPlaceDtos.AddRange(pu);
|
||||
|
||||
//按用户组
|
||||
foreach (var groupCode in gainfoGroups)
|
||||
@@ -529,9 +529,9 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
var dg = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Device, AssignTypeEnumType.Group, groupCode.ToString());
|
||||
var gg = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Group, AssignTypeEnumType.Group, groupCode.ToString());
|
||||
var pg = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.BusinessPlace, AssignTypeEnumType.Group, groupCode.ToString());
|
||||
deviceCodes.AddRange(dg);
|
||||
deviceGroupCodes.AddRange(gg);
|
||||
placeCodes.AddRange(pg);
|
||||
deviceDtos.AddRange(dg);
|
||||
deviceGroupDtos.AddRange(gg);
|
||||
businessPlaceDtos.AddRange(pg);
|
||||
}
|
||||
|
||||
//按部门
|
||||
@@ -539,48 +539,45 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
var dd = GetAssignCodesInternal(gainfoFactoryDevicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Device, AssignTypeEnumType.Department, gainfo.DepartmentNo);
|
||||
var gd = GetAssignCodesInternal(gainfoFactoryDevicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Group, AssignTypeEnumType.Department, gainfo.DepartmentNo);
|
||||
var pd = GetAssignCodesInternal(gainfoFactoryDevicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.BusinessPlace, AssignTypeEnumType.Department, gainfo.DepartmentNo);
|
||||
deviceCodes.AddRange(dd);
|
||||
deviceGroupCodes.AddRange(gd);
|
||||
placeCodes.AddRange(pd);
|
||||
deviceDtos.AddRange(dd);
|
||||
deviceGroupDtos.AddRange(gd);
|
||||
businessPlaceDtos.AddRange(pd);
|
||||
|
||||
//按厂区
|
||||
var dt = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Device, AssignTypeEnumType.Tenant, gainfo.Factory);
|
||||
var gt = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.Group, AssignTypeEnumType.Tenant, gainfo.Factory);
|
||||
var pt = GetAssignCodesInternal(devicePermissions, deviceGroups, DeviceAssignmentTypeEnumType.BusinessPlace, AssignTypeEnumType.Tenant, gainfo.Factory);
|
||||
placeCodes.AddRange(pt);
|
||||
deviceCodes.AddRange(dt);
|
||||
deviceGroupCodes.AddRange(gt);
|
||||
deviceDtos.AddRange(dt);
|
||||
deviceGroupDtos.AddRange(gt);
|
||||
businessPlaceDtos.AddRange(pt);
|
||||
|
||||
var groupCodes = deviceGroupCodes.SelectMany(x => x.Codes).Distinct().ToList();
|
||||
var placecodes = placeCodes.SelectMany(x => x.Codes).Distinct().ToList();
|
||||
var deviceGroupCodes = deviceGroupDtos.SelectMany(x => x.Codes).Distinct().ToList();
|
||||
var businessPlaceCodes = businessPlaceDtos.SelectMany(x => x.Codes).Distinct().ToList();
|
||||
|
||||
var deveiceCodesByGroup = deviceGroupRelationships.Where(x => groupCodes.Contains(x.GroupCode)).GroupBy(x => x.TenantId)
|
||||
var deveiceCodesByGroup = deviceGroupRelationships.Where(x => deviceGroupCodes.Contains(x.GroupCode)).GroupBy(x => x.TenantId)
|
||||
.Select(x => new UserTenantDeviceCodeDto
|
||||
{
|
||||
Tenant = x.Key,
|
||||
Codes = x.Select(item => item.DeviceCode).Distinct().ToList()
|
||||
});
|
||||
|
||||
var placeGroup = deviceRegistries.Where(x => placecodes.Contains((Guid)x.BusinessPlaceCode)).GroupBy(x => x.TenantId)
|
||||
.Select(x => new UserTenantDeviceCodeDto
|
||||
var placeGroup = deviceRegistries.Where(x => businessPlaceCodes.Contains(x.BusinessPlaceCode.Value)).GroupBy(x => x.TenantId)
|
||||
.Select(x =>
|
||||
{
|
||||
Tenant = x.Key,
|
||||
}).ToList();
|
||||
var currentDeviceUniqueNos = x.Select(item => item.DeviceUniqueNo).ToList();
|
||||
|
||||
placeGroup.ForEach(t =>
|
||||
{
|
||||
var nos = deviceRegistries.Where(x => placecodes.Contains((Guid)x.BusinessPlaceCode))
|
||||
.Where(x => x.TenantId == t.Tenant)
|
||||
.Select(x => x.DeviceUniqueNo)
|
||||
.ToList();
|
||||
return new UserTenantDeviceCodeDto
|
||||
{
|
||||
Tenant = x.Key,
|
||||
Codes = devices.Where(d => currentDeviceUniqueNos.Contains(d.UniqueNo)).Select(d => d.Code).Distinct().ToList()
|
||||
};
|
||||
})
|
||||
.ToList();
|
||||
|
||||
t.Codes = devices.Where(d => nos.Contains(d.UniqueNo)).Select(d => d.Code).ToList();
|
||||
});
|
||||
deviceDtos.AddRange(deveiceCodesByGroup);
|
||||
deviceDtos.AddRange(placeGroup);
|
||||
|
||||
deviceCodes.AddRange(deveiceCodesByGroup);
|
||||
deviceCodes.AddRange(placeGroup);
|
||||
|
||||
return deviceCodes.GroupBy(x => x.Tenant).Select(x => new UserTenantDeviceCodeDto
|
||||
return deviceDtos.GroupBy(x => x.Tenant).Select(x => new UserTenantDeviceCodeDto
|
||||
{
|
||||
Tenant = x.Key,
|
||||
Codes = x.SelectMany(item => item.Codes).Distinct().ToList()
|
||||
|
||||
Reference in New Issue
Block a user