b.enterprise_name as beyond_enterprise_name,a.f_village_id,v.f_village_name as village_name,
deviceInfo.f_relation_device_type,
deviceInfo.f_device_name,
deviceInfo.f_device_model,
deviceInfo.f_iot_no,
deviceInfo.f_detection_medium,
deviceInfo.f_device_install_time,
deviceInfo.f_device_install_position,
deviceInfo.f_head,
deviceInfo.f_phone
from t_yehuaqi_user a left join t_enterprise_info b on a.beyond_enterprise_id=b.enterprise_id
left join t_user_manage_village v on a.f_village_id=v.f_village_id
left join t_yehuaqiuser_safety_device_info deviceInfo on a.user_id = deviceInfo.f_relation_user_id
<where> a.is_del = '0' and a.error_msg is null
<iftest="beyondEnterpriseId != null and beyondEnterpriseId != -2"> and a.beyond_enterprise_id =#{beyondEnterpriseId}</if>
<iftest="username != null and username != ''"> and a.username like concat('%', #{username}, '%')</if>
<iftest="nickName != null and nickName != ''"> and (a.nick_name like concat('%', #{nickName}, '%') or a.username like concat('%', #{nickName}, '%'))</if>