Commit 1c264a88 authored by peng.xiaozhe's avatar peng.xiaozhe

condition-monitor 首页报警相关bug修复

parent 04eac214
...@@ -459,6 +459,25 @@ async def sdu_alarm_aggs_date_importance(cid): ...@@ -459,6 +459,25 @@ async def sdu_alarm_aggs_date_importance(cid):
async def sdu_alarm_aggs_type(cid, start, end): async def sdu_alarm_aggs_type(cid, start, end):
sql = f"""
SELECT
COUNT(*) doc_count,
event_type
FROM
point_1min_event pevent
WHERE
cid = {cid}
AND pevent.event_datetime >= '{start}'
AND pevent.event_datetime <= '{end}'
GROUP BY
pevent.event_type;
"""
async with MysqlUtil() as conn:
datas = await conn.fetchall(sql)
return datas if datas else []
async def sdu_alarm_aggs_type_old(cid, start, end):
start_dt = datetime.strptime(start, "%Y-%m-%d %H:%M:%S") start_dt = datetime.strptime(start, "%Y-%m-%d %H:%M:%S")
end_dt = datetime.strptime(end, "%Y-%m-%d %H:%M:%S") end_dt = datetime.strptime(end, "%Y-%m-%d %H:%M:%S")
es_start_str = datetime(year=start_dt.year, month=start_dt.month, es_start_str = datetime(year=start_dt.year, month=start_dt.month,
......
...@@ -511,26 +511,26 @@ async def alarm_safe_power(cid, start, end): ...@@ -511,26 +511,26 @@ async def alarm_safe_power(cid, start, end):
for bucket in es_res: for bucket in es_res:
# 温度 # 温度
if bucket["key"] in ("overTemp", "overTempRange1min", if bucket["event_type"] in ("overTemp", "overTempRange1min",
"overTempRange15min"): "overTempRange15min"):
temperature_cnt += bucket["doc_count"] temperature_cnt += bucket["doc_count"]
# 漏电流 # 漏电流
elif bucket["key"] in ("overResidualCurrent",): elif bucket["event_type"] in ("overResidualCurrent",):
residual_current_cnt += bucket["doc_count"] residual_current_cnt += bucket["doc_count"]
# 负载率 # 负载率
elif bucket["key"] in ("overPR",): elif bucket["event_type"] in ("overPR",):
lr_cnt += bucket["doc_count"] lr_cnt += bucket["doc_count"]
# 功率因数 # 功率因数
elif bucket["key"] in ("underPhasePF", "underTotalPF"): elif bucket["event_type"] in ("underPhasePF", "underTotalPF"):
power_factor_cnt += bucket["doc_count"] power_factor_cnt += bucket["doc_count"]
# 欠压 # 欠压
elif bucket["key"] in ("underU",): elif bucket["event_type"] in ("underU",):
under_u_cnt += bucket["doc_count"] under_u_cnt += bucket["doc_count"]
# 过压 # 过压
elif bucket["key"] in ("overU",): elif bucket["event_type"] in ("overU",):
over_u_cnt += bucket["doc_count"] over_u_cnt += bucket["doc_count"]
# 过流 # 过流
elif bucket["key"] in ("overI",): elif bucket["event_type"] in ("overI",):
over_i_cnt += bucket["doc_count"] over_i_cnt += bucket["doc_count"]
alarm_map = { alarm_map = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment