added limit 1 to number of ENERGY_VALUE points of meter

pull/126/MERGE
13621160019@163.com 2022-02-23 14:02:48 +08:00
parent 2e3e38b4b3
commit 2f4831bbd8
2 changed files with 11 additions and 9 deletions

View File

@ -852,6 +852,7 @@ function config($translateProvider) {
METER_NAME_IS_ALREADY_IN_USE: 'Meter Name Is Already In Use',
METER_NOT_FOUND: 'Meter Not Found',
METER_OF_VARIABLE_NOT_FOUND: 'Meter Of Variable Not Found',
METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS: 'Meter Cannot Have More Than One ENERGY_VALUE Points',
METER_POINT_RELATION_EXISTS: 'Meter Point Relation Exists',
METER_POINT_RELATION_NOT_FOUND: 'Meter Point Relation Not Found',
NOT_FOUND: 'Not Found',
@ -1851,6 +1852,7 @@ function config($translateProvider) {
METER_NAME_IS_ALREADY_IN_USE: 'Meter Name Is Already In Use',
METER_NOT_FOUND: 'Meter Not Found',
METER_OF_VARIABLE_NOT_FOUND: 'Meter Of Variable Not Found',
METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS: 'Meter Cannot Have More Than One ENERGY_VALUE Points',
METER_POINT_RELATION_EXISTS: 'Meter Point Relation Exists',
METER_POINT_RELATION_NOT_FOUND: 'Meter Point Relation Not Found',
NOT_FOUND: 'Not Found',
@ -2848,6 +2850,7 @@ function config($translateProvider) {
METER_NAME_IS_ALREADY_IN_USE: 'Meter Name Is Already In Use',
METER_NOT_FOUND: 'Meter Not Found',
METER_OF_VARIABLE_NOT_FOUND: 'Meter Of Variable Not Found',
METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS: 'Meter Cannot Have More Than One ENERGY_VALUE Points',
METER_POINT_RELATION_EXISTS: 'Meter Point Relation Exists',
METER_POINT_RELATION_NOT_FOUND: 'Meter Point Relation Not Found',
NOT_FOUND: 'Not Found',

View File

@ -933,18 +933,17 @@ class MeterPointCollection:
cnx.disconnect()
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
description='API.POINT_NOT_FOUND')
if row[1] == 'ENERGY_VALUE':
query = (" SELECT tmp.id,tmp.meter_id,tmp.point_id,tp.object_type "
" FROM tbl_meters_points tmp "
" LEFT JOIN tbl_points tp ON tmp.point_id = tp.id"
" WHERE tmp.meter_id = %s AND tp.object_type = %s")
cursor.execute(query, (id_, 'ENERGY_VALUE',))
rows = cursor.fetchall()
if rows is not None:
elif row[1] == 'ENERGY_VALUE':
query = (" SELECT p.id "
" FROM tbl_meters_points mp, tbl_points p "
" WHERE mp.meter_id = %s AND mp.point_id = p.id AND p.object_type = 'ENERGY_VALUE' ")
cursor.execute(query, (id_,))
rows_points = cursor.fetchall()
if rows_points is not None and len(rows_points) > 0:
cursor.close()
cnx.disconnect()
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
description='API.POINT_OBJECT_TYPE_IS_ALREADY_IN_USE')
description='API.METER_CANNOT_HAVE_MORE_THAN_ONE_ENERGY_VALUE_POINTS')
query = (" SELECT id "
" FROM tbl_meters_points "