and a.tdmx_tdls = #{tdls}
and a.tdmx_fdywdh = #{fdywdh}
and a.tdmx_pch = #{pch}
and a.tdmx_sfzc = #{zcbz}
and case when NOT EXISTS ( SELECT * FROM fd_mx_wlgs WHERE tdmx_tdls = a.tdmx_tdls) then 1
when EXISTS ( SELECT * FROM fd_mx_wlgs WHERE tdmx_tdfl = a.tdmx_tdfl AND wlgs_no = #{companyNo} ) then 1
when not EXISTS ( SELECT * FROM fd_mx_wlgs WHERE tdmx_tdfl = a.tdmx_tdfl) and tdmx_fdwlgsbh is null then 1
when tdmx_fdwlgsbh =#{companyNo} then 1
end >0