Commit 8663e19b authored by lcn's avatar lcn

修复Bug

parent 2e78d4a7
...@@ -784,13 +784,12 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -784,13 +784,12 @@ async def elec_index_service_new15(cid, point_id, start, end):
common_indexes = [] common_indexes = []
_common_items = {i.rsplit("_", 1)[0] for i in common_items} _common_items = {i.rsplit("_", 1)[0] for i in common_items}
for item in _common_items: for item in _common_items:
item_name = item.rsplit("_", 1)[0]
if datas: if datas:
max_item_name = f"{item}_max" max_item_name = f"{item}_max"
max_value = df[max_item_name].max() max_value = df[max_item_name].max()
if not pd.isna(max_value): if not pd.isna(max_value):
max_datas = df.loc[df[max_item_name].idxmax()].to_dict() max_datas = df.loc[df[max_item_name].idxmax()].to_dict()
max_time = max_datas.get(f"{item_name}_max_time") max_time = max_datas.get(f"{item}_max_time")
max_time = '' if pd.isnull(max_time) else str(max_time) max_time = '' if pd.isnull(max_time) else str(max_time)
else: else:
max_value, max_time = "", "" max_value, max_time = "", ""
...@@ -798,7 +797,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -798,7 +797,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_value = df[min_item_name].min() min_value = df[min_item_name].min()
if not pd.isna(min_value): if not pd.isna(min_value):
min_datas = df.loc[df[min_item_name].idxmin()].to_dict() min_datas = df.loc[df[min_item_name].idxmin()].to_dict()
min_time = min_datas.get(f"{item_name}_min_time") min_time = min_datas.get(f"{item}_min_time")
min_time = '' if pd.isnull(min_time) else str(min_time) min_time = '' if pd.isnull(min_time) else str(min_time)
else: else:
min_value, min_time = "", "" min_value, min_time = "", ""
...@@ -809,7 +808,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -809,7 +808,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
else: else:
avg_value = "" avg_value = ""
elec_index = ElecIndex( elec_index = ElecIndex(
stats_index=item_name, stats_index=item,
max=max_value, max=max_value,
max_time=max_time or "", max_time=max_time or "",
min=min_value, min=min_value,
...@@ -818,7 +817,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -818,7 +817,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
) )
else: else:
elec_index = ElecIndex( elec_index = ElecIndex(
stats_index=item_name, stats_index=item,
max="", max="",
max_time="", max_time="",
min="", min="",
...@@ -830,13 +829,12 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -830,13 +829,12 @@ async def elec_index_service_new15(cid, point_id, start, end):
elec_qual_indexes = [] elec_qual_indexes = []
_elec_qual_items = {i.rsplit("_", 1)[0] for i in elec_qual_items} _elec_qual_items = {i.rsplit("_", 1)[0] for i in elec_qual_items}
for item in _elec_qual_items: for item in _elec_qual_items:
item_name = item.rsplit("_", 1)[0]
if datas: if datas:
max_item_name = f"{item}_max" max_item_name = f"{item}_max"
max_value = df[max_item_name].max() max_value = df[max_item_name].max()
if not pd.isna(max_value): if not pd.isna(max_value):
max_datas = df.loc[df[max_item_name].idxmax()].to_dict() max_datas = df.loc[df[max_item_name].idxmax()].to_dict()
max_time = max_datas.get(f"{item_name}_max_time") max_time = max_datas.get(f"{item}_max_time")
max_time = '' if pd.isnull(max_time) else str(max_time) max_time = '' if pd.isnull(max_time) else str(max_time)
else: else:
max_value, max_time = "", "" max_value, max_time = "", ""
...@@ -844,7 +842,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -844,7 +842,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_value = df[min_item_name].min() min_value = df[min_item_name].min()
if not pd.isna(min_value): if not pd.isna(min_value):
min_datas = df.loc[df[min_item_name].idxmin()].to_dict() min_datas = df.loc[df[min_item_name].idxmin()].to_dict()
min_time = min_datas.get(f"{item_name}_min_time") min_time = min_datas.get(f"{item}_min_time")
min_time = '' if pd.isnull(min_time) else str(min_time) min_time = '' if pd.isnull(min_time) else str(min_time)
else: else:
min_value, min_time = "", "" min_value, min_time = "", ""
...@@ -855,7 +853,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -855,7 +853,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
else: else:
avg_value = "" avg_value = ""
elec_index = ElecIndex( elec_index = ElecIndex(
stats_index=item_name, stats_index=item,
max=max_value, max=max_value,
max_time=max_time, max_time=max_time,
min=min_value, min=min_value,
...@@ -864,7 +862,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -864,7 +862,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
) )
else: else:
elec_index = ElecIndex( elec_index = ElecIndex(
stats_index=item_name, stats_index=item,
max="", max="",
max_time="", max_time="",
min="", min="",
......
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