select d.device_id,d.device_name,
(select d.dict_item_name from t_dict d where d.dict_type='device_type' and d.dict_item_id= d.device_type) device_type,
if(d.device_status='1','正常','故障') device_status,p.dept_name
from t_device d,t_dept p
<where>
d.dept_id = p.dept_id
<if test="deviceType!=null && deviceType.length()>0">
and d.device_type = #{deviceType}
</if>
<if test="collectionType!=null && collectionType.length()>0">
and d.collection_type = #{collectionType}
</if>
<if test="nodeList!=null && nodeList.size()>0">
and p.dept_no in
<foreach close=")" collection="nodeList" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</where>
ORDER BY p.dept_no limit #{pageNo},#{pageSize}