" left join (select danger_id ,GROUP_CONCAT(inspect_name SEPARATOR '@') 'inspect_content' from danger_inspect_info group by danger_id)aaa on aaa.danger_id = t.id "+
" left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record group by danger_id)bbb on bbb.danger_id = t.id "+
" left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info group by danger_id)ccc on ccc.danger_id = t.id ${ew.customSqlSegment}")
select ifnull(aaa.inspect_content,'') inspect_content, ifnull(bbb.inspection_num,0) inspection_num, ifnull(ccc.rectification_num,0) 'rectification_num', t.* from danger_level_manage t
left join (select danger_id ,GROUP_CONCAT(inspect_name SEPARATOR '@') 'inspect_content' from danger_inspect_info group by danger_id)aaa on aaa.danger_id = t.id
left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record group by danger_id)bbb on bbb.danger_id = t.id
left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info group by danger_id)ccc on ccc.danger_id = t.id
left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record
where 1=1
<iftest="startTime != null and startTime !=''">
and DATE_FORMAT(report_date,'%Y-%m-%d') >= #{startTime}
</if>
<iftest="endTime != null and endTime !=''">
and DATE_FORMAT(report_date,'%Y-%m-%d') <= #{endTime}
</if>
group by danger_id)bbb on bbb.danger_id = t.id
left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info
where 1=1
<iftest="startTime != null and startTime !=''">
and DATE_FORMAT(rec_ord_report_date,'%Y-%m-%d') >= #{startTime}
</if>
<iftest="endTime != null and endTime !=''">
and DATE_FORMAT(rec_ord_report_date,'%Y-%m-%d') <= #{endTime}
</if>
group by danger_id)ccc on ccc.danger_id = t.id
<where>
<iftest="param.departId != null and param.departId != ''"> and t.depart_id = #{param.departId}</if>
<iftest="param.dangerType != null and param.dangerType != ''"> and t.danger_type = #{param.dangerType}</if>