SELECT baseuser.id id,
baseuser.id userId,
baseuser.realname userName,
baseuser.status status,
baseuser.user_type userType,
depart.id orgId,
group_concat(jzdepart.id) jzorgId,
suser.mobilePhone telphone,
suser.idcard idcard,
SUBSTR(suser.idcard,7,8) birth,
suser.dingIsSynchronization dingIsSynchronization,
userpersonnel.position_status positionStatus,
userpersonnel.belong_dutiesid dutiesId,
specialattend.id attendType,
suser.gender gender,
userpersonnel.contract_stime contractStime,
userpersonnel.leave_date leaveDate,
userpersonnel.in_postid inPostid,
security_strategy.social_security_unit socialSecurityUnit,
depart.projectid as projectId,
prj.zone as zoneId,
zone.name as zoneName,
userpersonnel.correction_date as correctionDate,
userpersonnel.manager_type as managerType,
userpersonnel.dutieslevel as dutieslevel

FROM t_s_base_user AS baseuser
LEFT JOIN t_s_user AS suser ON baseuser.id = suser.id
LEFT JOIN t_bus_user_personnel AS userpersonnel ON baseuser.id = userpersonnel.userid
LEFT JOIN t_bus_duties AS duties ON userpersonnel.belong_dutiesid = duties.id AND duties.delete_flag <> '1' AND duties.status <> '1'
LEFT JOIN t_bus_user_certificate AS usercertificate ON baseuser.id = usercertificate.userid AND usercertificate.delete_flag <> '1'
LEFT JOIN t_bus_certificate_subsidy AS certificatesubsidy ON usercertificate.certificateid = certificatesubsidy.id AND certificatesubsidy.delete_flag <> '1' AND certificatesubsidy.status <> '1'
LEFT JOIN t_s_user_org AS userorg ON baseuser.id = userorg.user_id AND userorg.status = '0' AND userorg.ifpluralism <> '1' 
LEFT JOIN t_s_user_org AS userjzorg ON baseuser.id = userjzorg.user_id AND userjzorg.status = '0' AND userjzorg.ifpluralism = '1' 
LEFT JOIN t_s_depart AS depart ON userorg.org_id = depart.id AND depart.status <> '1'
LEFT JOIN t_s_depart AS jzdepart ON userjzorg.org_id = jzdepart.id AND jzdepart.status <> '1'
LEFT JOIN t_bus_special_attend as specialattend ON specialattend.userid = baseuser.id AND attendtype = '1'
left join t_bus_user_wagestrategy as wagestrategy on wagestrategy.userid = baseuser.id and wagestrategy.delete_flag <> '1' 
left join t_bus_social_security_strategy as security_strategy on security_strategy.id = wagestrategy.social_security_strategyid
left join t_b_project as prj on prj.id = depart.projectid
left join t_b_zone as zone on zone.id = prj.zone
WHERE 
baseuser.delete_flag <> '1'
<#if userId ?exists &&  userId ?length gt 0>
	AND baseuser.id = :userId 
</#if>


