Commit 53467480 authored by wang.wenrong's avatar wang.wenrong

fix_录波详情

parent 062a5e3f
...@@ -515,22 +515,28 @@ class ScopeDetail(Model): ...@@ -515,22 +515,28 @@ class ScopeDetail(Model):
value: list = List("值") value: list = List("值")
@dataclass
class ScopeDetails(Model):
item: str = Str("名称").eg("ia")
value_datas: list = List("值")
@dataclass @dataclass
class ScopeDetailResp(Model): class ScopeDetailResp(Model):
name: str = Str("监测点名称").eg("华侨新村270栋101") point: str = Str("监测点名称").eg("华侨新村270栋101")
ctnum: int = Int("接线方式 2-两表法 3-三表法").eg(1) ctnum: int = Int("接线方式 2-两表法 3-三表法").eg(1)
sid: str = Str("硬件编号").eg("A2270457094") sid: str = Str("硬件编号").eg("A2270457094")
event_datetime: str = Str("触发时间").eg("2022-05-26 15:55:03") check_dt: str = Str("触发时间").eg("2022-05-26 15:55:03")
duration: str = Str("录波时长").eg("400ms") contin_time: str = Str("录波时长").eg("400ms")
message: str = Str("触发原因").eg("漏电流越限") item: str = Str("相限").eg("A相")
scope_g: str = Str("录波颗粒度 0.25ms/0.2s/2s").eg("0.25ms") scope_g: str = Str("录波颗粒度 0.25ms/0.2s/2s").eg("0.25ms")
scope_type: str = Str("录波类型").eg("over_res_cur") type: str = Str("录波类型").eg("over_res_cur")
conclusion: str = Str("分析结论").eg("xxxxxxx") location: int = Int("location触发点").eg(0)
u_list: list = List("电压曲线").items(ScopeDetail) v: list = List("电压曲线").items(ScopeDetails)
u_slots: list = List("电压横坐标")
i_list: list = List("电流曲线").items(ScopeDetail) i: list = List("电流曲线").items(ScopeDetails)
i_slots: list = List("电流横坐标")
lc_list: list = List("漏电流曲线").items(ScopeDetail) residual_current: list = List("漏电流曲线").items(ScopeDetails)
lc_slots: list = List("漏电流横坐标")
power_list: list = List("功率曲线").items(ScopeDetail) p: list = List("功率曲线").items(ScopeDetails)
power_slots: list = List("功率横坐标")
...@@ -76,3 +76,19 @@ async def get_scope_url_by_pid(mtid, start_dt, end_dt): ...@@ -76,3 +76,19 @@ async def get_scope_url_by_pid(mtid, start_dt, end_dt):
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
result = await conn.fetchall(sql,) result = await conn.fetchall(sql,)
return result return result
async def get_e_type_by_event_type(event_type):
sql = f"""
SELECT
`name` type
FROM
event_type
WHERE
e_type = '{event_type}'
"""
async with MysqlUtil() as conn:
result = await conn.fetchone(sql,)
return result
...@@ -20,9 +20,10 @@ from pot_libs.utils.time_format import convert_dt_to_timestr, \ ...@@ -20,9 +20,10 @@ from pot_libs.utils.time_format import convert_dt_to_timestr, \
convert_to_es_str, time_str_to_str convert_to_es_str, time_str_to_str
from unify_api.modules.anshiu.components.scope_operations_cps import \ from unify_api.modules.anshiu.components.scope_operations_cps import \
ScopeListItem, ScopeContent, ScopeDetailsResp, GetScopeConfigList, \ ScopeListItem, ScopeContent, ScopeDetailsResp, GetScopeConfigList, \
init_scope_config_example, ScopeItemDownload, ScopeDetail init_scope_config_example, ScopeItemDownload, ScopeDetail, ScopeDetails
from unify_api.modules.anshiu.dao.scope_operations_dao import \ from unify_api.modules.anshiu.dao.scope_operations_dao import \
get_scope_event_by_event_id, get_scope_detail_by_pid, get_threshold_by_mtid get_scope_event_by_event_id, get_scope_detail_by_pid, \
get_threshold_by_mtid, get_e_type_by_event_type
from unify_api.modules.anshiu.procedures.scope_operations_pds import \ from unify_api.modules.anshiu.procedures.scope_operations_pds import \
get_scope_config_by_pid, set_scope_config_by_pid, add_scope_config_by_pid, \ get_scope_config_by_pid, set_scope_config_by_pid, add_scope_config_by_pid, \
get_scope_list_by_pid get_scope_list_by_pid
...@@ -524,23 +525,18 @@ async def scope_detail_service(event_id): ...@@ -524,23 +525,18 @@ async def scope_detail_service(event_id):
for k, v in wave_data.items(): for k, v in wave_data.items():
v = [value if not math.isnan(value) else '' for value in v] v = [value if not math.isnan(value) else '' for value in v]
if k in i_fields: if k in i_fields:
i_list.append(ScopeDetail(name=k, value=v)) i_list.append(ScopeDetails(item=k, value_datas=v))
u_count = len(v) u_count = len(v)
if k in v_fields: if k in v_fields:
u_list.append(ScopeDetail(name=k, value=v)) u_list.append(ScopeDetails(item=k, value_datas=v))
i_count = len(v) i_count = len(v)
# 2s颗粒度的会有漏电流及功率 # 2s颗粒度的会有漏电流及功率
if k in ("lc", "ileak_rms"): if k in ("lc", "ileak_rms"):
residual_current.append(ScopeDetail(name='漏电流', value=v)) residual_current.append(ScopeDetails(item='漏电流', value_datas=v))
lc_count = len(v) lc_count = len(v)
if k == "pttl": if k == "pttl":
power.append(ScopeDetail(name='总有功功率', value=v)) power.append(ScopeDetails(item='总有功功率', value_datas=v))
power_count = len(v) power_count = len(v)
u_slots = [i for i in range(1, u_count + 1)]
i_slots = [i for i in range(1, i_count + 1)]
lc_slots = [i for i in range(1, lc_count + 1)]
power_slots = [i for i in range(1, power_count + 1)]
# 结论分析 # 结论分析
result = await get_scope_conclusion(wave_data, event_type, mtid, sid, result = await get_scope_conclusion(wave_data, event_type, mtid, sid,
ctnum) ctnum)
...@@ -560,10 +556,16 @@ async def scope_detail_service(event_id): ...@@ -560,10 +556,16 @@ async def scope_detail_service(event_id):
data["message"] = event_data.get("message") data["message"] = event_data.get("message")
data["conclusion"] = result data["conclusion"] = result
data["scope_g"] = scope_g data["scope_g"] = scope_g
data["scope_type"] = event_data.get("event_type") event_type = event_data.get("event_type")
e_type = await get_e_type_by_event_type(event_type)
data["type"] = e_type["type"]
data["ctnum"] = ctnum data["ctnum"] = ctnum
return data or {}, u_list, i_list, residual_current, power, u_slots, \ data["item"] = event_data["phase"]
i_slots, lc_slots, power_slots index_loc = json.loads(scope_data.get("index_loc"))
data["location"] = index_loc[f"{data['item']}"][
'location'] if index_loc.get(
data['item']) else index_loc.get("index_loc")
return data or {}, u_list, i_list, residual_current, power,
async def get_scope_conclusion(wave_data, event_type, mtid, sid, ctnum): async def get_scope_conclusion(wave_data, event_type, mtid, sid, ctnum):
......
...@@ -82,28 +82,24 @@ async def post_scope_detail(req, body: ScopeDetailRep) -> ScopeDetailResp: ...@@ -82,28 +82,24 @@ async def post_scope_detail(req, body: ScopeDetailRep) -> ScopeDetailResp:
event_id = body.id event_id = body.id
# 2,获取信息 # 2,获取信息
data, u_list, i_list, residual_current, power, u_slots, \ data, u_list, i_list, residual_current, power = await scope_detail_service(
i_slots, lc_slots, power_slots = await scope_detail_service(event_id) event_id)
# 3,返回信息 # 3,返回信息
return ScopeDetailResp( return ScopeDetailResp(
name=data.get("name"), point=data.get("name"),
ctnum=data.get("ctnum"), ctnum=data.get("ctnum"),
sid=data.get("sid"), check_dt=data.get("event_datetime"),
event_datetime=data.get("event_datetime"), contin_time=data.get("duration"),
duration=data.get("duration"), item=data.get("item"),
message=data.get("message"),
scope_g=data.get("scope_g"), scope_g=data.get("scope_g"),
scope_type=data.get("scope_type"), type=data.get("type"),
conclusion=data.get("conclusion"), v=u_list,
u_list=u_list, location=data.get("location"),
u_slots=u_slots, i=i_list,
i_list=i_list, residual_current=residual_current,
i_slots=i_slots, p=power,
lc_list=residual_current,
lc_slots=lc_slots,
power_list=power,
power_slots=power_slots,
) )
......
...@@ -10,9 +10,6 @@ from unify_api.modules.zhiwei_u import config ...@@ -10,9 +10,6 @@ from unify_api.modules.zhiwei_u import config
from unify_api.utils import time_format from unify_api.utils import time_format
from pot_libs.utils.exc_util import DBException from pot_libs.utils.exc_util import DBException
from dataclasses import fields from dataclasses import fields
from unify_api.modules.zhiwei_u.dao.data_es_dao import query_search_scope, \
query_search_scope_pids
from unify_api.modules.zhiwei_u.dao.data_es_dao import get_scope_pids, \ from unify_api.modules.zhiwei_u.dao.data_es_dao import get_scope_pids, \
get_search_scope get_search_scope
......
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