2026-08-28 15:06:01 +08:00
|
|
|
package schema
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
2026-09-17 12:49:07 +08:00
|
|
|
"entgo.io/ent/dialect"
|
2026-08-28 15:06:01 +08:00
|
|
|
"entgo.io/ent/dialect/entsql"
|
|
|
|
|
"entgo.io/ent/schema"
|
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
|
"entgo.io/ent/schema/index"
|
|
|
|
|
)
|
|
|
|
|
|
2026-09-10 16:59:15 +08:00
|
|
|
// ProcessStep 工序步骤模板:一份工艺流程包含多个采集/考核步骤(按 seq 顺序执行)
|
2026-08-28 15:06:01 +08:00
|
|
|
type ProcessStep struct {
|
|
|
|
|
ent.Schema
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ProcessStep) Annotations() []schema.Annotation {
|
2026-10-08 13:09:53 +08:00
|
|
|
return []schema.Annotation{entsql.Annotation{Table: "process_step"}, entsql.WithComments(true), schema.Comment("ProcessStep 工序步骤模板:一份工艺流程包含多个采集/考核步骤(按 seq 顺序执行)")}
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ProcessStep) Fields() []ent.Field {
|
|
|
|
|
return []ent.Field{
|
|
|
|
|
field.Int("id").Positive(),
|
2026-09-10 16:59:15 +08:00
|
|
|
field.Int("flowId").Optional().Comment("所属工艺流程图ID"),
|
2026-08-28 15:06:01 +08:00
|
|
|
field.Int("seq").Default(1).Comment("步骤序号"),
|
|
|
|
|
field.String("name").MaxLen(128).Comment("步骤名称"),
|
2026-10-20 16:36:26 +08:00
|
|
|
field.String("collectType").Default("NONE").MaxLen(20).Comment("采集方式 AUTO(拧紧枪自动)/MANUAL(手填)/SCAN(扫码,与手填等价采一串字符串)/NONE(仅记录)"),
|
2026-09-10 16:59:15 +08:00
|
|
|
field.Bool("needCheck").Default(false).Comment("是否需要检测确认(报工前须检验通过)"),
|
2026-10-05 20:15:38 +08:00
|
|
|
field.Bool("needOperatorSign").Default(false).Comment("是否需要操作工签字(报工前须签字确认)"),
|
|
|
|
|
field.Bool("needInspectorSign").Default(false).Comment("是否需要检验员签字(审核通过并签字后放行)"),
|
2026-10-09 13:46:33 +08:00
|
|
|
field.Bool("needAudit").Default(false).Comment("是否需要审核人复核签字(审核通过后放行)"),
|
|
|
|
|
field.String("auditRole").Default("").MaxLen(64).Optional().Comment("审核角色(如班组长/工艺员),具该角色的人员可签"),
|
2026-09-17 12:49:07 +08:00
|
|
|
// 本步骤图纸/附件(按工序分发到工位终端),多份,存 {name,url} 列表
|
|
|
|
|
field.JSON("attachment", []map[string]string{}).Optional().SchemaType(map[string]string{
|
|
|
|
|
dialect.Postgres: "jsonb",
|
|
|
|
|
}).Comment("本步骤图纸/附件列表 [{name,url}]"),
|
2026-08-28 15:06:01 +08:00
|
|
|
field.String("remark").Default("").MaxLen(255),
|
|
|
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ProcessStep) Indexes() []ent.Index {
|
2026-08-31 08:06:55 +08:00
|
|
|
return []ent.Index{
|
|
|
|
|
index.Fields("flowId"),
|
|
|
|
|
}
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|