47 lines
1.8 KiB
Go
47 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"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// Dock 接驳台主数据:DOCK01~DOCK20(产线,DOCKn↔工位n)+ DOCK21(库房收货)。
|
|||
|
|
// 接驳台真源在 MES(工位维护、AGV 通讯、排产推荐都查本表);仓库不维护接驳台。
|
|||
|
|
// hasPallet 标记该接驳台当前是否有托盘:来源 PLC 托盘传感器 或 AGV 到位/卸货自动维护。
|
|||
|
|
type Dock struct {
|
|||
|
|
ent.Schema
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (Dock) Annotations() []schema.Annotation {
|
|||
|
|
return []schema.Annotation{entsql.Annotation{Table: "dock"}}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (Dock) Fields() []ent.Field {
|
|||
|
|
return []ent.Field{
|
|||
|
|
field.String("dockCode").Unique().MaxLen(20).Comment("接驳台编码 DOCK01..21"),
|
|||
|
|
field.String("name").Default("").MaxLen(64).Comment("接驳台名称"),
|
|||
|
|
// type: line(产线) / store(库房) / other(其他,如缓存区、线边暂存位)
|
|||
|
|
field.String("dockType").Default("line").MaxLen(16).Comment("类型 line产线/store库房/other其他"),
|
|||
|
|
// 关联工位(产线接驳台 DOCKn↔工位n,1:1);库房/其他接驳台不挂工位,为 0
|
|||
|
|
field.Int("stationNo").Default(0).Comment("关联工位号(与工位1:1,非产线为0)"),
|
|||
|
|
field.Bool("hasPallet").Default(false).Comment("当前是否有托盘"),
|
|||
|
|
// 有托盘时的关联出库/任务(便于查这个托盘是哪批料、要送到哪)
|
|||
|
|
field.String("palletRef").Default("").MaxLen(64).Optional().Comment("托盘关联(出库单号/备料单号)"),
|
|||
|
|
// ENABLED / DISABLED
|
|||
|
|
field.String("status").Default("ENABLED").MaxLen(20),
|
|||
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (Dock) Indexes() []ent.Index {
|
|||
|
|
return []ent.Index{
|
|||
|
|
index.Fields("dockCode").Unique(),
|
|||
|
|
index.Fields("dockType"),
|
|||
|
|
}
|
|||
|
|
}
|