This commit is contained in:
SunYF
2026-10-26 16:32:35 +08:00
parent 4b14f9540a
commit f86feb2271
99 changed files with 1652 additions and 521 deletions
+13 -1
View File
@@ -102,7 +102,19 @@ func (s *Service) evaluateTorqueCriterion(ctx context.Context, sn, stationNo str
SetTorqueNgPending(true).SetTorqueNgAt(time.Now()).SetTorqueNgBy(operator).Save(ctx); e != nil {
log.Printf("[torque] 置拧紧不合格标记失败 sn=%s: %v", sn, e)
}
s.Evaluate(ctx, "torque_ng", 1, "拧紧扭矩不合格", "SN="+sn+" 工位"+stationNo, "torque_record", sn, orderNo)
// B2.1 拧紧报警改由基础配置 torque.ng.alert.enabled 开关控制(不再走预警规则表):
// 开关开启(默认) → 直接 CreateAlert 落预警(绕过 Evaluate 的阈值比较);
// 开关关闭 → 只写 step_data + 置 torque_ng_pending(已在上面完成),不落 alert。
if s.CfgInt(ctx, CfgTorqueNgAlert, 1) == 1 {
// 直写预警(绕过 Evaluate 阈值比较);target 含「工位N」供终端按工位过滤,message 带工单号便于中心检索
msg := "拧紧扭矩不合格:SN=" + sn + " 工位" + stationNo
if orderNo != "" {
msg += " 工单" + orderNo
}
if err := s.CreateAlert(ctx, "torque_ng", "critical", "SN="+sn+" 工位"+stationNo, msg); err != nil {
log.Printf("[torque] 写拧紧不合格预警失败 sn=%s: %v", sn, err)
}
}
}
}