gen_report.py 926 B

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding:utf-8 -*-
  2. import importlib
  3. from apps.report.gen_excel import gen_template
  4. class Report():
  5. def __init__(self, code, query_params):
  6. self.code = code
  7. self.module_url = "apps.report.reports." + code
  8. self.module = self.import_module(self.module_url).Query(query_params=query_params)
  9. def import_module(self, module_url):
  10. return importlib.import_module(module_url)
  11. class BaseQuery():
  12. def __init__(self, query_params):
  13. self.query_params = query_params
  14. self.header = []
  15. self.file_name = ""
  16. self.report_config()
  17. def report_config(self):
  18. pass
  19. def get_template(self):
  20. return gen_template(self.header, self.file_name)
  21. def instance_data(self):
  22. return []
  23. def get_instance(self, db):
  24. self.db = db
  25. data = self.instance_data()
  26. return gen_template(self.header, self.file_name, data)