2026-08-31 08:06:55 +08:00
|
|
|
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"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId)
|
|
|
|
|
type Station struct {
|
|
|
|
|
ent.Schema
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Station) Annotations() []schema.Annotation {
|
2026-10-08 13:09:53 +08:00
|
|
|
return []schema.Annotation{entsql.Annotation{Table: "station"}, entsql.WithComments(true), schema.Comment("Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId)")}
|
2026-08-31 08:06:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Station) Fields() []ent.Field {
|
|
|
|
|
return []ent.Field{
|
|
|
|
|
field.Int("id").Positive(),
|
|
|
|
|
field.Int("stationNo").Unique().Comment("工位号 1..12"),
|
|
|
|
|
field.String("name").Default("").MaxLen(64).Comment("工位名称"),
|
|
|
|
|
field.Int("flowId").Optional().Comment("绑定工艺流程图ID"),
|
2026-09-10 16:59:15 +08:00
|
|
|
// LINE(线上位,连PLC) / OFFLINE(线下位,如 0 上线位、13 下线位,不连PLC)
|
|
|
|
|
field.String("stationType").Default("LINE").MaxLen(20).Comment("工位类型 LINE/OFFLINE"),
|
2026-08-31 08:06:55 +08:00
|
|
|
// ENABLED / DISABLED
|
|
|
|
|
field.String("status").Default("ENABLED").MaxLen(20),
|
2026-09-18 18:54:54 +08:00
|
|
|
// 内置工位标识:由种子/初始化数据(或迁入数据)写入,代表实体产线上的固定工位,
|
|
|
|
|
// 需与 PLC 通讯、必须按工位号顺序流转;内置工位不允许改工位类型、不允许删除。
|
|
|
|
|
// 页面「新增工位」创建的是非内置工位(可改类型、可删除)。
|
|
|
|
|
field.Bool("isBuiltin").Default(false).Comment("内置工位:不可改类型/不可删除"),
|
2026-09-23 11:41:28 +08:00
|
|
|
// 终端可见页签(按工位配置,2026-09-23):空=全部显示(兼容存量工位);
|
2026-10-05 20:15:38 +08:00
|
|
|
// 可选值 online(上线建档)/work(作业)/material(物料叫料)/move(产线点位:上料/下料,历史 key 沿用)/pdf(工艺文件)/inspect(巡检异常)/offline(下线完工)
|
2026-09-23 11:41:28 +08:00
|
|
|
field.JSON("visibleTabs", []string{}).Optional(),
|
2026-08-31 08:06:55 +08:00
|
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Station) Indexes() []ent.Index {
|
|
|
|
|
return []ent.Index{index.Fields("stationNo").Unique()}
|
|
|
|
|
}
|