45 lines
1.8 KiB
Go
45 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"
|
||
|
|
)
|
||
|
|
|
||
|
|
// LinePoint 产线点位台账:记录每个点位当前存放的工件(唯一事实源)。
|
||
|
|
// 产线布局(修正版):上料位 IN(工位1/2间主线,带传感器)、工位 1~10(有终端)、
|
||
|
|
// 末端下料检测位 11(上排末端)/12(下排末端)(无终端,PLC 点位)、缓存位 C1~C8、
|
||
|
|
// 每个有终端工位配 R1、R2 两个接驳台(AGV 点位,PLC 只读到位信号)。
|
||
|
|
type LinePoint struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (LinePoint) Annotations() []schema.Annotation {
|
||
|
|
return []schema.Annotation{entsql.Annotation{Table: "line_point"}}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (LinePoint) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.Int("id").Positive(),
|
||
|
|
field.String("pointType").MaxLen(20).Comment("FEED上料位/STATION工位/CACHE缓存位/DOCK接驳台/END末端"),
|
||
|
|
field.String("pointNo").MaxLen(32).Comment("点位编号:IN上料位 / 1~10工位 / C1~C8缓存位 / 1-R1接驳台 / END-U上排末端 / END-D下排末端"),
|
||
|
|
field.String("label").Default("").MaxLen(64).Comment("点位名称"),
|
||
|
|
field.Int("seq").Default(0).Comment("传送带顺序(上料位→工位→末端,用于相邻缓存位判定)"),
|
||
|
|
field.Int("stationNo").Default(0).Comment("所属工位号(DOCK/CACHE 归属;0=无)"),
|
||
|
|
field.String("currentSn").Default("").MaxLen(128).Comment("当前存放工件SN(空=空闲)"),
|
||
|
|
field.String("orderNo").Default("").MaxLen(64).Comment("当前工件所属工单号"),
|
||
|
|
field.Bool("occupied").Default(false).Comment("是否占用"),
|
||
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (LinePoint) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("pointType", "pointNo").Unique(),
|
||
|
|
}
|
||
|
|
}
|