修复支撑阻力企业微信重复

This commit is contained in:
dekun
2026-06-02 06:55:57 +08:00
parent 9115523df7
commit ef99fb6c2e
5 changed files with 191 additions and 46 deletions
+16 -12
View File
@@ -85,6 +85,7 @@ from key_monitor_lib import (
KEY_MONITOR_RS_TYPES,
auto_amp_ok,
auto_confirm_ok,
claim_rs_level_notify,
detect_rs_box_break,
format_auto_amp_line,
format_auto_confirm_line,
@@ -4287,16 +4288,20 @@ def _process_key_rs_level_alert(conn, row):
max_n = int(tick["notify_max"])
interval = int(tick["interval_min"])
bar_ts = tick.get("bar_ts")
prior_count = int(tick.get("prior_count", notify_index - 1))
if tick.get("need_claim_first"):
conn.execute(
"UPDATE key_monitors SET notification_count=1, direction=?, last_notified_at=?, last_rs_bar_ts=? "
"WHERE id=? AND COALESCE(notification_count,0)=0",
(br["direction"], app_now_str(), bar_ts, row["id"]),
)
if conn.total_changes == 0:
return
conn.commit()
notified_at = app_now_str()
if not claim_rs_level_notify(
conn,
row["id"],
notify_index,
br["direction"],
notified_at,
bar_ts,
prior_count=prior_count,
):
return
conn.commit()
trigger_time = ms_to_app_local_str(int(ts)) if ts else app_now_str()
msg = build_wechat_rs_level_message(
@@ -4316,9 +4321,8 @@ def _process_key_rs_level_alert(conn, row):
)
send_wechat_msg(msg)
conn.execute(
"UPDATE key_monitors SET direction=?, notification_count=?, last_notified_at=?, "
"last_alert_message=?, last_rs_bar_ts=? WHERE id=?",
(br["direction"], notify_index, app_now_str(), msg, bar_ts, row["id"]),
"UPDATE key_monitors SET last_alert_message=? WHERE id=?",
(msg, row["id"]),
)
conn.commit()
if notify_index >= max_n: