Skip to content

Commit 6237632

Browse files
committed
docs: dataease sync and dataset
1 parent 020435e commit 6237632

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
60.2 KB
Loading

manual/user_manual/dataease.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,103 @@
4040

4141
![仪表板权限设置](../img/user_manual/dashboard-permissions.png)
4242

43+
## 数据同步
44+
!!! Abstract ""
45+
46+
在 【系统】>【企业设置】>【三方设置】>【DataEase】中点击同步,即可将 Cordys CRM 中用户、角色、部门等的信息同步到 DataEase 中,配置页面也可以配置定时同步。
47+
![仪表板权限设置](../img/user_manual/dataease-sync.png)
48+
49+
## 编写通用数据集
50+
!!! Abstract ""
51+
52+
Cordys CRM 通过数据权限的设计,使得不同角色能够访问到不同数据范围的数据;经过数据同步后,DataEase 会创建对应的用户与角色,并且创建数据权限和部门ID的系统变量,用户可以在编写数据集时,使用这些变量过滤数据,确保用户只能访问到有权限的数据。
53+
54+
```
55+
-- 关键SQL
56+
select c.*
57+
from opportunity c
58+
left join sys_organization_user sou on c.owner = sou.user_id
59+
where c.organization_id = '100001'
60+
and
61+
(
62+
-- 根据数据权限和部门ID过滤数据
63+
($DE_PARAM{'$f2cde[OPPORTUNITY_DATA_SCOPE_TYPE]' = 'ALL'} or $DE_PARAM{'$f2cde[账户]' = 'admin'})
64+
or
65+
($DE_PARAM{ '$f2cde[OPPORTUNITY_DATA_SCOPE_TYPE]' = 'DEPT_CUSTOM'} and $DE_PARAM{ sou.department_id in ($f2cde[OPPORTUNITY_DATA_SCOPE_DEPT_ID])})
66+
or
67+
($DE_PARAM{'$f2cde[OPPORTUNITY_DATA_SCOPE_TYPE]'} = 'SELF' and $DE_PARAM{sou.user_id = '$f2cde[账户]'})
68+
or
69+
1=2
70+
)
71+
```
72+
73+
```
74+
-- 示例SQL
75+
select
76+
c.id,
77+
c.name as '商机名称',
78+
su.name as '负责人',
79+
sd.name as '部门',
80+
c.amount as '金额',
81+
osc.name as '商机阶段',
82+
cc.name as '客户名称',
83+
IF(sou.enable, '否', '是') as '是否离职',
84+
FROM_UNIXTIME(c.create_time / 1000) as '创建时间',
85+
FROM_UNIXTIME(c.update_time / 1000) as '更新时间',
86+
FROM_UNIXTIME(c.expected_end_time / 1000) as '结束时间',
87+
FROM_UNIXTIME(c.actual_end_time / 1000) as '实际结束时间',
88+
FROM_UNIXTIME(c.follow_time / 1000) as '跟进时间',
89+
(
90+
select REPLACE(REPLACE(REPLACE(JSON_ARRAYAGG(p.name), '"', ''), '[', ''), ']', '')
91+
from product p
92+
where c.products like concat('%', p.id, '%')
93+
) as '产品类型',
94+
(
95+
select f.field_value
96+
from opportunity_field f
97+
where f.resource_id = c.id and f.field_id = (
98+
select id from sys_module_field smf where smf.internal_key = 'opportunityCode'
99+
)
100+
LIMIT 1
101+
) AS '业务商机编号',
102+
(
103+
select option.label
104+
from opportunity_field f
105+
left join (
106+
SELECT temp.*, smfb.id as field_id
107+
from sys_module_field_blob smfb,
108+
JSON_TABLE(
109+
smfb.prop,
110+
'$.options[*]' COLUMNS (
111+
label VARCHAR(255) PATH '$.label',
112+
value VARCHAR(50) PATH '$.value'
113+
)
114+
) AS temp
115+
) option on f.field_id = option.field_id and option.value = f.field_value
116+
where f.resource_id = c.id and f.field_id = (
117+
select id from sys_module_field smf where smf.internal_key = 'opportunitySource'
118+
)
119+
LIMIT 1
120+
) AS '商机来源'
121+
from opportunity c
122+
LEFT JOIN sys_organization_user sou on c.owner = sou.user_id
123+
LEFT JOIN sys_department sd on sd.id = sou.department_id
124+
LEFT JOIN sys_user su on su.id = c.owner
125+
LEFT JOIN customer cc on c.customer_id = cc.id
126+
LEFT JOIN opportunity_stage_config osc on osc.id = c.stage
127+
where c.organization_id = '100001'
128+
and
129+
(
130+
-- 根据数据权限和部门ID过滤数据
131+
($DE_PARAM{'$f2cde[OPPORTUNITY_DATA_SCOPE_TYPE]' = 'ALL'} or $DE_PARAM{'$f2cde[账户]' = 'admin'})
132+
or
133+
($DE_PARAM{ '$f2cde[OPPORTUNITY_DATA_SCOPE_TYPE]' = 'DEPT_CUSTOM'} and $DE_PARAM{ sou.department_id in ($f2cde[OPPORTUNITY_DATA_SCOPE_DEPT_ID])})
134+
or
135+
($DE_PARAM{'$f2cde[OPPORTUNITY_DATA_SCOPE_TYPE]'} = 'SELF' and $DE_PARAM{sou.user_id = '$f2cde[账户]'})
136+
or
137+
1=2
138+
)
139+
```
43140

44141
## DataEase 对接效果
45142

0 commit comments

Comments
 (0)