feat: 新增产品工艺管理与工序审核功能
- 新增产品工艺(product_process)及明细(product_process_item)数据模型 - 新增工序审核开关(need_audit)与审核角色(audit_role)字段 - 新增待审核签字页面与路由 - 优化 WMS/MES 接口交互,增加业务错误处理与友好提示 - 补充库存过滤逻辑,避免返回已出库 SN 数据 - 调整默认查询时间范围为近一个月,优化用户体验
This commit is contained in:
@@ -31,6 +31,8 @@ func (ProcessStep) Fields() []ent.Field {
|
||||
field.Bool("needCheck").Default(false).Comment("是否需要检测确认(报工前须检验通过)"),
|
||||
field.Bool("needOperatorSign").Default(false).Comment("是否需要操作工签字(报工前须签字确认)"),
|
||||
field.Bool("needInspectorSign").Default(false).Comment("是否需要检验员签字(审核通过并签字后放行)"),
|
||||
field.Bool("needAudit").Default(false).Comment("是否需要审核人复核签字(审核通过后放行)"),
|
||||
field.String("auditRole").Default("").MaxLen(64).Optional().Comment("审核角色(如班组长/工艺员),具该角色的人员可签"),
|
||||
// 本步骤图纸/附件(按工序分发到工位终端),多份,存 {name,url} 列表
|
||||
field.JSON("attachment", []map[string]string{}).Optional().SchemaType(map[string]string{
|
||||
dialect.Postgres: "jsonb",
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// ProductProcessItem 产品工艺明细:有序工艺执行点(seq 从 1 严格递增=串行执行顺序)。
|
||||
// 同一工艺在同一产品工艺内不重复(唯一索引兜底);不存工位——工位在建工单时
|
||||
// 按 station.flow_id 自动推导(同工艺的全部启用工位),产品工艺只定义"经过哪些工艺、什么顺序"。
|
||||
type ProductProcessItem struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (ProductProcessItem) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{entsql.Annotation{Table: "product_process_item"}, entsql.WithComments(true), schema.Comment("ProductProcessItem 产品工艺明细:有序工艺执行点(seq 严格递增=串行;工位建单时推导,不落本表)")}
|
||||
}
|
||||
|
||||
func (ProductProcessItem) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.Int("productProcessId").Comment("所属产品工艺ID"),
|
||||
field.Int("seq").Comment("顺序号(从1严格递增,即执行顺序)"),
|
||||
field.Int("flowId").Comment("工艺ID(process_flow)"),
|
||||
field.Time("createdAt").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (ProductProcessItem) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("productProcessId"),
|
||||
// 同一产品工艺内同一工艺不重复(客户裁决:不能出现两次)
|
||||
index.Fields("productProcessId", "flowId").Unique(),
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,9 @@ func (WorkOrder) Fields() []ent.Field {
|
||||
field.JSON("flowCombination", []map[string]int{}).Optional().SchemaType(map[string]string{
|
||||
dialect.Postgres: "jsonb",
|
||||
}).Comment("工艺组合 [{flowId,stationNo}] 按工位号升序"),
|
||||
// 产品工艺来源(2026-10-09):建单选产品时带出默认产品工艺并自动填组合;组合是快照、可手改,
|
||||
// 本字段恒保留=来源定义(0=无来源,历史工单),供追溯与偏差提示,不随组合编辑清空。
|
||||
field.Int("productProcessId").Default(0).Comment("来源产品工艺ID(0=无来源)"),
|
||||
// CREATED / RELEASED / IN_PROGRESS / COMPLETED / CLOSED
|
||||
field.String("status").Default("CREATED").MaxLen(20),
|
||||
field.Time("planStart").Optional().Nillable().Comment("计划开始"),
|
||||
|
||||
Reference in New Issue
Block a user