Commit cbee7a55 authored by lcn's avatar lcn

BUG修复

parent e0e81eef
......@@ -773,7 +773,10 @@ async def elec_index_service_new15(cid, point_id, start, end):
"freq_dev_mean", "freq_dev_min", "freq_dev_max"]
datas = await get_electric_datas_dao(table_name, point_id, start, end)
if not datas:
return ctnum, [], []
return ElecIndexResponse(
ctnum=ctnum, common_indexes=[],
elec_qual_indexes=[]
)
df = pd.DataFrame(list(datas))
# 常规参数统计
common_indexes = []
......@@ -798,7 +801,10 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_value, min_time = "", ""
mean_item_name = f"{item}_mean"
avg_value = df[mean_item_name].mean()
avg_value = round(avg_value, 2) if avg_value else ""
if not pd.isna(avg_value):
avg_value = round(avg_value, 2) if avg_value else ""
else:
avg_value = ""
elec_index = ElecIndex(
stats_index=item_name,
max=max_value,
......@@ -831,7 +837,10 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_value, min_time = "", ""
mean_item_name = f"{item}_mean"
avg_value = df[mean_item_name].mean()
avg_value = round(avg_value, 2) if avg_value else ""
if not pd.isna(avg_value):
avg_value = round(avg_value, 2) if avg_value else ""
else:
avg_value = ""
elec_index = ElecIndex(
stats_index=item_name,
max=max_value,
......@@ -862,7 +871,10 @@ async def elec_index_service_new15(cid, point_id, start, end):
avg=value.get("mean_value") or '',
)
)
return ctnum, common_indexes, elec_qual_indexes
return ElecIndexResponse(
ctnum=ctnum, common_indexes=common_indexes,
elec_qual_indexes=elec_qual_indexes
)
async def elec_current_service_new15(point_id):
# 获取mtid
......
......@@ -475,12 +475,7 @@ async def post_elec_index(req, body: PageRequest) -> ElecIndexResponse:
log.error("param error, ranges is NULL")
raise ParamException(message="param error, ranges is NULL")
# return await elec_index_service(cid, point_id, date_start, date_end)
ctnum, common_indexes, elec_qual_indexes = \
await elec_index_service_new15(cid, point_id, date_start, date_end)
return ElecIndexResponse(
ctnum=ctnum, common_indexes=common_indexes,
elec_qual_indexes=elec_qual_indexes
)
return await elec_index_service_new15(cid, point_id, date_start, date_end)
@summary("电能质量-历史曲线")
......
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