Files
bj_power/bj_power_mes/schema/workpiece.go
T
SunYF 1f7a42fc38 refactor(mes): 移除工位接驳台绑定逻辑,改为独立dock主数据
- 移除station表的hasDock、dockCode字段及相关代码
- 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台
- 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式
- 新增SQL注释固化脚本,完善MES表注释
2026-10-08 13:09:53 +08:00

45 lines
1.5 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"
)
// Workpiece 工件(SN):序列号管理的成品/主件
type Workpiece struct {
ent.Schema
}
func (Workpiece) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece"}, entsql.WithComments(true), schema.Comment("Workpiece 工件(SN):序列号管理的成品/主件")}
}
func (Workpiece) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("sn").Unique().MaxLen(64).Comment("工件唯一SN"),
field.String("orderNo").Default("").MaxLen(64).Comment("所属工单"),
field.Int("workOrderId").Optional().Comment("工单ID"),
field.Int("currentStationNo").Optional().Comment("最后完成报工的工位号(0=未报任何工艺;下一道=工艺组合中工位号更大的下一条)"),
// ONLINE(已进线) / PROCESSING(在工位) / DONE(完工) / REPAIR / SCRAPPED
field.String("status").Default("ONLINE").MaxLen(20),
field.Time("onlineAt").Optional().Nillable().Comment("进线时间"),
field.Time("doneAt").Optional().Nillable().Comment("完工时间"),
field.Time("createdAt").Default(time.Now).Immutable(),
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
}
}
func (Workpiece) Indexes() []ent.Index {
return []ent.Index{
index.Fields("sn").Unique(),
index.Fields("orderNo"),
index.Fields("status"),
}
}