flow_direction_radar_chart.py 868 B

12345678910111213141516171819202122232425
  1. from abstract_api import AbstractApi
  2. from apis.operate_mysql import OperateMysql
  3. class Flow_direction_radar_chart(AbstractApi):
  4. def operation(self, request):
  5. data_dict = {}
  6. operate_mysql = OperateMysql()
  7. table_name = "table_" + request['deviceName']
  8. limit = request['limit']
  9. speed = request['speed']
  10. direction = request['direction']
  11. sql = "SELECT * FROM %s order by times desc limit %s" % (table_name, limit)
  12. res = operate_mysql.execute_sql(sql)
  13. if len(res) != 0:
  14. for index in res:
  15. for s in speed:
  16. data_dict.setdefault('direction_list', []).append(index[s])
  17. for d in direction:
  18. data_dict.setdefault('speed_list', []).append(index[d])
  19. return data_dict
  20. else:
  21. return None