- 网关管理:GatewayEntity/Service/Controller CRUD + 测试连接;设备 GatewayId 外键关联 - JWT 认证:登录签发 Token(权限编码写入 Claims)、RequirePermission 权限过滤器、CurrentUser 上下文 - RBAC:用户/角色/权限实体与 CRUD,预定义 4 角色 + 6 权限种子(admin/admin123) - 组织架构:sys_org 固定层级树(公司/实验室/部门/班组白夜班),层级校验,用户挂 OrgId/岗位/技能标签 - 数据权限:角色 DataScope(全部/本组织及下级),用户列表按组织子树过滤 - 防锁死保护:禁止删/禁自己,保证至少一名活跃管理员,角色摘除 user:manage 前校验 - 审计日志:AuditRecorder 接入设备增删改/指令下发/登录登出/组织变更,AuditController 查询 - 设备指令下发按网关表取连接参数;设备列表支持 gatewayId/productId 筛选 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
104 lines
3.6 KiB
C#
104 lines
3.6 KiB
C#
using SqlSugar;
|
||
|
||
namespace Model.Entity.Config
|
||
{
|
||
/// <summary>
|
||
/// IOT 设备(IOT设备注册与管理 - 设备管理)
|
||
/// 一台设备 = 一个从站实例,通过所属网关(IP:端口 或 串口)通讯
|
||
/// </summary>
|
||
public class IotDeviceEntity : BaseEntity
|
||
{
|
||
#region 基础信息
|
||
/// <summary>
|
||
/// 设备编号(唯一)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "设备编号", Length = 64)]
|
||
public string Code { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备名称
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "设备名称", Length = 100)]
|
||
public string Name { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备类型(型号,如 温度箱/充放电柜,对应 DeviceCommand 驱动类)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "设备类型", Length = 64)]
|
||
public string DeviceType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 所属产品Id(关联 ProductEntity.Id,仅用于归类,0=未分类)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "所属产品Id", DefaultValue = "0")]
|
||
public long ProductId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 所属网关Id(关联 GatewayEntity.Id,0=未分配)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "所属网关Id", DefaultValue = "0")]
|
||
public long GatewayId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 从站地址(协议从站号,网关下区分设备)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "从站地址")]
|
||
public byte SlaveId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 制造商
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "制造商", Length = 100, IsNullable = true)]
|
||
public string? Manufacturer { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备描述
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "设备描述", Length = 500, IsNullable = true)]
|
||
public string? Description { get; set; }
|
||
#endregion
|
||
|
||
#region 连接与协议配置
|
||
/// <summary>
|
||
/// 通讯协议类型(ModbusTcp/ModbusRtu/S7/Tcp/Serial)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "通讯协议类型")]
|
||
public IotDeviceProtocolEnum ProtocolType { get; set; } = IotDeviceProtocolEnum.ModbusTcp;
|
||
|
||
/// <summary>
|
||
/// 是否启用采集(停用则采集调度跳过该设备)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "是否启用")]
|
||
public bool IsEnabled { get; set; } = true;
|
||
#endregion
|
||
|
||
#region 运行状态(采集调度器更新)
|
||
/// <summary>
|
||
/// 在线状态
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "在线状态")]
|
||
public IotDeviceOnlineStatusEnum OnlineStatus { get; set; } = IotDeviceOnlineStatusEnum.Offline;
|
||
|
||
/// <summary>
|
||
/// 最后采集时间
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "最后采集时间", IsNullable = true)]
|
||
public DateTime? LastCollectTime { get; set; }
|
||
|
||
/// <summary>
|
||
/// 最近错误信息(通讯异常时记录)
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "最近错误", Length = 500, IsNullable = true)]
|
||
public string? LastError { get; set; }
|
||
#endregion
|
||
|
||
#region 审计信息
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
[SugarColumn(ColumnDescription = "备注", Length = 500, IsNullable = true)]
|
||
public string? Remark { get; set; }
|
||
#endregion
|
||
}
|
||
}
|