Files
bj_power/bj_power_mes/schema/route_segment.go
T

38 lines
1.3 KiB
Go
Raw Normal View History

package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
)
// RouteSegment 工艺路线的一段:一个流程图 + 一组并行工位 + 段序号。
// stations 存并行工位号 JSON(如 [4,4] 两并工位;[0] 上线位、[13] 下线位)。
type RouteSegment struct {
ent.Schema
}
func (RouteSegment) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "route_segment"}}
}
func (RouteSegment) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("routeId").Comment("所属工艺路线ID"),
field.Int("seq").Default(1).Comment("段序号(从 0 开始,按序执行)"),
field.Int("flowId").Optional().Comment("该段对应的工艺流程图ID"),
// 并行工位号数组,如 [4,4]
field.JSON("stations", []int{}).Optional().SchemaType(map[string]string{
"postgres": "jsonb",
}).Comment("本段并行工位号列表"),
// LINE(线上位,连PLC) / OFFLINE(线下位,如 0 上线位、13 下线位,不连PLC)
field.String("segmentType").Default("LINE").MaxLen(20).Comment("段类型 LINE/OFFLINE"),
field.String("remark").Default("").MaxLen(255),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}