fix 功能调整
This commit is contained in:
@@ -80,6 +80,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
group.ThrowIfNull("设备组不存在");
|
||||
|
||||
await CheckNoNextGroupAsync(group.Code);
|
||||
await CheckGroupTypeMatchAsync(request, group);
|
||||
|
||||
//下发任务
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(async () =>
|
||||
@@ -87,7 +88,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
var relationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>().Where(x => x.GroupCode == request.GroupCode).ToListAsync();
|
||||
await _dbContext.DeleteAsync(relationships);
|
||||
|
||||
request.DeviceCodes = await _dbContext.Queryable<DeviceEntity>().Where(x => request.DeviceCodes.Contains(x.Code)).Select(x => x.Code).ToListAsync();
|
||||
|
||||
var entities = request.DeviceCodes.Select(x => new DeviceGroupRelationshipEntity
|
||||
{
|
||||
GroupCode = request.GroupCode,
|
||||
@@ -115,7 +116,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
/****************************************************** help methods *********************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// 检查
|
||||
/// 检查父级分组存在设备
|
||||
/// </summary>
|
||||
/// <param name="pCode"></param>
|
||||
/// <returns></returns>
|
||||
@@ -139,6 +140,25 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
exists.ThrowIfTrue("存在下级设备分组");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查分组分类匹配
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
private async Task CheckGroupTypeMatchAsync(DeviceAssignRequest request, DeviceGroupEntity group)
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => request.DeviceCodes.Contains(x.Code)).ToListAsync();
|
||||
//检查分组的分类控制
|
||||
if (group.Type.HasValue)
|
||||
{
|
||||
devices.Any(x => x.Type != group.Type).ThrowIfTrue("存在设备类型有误,无法分配到当前分组");
|
||||
}
|
||||
|
||||
//重新赋值到请求参数中
|
||||
request.DeviceCodes = devices.Select(x => x.Code).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取树
|
||||
|
||||
Reference in New Issue
Block a user