| 
					
				 | 
			
			
				@@ -20,6 +20,24 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             <result property="latestValue" column="latest_value" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </collection> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </resultMap> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <!-- 设备结果集 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <resultMap type="com.huaxu.dto.MonitorDataCollectDto" id="deviceDataMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="sceneId" column="scene_id" jdbcType="INTEGER"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="sceneName" column="scene_name" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="deviceId" column="device_id" jdbcType="INTEGER"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="deviceName" column="device_name" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="pointX" column="point_x" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="pointY" column="point_y" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="address" column="address" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="sceneState" column="scene_state" jdbcType="INTEGER"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <collection property="MonitorDataEntities" ofType="com.huaxu.dto.MonitorDataDto" javaType="list"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <result property="attributeId" column="attribute_id" jdbcType="INTEGER"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <result property="unit" column="unit" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <result property="isAlarm" column="is_Alarm" jdbcType="VARCHAR"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </collection> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </resultMap> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     <sql id="Base_Column_List"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         t1.id scene_Id, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -215,12 +233,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             select b1.device_id,b1.attribute_id,max(latest_value) latest_value 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             from sms_day_report b1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             where b1.year = year(now() + interval-1 day) and b1.month = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                <if test="sceneIds != null and sceneIds.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    and b1.parent_scene_id  in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             group by b1.device_id,b1.attribute_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         )t8 on t8.device_id=t2.device_id and t8.attribute_id =t5.attribute_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         where t1.parent_scene_id = 0 and t1. status = 1 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -247,4 +259,44 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         order by t1.scene_name,t5.seq 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <!--按管网名称分类查询设备数量--> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="selectDeviceCount" resultType="java.util.Map"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select  t1.id,t1.scene_name sceneName,sum(if(t5.id is null,0,1)) deviceCount 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from sms_scene t1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        inner join sms_scene_type t3 on t1.scene_type_id=t3.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 t6 on t2.device_id=t6.id and t6. status = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene t4 on t2.scene_id=t4.id and t4. status = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene_type t5 on t4.scene_type_id=t5.id and t5. status = 1 and t5.scene_type_name = #{sceneTypeName} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="sceneIds != null and sceneIds.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and t1.id  in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="sceneIds == null or sceneIds.size() == 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and t1.id is null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="sceneId != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and t1.id = #{sceneId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="deviceName != null and deviceName != ''"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and t6.device_name like concat('%', #{deviceName},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by t1.id,t1.scene_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <!--查询设备地图参数数据--> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="selectDeviceMapParam" resultMap="deviceDataMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select  distinct t1.id device_id,t1.device_code,t1.device_name,t1.point_x,point_y,t1.address,t2.attribute_id, ifnull(t2.remark, t3.`name`) attribute_name,t3.unit, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         case when t2.attribute_id is  null then null when t6.id is null then 0 else 1 end is_alarm, if (t4.alarm_count>0, 1, 0) scene_state 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from sms_device  t1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_parm t2 on t2.device_id=t1.id and t2.is_map=1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute t3 on t2.attribute_id=t3.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select a1.device_id,count(1) alarm_count from sms_alarm_details a1 where a1.device_id= #{deviceId} and a1.`status` = 1 and a1.state = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        )t4 on t4.device_id=t1.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_alarm_details t6 on t6.device_id=t1.id and t6.attribute_id=t2.attribute_id and t6.status = 1 and t6.state=1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where t1. status = 1 and t1. enable_state = 1 and t1.id= #{deviceId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </mapper> 
			 |