提交 515b548e 编写于 作者: nengyuangzhang's avatar nengyuangzhang

Merge branch 'PR' into develop

......@@ -462,6 +462,23 @@ class DataSourcePointCollection:
cursor.execute(query_point, (id_,))
rows_point = cursor.fetchall()
cnx_history = mysql.connector.connect(**config.myems_historical_db)
history = cnx_history.cursor()
history.execute(" SELECT point_id, utc_date_time, actual_value "
" FROM tbl_analog_value_latest "
" WHERE utc_date_time >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 MINUTE)")
analog = history.fetchall()
history.execute(" SELECT point_id, utc_date_time, actual_value "
" FROM tbl_digital_value_latest "
" WHERE utc_date_time >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 MINUTE)")
digital = history.fetchall()
history.execute(" SELECT point_id, utc_date_time, actual_value "
" FROM tbl_energy_value_latest "
" WHERE utc_date_time >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 MINUTE)")
energy = history.fetchall()
if rows_point is not None and len(rows_point) > 0:
for row in rows_point:
meta_result = {"id": row[0],
......@@ -476,11 +493,25 @@ class DataSourcePointCollection:
"is_trend": bool(row[9]),
"is_virtual": bool(row[10]),
"address": row[11],
"description": row[12]}
"description": row[12],
"analog_value": None,
"digital_value": None,
"energy_value": None}
for point in analog:
if point[0] == meta_result['id'] and isinstance(point[1], datetime):
meta_result['analog_value'] = point[2]
for point in digital:
if point[0] == meta_result['id'] and isinstance(point[1], datetime):
meta_result['digital_value'] = point[2]
for point in energy:
if point[0] == meta_result['id'] and isinstance(point[1], datetime):
meta_result['energy_value'] = point[2]
result.append(meta_result)
cursor.close()
cnx.close()
history.close()
cnx_history.close()
resp.text = json.dumps(result)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册