- 移除station表的hasDock、dockCode字段及相关代码 - 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台 - 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式 - 新增SQL注释固化脚本,完善MES表注释
41 lines
1.3 KiB
Go
41 lines
1.3 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"
|
|
)
|
|
|
|
// AlertRule 预警规则:按类型 + 阈值触发,命中后写入 alert 消息表
|
|
type AlertRule struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (AlertRule) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{entsql.Annotation{Table: "alert_rule"}, entsql.WithComments(true), schema.Comment("AlertRule 预警规则:按类型 + 阈值触发,命中后写入 alert 消息表")}
|
|
}
|
|
|
|
func (AlertRule) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("id").Positive(),
|
|
field.String("name").MaxLen(80).Comment("规则名称"),
|
|
field.String("type").MaxLen(40).Comment("预警类型 torque_ng/inspection_ng/inventory_low/task_overdue"),
|
|
field.Float("threshold").Default(0).Comment("阈值(不同类含义不同)"),
|
|
field.String("receiver").Default("").MaxLen(255).Comment("接收人,逗号分隔"),
|
|
field.Bool("enabled").Default(true).Comment("是否启用"),
|
|
field.String("createdBy").Default("").MaxLen(64).Comment("创建人"),
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
}
|
|
}
|
|
|
|
func (AlertRule) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("type"),
|
|
index.Fields("enabled"),
|
|
}
|
|
}
|