test .
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
@@ -36,6 +37,12 @@ public class DevicePermissionSaveRequest : IValidatableObject
|
||||
/// AssignType == AssignTypeEnumType.Department 需要传入
|
||||
/// </summary>
|
||||
public string TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(DeviceTypeEnumType))]
|
||||
public DeviceTypeEnumType Type { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
@@ -32,17 +33,24 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
|
||||
public async Task AssignAsync(DevicePermissionSaveRequest request)
|
||||
{
|
||||
throw new Exception("系统维护中,暂不可操作");
|
||||
if (_currentUser.GetStringSubjectId() != "14")
|
||||
{
|
||||
throw new Exception("系统维护中,暂不可操作");
|
||||
}
|
||||
|
||||
|
||||
var tenantId = request.AssignType == AssignTypeEnumType.Department ? request.TenantId : _currentUser.GetStringTenantId();
|
||||
|
||||
await GenerateDeviceTasksAsync(async () =>
|
||||
{
|
||||
var values = await GetUniqueValuesAsync(request.Type, request.UniqueType);
|
||||
|
||||
//删除当前匹配的基地权限
|
||||
var p = await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => x.AssignType == request.AssignType)
|
||||
.Where(x => x.AssignValue == request.AssignValue)
|
||||
.Where(x => x.UniqueType == request.UniqueType)
|
||||
.WhereIF(values.Any(), x => values.Contains(x.UniqueValue))
|
||||
.Where(x => x.TenantId == tenantId)
|
||||
.ToListAsync();
|
||||
|
||||
@@ -65,6 +73,29 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
}, null);
|
||||
}
|
||||
|
||||
private async Task<List<Guid>> GetUniqueValuesAsync(DeviceTypeEnumType? type, DeviceAssignmentTypeEnumType assignmentType)
|
||||
{
|
||||
if (!type.HasValue)
|
||||
{
|
||||
return new List<Guid>();
|
||||
}
|
||||
|
||||
if (assignmentType == DeviceAssignmentTypeEnumType.BusinessPlace)
|
||||
{
|
||||
return new List<Guid>();
|
||||
}
|
||||
else if (assignmentType == DeviceAssignmentTypeEnumType.Device)
|
||||
{
|
||||
return await _dbContext.Queryable<DeviceEntity>().Where(x => x.Enable).Where(x => x.Type == type).Select(x => x.Code).ToListAsync();
|
||||
}
|
||||
else if (assignmentType == DeviceAssignmentTypeEnumType.Group)
|
||||
{
|
||||
return await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Type == type).Select(x => x.Code).ToListAsync();
|
||||
}
|
||||
|
||||
throw new UserFriendlyException("不支持当前操作");
|
||||
}
|
||||
|
||||
public async Task AssignToUniqueAsync(DevicePermissionsAssignToDeviceRequest request)
|
||||
{
|
||||
var tenantId = request.AssignType == AssignTypeEnumType.Department ? request.TenantId : _currentUser.GetStringTenantId();
|
||||
@@ -242,10 +273,10 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
}
|
||||
|
||||
_logger.LogInformation("任务产生数量{count}", waitTasks.Count);
|
||||
if (waitTasks.Any())
|
||||
{
|
||||
await _dbContext.InsertAsync(waitTasks);
|
||||
}
|
||||
// if (waitTasks.Any())
|
||||
// {
|
||||
// await _dbContext.InsertAsync(waitTasks);
|
||||
// }
|
||||
}
|
||||
|
||||
public async Task<PermissionUsersInfoDto> GetPermissionUsersInfoAsync(List<string> userNos)
|
||||
|
||||
Reference in New Issue
Block a user