用户报表(包含自定义字段)生成
其中,instance_id 对应用户 id,如下加粗标准的内容可以作为参考。
AS "员工ID",max(aaacontact.LANDLINE) AS "电话",max(aaacontact.MOBILE)
AS "手机" ,string_agg(qd.queuename,',') AS "关联组",string_agg( ar.NAME, ',' ) AS "角色", max(useradditionalfields.udf_char1) AS "自定义字段内容" FROM aaauser LEFT JOIN sduser ON aaauser.user_id=sduser.userid LEFT JOIN aaauser sdus on sduser.REPORTINGTO = sdus.USER_ID LEFT JOIN aaalogin ON aaalogin.user_id = aaauser.user_id LEFT JOIN aaaaccount ON aaalogin.login_id = aaaaccount.login_id LEFT JOIN useradditionalfields ON aaauser.user_id=useradditionalfields.instance_id LEFT JOIN userdepartment ON aaauser.user_id=userdepartment.userid LEFT JOIN departmentdefinition ON userdepartment.deptid=departmentdefinition.deptid LEFT JOIN sdorganization ON departmentdefinition.siteid = sdorganization.org_id LEFT JOIN aaausercontactinfo ON aaausercontactinfo.user_id=aaauser.user_id LEFT JOIN aaacontactinfo ON aaausercontactinfo.contactinfo_id=aaacontactinfo.contactinfo_id LEFT JOIN AaaUserContactInfo aaausercontact ON aaauser.USER_ID=aaausercontact.USER_ID LEFT JOIN AaaContactInfo aaacontact ON aaausercontact.CONTACTINFO_ID=aaacontact.CONTACTINFO_ID LEFT JOIN Queue_Technician qt ON qt.TECHNICIANID=AaaUser.USER_ID LEFT JOIN QueueDefinition qd ON qt.QUEUEID=qd.QUEUEID LEFT JOIN AaaLogin al ON aaauser.USER_ID=al.USER_ID LEFT JOIN AaaAccount aa ON al.LOGIN_ID=aa.LOGIN_ID LEFT JOIN sdAuthorizedRole aar ON aa.ACCOUNT_ID=aar.ACCOUNT_ID LEFT JOIN AaaRole ar ON aar.ROLE_ID=ar.ROLE_ID LEFT JOIN AaaRoleToCategory ON ar.ROLE_ID=AaaRoleToCategory.ROLE_ID WHERE sduser.status='ACTIVE' GROUP BY aaauser.user_id;