test_helper.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # -*- coding: utf-8 -*-
  2. from .query_model_helper import QueryModelHelper
  3. class TestHelper:
  4. def __init__(self, env, get_model_from_func, detail_field, reference_field):
  5. self._env = env
  6. self._get_model_from = get_model_from_func
  7. self._detail_field = detail_field
  8. self._reference_field = reference_field
  9. pass
  10. def do(self):
  11. test = self._get_model_from(self._detail_field, self._reference_field,False)
  12. show_field_setting = [FieldSetting('jc_supply_chain_sale_order.name', '订单编号', 1),
  13. FieldSetting('jc_supply_chain_sale_order.bill_state', None, 2),
  14. FieldSetting('jc_supply_chain_sale_order.date', None, 7),
  15. FieldSetting('c_supply_chain_sale_order_detail.goods_id', None, 11),
  16. FieldSetting('jc_supply_chain_sale_order_detail.price', None, 21),
  17. FieldSetting('jc_supply_chain_sale_order_detail.money', None, 30, True, True),
  18. FieldSetting('jc_supply_chain_sale_order.customer_name', None, 3),
  19. FieldSetting('aaa', None, 2),
  20. FieldSetting('bbb', None, 2),
  21. FieldSetting('ccc', None, 2),
  22. FieldSetting('ddd', None, 2),
  23. FieldSetting('eee', None, 2),
  24. FieldSetting('fff', None, 2),
  25. FieldSetting('ggg', None, 2)]
  26. condition_field_setting = [
  27. FieldSetting('jc_supply_chain_sale_order.name', '订单编号', 1),
  28. FieldSetting('jc_supply_chain_sale_order.bill_state', None, 2),
  29. FieldSetting('jc_supply_chain_sale_order.date', None, 7),
  30. FieldSetting('c_supply_chain_sale_order_detail.goods_id', None, 11),
  31. FieldSetting('jc_supply_chain_sale_order_detail.price', None, 21),
  32. FieldSetting('jc_supply_chain_sale_order_detail.money', None, 30),
  33. FieldSetting('jc_supply_chain_sale_order.customer_name', None, 3),
  34. FieldSetting('aaa', None, 2),
  35. FieldSetting('bbb', None, 2),
  36. ]
  37. helper2 = QueryModelHelper(self._env, test)
  38. search_field_list = ['jc_supply_chain_sale_order.name', 'jc_supply_chain_sale_order.bill_state',
  39. 'jc_supply_chain_sale_order.date', 'jc_supply_chain_sale_order_detail.goods_id',
  40. 'jc_supply_chain_sale_order_detail.price', 'jc_supply_chain_sale_order_detail.money',
  41. 'jc_supply_chain_sale_order.customer_name']
  42. helper2.set_query_fields_list(search_field_list)
  43. helper2.set_setting(show_field_setting, condition_field_setting, [2], [])
  44. res = helper2.execute_query()
  45. print('execute result:', res)
  46. return
  47. class FieldSetting:
  48. def __init__(self, field, new_name, sequence, is_sum=False, is_number=False):
  49. self.field = field
  50. self.new_show_name = new_name
  51. self.sequence = sequence
  52. self.is_sum = is_sum
  53. self.is_number = is_number
  54. return
  55. def get_is_sum(self):
  56. return self.is_sum if self.is_number else False