SELECT
s.type,
sac.is_approve,
sac.is_watermark,
s.document_sn,
s.`name`,
s.version,
s.depart_id,
sd.depart_name,
su1.realname setAuditorName,
su2.realname ApproverName
FROM
(
SELECT
id,
type,
document_sn,
`name`,
version,
depart_id,
auditor,
approver
FROM
( SELECT DISTINCT * FROM sd_system_document WHERE `status` = 1 ORDER BY implement_date DESC, create_time DESC ) s
GROUP BY
s.type
) s
LEFT JOIN sys_depart sd ON s.depart_id = sd.ID
LEFT JOIN sd_auth_config sac ON sac.type = s.type
LEFT JOIN sys_user su1 ON s.auditor = su1.id
LEFT JOIN sys_user su2 ON s.approver = su2.id