Commit c473ef7a authored by wang.wenrong's avatar wang.wenrong

获取监测点修改,复用其他cid数据

parent fd317f5f
...@@ -73,14 +73,14 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse: ...@@ -73,14 +73,14 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
if not is_power_equipment: if not is_power_equipment:
sql = "SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p " \ 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 " \ "left join monitor_reuse m on p.mtid = m.mtid " \
"WHERE p.cid_belongedto=%s or m.cid = %s" "WHERE p.cid=%s or m.cid = %s"
else: else:
# 动力设备 # 动力设备
sql = "SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p " \ 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 m on p.mtid = m.mtid " \
"left join monitor_reuse mr on p.mtid = mr.mtid " \ "left join monitor_reuse mr on p.mtid = mr.mtid " \
"WHERE m.demolished = 0 and m.is_power_equipment = 1 and (" \ "WHERE m.demolished = 0 and m.is_power_equipment = 1 and (" \
"p.cid_belongedto=%s or mr.cid = %s)" "p.cid=%s or mr.cid = %s)"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
result = await conn.fetchall(sql, args=(cid, cid)) result = await conn.fetchall(sql, args=(cid, cid))
...@@ -98,14 +98,16 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse: ...@@ -98,14 +98,16 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
point['pid'] in point_mid_map] point['pid'] in point_mid_map]
# 根据pid获取mtd # 根据pid获取mtd
sql = "SELECT id, `group`, item FROM location WHERE ( cid=%s or mtid in " \ sql = "SELECT ln.lid, mr.`name` `group`, ln.item FROM location ln LEFT JOIN" \
"%s ) and `type` in %s" " monitor mr on ln.mtid = mr.mtid WHERE ( ln.cid=%s or ln.mtid in " \
"%s ) and ln.`ad_type` in %s"
try: try:
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
result = await conn.fetchall(sql, args=( result = await conn.fetchall(sql, args=(
cid, point_map_mtids, ["temperature", "residual_current"])) cid, point_map_mtids, ["temperature", "residual_current"]))
for res in result: for res in result:
id = res.get("id") id = res.get("lid")
group = res.get("group") group = res.get("group")
item = res.get("item") item = res.get("item")
groups.setdefault(group, []).append((id, item)) groups.setdefault(group, []).append((id, item))
...@@ -126,7 +128,7 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse: ...@@ -126,7 +128,7 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
list_point.append(comm_point) list_point.append(comm_point)
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
sql = "SELECT inlid, `name` FROM inline WHERE cid_belongedto=%s" sql = "SELECT inlid, `name` FROM inline WHERE cid=%s"
inlines = await conn.fetchall(sql, args=(cid,)) inlines = await conn.fetchall(sql, args=(cid,))
inline_list = [Inline(inline_id=inline["inlid"], name=inline["name"]) inline_list = [Inline(inline_id=inline["inlid"], name=inline["name"])
for inline in inlines] for inline in inlines]
......
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