42 lines
1.4 KiB
Go
42 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"
|
||
|
|
)
|
||
|
|
|
||
|
|
// StationState 工位运行状态(当日有效):工人自主 停止接单/恢复接单。
|
||
|
|
// 停单后上位机不再向该工位下发工件流转指令;某工艺全部工位停单=工件目的地不可达,报警。
|
||
|
|
// 跨天自动失效(只认当天记录),次日默认全部恢复接单。
|
||
|
|
type StationState struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (StationState) Annotations() []schema.Annotation {
|
||
|
|
return []schema.Annotation{entsql.Annotation{Table: "station_state"}}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (StationState) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.Int("id").Positive(),
|
||
|
|
field.Int("stationNo").Comment("工位号"),
|
||
|
|
field.String("date").MaxLen(10).Comment("生效日期 yyyy-MM-dd(只认当天)"),
|
||
|
|
field.Bool("paused").Default(false).Comment("是否停止接单"),
|
||
|
|
field.String("reason").Default("").MaxLen(255).Comment("停单原因(缺料/故障/其他)"),
|
||
|
|
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
|
||
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
||
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (StationState) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("stationNo", "date").Unique(),
|
||
|
|
}
|
||
|
|
}
|