Commit 21b257c1 authored by lcn's avatar lcn

bug修复

parent d2c161bf
......@@ -23,21 +23,23 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
list_point = []
points = {}
groups = {}
# 查询属于当前工厂下的监测点 + 其他工厂但是被复用到当前工厂的监测点
if not is_power_equipment:
sql = "SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p " \
"left join monitor_reuse m on p.mtid = m.mtid " \
"WHERE p.cid=%s or m.cid = %s"
else:
# 动力设备
sql = "SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p " \
"left join monitor m on p.mtid = m.mtid " \
"left join monitor_reuse mr on p.mtid = mr.mtid " \
"WHERE m.demolished = 0 and m.is_power_equipment = 1 and (" \
"p.cid=%s or mr.cid = %s)"
"WHERE m.demolished = 0 and (p.cid=%s or mr.cid = %s) "
# 查询属于当前工厂下的监测点 + 其他工厂但是被复用到当前工厂的监测点
if is_power_equipment:
# 动力设备
sql += " and m.is_power_equipment = 1 "
async with MysqlUtil() as conn:
result = await conn.fetchall(sql, args=(cid, cid))
if not result:
return ListPointResponse(
points=list_point,
inlines=[],
power_show_all=0
)
# 去调拆表的POINT
point_ids = [point["pid"] for point in result]
point_mid_map, point_count = await point_to_mid(point_ids)
......
......@@ -75,12 +75,11 @@ async def get_elec_mtid_sid_by_cid(cid):
async def load_add_to_compy_ids(cid):
if not isinstance(cid, (list, tuple)):
cid = [cid]
symbol = "in" if isinstance(cid, (list, tuple)) else "="
db = SETTING.mysql_db
sql = f"SELECT monitor.mtid, monitor.sid FROM {db}.monitor " \
f"INNER JOIN {db}.point ON point.mtid=monitor.mtid " \
f"WHERE monitor.cid in %s AND point.add_to_company=1 " \
f"WHERE monitor.cid {symbol} %s AND point.add_to_company=1 " \
f"AND monitor.demolished=0;"
async with MysqlUtil() as conn:
ids = await conn.fetchall(sql, (cid,))
......
......@@ -187,7 +187,10 @@ async def normal_rate_of_location(cid):
async def real_time_load(cid, end_dt=None):
"""实时负荷"""
td_tbls = []
for item in await load_add_to_compy_ids(cid):
add_to_compy_ids = await load_add_to_compy_ids(cid)
if not add_to_compy_ids:
return 0
for item in add_to_compy_ids:
mtid, sid = item["mtid"], item["sid"]
tbl = get_td_table_name("electric", mtid)
td_tbls.append(tbl)
......
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