Files
bj_power/bj_power_mes/schema/equipment.go
T

55 lines
1.8 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 (
"time"
"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"
)
// Equipment 设备
type Equipment struct {
ent.Schema
}
func (Equipment) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "equipment"},
}
}
func (Equipment) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("name").MaxLen(50).Comment("设备名称"),
field.Int("equipmentTypeId").Comment("设备类型ID"),
field.Enum("status").
GoType(constants.EquipmentStatus("")).
Default(string(constants.EquipmentStatus_Idle)).
Comment("设备状态"),
field.Int("slotCount").Default(1).Comment("槽位数量"),
field.Bool("enabled").Default(true).Comment("是否启用调度"),
field.Bool("exchange").Default(false).Comment("是否支持换料"),
field.Bool("batch").Default(false).Comment("是否批量完成(所有槽位同时完成)"),
field.String("ipAddress").Default("").Comment("IP地址"),
field.String("location").Default("").Comment("物理位置"),
field.String("doneSignalName").Default("").Comment("加工完成信号名称(PLC信号表name)"),
field.String("ngSignalName").Default("").Comment("检测NG信号名称(PLC信号表name"),
field.String("remark").Default("").Comment("备注"),
field.Time("createdAt").Default(time.Now).Optional().Nillable().Comment("创建时间"),
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable().Comment("更新时间"),
}
}
func (Equipment) Edges() []ent.Edge {
return []ent.Edge{
edge.From("equipmentType", EquipmentType.Type).Ref("equipments").Field("equipmentTypeId").Unique().Required(),
edge.To("slots", EquipmentSlot.Type).Comment("设备槽位"),
}
}