feat: 来料检处置项实体与复检、日排产达成对比、PLC/WMS 传输日志

- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端
- MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流
- 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志
- MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整
- 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整
- 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
This commit is contained in:
SunYF
2026-11-16 16:42:44 +08:00
parent b32ec7c03d
commit d92ca803d5
72 changed files with 5135 additions and 1526 deletions
+26
View File
@@ -141,6 +141,32 @@ func (s *Service) CreateAlert(ctx context.Context, typ, level, target, message s
return err
}
// CreateAlertDedup 带时间窗去重的预警创建(2026-11-16 通信类预警专用):
// 同 type+target 在 windowMin 分钟内已有 UNREAD 预警时跳过,防轮询场景刷爆预警中心。
// 返回 (true, nil)=实际落库;(false, nil)=窗口内已有同款被去重。
func (s *Service) CreateAlertDedup(ctx context.Context, typ, level, target, message string, windowMin int) (bool, error) {
if windowMin <= 0 {
windowMin = 10
}
if windowMin > 1440 {
windowMin = 1440 // 上限 1 天,防误传超长窗口永久吞预警
}
since := time.Now().Add(-time.Duration(windowMin) * time.Minute)
cnt, cerr := s.ctx.EntClient.Alert.Query().Where(
alert.TypeEQ(typ),
alert.StatusEQ("UNREAD"),
alert.TargetEQ(target),
alert.CreatedAtGTE(since),
).Count(ctx)
if cerr == nil && cnt > 0 {
return false, nil
}
if err := s.CreateAlert(ctx, typ, level, target, message); err != nil {
return false, err
}
return true, nil
}
// publishStationAlert 报警写入成功后经 SSE Hub 广播 station.alert 事件(载荷=报警 JSON)。
// 终端侧按「工位N」自行过滤(Hub 是广播语义,按工位点对点过滤交给唯一消费者=终端后端)。
func (s *Service) publishStationAlert(a *ent.Alert) {