using Newtonsoft.Json; using SqlSugar; using WIDESEAWCS_Core.DB.Models; namespace WIDESEAWCS_Model.Models { /// /// 机械手状态数据库实体 /// /// /// 对应数据库表 Dt_RobotState,使用 RowVersion 实现乐观并发控制。 /// 复杂对象(RobotCrane、CurrentTask、数组等)以 JSON 字符串存储。 /// [SugarTable(nameof(Dt_RobotState), "机械手状态表")] public class Dt_RobotState : BaseEntity { /// /// 主键 ID /// [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键ID")] public int Id { get; set; } /// /// 机械手 IP 地址,唯一索引 /// [SugarColumn(Length = 50, ColumnDescription = "机械手IP地址", IsJsonKey = true)] public string IPAddress { get; set; } = string.Empty; /// /// 行版本,用于乐观并发控制 /// /// /// SqlSugar 会自动管理此字段,每次更新时数据库自动递增。 /// 更新时 WHERE RowVersion = @expectedRowVersion,检查影响行数判断是否冲突。 /// [SugarColumn(ColumnDescription = "行版本(乐观锁)", IsJsonKey = true)] public byte[] RowVersion { get; set; } = Array.Empty(); /// /// 是否已订阅消息事件 /// [SugarColumn(ColumnDescription = "是否已订阅消息事件", IsJsonKey = true)] public bool IsEventSubscribed { get; set; } /// /// 机械手运行模式 /// /// 1: 手动模式, 2: 自动模式 [SugarColumn(ColumnDescription = "运行模式", IsNullable = true, IsJsonKey = true)] public int? RobotRunMode { get; set; } /// /// 机械手控制模式 /// /// 1: 客户端控制, 2: 其他 [SugarColumn(ColumnDescription = "控制模式", IsNullable = true, IsJsonKey = true)] public int? RobotControlMode { get; set; } /// /// 机械手手臂抓取对象状态 /// /// 0: 无物料(手臂空闲), 1: 有物料(已抓取货物) [SugarColumn(ColumnDescription = "手臂抓取状态", IsNullable = true, IsJsonKey = true)] public int? RobotArmObject { get; set; } /// /// 机械手设备基础信息(JSON 序列化) /// [SugarColumn(Length = 2000, ColumnDescription = "设备信息JSON", IsJsonKey = true)] public string RobotCraneJson { get; set; } = string.Empty; /// /// 机械手初始化完成回到待机位状态 /// /// Possible values: "Homed", "Homing" [SugarColumn(Length = 50, ColumnDescription = "回零状态", IsNullable = true, IsJsonKey = true)] public string? Homed { get; set; } /// /// 机械手当前正在执行的动作 /// [SugarColumn(Length = 50, ColumnDescription = "当前动作", IsNullable = true, IsJsonKey = true)] public string? CurrentAction { get; set; } /// /// 机械手当前运行状态 /// [SugarColumn(Length = 50, ColumnDescription = "运行状态", IsNullable = true, IsJsonKey = true)] public string? OperStatus { get; set; } /// /// 最近一次取货完成的位置数组(JSON) /// [SugarColumn(Length = 500, ColumnDescription = "取货位置数组JSON", IsNullable = true, IsJsonKey = true)] public string? LastPickPositionsJson { get; set; } /// /// 最近一次放货完成的位置数组(JSON) /// [SugarColumn(Length = 500, ColumnDescription = "放货位置数组JSON", IsNullable = true, IsJsonKey = true)] public string? LastPutPositionsJson { get; set; } /// /// 电池/货位条码列表(JSON) /// [SugarColumn(Length = 2000, ColumnDescription = "电芯条码列表JSON", IsNullable = true, IsJsonKey = true)] public string? CellBarcodeJson { get; set; } /// /// 机械手当前正在执行的任务(JSON 序列化) /// [SugarColumn(Length = 2000, ColumnDescription = "当前任务JSON", IsNullable = true, IsJsonKey = true)] public string? CurrentTaskJson { get; set; } /// /// 是否需要执行拆盘任务 /// [SugarColumn(ColumnDescription = "是否拆盘任务", IsJsonKey = true)] public bool IsSplitPallet { get; set; } /// /// 是否需要执行组盘任务 /// [SugarColumn(ColumnDescription = "是否组盘任务", IsJsonKey = true)] public bool IsGroupPallet { get; set; } /// /// 机器人已处理的任务总数 /// [SugarColumn(ColumnDescription = "已处理任务总数", IsJsonKey = true)] public int RobotTaskTotalNum { get; set; } /// /// 是否处于假电芯补充模式 /// [SugarColumn(ColumnDescription = "是否假电芯模式", IsJsonKey = true)] public bool IsInFakeBatteryMode { get; set; } /// /// 当前批次起始编号 /// [SugarColumn(ColumnDescription = "当前批次编号", IsJsonKey = true)] public int CurrentBatchIndex { get; set; } = 1; /// /// 换盘任务当前阶段 /// [SugarColumn(ColumnDescription = "换盘阶段", IsJsonKey = true)] public int ChangePalletPhase { get; set; } /// /// 是否扫码NG /// [SugarColumn(ColumnDescription = "是否扫码NG", IsJsonKey = true)] public bool IsScanNG { get; set; } /// /// 是否电芯到位 /// [SugarColumn(ColumnDescription = "电芯是否到位", IsJsonKey = true)] public bool BatteryArrived { get; set; } } }