FineDB 表结构-https://help.fanruan.com/finereport/doc-view-3151.html
=============
select
u.ID 用户ID,
u.USERNAME ,
u.REALNAME 姓名,
rd.id 部门ID,
d.NAME 部门
from FINE_USER u
left join FINE_USER_ROLE_MIDDLE rm on u.id=rm.userId
left join FINE_CUSTOM_ROLE rc on rm.ROLETYPE=2 and rm.ROLEID=rc.id
left join FINE_DEP_ROLE rd on rm.ROLETYPE=1 and rm.ROLEID=rd.id
left join FINE_DEPARTMENT d on d.id=rd.DEPARTMENTID