t1.id scene_Id, t1.scene_name , t1.point_x , t1.point_y, t1.address , t5.device_id, t5.attribute_id , ifnull(t5.remark, t9.`name`) attribute_name, t9.unit , case when t5.attribute_id is null then null when t6.id is null then 0 else 1 end is_alarm, t5.parm_type attribute_type, if (t5.device_id is null, null, t4.device_code) device_code inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1 left join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1 left join sms_device t4 on t2.device_id=t4.id and t4. status = 1 and t4. enable_state = 1 left join sms_device_parm t5 on t5.scene_id = t2.scene_id and t5.device_id=t2.device_id and t5. status = 1 and t5.is_suspension = 1 and t5.is_map = 1 left join sms_device_attribute t9 on t5.attribute_id=t9.id and t9.status = 1 left join sms_alarm_details t6 on t6.scene_id=t2.scene_id and t6.device_id=t2.device_id and t6.attribute_id=t5.attribute_id and t6.status = 1 and t6.state=1 left join ( select parent_scene_id,count(1) alarm_count from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 and a1.scene_id in #{item} group by parent_scene_id )t7 on t7.parent_scene_id=t1.id