Files
bj_power/bj_power_mes/schema/product_process.go
T

44 lines
1.9 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"
"entgo.io/ent/schema/index"
)
// ProductProcess 产品工艺:产品级的工艺定义("这个产品该按什么顺序经过哪些工艺")。
// 只选工艺+顺序(seq 严格递增=串行),不绑工位——工位在建工单时按「工位绑定」(station.flow_id)
// 自动推导(同工艺的全部启用工位),并复制为工单工艺组合 flow_combination 快照。
// 约束:① 同一工艺在同一产品工艺内不重复(明细表唯一索引);② 一个产品对应一个产品工艺(新建重复直接报错,编辑复用原行);
// ③ 被工单引用过(work_order.product_process_id)后只读,只能停用+新建,历史工单可反查当时定义。
type ProductProcess struct {
ent.Schema
}
func (ProductProcess) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "product_process"}, entsql.WithComments(true), schema.Comment("ProductProcess 产品工艺:产品级工艺定义(有序工艺集合,不绑工位;建工单时推导工位并复制为工艺组合快照)")}
}
func (ProductProcess) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("productCode").MaxLen(64).Comment("产品编码(WMS 物料档案 item_type=3 图号)"),
field.String("productName").Default("").MaxLen(128).Comment("产品名称(快照,WMS 改名不回写)"),
field.String("name").MaxLen(128).Comment("产品工艺名称,如 DX100常规"),
// ACTIVE / INACTIVE(停用不删:历史工单按 product_process_id 反查当时定义)
field.String("status").Default("ACTIVE").MaxLen(20),
field.String("remark").Default("").MaxLen(255),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (ProductProcess) Indexes() []ent.Index {
return []ent.Index{
index.Fields("productCode"),
}
}