本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
45 lines
1.5 KiB
Go
45 lines
1.5 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"
|
|
)
|
|
|
|
// FlowMaterial 工艺物料清单:一道工艺装什么料、单台用多少(备料/齐套校验的唯一源头)。
|
|
// 约束:物料必须属于产品物料清单子集(写入时校验)。
|
|
type FlowMaterial struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (FlowMaterial) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{entsql.Annotation{Table: "flow_material"}, entsql.WithComments(true), schema.Comment("FlowMaterial 工艺物料清单:一道工艺装什么料、单台用多少(备料/齐套校验的唯一源头)。")}
|
|
}
|
|
|
|
func (FlowMaterial) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("id").Positive(),
|
|
field.Int("flowId").Comment("所属工艺ID"),
|
|
field.String("materialCode").MaxLen(64).Comment("物料编码"),
|
|
field.String("materialName").Default("").MaxLen(128),
|
|
field.String("spec").Default("").MaxLen(128),
|
|
field.String("unit").Default("").MaxLen(16),
|
|
// 是否逐件SN管理(冗余自物料档案 sn_mode,绑定/备料行为唯一依据):1 序列号=是(录SN) / 2 序列号=否
|
|
field.Int("snMode").Default(2),
|
|
field.Float("unitQty").Default(0).Comment("单台用量"),
|
|
field.Float("lossRate").Default(0).Comment("损耗率%"),
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
}
|
|
}
|
|
|
|
func (FlowMaterial) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("flowId"),
|
|
index.Fields("flowId", "materialCode").Unique(),
|
|
}
|
|
}
|