alarm_limit_from_database.py 954 B

12345678910111213141516171819
  1. from abstract_api import AbstractApi
  2. from apis.operate_mysql import OperateMysql
  3. class Alarm_limit_from_database(AbstractApi):
  4. def operation(self, request):
  5. operate_mysql = OperateMysql()
  6. device_name = request['device']
  7. if device_name == "all":
  8. sql = "SELECT id,io_point_name,alarm_low_limit,alarm_up_limit FROM data_point_tbl WHERE alarm_low_limit IS NOT Null AND alarm_up_limit IS NOT Null;"
  9. res = operate_mysql.execute_sql(sql)
  10. elif isinstance(device_name, list) and device_name:
  11. device_name = ','.join(["'%s'" % item for item in device_name])
  12. sql = "SELECT id,io_point_name,alarm_low_limit,alarm_up_limit FROM data_point_tbl WHERE alarm_low_limit IS NOT Null AND alarm_up_limit IS NOT Null AND device_name= ( %s );" % device_name
  13. res = operate_mysql.execute_sql(sql)
  14. else:
  15. res = "传入空列表或参数错误"
  16. return res