feat: 新增产品工艺管理与工序审核功能

- 新增产品工艺(product_process)及明细(product_process_item)数据模型
- 新增工序审核开关(need_audit)与审核角色(audit_role)字段
- 新增待审核签字页面与路由
- 优化 WMS/MES 接口交互,增加业务错误处理与友好提示
- 补充库存过滤逻辑,避免返回已出库 SN 数据
- 调整默认查询时间范围为近一个月,优化用户体验
This commit is contained in:
SunYF
2026-10-09 13:46:33 +08:00
parent e2f1dacf76
commit b032f47fc7
95 changed files with 10546 additions and 1457 deletions
+69 -1
View File
@@ -621,6 +621,8 @@ var (
{Name: "need_check", Type: field.TypeBool, Comment: "是否需要检测确认(报工前须检验通过)", Default: false},
{Name: "need_operator_sign", Type: field.TypeBool, Comment: "是否需要操作工签字(报工前须签字确认)", Default: false},
{Name: "need_inspector_sign", Type: field.TypeBool, Comment: "是否需要检验员签字(审核通过并签字后放行)", Default: false},
{Name: "need_audit", Type: field.TypeBool, Comment: "是否需要审核人复核签字(审核通过后放行)", Default: false},
{Name: "audit_role", Type: field.TypeString, Nullable: true, Size: 64, Comment: "审核角色(如班组长/工艺员),具该角色的人员可签", Default: ""},
{Name: "attachment", Type: field.TypeJSON, Nullable: true, Comment: "本步骤图纸/附件列表 [{name,url}]", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
@@ -639,6 +641,63 @@ var (
},
},
}
// ProductProcessColumns holds the columns for the "product_process" table.
ProductProcessColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "product_code", Type: field.TypeString, Size: 64, Comment: "产品编码(WMS 物料档案 item_type=3 图号)"},
{Name: "product_name", Type: field.TypeString, Size: 128, Comment: "产品名称(快照,WMS 改名不回写)", Default: ""},
{Name: "name", Type: field.TypeString, Size: 128, Comment: "产品工艺名称,如 DX100常规"},
{Name: "is_default", Type: field.TypeBool, Comment: "是否该产品的默认产品工艺(每产品至多一条)", Default: false},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ACTIVE"},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// ProductProcessTable holds the schema information for the "product_process" table.
ProductProcessTable = &schema.Table{
Name: "product_process",
Comment: "ProductProcess 产品工艺:产品级工艺定义(有序工艺集合,不绑工位;建工单时推导工位并复制为工艺组合快照)",
Columns: ProductProcessColumns,
PrimaryKey: []*schema.Column{ProductProcessColumns[0]},
Indexes: []*schema.Index{
{
Name: "productprocess_product_code",
Unique: false,
Columns: []*schema.Column{ProductProcessColumns[1]},
},
{
Name: "productprocess_product_code_is_default",
Unique: false,
Columns: []*schema.Column{ProductProcessColumns[1], ProductProcessColumns[4]},
},
},
}
// ProductProcessItemColumns holds the columns for the "product_process_item" table.
ProductProcessItemColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "product_process_id", Type: field.TypeInt, Comment: "所属产品工艺ID"},
{Name: "seq", Type: field.TypeInt, Comment: "顺序号(从1严格递增,即执行顺序)"},
{Name: "flow_id", Type: field.TypeInt, Comment: "工艺ID(process_flow)"},
{Name: "created_at", Type: field.TypeTime},
}
// ProductProcessItemTable holds the schema information for the "product_process_item" table.
ProductProcessItemTable = &schema.Table{
Name: "product_process_item",
Comment: "ProductProcessItem 产品工艺明细:有序工艺执行点(seq 严格递增=串行;工位建单时推导,不落本表)",
Columns: ProductProcessItemColumns,
PrimaryKey: []*schema.Column{ProductProcessItemColumns[0]},
Indexes: []*schema.Index{
{
Name: "productprocessitem_product_process_id",
Unique: false,
Columns: []*schema.Column{ProductProcessItemColumns[1]},
},
{
Name: "productprocessitem_product_process_id_flow_id",
Unique: true,
Columns: []*schema.Column{ProductProcessItemColumns[1], ProductProcessItemColumns[3]},
},
},
}
// RoleColumns holds the columns for the "role" table.
RoleColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
@@ -1001,6 +1060,7 @@ var (
{Name: "created_by", Type: field.TypeString, Size: 64, Comment: "创建人", Default: ""},
{Name: "due_date", Type: field.TypeTime, Nullable: true, Comment: "完成日期(必填)"},
{Name: "flow_combination", Type: field.TypeJSON, Nullable: true, Comment: "工艺组合 [{flowId,stationNo}] 按工位号升序", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "product_process_id", Type: field.TypeInt, Comment: "来源产品工艺ID(0=无来源)", Default: 0},
{Name: "status", Type: field.TypeString, Size: 20, Default: "CREATED"},
{Name: "plan_start", Type: field.TypeTime, Nullable: true, Comment: "计划开始"},
{Name: "plan_end", Type: field.TypeTime, Nullable: true, Comment: "计划结束"},
@@ -1024,7 +1084,7 @@ var (
{
Name: "workorder_status",
Unique: false,
Columns: []*schema.Column{WorkOrderColumns[15]},
Columns: []*schema.Column{WorkOrderColumns[16]},
},
{
Name: "workorder_product_type_id",
@@ -1192,6 +1252,8 @@ var (
PlcSendLogTable,
ProcessFlowTable,
ProcessStepTable,
ProductProcessTable,
ProductProcessItemTable,
RoleTable,
SemiFlowTable,
StationTable,
@@ -1262,6 +1324,12 @@ func init() {
ProcessStepTable.Annotation = &entsql.Annotation{
Table: "process_step",
}
ProductProcessTable.Annotation = &entsql.Annotation{
Table: "product_process",
}
ProductProcessItemTable.Annotation = &entsql.Annotation{
Table: "product_process_item",
}
RoleTable.Annotation = &entsql.Annotation{
Table: "role",
}