48 lines
1.4 KiB
Go
48 lines
1.4 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"
|
|
)
|
|
|
|
// PlcSendLog PLC 工序码下发日志
|
|
type PlcSendLog struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (PlcSendLog) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{entsql.Annotation{Table: "plc_send_log"}}
|
|
}
|
|
|
|
func (PlcSendLog) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("id").Positive(),
|
|
field.String("orderNo").Default("").MaxLen(64).Comment("工单号"),
|
|
field.String("sn").Default("").MaxLen(64).Comment("工件SN"),
|
|
field.Int("stationNo").Optional().Comment("工位号"),
|
|
field.String("processCombination").Default("").MaxLen(64).Comment("工序组合,如 135"),
|
|
field.JSON("processCodes", []int{}).Optional().Comment("工序码表"),
|
|
// PENDING / SENT / DONE / TIMEOUT / REPLY_NG
|
|
field.String("status").Default("PENDING").MaxLen(20),
|
|
field.Time("sendTime").Optional().Nillable().Comment("下发时间"),
|
|
field.Time("doneTime").Optional().Nillable().Comment("收到完成信号时间"),
|
|
field.Bool("ack").Default(false).Comment("是否收到完成信号"),
|
|
field.String("remark").Default("").MaxLen(255),
|
|
field.String("operator").Default("").MaxLen(64),
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
}
|
|
}
|
|
|
|
func (PlcSendLog) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("orderNo"),
|
|
index.Fields("sn"),
|
|
index.Fields("status"),
|
|
}
|
|
}
|