Files
bj_power/bj_power_mes/schema/alert.go
T
SunYF 8be6e03a15 docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
2026-10-10 15:58:59 +08:00

56 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"
)
// Alert 预警消息:规则命中或手动触发后写入,供前端预警中心收件箱展示。
// 遗留5 告警框架(第一阶段):type=业务类型(如 torque_ng)、level=级别(信息/警告/严重)、
// target=目标对象(工位/库房/SN 等)、message 落 content 列;
// 处置闭环用 resolved_at/resolved_by(与 status=READ 配套)。
type Alert struct {
ent.Schema
}
func (Alert) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "alert"}, entsql.WithComments(true), schema.Comment("Alert 预警消息:规则命中或手动触发后写入,供前端预警中心收件箱展示")}
}
func (Alert) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("ruleId").Default(0).Comment("关联规则ID,0=手动触发"),
field.String("type").MaxLen(40).Comment("预警类型"),
// 遗留5 告警框架(第一阶段):级别 信息/警告/严重,供 GET /alerts 按 level 筛选
field.String("level").Default("").MaxLen(20).Comment("级别:信息/警告/严重(空=历史数据未分级)"),
// 目标对象:工位号/库房/物料编码/SN 等(人工可读),供检索定位
field.String("target").Default("").MaxLen(128).Comment("目标对象(工位/库房/SN 等)"),
field.String("title").MaxLen(120).Comment("标题"),
field.String("content").Default("").MaxLen(500).Comment("内容"),
field.String("refType").Default("").MaxLen(40).Comment("关联业务类型"),
field.String("refId").Default("").MaxLen(64).Comment("关联业务ID"),
// 关联工单号(客户第12条「记录查看加一项看工单号查询」):预警中心按工单号检索用,可空。
field.String("orderNo").Default("").MaxLen(64).Comment("关联工单号(按工单号查询用)"),
field.String("status").Default("UNREAD").MaxLen(10).Comment("UNREAD/READ"),
field.String("receiver").Default("").MaxLen(255).Comment("接收人"),
// 处置闭环(遗留5 第一阶段):谁在何时处置(resolve)了该预警;未处置时为空
field.Time("resolvedAt").Optional().Comment("处置时间(resolve 时写入,未处置为空)"),
field.String("resolvedBy").Default("").MaxLen(64).Comment("处置人(resolve 时写入)"),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (Alert) Indexes() []ent.Index {
return []ent.Index{
index.Fields("status"),
index.Fields("type"),
index.Fields("createdAt"),
}
}