36 lines
982 B
Go
36 lines
982 B
Go
package schema
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"entgo.io/ent"
|
||
|
|
"entgo.io/ent/dialect"
|
||
|
|
"entgo.io/ent/schema/field"
|
||
|
|
"entgo.io/ent/schema/index"
|
||
|
|
)
|
||
|
|
|
||
|
|
// MaterialRequest 备料单:MES 按 BOM×数量 调 WMS 检查/锁定库存的记录
|
||
|
|
type MaterialRequest struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (MaterialRequest) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.String("request_no").Unique().Comment("备料单号"),
|
||
|
|
field.String("order_no").Comment("工单号"),
|
||
|
|
field.JSON("items", []map[string]any{}).Optional().SchemaType(map[string]string{
|
||
|
|
dialect.Postgres: "jsonb",
|
||
|
|
}).Comment("[{materialCode,materialName,totalQty,availQty,enough}]"),
|
||
|
|
field.Bool("all_enough").Default(false),
|
||
|
|
field.String("status").Default("已检查").Comment("已检查/库存不足/已生成出库建议"),
|
||
|
|
field.String("operator").Optional(),
|
||
|
|
field.Time("created_at").Default(time.Now).Immutable(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (MaterialRequest) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("order_no"),
|
||
|
|
}
|
||
|
|
}
|