where z.id = x.dy_level_id and x.id = y.line_id and j.term_id = y.id and j.channel_id = k.id
<!-- terminal_channels k,-->
and x.status = #{status} and y.status = #{status} and z.status = #{status} and k.status = #{status}
<!-- terminal_schedulemapper l-->
<!-- where z.id = x.dy_level_id and x.id = y.line_id and j.term_id = y.id and j.channel_id = k.id and y.id = l.term_id and j.channel_id = l.channel_id-->
<!-- and x.status = #{status} and y.status = #{status} and z.status = #{status} and k.status = #{status}-->
<!-- <if test="termid != null">-->
<!-- and y.id = #{termid}-->
<!-- </if>-->
SELECT
z.id AS id,
z.name AS name,
z.dy_value AS dyvalue,
x.id AS line_id,
x.name AS line_name,
x.bs_manufacturer AS bs_manufacturer,
y.id AS term_id,
y.tower_id AS tower_id,
y.cmdid AS cmdid,
y.display_name AS display_name,
k.id AS channel_id,
k.channel_name AS channel_name,
l.schedule_id AS schedule_id
FROM
(((((dy_level z
left JOIN `lines` x ON z.id = x.dy_level_id)
left JOIN terminals y ON x.id = y.line_id)
left JOIN terminal_channel_mapper j ON j.term_id = y.id)
left JOIN terminal_channels k ON j.channel_id = k.id)
left JOIN terminal_schedulemapper l ON j.channel_id = l.channel_id)
where
x.status = #{status} and y.status = #{status} and z.status = #{status} and k.status = #{status}