SELECT IFNULL(t.`create_time`,"") AS createTime,t.*,s.device_name AS deviceName,s.category,s.unit,e.unit_name AS enterpriseName,s.`device_number` AS deviceNum FROM safety_device_info s
LEFT JOIN (SELECT device_num,MAX(id) AS did ,`status`,concentration, create_time FROM monitor GROUP BY device_num) t ON t.`device_num` = s.`device_number`
LEFT JOIN enterprise_basic_info e ON e.id = s.enterprise_id
WHERE s.data_type = 3
<iftest="deviceName!=null">
AND s.device_name LIKE concat('%',#{deviceName},'%')
</if>
<iftest="deviceNumber!=null">
AND s.device_number LIKE concat('%',#{deviceNumber},'%')
</if>
<iftest="enterpriseId!=null and enterpriseId!=''">