Commit 6c411fe4 authored by ZZH's avatar ZZH

event type name support multi lang 2024-05-30

parent 1599f549
...@@ -123,6 +123,114 @@ EVENT_TYPE_MAP = { ...@@ -123,6 +123,114 @@ EVENT_TYPE_MAP = {
"over_rms_i": "电流越限", "over_rms_i": "电流越限",
} }
E_TYPE_NAME_LANG = {
"overU": {
"zh_CN": "过压",
"en_US": "Overvoltage",
"de_DE": "Überspannung"
},
"overI": {
"zh_CN": "过流",
"en_US": "Overcurrent",
"de_DE": "Überstrom"
},
"overPR": {
"zh_CN": "负载率越限",
"en_US": "Overload Limit Exceeded",
"de_DE": "Überlastungsrate überschreitet Grenzwert"
},
"overResidualCurrent": {
"zh_CN": "漏电流越限",
"en_US": "Leakage Current Exceeded Limit",
"de_DE": "Fehlerstrom überschreitet Grenzwert"
},
"overTemp": {
"zh_CN": "温度越限",
"en_US": "Temperature Exceeded Limit",
"de_DE": "Temperatur überschreitet Grenzwert"
},
"overTempRange1min": {
"zh_CN": "温升1分越限",
"en_US": "Temperature Rise Exceeds Limit by 1 Degree",
"de_DE": "Temperaturanstieg überschreitet 1-Minuten-Grenzwert"
},
"overTempRange15min": {
"zh_CN": "温升15分越限",
"en_US": "Temperature Rise Exceeds Limit by 15 Degrees",
"de_DE": "Temperaturanstieg überschreitet 15-Minuten-Grenzwert"
},
"overTempTrendDaily": {
"zh_CN": "温度日前预警",
"en_US": "Advance Temperature Warning",
"de_DE": "Temperaturvorwarnung für den Tag"
},
"overTempTrendQuarterly": {
"zh_CN": "温度实时预警",
"en_US": "Real-time Temperature Alert",
"de_DE": "Echtzeit-Temperaturwarnung"
},
"overTHDU": {
"zh_CN": "电压总谐波畸变率越限",
"en_US": "Total Harmonic Distortion (THD) of Voltage Exceeds Limit",
"de_DE": "Gesamtharmonische Spannungsverzerrung überschreitet Grenzwert"
},
"overTHDI": {
"zh_CN": "电流总谐波有效值越限",
"en_US": "Total Harmonic Distortion (THD) of Current Exceeds Limit",
"de_DE": "Gesamtharmonische Stromverzerrung überschreitet Grenzwert"
},
"unbalanceU": {
"zh_CN": "三相电压不平衡度",
"en_US": "Three-phase Voltage Imbalance",
"de_DE": "Dreiphasige Spannungsungleichgewicht"
},
"unbalanceI": {
"zh_CN": "三相电流不平衡度",
"en_US": "Three-phase Current Imbalance",
"de_DE": "Dreiphasige Stromungleichgewicht"
},
"underPhasePF": {
"zh_CN": "某相功率因数越下限",
"en_US": "Power Factor of a Phase Falls Below the Lower Limit",
"de_DE": "Unterschreitung des Leistungsfaktors einer Phase"
},
"underTotalPF": {
"zh_CN": "总功率因数越下限",
"en_US": "Total Power Factor Falls Below the Lower Limit",
"de_DE": "Unterschreitung des Gesamtleistungsfaktors"
},
"underU": {
"zh_CN": "欠压",
"en_US": "Undervoltage",
"de_DE": "Unterspannung"
},
"over_rms_u": {
"zh_CN": "电压越上限",
"en_US": "Voltage Above Upper Limit",
"de_DE": "Überschreiten der Spannungsgrenze"
},
"under_rms_u": {
"zh_CN": "电压越下限",
"en_US": "Voltage Below Lower Limit",
"de_DE": "Unterschreiten der Spannungsgrenze"
},
"over_gap_u": {
"zh_CN": "电压波动",
"en_US": "Voltage Fluctuatio",
"de_DE": "Spannungsschwankung"
},
"over_gap_i": {
"zh_CN": "电流波动",
"en_US": "Current Fluctuation",
"de_DE": "Stromschwankung"
},
"over_rms_i": {
"zh_CN": "电流越限",
"en_US": "Current Exceeds Limit",
"de_DE": "Strom überschreitet Grenzwert"
},
}
EVENT_TYPE_UNIT_MAP = { EVENT_TYPE_UNIT_MAP = {
"overI": '%', "overI": '%',
"overPR": '%', "overPR": '%',
...@@ -619,20 +727,20 @@ E_TYPE_LANG = { ...@@ -619,20 +727,20 @@ E_TYPE_LANG = {
PHASE_LINE_LANG = { PHASE_LINE_LANG = {
"A相": { "A相": {
"en_US": "Phase A", "en_US": "Phase A",
"de_DE": "" "de_DE": "Phase A"
}, },
"B相": { "B相": {
"en_US": "Phase B", "en_US": "Phase B",
"de_DE": "" "de_DE": "Phase B"
}, },
"C相": { "C相": {
"en_US": "Phase C", "en_US": "Phase C",
"de_DE": "" "de_DE": "Phase C"
}, },
"N线": { "N线": {
"en_US": "Neutral Line", "en_US": "Neutral Line",
"de_DE": "" "de_DE": "N-Leitung"
}, },
} }
...@@ -17,7 +17,7 @@ from unify_api.modules.common.dao.common_dao import ( ...@@ -17,7 +17,7 @@ from unify_api.modules.common.dao.common_dao import (
load_user_lang, load_monitor_names load_user_lang, load_monitor_names
) )
from unify_api.modules.common.procedures.multi_lang import ( from unify_api.modules.common.procedures.multi_lang import (
load_event_msg, load_phase_line load_event_msg, load_phase_line, load_e_type_name
) )
...@@ -253,7 +253,7 @@ async def pack_alarm_records(records, pid, lang): ...@@ -253,7 +253,7 @@ async def pack_alarm_records(records, pid, lang):
for r in records: for r in records:
event_type = r.get("event_type") event_type = r.get("event_type")
event_duration = r.get("event_duration") event_duration = r.get("event_duration")
type_str = constants.EVENT_TYPE_MAP.get(event_type) type_str = load_e_type_name(event_type, lang)
es_id = r.get("id") es_id = r.get("id")
if pid and r.get("event_mode") == "scope": if pid and r.get("event_mode") == "scope":
url, redirect_type = f"/scope_details?doc_id={es_id}", "scope" url, redirect_type = f"/scope_details?doc_id={es_id}", "scope"
......
...@@ -4,7 +4,7 @@ DATE:2024/5/30 11:34 ...@@ -4,7 +4,7 @@ DATE:2024/5/30 11:34
""" """
from pot_libs.logger import log from pot_libs.logger import log
from unify_api.constants import E_TYPE_LANG, PHASE_LINE_LANG from unify_api.constants import E_TYPE_LANG, PHASE_LINE_LANG, E_TYPE_NAME_LANG
def load_event_msg(e_type, event_param, lang): def load_event_msg(e_type, event_param, lang):
...@@ -29,3 +29,7 @@ def load_phase_line(mtr_name, lang): ...@@ -29,3 +29,7 @@ def load_phase_line(mtr_name, lang):
return PHASE_LINE_LANG.get(lst[-1], {}).get(lang) return PHASE_LINE_LANG.get(lst[-1], {}).get(lang)
return "" return ""
def load_e_type_name(e_type, lang="zh_CN"):
return E_TYPE_NAME_LANG.get(e_type, {}).get(lang, "")
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