fixed issues 199
parent
ac9a4991f5
commit
51b9e43a04
|
@ -913,7 +913,6 @@ class MeterPointCollection:
|
|||
description='API.INVALID_METER_ID')
|
||||
|
||||
new_values = json.loads(raw_json)
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_system_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
|
@ -925,15 +924,33 @@ class MeterPointCollection:
|
|||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||
description='API.METER_NOT_FOUND')
|
||||
|
||||
cursor.execute(" SELECT name "
|
||||
cursor.execute(" SELECT name, object_type "
|
||||
" FROM tbl_points "
|
||||
" WHERE id = %s ", (new_values['data']['point_id'],))
|
||||
if cursor.fetchone() is None:
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
cursor.close()
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||
description='API.POINT_NOT_FOUND')
|
||||
if row[1] == 'ENERGY_VALUE':
|
||||
query = (" SELECT point_id "
|
||||
" FROM tbl_meters_points "
|
||||
" WHERE meter_id = %s")
|
||||
cursor.execute(query, (id_,))
|
||||
rows = cursor.fetchall()
|
||||
if rows is not None:
|
||||
for row1 in rows:
|
||||
cursor.execute(" SELECT object_type "
|
||||
" FROM tbl_points "
|
||||
" WHERE id = %s ", (row1[0],))
|
||||
row = cursor.fetchone()
|
||||
if row is not None:
|
||||
if row[0] == 'ENERGY_VALUE':
|
||||
cursor.close()
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
||||
description='API.POINT_OBJECT_TYPE_IS_ALREADY_IN_USE')
|
||||
|
||||
query = (" SELECT id "
|
||||
" FROM tbl_meters_points "
|
||||
|
|
Loading…
Reference in New Issue