fix 优化细节
This commit is contained in:
@@ -89,29 +89,32 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
|
||||
public async Task AssignGainfosAsync(GainfoAssignRequest request)
|
||||
{
|
||||
var pGrp = await _dbContext.Queryable<GainfoGroupEntity>().Where(x => x.Code == request.GroupCode).FirstAsync();
|
||||
pGrp?.Editable.ThrowIfFalse("不可分配人员到当前分组");
|
||||
|
||||
if (request.UserNos.IsPresent())
|
||||
{
|
||||
var pGrp = await _dbContext.Queryable<GainfoGroupEntity>().Where(x => x.Code == request.GroupCode).FirstAsync();
|
||||
pGrp?.Editable.ThrowIfFalse("不可分配人员到当前分组");
|
||||
}
|
||||
|
||||
var existsNextGroup = await _dbContext.Queryable<GainfoGroupEntity>().Where(x => x.PCode == request.GroupCode).AnyAsync();
|
||||
existsNextGroup.ThrowIfTrue("存在下级分组,无法分配人员");
|
||||
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(async () =>
|
||||
{
|
||||
var relations = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().Where(x => x.GroupCode == request.GroupCode).ToListAsync();
|
||||
await _dbContext.DeleteReallyAsync(relations);
|
||||
var relations = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().Where(x => x.GroupCode == request.GroupCode).ToListAsync();
|
||||
await _dbContext.DeleteReallyAsync(relations);
|
||||
|
||||
request.UserNos = await _dbContext.Queryable<GainfoEntity>().Where(x => request.UserNos.Contains(x.No)).Select(x => x.No).ToListAsync();
|
||||
var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity
|
||||
{
|
||||
GroupCode = request.GroupCode,
|
||||
UserNo = x,
|
||||
|
||||
request.UserNos = await _dbContext.Queryable<GainfoEntity>().Where(x => request.UserNos.Contains(x.No)).Select(x => x.No).ToListAsync();
|
||||
var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity
|
||||
{
|
||||
GroupCode = request.GroupCode,
|
||||
UserNo = x,
|
||||
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(entities);
|
||||
}).ToList();
|
||||
|
||||
}, null);
|
||||
await _dbContext.InsertAsync(entities);
|
||||
|
||||
}, null);
|
||||
}
|
||||
|
||||
//******************************************************* help methods ***********************************************************
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
|
||||
/// <summary>
|
||||
/// 设备唯一码,IP/MAC/SNO
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "设备唯一码", UniqueGroupNameList = new[] { "Idx_Device_UniqueNo" })]
|
||||
[SugarColumn(ColumnDescription = "设备唯一码", IsNullable = false, UniqueGroupNameList = new[] { "Idx_Device_UniqueNo" })]
|
||||
public string UniqueNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,10 +23,10 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion
|
||||
/// </summary>
|
||||
public string UserNo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设备唯一号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, IndexGroupNameList = new[] { "idx_DeviceTask_DeviceUniqueNo" })]
|
||||
public string DeviceUniqueNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user