package schema import ( "bj_power_mes/constants" "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" ) // EquipmentSlot 设备槽位,每台设备下的具体工? type EquipmentSlot struct { ent.Schema } func (EquipmentSlot) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.Annotation{ Table: "equipment_slot", Options: "COMMENT='设备槽位表,记录每台设备下各槽位的状态、占用的工件及FIFO排序信息'", }, entsql.WithComments(true), } } func (EquipmentSlot) Fields() []ent.Field { return []ent.Field{ field.Int("id").Positive().Comment("主键ID"), field.Int("equipmentId").Optional().Nillable().Comment("所属设备ID"), field.Int("slotNo").Comment("槽位序号,从1开始递增"), field.Enum("status"). GoType(constants.SlotStatus("")). Default(string(constants.SlotStatus_Empty)). Comment("槽位状态:Empty/Occupied搬运?Processing加工?Completed"), field.Int("currentJobId").Optional().Nillable().Comment("当前占用的工件ID"), field.Time("occupiedAt").Optional().Nillable().Comment("占用时间,用于FIFO排序,先占用的优先出?), } } func (EquipmentSlot) Edges() []ent.Edge { return []ent.Edge{ edge.From("equipment", Equipment.Type).Ref("slots").Field("equipmentId").Unique().Comment("所属设?), edge.To("currentJob", Job.Type).Field("currentJobId").Unique().Comment("当前占用的工?), } } func (EquipmentSlot) Indexes() []ent.Index { return []ent.Index{ index.Fields("equipmentId", "slotNo").Unique(), index.Fields("currentJobId"), } }