Files
bj_power/bj_power_mes/schema/product_process.go
T
SunYF b032f47fc7 feat: 新增产品工艺管理与工序审核功能
- 新增产品工艺(product_process)及明细(product_process_item)数据模型
- 新增工序审核开关(need_audit)与审核角色(audit_role)字段
- 新增待审核签字页面与路由
- 优化 WMS/MES 接口交互,增加业务错误处理与友好提示
- 补充库存过滤逻辑,避免返回已出库 SN 数据
- 调整默认查询时间范围为近一个月,优化用户体验
2026-10-09 13:46:33 +08:00

47 lines
2.2 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"
)
// ProductProcess 产品工艺:产品级的工艺定义("这个产品该按什么顺序经过哪些工艺")。
// 只选工艺+顺序(seq 严格递增=串行),不绑工位——工位在建工单时按「工位绑定」(station.flow_id)
// 自动推导(同工艺的全部启用工位),并复制为工单工艺组合 flow_combination 快照。
// 约束:① 同一工艺在同一产品工艺内不重复(明细表唯一索引);② 每产品至多一条默认(is_default);
// ③ 被工单引用过(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常规"),
// 每产品至多一条默认:建工单选完产品自动带出默认产品工艺(设新自动取消旧默认)
field.Bool("isDefault").Default(false).Comment("是否该产品的默认产品工艺(每产品至多一条)"),
// 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"),
index.Fields("productCode", "isDefault"),
}
}