@@ 815-844 (lines=30) @@ | ||
812 | description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
813 | ||
814 | for variable in new_values['data']['expression']['variables']: |
|
815 | if variable['meter_type'].lower() == 'meter': |
|
816 | cursor.execute(" SELECT name " |
|
817 | " FROM tbl_meters " |
|
818 | " WHERE id = %s ", (variable['meter_id'],)) |
|
819 | if cursor.fetchone() is None: |
|
820 | cursor.close() |
|
821 | cnx.disconnect() |
|
822 | raise falcon.HTTPError(falcon.HTTP_404, |
|
823 | title='API.NOT_FOUND', |
|
824 | description='API.METER_OF_VARIABLE_NOT_FOUND') |
|
825 | elif variable['meter_type'].lower() == 'offline_meter': |
|
826 | cursor.execute(" SELECT name " |
|
827 | " FROM tbl_offline_meters " |
|
828 | " WHERE id = %s ", (variable['meter_id'],)) |
|
829 | if cursor.fetchone() is None: |
|
830 | cursor.close() |
|
831 | cnx.disconnect() |
|
832 | raise falcon.HTTPError(falcon.HTTP_404, |
|
833 | title='API.NOT_FOUND', |
|
834 | description='API.OFFLINE_METER_OF_VARIABLE_NOT_FOUND') |
|
835 | elif variable['meter_type'].lower() == 'virtual_meter': |
|
836 | cursor.execute(" SELECT name " |
|
837 | " FROM tbl_virtual_meters " |
|
838 | " WHERE id = %s ", (variable['meter_id'],)) |
|
839 | if cursor.fetchone() is None: |
|
840 | cursor.close() |
|
841 | cnx.disconnect() |
|
842 | raise falcon.HTTPError(falcon.HTTP_404, |
|
843 | title='API.NOT_FOUND', |
|
844 | description='API.VIRTUAL_METER_OF_VARIABLE_NOT_FOUND') |
|
845 | ||
846 | update_row = (" UPDATE tbl_virtual_meters " |
|
847 | " SET name = %s, energy_category_id = %s, is_counted = %s, " |
|
@@ 280-309 (lines=30) @@ | ||
277 | description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY') |
|
278 | ||
279 | for variable in new_values['data']['expression']['variables']: |
|
280 | if variable['meter_type'].lower() == 'meter': |
|
281 | cursor.execute(" SELECT name " |
|
282 | " FROM tbl_meters " |
|
283 | " WHERE id = %s ", (variable['meter_id'],)) |
|
284 | if cursor.fetchone() is None: |
|
285 | cursor.close() |
|
286 | cnx.disconnect() |
|
287 | raise falcon.HTTPError(falcon.HTTP_404, |
|
288 | title='API.NOT_FOUND', |
|
289 | description='API.METER_OF_VARIABLE_NOT_FOUND') |
|
290 | elif variable['meter_type'].lower() == 'offline_meter': |
|
291 | cursor.execute(" SELECT name " |
|
292 | " FROM tbl_offline_meters " |
|
293 | " WHERE id = %s ", (variable['meter_id'],)) |
|
294 | if cursor.fetchone() is None: |
|
295 | cursor.close() |
|
296 | cnx.disconnect() |
|
297 | raise falcon.HTTPError(falcon.HTTP_404, |
|
298 | title='API.NOT_FOUND', |
|
299 | description='API.OFFLINE_METER_OF_VARIABLE_NOT_FOUND') |
|
300 | elif variable['meter_type'].lower() == 'virtual_meter': |
|
301 | cursor.execute(" SELECT name " |
|
302 | " FROM tbl_virtual_meters " |
|
303 | " WHERE id = %s ", (variable['meter_id'],)) |
|
304 | if cursor.fetchone() is None: |
|
305 | cursor.close() |
|
306 | cnx.disconnect() |
|
307 | raise falcon.HTTPError(falcon.HTTP_404, |
|
308 | title='API.NOT_FOUND', |
|
309 | description='API.VIRTUAL_METER_OF_VARIABLE_NOT_FOUND') |
|
310 | ||
311 | add_values = (" INSERT INTO tbl_virtual_meters " |
|
312 | " (name, uuid, energy_category_id, is_counted, " |