Commit 2e78d4a7 authored by lcn's avatar lcn

修复Bug

parent 313d2526
...@@ -212,7 +212,8 @@ async def elec_card_level_service(point_list): ...@@ -212,7 +212,8 @@ async def elec_card_level_service(point_list):
# point_mid = await batch_get_wiring_type(point_list) # point_mid = await batch_get_wiring_type(point_list)
# # 3. 获取redis数据 # # 3. 获取redis数据
# res_redis = await elec_current_data(point_mid) # res_redis = await elec_current_data(point_mid)
mtids = [monitor["mtid"] for monitor in monitor_point_list if monitor["mtid"]] mtids = [monitor["mtid"] for monitor in monitor_point_list if
monitor["mtid"]]
cid = monitor_point_list[0]['cid'] if len(monitor_point_list) > 0 else 0 cid = monitor_point_list[0]['cid'] if len(monitor_point_list) > 0 else 0
results = await elec_current_data_new15(mtids, cid) results = await elec_current_data_new15(mtids, cid)
# 4. 返回数据 # 4. 返回数据
...@@ -773,17 +774,18 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -773,17 +774,18 @@ async def elec_index_service_new15(cid, point_id, start, end):
"ua_dev_mean", "ua_dev_min", "ua_dev_max", "ua_dev_mean", "ua_dev_min", "ua_dev_max",
"freq_dev_mean", "freq_dev_min", "freq_dev_max"] "freq_dev_mean", "freq_dev_min", "freq_dev_max"]
datas = await get_electric_datas_dao(table_name, point_id, start, end) datas = await get_electric_datas_dao(table_name, point_id, start, end)
if not datas: # if not datas:
return ElecIndexResponse( # return ElecIndexResponse(
ctnum=ctnum, common_indexes=[], # ctnum=ctnum, common_indexes=[],
elec_qual_indexes=[] # elec_qual_indexes=[]
) # )
df = pd.DataFrame(list(datas)) df = pd.DataFrame(list(datas))
# 常规参数统计 # 常规参数统计
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] item_name = item.rsplit("_", 1)[0]
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):
...@@ -814,12 +816,22 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -814,12 +816,22 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_time=min_time or "", min_time=min_time or "",
avg=avg_value, avg=avg_value,
) )
else:
elec_index = ElecIndex(
stats_index=item_name,
max="",
max_time="",
min="",
min_time="",
avg="",
)
common_indexes.append(elec_index) common_indexes.append(elec_index)
# 电能质量统计 # 电能质量统计
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] item_name = item.rsplit("_", 1)[0]
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):
...@@ -850,6 +862,15 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -850,6 +862,15 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_time=min_time, min_time=min_time,
avg=avg_value, avg=avg_value,
) )
else:
elec_index = ElecIndex(
stats_index=item_name,
max="",
max_time="",
min="",
min_time="",
avg="",
)
elec_qual_indexes.append(elec_index) elec_qual_indexes.append(elec_index)
# 小程序需要这漏电流和温度 # 小程序需要这漏电流和温度
if cid: if cid:
...@@ -877,6 +898,7 @@ async def elec_index_service_new15(cid, point_id, start, end): ...@@ -877,6 +898,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
elec_qual_indexes=elec_qual_indexes elec_qual_indexes=elec_qual_indexes
) )
async def elec_current_service_new15(point_id): async def elec_current_service_new15(point_id):
# 获取mtid # 获取mtid
meter_info = await get_meter_by_point_new15(point_id) meter_info = await get_meter_by_point_new15(point_id)
...@@ -903,7 +925,7 @@ async def elec_current_service_new15(point_id): ...@@ -903,7 +925,7 @@ async def elec_current_service_new15(point_id):
time_str = str(res["ts"])[0:19] time_str = str(res["ts"])[0:19]
else: else:
time_str = time_format.get_datetime_str(0) time_str = time_format.get_datetime_str(0)
return time_str,res return time_str, res
def get_sdu_i_and_u(res, ctnum): def get_sdu_i_and_u(res, ctnum):
......
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