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