using SqlSugar; namespace Evergreen.Health.Application.Health.Entities; [SugarTable("health_ib43_binding", "IB43床位用户绑定历史")] [SugarIndex("ux_ib43_active_slot", nameof(ActiveSlot), OrderByType.Asc, IsUnique = true)] [SugarIndex("ix_ib43_binding_user", nameof(UserId), OrderByType.Asc)] public sealed class HealthIb43Binding { [SugarColumn(IsPrimaryKey = true, Length = 32)] public string Id { get; set; } = Guid.NewGuid().ToString("N"); [SugarColumn(Length = 64)] public string DeviceKey { get; set; } = ""; [SugarColumn(Length = 128)] public string ProductKey { get; set; } = ""; [SugarColumn(Length = 128)] public string SerialNumber { get; set; } = ""; [SugarColumn(Length = 5)] public string Side { get; set; } = ""; // 活跃时为设备哈希+侧别,解绑时为 NULL。数据库唯一索引防止并发抢占。 [SugarColumn(Length = 70, IsNullable = true)] public string ActiveSlot { get; set; } public long UserId { get; set; } [SugarColumn(Length = 80)] public string BedName { get; set; } = ""; public bool Simulation { get; set; } public long StartedAtMs { get; set; } [SugarColumn(IsNullable = true)] public long? EndedAtMs { get; set; } public long AssignedBy { get; set; } [SugarColumn(IsNullable = true)] public long? ReleasedBy { get; set; } } [SugarTable("health_ib43_observation", "IB43按用户侧别保存的观测增量")] [SugarIndex("ux_ib43_report_binding", nameof(ReportId), OrderByType.Asc, nameof(BindingId), OrderByType.Asc, IsUnique = true)] [SugarIndex("ix_ib43_obs_owner_time", nameof(UserId), OrderByType.Asc, nameof(BindingId), OrderByType.Asc, nameof(ReceivedAtMs), OrderByType.Asc)] public sealed class HealthIb43Observation { [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public long Id { get; set; } [SugarColumn(Length = 32)] public string ReportId { get; set; } = ""; [SugarColumn(Length = 32)] public string BindingId { get; set; } = ""; public long UserId { get; set; } public long ReceivedAtMs { get; set; } public bool HasHeartRate { get; set; } public bool HasRespiration { get; set; } public bool HasPresence { get; set; } public bool HasSnoring { get; set; } // 只含该侧有效解析字段及来源,不含另一侧、原始完整报文或凭据。 [SugarColumn(ColumnDataType = "text")] public string ReadingsJson { get; set; } = "{}"; }