<if test="(mac != null and mac != '') or (roomNo != null and roomNo != '') or (bedNo != null and bedNo!= '') or (kinds != null and kinds.size > 0)">
and
<trim prefix="(" prefixOverrides="or" suffix=")">
<if test="mac != null and mac != ''">
or device.mac like concat('%',#{mac},'%')
</if>
<if test="roomNo != null and roomNo != ''">
or room.no like concat('%', #{roomNo}, '%')
</if>
<if test="bedNo != null and bedNo!= ''">
or bed.no like concat('%', #{bedNo}, '%')
</if>
<if test="kinds != null and kinds.size > 0">
or device.kind in
<foreach collection="kinds" item="kind" index="index" open="(" close=")" separator=",">
#{kind}
</foreach>
</if>
</trim>
</if>