1. 新增预警规则、预警消息、业务附件数据库表与CRUD逻辑 2. 为拧紧记录添加审核人、审核时间字段及审核留痕功能 3. 优化产线点位类型与编号描述,更新工位组合下发菜单名称为工艺路线派工 4. 新增上传文件获取原文件名与大小的工具方法 5. 在系统管理菜单新增预警中心与附件中心入口
41 lines
1.1 KiB
Go
41 lines
1.1 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"}}
|
|
}
|
|
|
|
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"),
|
|
}
|
|
}
|