36 lines
982 B
Go
36 lines
982 B
Go
package schema
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"entgo.io/ent"
|
||
|
|
"entgo.io/ent/schema/field"
|
||
|
|
"entgo.io/ent/schema/index"
|
||
|
|
)
|
||
|
|
|
||
|
|
// PlcSendLog PLC 工序号下发记录
|
||
|
|
// 例:产线12道工序,收齐 5 个工序号则下发 125 给 PLC 执行 1 序 2 序 5 序
|
||
|
|
type PlcSendLog struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PlcSendLog) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.String("order_no").Optional().Comment("关联工单号"),
|
||
|
|
field.String("code_str").Comment("下发的工序号串,如 125"),
|
||
|
|
field.String("mode").Default("sim").Comment("sim/real"),
|
||
|
|
field.String("result").Default("已下发").Comment("已下发/已确认/失败"),
|
||
|
|
field.String("error_text").Optional(),
|
||
|
|
field.Time("sent_at").Default(time.Now),
|
||
|
|
field.Time("ack_at").Optional().Nillable().Comment("PLC 完成确认时间"),
|
||
|
|
field.Time("created_at").Default(time.Now).Immutable(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PlcSendLog) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("order_no"),
|
||
|
|
index.Fields("sent_at"),
|
||
|
|
}
|
||
|
|
}
|