初始化2
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// WorkpieceProcess 工件-工序实绩(某工件在某工位完成某道工序的一次记录,构成工序时间线)
|
||||
type WorkpieceProcess struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (WorkpieceProcess) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{entsql.Annotation{Table: "workpiece_process"}}
|
||||
}
|
||||
|
||||
func (WorkpieceProcess) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.String("sn").MaxLen(64).Comment("工件SN"),
|
||||
field.Int("processCode").Comment("工序代码"),
|
||||
field.String("stationNo").Default("").MaxLen(32).Comment("工位号"),
|
||||
field.String("orderNo").Default("").MaxLen(64),
|
||||
field.String("processName").Default("").MaxLen(64),
|
||||
// PENDING / DOING / DONE / NG / REPAIRED
|
||||
field.String("status").Default("DONE").MaxLen(20),
|
||||
field.String("operator").Default("").MaxLen(64),
|
||||
field.String("result").Default("OK").MaxLen(10).Comment("总判定 OK/NG"),
|
||||
field.Time("startedAt").Optional().Nillable(),
|
||||
field.Time("endedAt").Optional().Nillable(),
|
||||
field.String("remark").Default("").MaxLen(255),
|
||||
field.Time("createdAt").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (WorkpieceProcess) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("sn"),
|
||||
index.Fields("sn", "processCode"),
|
||||
index.Fields("orderNo"),
|
||||
index.Fields("stationNo"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user