46 lines
1.5 KiB
Go
46 lines
1.5 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"
|
||
|
|
)
|
||
|
|
|
||
|
|
// PlcMoveCmd 上位机移料指令:PLC 不控制任何流程,只执行本指令(如“从 C2 到工位4”)。
|
||
|
|
// 状态机:ISSUED 已下发 → ACK PLC已应答 → ARRIVED 已到位 → CLOSED 已闭环;异常 FAILED。
|
||
|
|
type PlcMoveCmd struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PlcMoveCmd) Annotations() []schema.Annotation {
|
||
|
|
return []schema.Annotation{entsql.Annotation{Table: "plc_move_cmd"}}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PlcMoveCmd) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.Int("id").Positive(),
|
||
|
|
field.String("cmdNo").MaxLen(64).Comment("指令号(幂等去重)"),
|
||
|
|
field.String("sn").MaxLen(128).Comment("被移工件SN"),
|
||
|
|
field.String("orderNo").Default("").MaxLen(64).Comment("所属工单号"),
|
||
|
|
field.String("fromPoint").MaxLen(32).Comment("起点位编号"),
|
||
|
|
field.String("toPoint").MaxLen(32).Comment("目标点位编号"),
|
||
|
|
field.String("status").Default("ISSUED").MaxLen(20).Comment("ISSUED/ACK/ARRIVED/CLOSED/FAILED"),
|
||
|
|
field.String("operator").Default("").MaxLen(64).Comment("下发人(SYSTEM=自动)"),
|
||
|
|
field.String("message").Default("").MaxLen(255).Comment("异常/备注"),
|
||
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
||
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PlcMoveCmd) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("cmdNo").Unique(),
|
||
|
|
index.Fields("sn"),
|
||
|
|
index.Fields("status"),
|
||
|
|
}
|
||
|
|
}
|