37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package schema
|
||||
|
|
|
|||
|
|
import (
|
|||
|
|
"entgo.io/ent"
|
|||
|
|
"entgo.io/ent/schema/field"
|
|||
|
|
"entgo.io/ent/schema/index"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// Dock 接驳台主数据:21 个固定编码 DOCK01~DOCK20(产线,DOCK n ↔ 工位 n)+ DOCK21(库房收货)。
|
|||
|
|
// has_pallet 标记该接驳台当前是否有托盘;来源:PLC 托盘传感器(MES 同步) 或 AGV 到位/卸货自动维护。
|
|||
|
|
type Dock struct {
|
|||
|
|
ent.Schema
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (Dock) Fields() []ent.Field {
|
|||
|
|
return []ent.Field{
|
|||
|
|
field.String("dock_code").Unique().MaxLen(20).Comment("接驳台编码 DOCK01..21"),
|
|||
|
|
field.String("name").Default("").MaxLen(64).Comment("接驳台名称"),
|
|||
|
|
// type: line(产线) / store(库房)
|
|||
|
|
field.String("dock_type").Default("line").MaxLen(16).Comment("类型 line产线/store库房"),
|
|||
|
|
// 关联工位(产线接驳台 DOCKn↔工位n),库房为 0
|
|||
|
|
field.Int("station_no").Default(0).Comment("关联工位号(产线 1..12),库房 0"),
|
|||
|
|
field.Bool("has_pallet").Default(false).Comment("当前是否有托盘"),
|
|||
|
|
// 有托盘时的关联出库/任务(便于查这个托盘是哪批料、要送到哪)
|
|||
|
|
field.String("pallet_ref").Default("").MaxLen(64).Optional().Comment("托盘关联(出库单号/备料单号)"),
|
|||
|
|
// ENABLED / DISABLED
|
|||
|
|
field.String("status").Default("ENABLED").MaxLen(20),
|
|||
|
|
field.Int64("created_at").DefaultFunc(nowUnix).Comment("创建时间"),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (Dock) Indexes() []ent.Index {
|
|||
|
|
return []ent.Index{
|
|||
|
|
index.Fields("dock_code").Unique(),
|
|||
|
|
index.Fields("dock_type"),
|
|||
|
|
}
|
|||
|
|
}
|