package schema import ( "time" "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" ) // AgvPoint AGV 点位(硬件级别真源)。 // 点位编码(position_code)与接驳台的一一对应关系为硬件内置:软件层只能“启用/停用”与改显示名(name), // 绝对不能修改核心物理编码和绑定关系(dock_id)。 // 纯 AGV 点位(无接驳台)用 is_dock=false 表示;派车时无传感器,仅做二次确认“请确保现场安全”。 type AgvPoint struct { ent.Schema } func (AgvPoint) Annotations() []schema.Annotation { return []schema.Annotation{entsql.Annotation{Table: "agv_point"}, entsql.WithComments(true), schema.Comment("AgvPoint AGV 点位(硬件级别真源):点位编码与接驳台一一对应,软件仅可启用/停用与改显示名。")} } func (AgvPoint) Fields() []ent.Field { return []ent.Field{ field.String("position_code").Unique().MaxLen(32).Comment("AGV 点位编码(硬件映射=送往 RCS 的目标坐标,软件不可改)"), field.String("name").Default("").MaxLen(64).Comment("点位显示名称(可编辑)"), field.Bool("is_dock").Default(false).Comment("是否接驳台点位(true=绑定接驳台,false=纯待命/充电点位)"), // 硬件内置绑定:该点位对应的接驳台 ID(is_dock=true 时强绑定,软件不可改) field.Int("dock_id").Optional().Nillable().Comment("绑定的接驳台 ID(is_dock=true 时硬件内置强绑定)"), field.Bool("enabled").Default(true).Comment("是否启用(可编辑)"), field.Time("created_at").Default(time.Now).Immutable(), } } func (AgvPoint) Indexes() []ent.Index { return []ent.Index{ index.Fields("position_code").Unique(), index.Fields("is_dock"), index.Fields("enabled"), } }