2026-08-28 15:06:01 +08:00
|
|
|
package schema
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
|
"entgo.io/ent/dialect"
|
|
|
|
|
"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
|
|
|
// AssociationTrace 成品追溯关联:成品SN ↔ 结构件批次 + 电气件SN
|
2026-08-28 15:06:01 +08:00
|
|
|
type AssociationTrace struct {
|
|
|
|
|
ent.Schema
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (AssociationTrace) Annotations() []schema.Annotation {
|
|
|
|
|
return []schema.Annotation{entsql.Annotation{Table: "association_trace"}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (AssociationTrace) Fields() []ent.Field {
|
|
|
|
|
return []ent.Field{
|
|
|
|
|
field.Int("id").Positive(),
|
|
|
|
|
field.String("finishedSn").Unique().MaxLen(64).Comment("成品SN(主件)"),
|
|
|
|
|
field.String("orderNo").Default("").MaxLen(64),
|
|
|
|
|
field.String("processCode").Default("").MaxLen(64).Comment("成品的工序组合"),
|
|
|
|
|
field.JSON("batchItems", []string{}).Optional().SchemaType(map[string]string{
|
|
|
|
|
dialect.Postgres: "jsonb",
|
|
|
|
|
}).Comment("结构件批次号列表"),
|
|
|
|
|
field.JSON("serialItems", []string{}).Optional().SchemaType(map[string]string{
|
|
|
|
|
dialect.Postgres: "jsonb",
|
2026-09-10 16:59:15 +08:00
|
|
|
}).Comment("电气件SN码列表"),
|
2026-08-28 15:06:01 +08:00
|
|
|
field.String("operator").Default("").MaxLen(64).Comment("完工关联登记人"),
|
|
|
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (AssociationTrace) Indexes() []ent.Index {
|
|
|
|
|
return []ent.Index{index.Fields("finishedSn").Unique()}
|
|
|
|
|
}
|