2026-08-27 10:09:54 +08:00
|
|
|
|
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"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-08-27 10:56:41 +08:00
|
|
|
|
// EquipmentSlot 设备槽位
|
2026-08-27 10:09:54 +08:00
|
|
|
|
type EquipmentSlot struct {
|
|
|
|
|
|
ent.Schema
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (EquipmentSlot) Annotations() []schema.Annotation {
|
|
|
|
|
|
return []schema.Annotation{
|
2026-08-27 10:56:41 +08:00
|
|
|
|
entsql.Annotation{Table: "equipment_slot"},
|
2026-08-27 10:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (EquipmentSlot) Fields() []ent.Field {
|
|
|
|
|
|
return []ent.Field{
|
2026-08-27 10:56:41 +08:00
|
|
|
|
field.Int("id").Positive(),
|
|
|
|
|
|
field.Int("equipmentId").Optional().Nillable().Comment("设备ID"),
|
|
|
|
|
|
field.Int("slotNo").Comment("槽位序号(1-based)"),
|
2026-08-27 10:09:54 +08:00
|
|
|
|
field.Enum("status").
|
|
|
|
|
|
GoType(constants.SlotStatus("")).
|
|
|
|
|
|
Default(string(constants.SlotStatus_Empty)).
|
2026-08-27 10:56:41 +08:00
|
|
|
|
Comment("槽位状态"),
|
|
|
|
|
|
field.Int("currentJobId").Optional().Nillable().Comment("当前工件ID"),
|
|
|
|
|
|
field.Time("occupiedAt").Optional().Nillable().Comment("占用时间(FIFO排序参考)"),
|
2026-08-27 10:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (EquipmentSlot) Edges() []ent.Edge {
|
|
|
|
|
|
return []ent.Edge{
|
2026-08-27 10:56:41 +08:00
|
|
|
|
edge.From("equipment", Equipment.Type).Ref("slots").Field("equipmentId").Unique(),
|
2026-08-27 10:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (EquipmentSlot) Indexes() []ent.Index {
|
|
|
|
|
|
return []ent.Index{
|
|
|
|
|
|
index.Fields("equipmentId", "slotNo").Unique(),
|
|
|
|
|
|
index.Fields("currentJobId"),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|