Files
bj_power/bj_power_mes/schema/equipment_slot.go
T

51 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"},
}
}
func (EquipmentSlot) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("equipmentId").Optional().Nillable().Comment("设备ID"),
field.Int("slotNo").Comment("槽位序号(1-based"),
field.Enum("status").
GoType(constants.SlotStatus("")).
Default(string(constants.SlotStatus_Empty)).
Comment("槽位状态"),
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(),
}
}
func (EquipmentSlot) Indexes() []ent.Index {
return []ent.Index{
index.Fields("equipmentId", "slotNo").Unique(),
index.Fields("currentJobId"),
}
}