46 lines
1.8 KiB
Go
46 lines
1.8 KiB
Go
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"
|
|
)
|
|
|
|
// Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId)
|
|
type Station struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (Station) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{entsql.Annotation{Table: "station"}}
|
|
}
|
|
|
|
func (Station) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("id").Positive(),
|
|
field.Int("stationNo").Unique().Comment("工位号 1..12"),
|
|
field.String("name").Default("").MaxLen(64).Comment("工位名称"),
|
|
field.Int("flowId").Optional().Comment("绑定工艺流程图ID"),
|
|
// LINE(线上位,连PLC) / OFFLINE(线下位,如 0 上线位、13 下线位,不连PLC)
|
|
field.String("stationType").Default("LINE").MaxLen(20).Comment("工位类型 LINE/OFFLINE"),
|
|
// ENABLED / DISABLED
|
|
field.String("status").Default("ENABLED").MaxLen(20),
|
|
// 内置工位标识:由种子/初始化数据(或迁入数据)写入,代表实体产线上的固定工位,
|
|
// 需与 PLC 通讯、必须按工位号顺序流转;内置工位不允许改工位类型、不允许删除。
|
|
// 页面「新增工位」创建的是非内置工位(可改类型、可删除)。
|
|
field.Bool("isBuiltin").Default(false).Comment("内置工位:不可改类型/不可删除"),
|
|
// 是否有接驳台:对应实体位置(1~10 号工位各 2 个接驳台;0/11/12/13 无),
|
|
// 由内置数据给定,页面不可手动更改。
|
|
field.Bool("hasDock").Default(false).Comment("是否有接驳台(实体位置,内置不可改)"),
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
}
|
|
}
|
|
|
|
func (Station) Indexes() []ent.Index {
|
|
return []ent.Index{index.Fields("stationNo").Unique()}
|
|
}
|