Files
bj_power/bj_power_mes/schema/workpiece_bind.go
T
SunYF 8be6e03a15 docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
2026-10-10 15:58:59 +08:00

54 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"
)
// WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 电气件=SN)
// 绑定到工件,构成"这台机实际用了哪些料"的单件追溯。绑定动作在工位扫码/手录产生。
type WorkpieceBind struct {
ent.Schema
}
func (WorkpieceBind) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_bind"}, entsql.WithComments(true), schema.Comment("WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 电气件=SN)")}
}
func (WorkpieceBind) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("sn").MaxLen(64).Comment("工件SN"),
field.String("orderNo").Default("").MaxLen(64).Comment("工单号"),
field.Int("flowId").Comment("装配工艺ID"),
field.String("stationNo").Default("").MaxLen(32).Comment("绑定工位"),
field.String("materialCode").MaxLen(64).Comment("物料编码"),
field.String("materialName").Default("").MaxLen(128).Comment("物料名称"),
field.String("spec").Default("").MaxLen(128).Comment("规格"),
field.String("unit").Default("").MaxLen(16).Comment("单位"),
// 是否逐件SN管理(冗余自物料档案 sn_mode,追溯展示/绑定口径依据):1 序列号=是(SN) / 2 序列号=否
field.Int("snMode").Default(2),
// 结构件=批次号;电气件=SN 码
field.String("bindValue").MaxLen(128).Comment("绑定值:批次号 或 SN"),
// BATCH(批次绑定) / SN(序列号绑定),冗余自 snMode 便于直接展示
field.String("bindType").Default("SN").MaxLen(10),
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
field.Time("createdAt").Default(time.Now).Immutable().Comment("绑定时间"),
}
}
func (WorkpieceBind) Indexes() []ent.Index {
return []ent.Index{
index.Fields("sn"),
index.Fields("sn", "flowId"),
index.Fields("sn", "materialCode"),
index.Fields("orderNo"),
index.Fields("materialCode", "bindValue"),
}
}