54 lines
1.9 KiB
Go
54 lines
1.9 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"}}
|
||
|
|
}
|
||
|
|
|
||
|
|
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("processCode").Comment("装配工序 1~12"),
|
||
|
|
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("单位"),
|
||
|
|
// 1 批次(结构件) / 2 序列号(精密件)
|
||
|
|
field.String("manageMode").Default("2").MaxLen(10),
|
||
|
|
// 结构件=批次号;精密件=SN 码
|
||
|
|
field.String("bindValue").MaxLen(128).Comment("绑定值:批次号 或 SN"),
|
||
|
|
// BATCH(批次绑定) / SN(序列号绑定),冗余自 manageMode 便于直接展示
|
||
|
|
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", "processCode"),
|
||
|
|
index.Fields("sn", "materialCode"),
|
||
|
|
index.Fields("orderNo"),
|
||
|
|
index.Fields("materialCode", "bindValue"),
|
||
|
|
}
|
||
|
|
}
|