业务模型¶
业务模型元素是对业务模型,模型数据表的封装。主要提供操作审批流,查询数据等功能。
实例化业务模型¶
[1]:
import debug
[2]:
from deepfos.element.bizmodel import BusinessModel
model = BusinessModel('project_module')
从模型表取数¶
获取逻辑表(包含业务模型的表关联关系)
[3]:
logic_tables = model.logic_tables
[4]:
from deepfos.core import TreeRenderer
TreeRenderer().show(logic_tables.root)
<project_info_84ce6e918e1c4b21a6d572d811092809>
├── <project_version_80ff83866f6a44dca7560666704cc7db>
| └── <collection_plan_ab666d8861334f1d9df162d452eb6736>
└── <project_detail_1c51e279091744409141d3f428760b6c>
使用业务主键 “锁定” 模型主表
[5]:
project_info = logic_tables['project_info']
project_info.lock(project_code__eq='HAITONG_A')
查询模型中的任意表,数据将受主表 “锁定条件” 影响
[6]:
project_info.data
[6]:
_create_time | _modify_time | _modifier | _creator | entity_name | project_code | _id | project_name | |
---|---|---|---|---|---|---|---|---|
0 | 2021-06-18 18:01:23 | 2021-06-18 18:01:23 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | demo1111 | HAITONG_A | 2 | HAITONG_A |
[7]:
project_version = logic_tables['project_version']
project_version.data
[7]:
_create_time | _modify_time | _modifier | _creator | project_approve_status | is_open_max | option_id_col | project_code | version | project_date | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 2021-06-18 18:01:23 | 2021-06-18 18:01:23 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 1 | 1 | option_id_col | HAITONG_A | 0 | 2021-06-20 |
1 | 2021-06-18 18:01:23 | 2021-06-18 18:01:23 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 1 | 1 | option_id_col | HAITONG_A | 1 | 2021-06-20 |
[8]:
project_detail = logic_tables['project_detail']
project_detail.data
[8]:
creator | project_code_sub | project_name | |
---|---|---|---|
0 | c538359d-8620-43d4-9a10-14a21285cf52 | HAITONG_A | Project X |
1 | c538359d-8620-43d4-9a10-14a21285cf52 | HAITONG_A | Project Y |
2 | c538359d-8620-43d4-9a10-14a21285cf52 | HAITONG_A | Project Z |
[9]:
collection_plan = logic_tables['collection_plan']
collection_plan.data
[9]:
_create_time | collection_id | _modify_time | collection_date | _modifier | _creator | collection_amount | project_code | version | _sort | ver_amount | os_amount | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2021-06-18 18:01:23 | SK1 | 2021-06-18 18:01:23 | 2021-06-19 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 1000.0 | HAITONG_A | 0 | 0 | None | None |
1 | 2021-06-18 18:01:23 | SK2 | 2021-06-18 18:01:23 | 2021-06-21 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 2000.0 | HAITONG_A | 0 | 1 | None | None |
2 | 2021-06-18 18:01:23 | SK1 | 2021-06-18 18:01:23 | 2021-06-19 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 1000.0 | HAITONG_A | 1 | 0 | None | None |
3 | 2021-06-18 18:01:23 | SK2 | 2021-06-18 18:01:23 | 2021-06-21 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 2000.0 | HAITONG_A | 1 | 1 | None | None |
如果希望只查询project_version
中version=1
的数据,可以给project_version
表增加锁定条件
[10]:
project_version.lock(version__eq='1')
project_version.data
[10]:
_create_time | _modify_time | _modifier | _creator | project_approve_status | is_open_max | option_id_col | project_code | version | project_date | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 2021-06-18 18:01:23 | 2021-06-18 18:01:23 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 1 | 1 | option_id_col | HAITONG_A | 1 | 2021-06-20 |
project_version
的子表collection_plan
能查询到的数据也将受到影响
[11]:
collection_plan.data
[11]:
_create_time | collection_id | _modify_time | collection_date | _modifier | _creator | collection_amount | project_code | version | _sort | ver_amount | os_amount | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2021-06-18 18:01:23 | SK1 | 2021-06-18 18:01:23 | 2021-06-19 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 1000.0 | HAITONG_A | 1 | 0 | None | None |
1 | 2021-06-18 18:01:23 | SK2 | 2021-06-18 18:01:23 | 2021-06-21 | c538359d-8620-43d4-9a10-14a21285cf52 | c538359d-8620-43d4-9a10-14a21285cf52 | 2000.0 | HAITONG_A | 1 | 1 | None | None |