Commit 4100febc authored by ZZH's avatar ZZH

fix query_points_by_storey 2023-7-7

parent 042ec0e5
...@@ -140,7 +140,7 @@ async def sdu_app_statistics_sort_service(cid, start, end): ...@@ -140,7 +140,7 @@ async def sdu_app_statistics_sort_service(cid, start, end):
async def sdu_electric_behave_service(cid, start, end, storeys, product): async def sdu_electric_behave_service(cid, start, end, storeys, product):
"""近30天用电行为""" """近30天用电行为"""
# 1.根据storeys获取points信息 # 1.根据storeys获取points信息
point_list = await points_by_storeys(storeys) point_list = await points_by_storeys(cid, storeys)
# 获取point_id列表 # 获取point_id列表
points = [i.get("point_id") for i in point_list] points = [i.get("point_id") for i in point_list]
# 2. es查询违规/大功率/正常次数 # 2. es查询违规/大功率/正常次数
......
...@@ -18,7 +18,7 @@ async def new_list_alarm_service(cid, storeys, offset, page_size, start, end, ...@@ -18,7 +18,7 @@ async def new_list_alarm_service(cid, storeys, offset, page_size, start, end,
importance, points, product): importance, points, product):
"""报警信息分页列表""" """报警信息分页列表"""
# 1.根据storeys获取points信息 # 1.根据storeys获取points信息
point_list = await points_by_storeys(storeys) point_list = await points_by_storeys(cid, storeys)
if not point_list: if not point_list:
return ListAlarmResponse(total=0, rows=[]) return ListAlarmResponse(total=0, rows=[])
# point_id和storey对应关系 # point_id和storey对应关系
......
...@@ -33,15 +33,15 @@ async def storey_by_cid(cid): ...@@ -33,15 +33,15 @@ async def storey_by_cid(cid):
return storey_list return storey_list
async def query_points_by_storey(storeys): async def query_points_by_storey(cid, storeys):
"""根据storey_id查询point_id和room_name""" """根据storey_id查询point_id和room_name"""
sql = "SELECT s.storey_id,s.storey_name,s.point_id,s.room_name,m.mtid," \ sql = "SELECT s.storey_id,s.storey_name,s.point_id,s.room_name,m.mtid," \
"p.ctnum,p.cid from storey_room_map s LEFT JOIN point p " \ "p.ctnum,p.cid from storey_room_map s LEFT JOIN point p " \
"on p.pid=s.point_id LEFT JOIN monitor m on m.mtid=p.mtid " \ "on p.pid=s.point_id LEFT JOIN monitor m on m.mtid=p.mtid " \
"where s.storey_id in %s and m.demolished=0 " \ "where s.storey_id in %s and s.cid=%s and m.demolished=0 " \
"order by s.storey_id, s.room_name" "order by s.storey_id, s.room_name"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
points = await conn.fetchall(sql, args=(tuple(storeys),)) points = await conn.fetchall(sql, args=(tuple(storeys), cid))
return points return points
......
...@@ -102,7 +102,7 @@ async def point_to_mid(points): ...@@ -102,7 +102,7 @@ async def point_to_mid(points):
return point_mid, len(point_mid) return point_mid, len(point_mid)
async def points_by_storeys(storeys): async def points_by_storeys(cid, storeys):
"""根据storey_id查询point_id和room_name""" """根据storey_id查询point_id和room_name"""
point_list = await query_points_by_storey(storeys) point_list = await query_points_by_storey(cid, storeys)
return point_list return point_list
...@@ -15,7 +15,7 @@ from unify_api.utils.common_utils import round_2, division_two ...@@ -15,7 +15,7 @@ from unify_api.utils.common_utils import round_2, division_two
async def kwh_points_service(cid, start, end, storeys): async def kwh_points_service(cid, start, end, storeys):
"""获取points电量""" """获取points电量"""
# 1.根据storeys获取points信息 # 1.根据storeys获取points信息
point_list = await points_by_storeys(storeys) point_list = await points_by_storeys(cid, storeys)
# 获取point_id列表 # 获取point_id列表
points = [i.get("point_id") for i in point_list] points = [i.get("point_id") for i in point_list]
# 2. es查询数据 # 2. es查询数据
......
...@@ -410,7 +410,7 @@ async def get_kwh_points_download(req): ...@@ -410,7 +410,7 @@ async def get_kwh_points_download(req):
start = args.get("start") start = args.get("start")
end = args.get("end") end = args.get("end")
# 2.根据storeys获取points信息 # 2.根据storeys获取points信息
point_list = await points_by_storeys(storeys) point_list = await points_by_storeys(cid, storeys)
# 获取point_id列表 # 获取point_id列表
points = [i.get("point_id") for i in point_list] points = [i.get("point_id") for i in point_list]
# 3. es查询数据 # 3. es查询数据
......
...@@ -28,10 +28,10 @@ from unify_api.modules.electric.components.electric import ( ...@@ -28,10 +28,10 @@ from unify_api.modules.electric.components.electric import (
) )
async def elec_current_storeys_service(storeys): async def elec_current_storeys_service(cid, storeys):
"""用电监测-实时监测-楼层""" """用电监测-实时监测-楼层"""
# 1.根据storeys获取points信息 # 1.根据storeys获取points信息
point_list = await points_by_storeys(storeys) point_list = await points_by_storeys(cid, storeys)
mtids = [i.get("mtid") for i in point_list] mtids = [i.get("mtid") for i in point_list]
d_rt_ele = await batch_load_rt_ele(mtids) d_rt_ele = await batch_load_rt_ele(mtids)
elec_data = {} elec_data = {}
...@@ -95,10 +95,10 @@ async def elec_current_storeys_service(storeys): ...@@ -95,10 +95,10 @@ async def elec_current_storeys_service(storeys):
return EscResp(elec_data=elec_list) return EscResp(elec_data=elec_list)
async def qual_current_storeys_service(storeys): async def qual_current_storeys_service(cid, storeys):
"""电能质量-实时参数-楼层""" """电能质量-实时参数-楼层"""
# 1.根据storeys获取points信息 # 1.根据storeys获取points信息
point_list = await points_by_storeys(storeys) point_list = await points_by_storeys(cid, storeys)
mtids = [point["mtid"] for point in point_list if point["mtid"]] mtids = [point["mtid"] for point in point_list if point["mtid"]]
d_rt_ele = await batch_load_rt_ele_with_hr(mtids) d_rt_ele = await batch_load_rt_ele_with_hr(mtids)
# 4. 返回数据 # 4. 返回数据
......
...@@ -411,14 +411,14 @@ async def post_qual_current(req, body: PageRequest) -> QualCurrentResponse: ...@@ -411,14 +411,14 @@ async def post_qual_current(req, body: PageRequest) -> QualCurrentResponse:
@summary("用电监测-实时监测-楼层") @summary("用电监测-实时监测-楼层")
async def post_elec_current_storeys(req, body: EcsReq) -> EscResp: async def post_elec_current_storeys(req, body: EcsReq) -> EscResp:
storeys = body.storeys cid, storeys = body.cid, body.storeys
return await elec_current_storeys_service(storeys) return await elec_current_storeys_service(cid, storeys)
@summary("电能质量-实时参数-楼层") @summary("电能质量-实时参数-楼层")
async def post_qual_current_storeys(req, body: EcsReq) -> QcsResp: async def post_qual_current_storeys(req, body: EcsReq) -> QcsResp:
storeys = body.storeys cid, storeys = body.cid, body.storeys
return await qual_current_storeys_service(storeys) return await qual_current_storeys_service(cid, storeys)
@summary("用电监测-卡片信息-level") @summary("用电监测-卡片信息-level")
......
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