fix 设备组数据展示,保存控制editable
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
|
||||
public class DeviceGroupTreeResponse
|
||||
{
|
||||
@@ -17,6 +20,27 @@ public class DeviceGroupTreeResponse
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备组类型
|
||||
/// </summary>
|
||||
public DeviceTypeEnumType? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组类型描述
|
||||
/// </summary>
|
||||
public string TypeDesc
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Type.HasValue)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return Type.Value.GetDescription();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下级
|
||||
/// </summary>
|
||||
|
||||
@@ -56,8 +56,9 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<DeviceGroupEntity>();
|
||||
|
||||
entity.Editable = true;
|
||||
entity.Code = Guid.NewGuid();
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
@@ -65,6 +66,8 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
var entity = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("设备组不存在,无法更新");
|
||||
|
||||
entity.Editable.ThrowIfFalse("不可编辑当前组");
|
||||
|
||||
var nextDevices = await GetDevicesAsync(entity.Code);
|
||||
if (!entity.Type.HasValue)
|
||||
{
|
||||
@@ -75,7 +78,6 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
(request.Type.HasValue && request.Type != entity.Type && nextDevices.Any()).ThrowIfTrue("分组设备类型不匹配,无法修改类型");
|
||||
}
|
||||
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,13 @@ public class DeviceGroupEntity : SugarBaseEntity, ITenantId, ISoftDeleted
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否可编辑
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否可编辑")]
|
||||
public bool Editable { get; set; }
|
||||
|
||||
|
||||
public string TenantId { get; set; }
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Sys.Api;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.CommonJobs;
|
||||
|
||||
@@ -28,11 +29,12 @@ public class CreateDefinitelyGroupJob
|
||||
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantResult.Data;
|
||||
|
||||
_logger.LogInformation("获取基地信息:{json}", JsonConvert.SerializeObject(tenants));
|
||||
|
||||
foreach (var tenant in tenants)
|
||||
{
|
||||
if (!await _dbContext.Queryable<GainfoGroupEntity>().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.IsDefault))
|
||||
{
|
||||
|
||||
var customGroup = new GainfoGroupEntity
|
||||
{
|
||||
PCode = null,
|
||||
@@ -82,6 +84,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Attendance,
|
||||
Name = "*通用考勤设备组",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
@@ -99,6 +102,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Attendance,
|
||||
Name = "*专用考勤设备组",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
@@ -121,6 +125,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Door,
|
||||
Name = "*非公共区域",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
@@ -141,6 +146,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Door,
|
||||
Name = "*公共区域",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
|
||||
Reference in New Issue
Block a user