| 
					
				 | 
			
			
				@@ -17,8 +17,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     <resultMap id="MonitorDataChartReportValue" type="com.huaxu.dto.MonitorDataChartReportValueDto"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <result property="dateLabel" column="dateLabel" /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <result property="dateStringLabel" column="dateStringLabel" /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <result property="monitorData" column="monitorData" /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <result property="data" column="data"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <result property="date" column="date"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </resultMap> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -28,41 +26,25 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join sms_device_attribute da on da.id=r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join sms_device d on d.id=r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </sql> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    <select id="MonitorDataChartReport" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`MONTH` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`)) as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`DAY` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`)) as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`HOUR` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`),' ',if(r.`HOUR`<10,CONCAT(0,r.`HOUR`),r.`HOUR`),':00') as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CONCAT(cast(ifnull(ROUND(r.AVG_VALUE,2),'') as char),ifnull(da.unit,'')) as "monitorData" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,ROUND(r.AVG_VALUE,2) as "data" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,r.COLLECT_DATE as "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataChartReportByDay" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.`HOUR` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CONCAT( r.PARENT_SCENE_NAME, r.DEVICE_NAME ) AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.DEVICE_CODE AS "devoceCode", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.ATTRIBUTE_NAME AS "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,d.DEVICE_CODE as "devoceCode" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,CONCAT(r.PARENT_SCENE_NAME,d.DEVICE_NAME) as "deviceName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,da.unit as "unit" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,r.ATTRIBUTE_NAME as "attributeName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        from ${tableName} r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <include refid="MonitorDataReportJoins"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        where dp.IS_CHART = 1 and r.PARENT_SCENE_ID=#{sceneId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="year != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ROUND( sum(r.AVG_VALUE), 2 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            max(r.COLLECT_DATE) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_day_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device_attribute da ON da.id = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where p.IS_CHART = 1 and p.`STATUS`= 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and p.PARENT_SCENE_ID=#{sceneId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and r.year=#{year} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="month != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and r.month=#{month} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="day != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -93,56 +75,186 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by r.hour ,r.PARENT_SCENE_NAME,r.DEVICE_NAME,r.DEVICE_CODE,r.ATTRIBUTE_NAME,da.unit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY r.`HOUR` ASC 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataChartReportByMonth" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.`day` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CONCAT( r.PARENT_SCENE_NAME, r.DEVICE_NAME ) AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.DEVICE_CODE AS "devoceCode", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.ATTRIBUTE_NAME AS "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by d.DEVICE_CODE,r.ATTRIBUTE_NAME,r.`MONTH` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by d.DEVICE_CODE,r.ATTRIBUTE_NAME,r.`DAY` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ROUND( sum(r.AVG_VALUE), 2 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            max(r.COLLECT_DATE) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device_attribute da ON da.id = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where p.IS_CHART = 1 and p.`STATUS`= 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and p.PARENT_SCENE_ID=#{sceneId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and r.year=#{year} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and r.month=#{month} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by d.DEVICE_CODE,r.ATTRIBUTE_NAME,r.`HOUR` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 5 or permissonType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ( d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                or 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 4 or permissonType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by r.day ,r.PARENT_SCENE_NAME,r.DEVICE_NAME,r.DEVICE_CODE,r.ATTRIBUTE_NAME,da.unit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY r.`day` ASC 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataChartReportByYear" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.`month` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CONCAT( r.PARENT_SCENE_NAME, r.DEVICE_NAME ) AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.DEVICE_CODE AS "devoceCode", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.ATTRIBUTE_NAME AS "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    <select id="MonitorDataEnergyReport" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`MONTH` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`)) as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`DAY` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`)) as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ROUND( sum(r.AVG_VALUE), 2 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            max(r.COLLECT_DATE) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_year_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device_attribute da ON da.id = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where p.IS_CHART = 1 and p.`STATUS`= 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and p.PARENT_SCENE_ID=#{sceneId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and r.year=#{year} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`HOUR` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`),' ',if(r.`HOUR`<10,CONCAT(0,r.`HOUR`),r.`HOUR`),':00') as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 5 or permissonType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ( d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                or 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 4 or permissonType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by r.month ,r.PARENT_SCENE_NAME,r.DEVICE_NAME,r.DEVICE_CODE,r.ATTRIBUTE_NAME,da.unit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY r.`month` ASC 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        r.PARENT_SCENE_NAME as "deviceName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,da.ATTRIBUTE_TYPE as "attributeType" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,da.unit as "unit" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,if(da.ATTRIBUTE_TYPE=3,'用水量','耗电量') as  "attributeName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,CONCAT(cast(ifnull(ROUND(sum(r.SUM_VALUE),2),0) as char),ifnull(da.unit,'')) as "monitorData" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,ifnull(ROUND(sum(r.SUM_VALUE),2) ,0)  as "data" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,max(r.COLLECT_DATE) as "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataEnergyReportByDay" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.`HOUR` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            IF( p.parm_type = 3, '用水量', '耗电量' ) AS "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            s.SCENE_NAME AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            p.parm_type AS "attributeType", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            from sms_year_report r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            from sms_month_report r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            from sms_day_report r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            max( r.COLLECT_DATE ) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_day_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene s on s.id=p.parent_scene_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE p.`STATUS`= 1 and p.parm_type in (3,5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND r.YEAR = #{year}  and r.month=#{month}  and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and r.PARENT_SCENE_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 5 or permissonType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ( d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                or 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 4 or permissonType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <include refid="MonitorDataReportJoins"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        where (da.ATTRIBUTE_TYPE=3 or da.ATTRIBUTE_TYPE=5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.HOUR 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        order by r.`hour` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataEnergyReportByMonth" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.`day` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            IF( p.parm_type = 3, '用水量', '耗电量' ) AS "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            s.SCENE_NAME AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            p.parm_type AS "attributeType", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            max( r.COLLECT_DATE ) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene s on s.id=p.parent_scene_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE p.`STATUS`= 1 and p.parm_type in (3,5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND r.YEAR = #{year}  and r.month=#{month} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and r.PARENT_SCENE_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -179,60 +291,140 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and r.year=#{year} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE,da.unit,r.year,r.month 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE asc,r.`MONTH` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and r.year=#{year}  and r.month=#{month} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE,da.unit,r.year,r.month,r.day 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE asc,r.`day` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and r.year=#{year}  and r.month=#{month} and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE,da.unit,r.year,r.month,r.day,r.hour 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE asc,r.`hour` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.day 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        order by r.`day` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataEnergyReportByYear" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            r.`month` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            IF( p.parm_type = 3, '用水量', '耗电量' ) AS "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            s.SCENE_NAME AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            p.parm_type AS "attributeType", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    <select id="MonitorDataQualityReport" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`MONTH` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`)) as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            max( r.COLLECT_DATE ) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_year_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene s on s.id=p.parent_scene_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE p.`STATUS`= 1 and p.parm_type in (3,5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND r.YEAR = #{year}  and r.month=#{month} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and r.PARENT_SCENE_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`DAY` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`)) as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            r.`HOUR` as "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`),' ',if(r.`HOUR`<10,CONCAT(0,r.`HOUR`),r.`HOUR`),':00') as "dateStringLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 5 or permissonType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ( d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                or 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 4 or permissonType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.month 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        order by r.`month` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        r.PARENT_SCENE_NAME as "deviceName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,da.ATTRIBUTE_TYPE as "attributeType" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,da.unit as "unit" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,if(da.ATTRIBUTE_TYPE=8,'PH',if(da.ATTRIBUTE_TYPE=11,'余氯','浊度')) as  "attributeName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,CONCAT(cast(ifnull(ROUND(avg(r.SUM_VALUE),2),0) as char),ifnull(da.UNIT,'')) as "monitorData" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,ifnull(ROUND(avg(r.SUM_VALUE),2) ,0)  as "data" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ,max(r.COLLECT_DATE) as "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataQualityReportByDay" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        r.`HOUR` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(p.parm_type=8,'PH',if(p.parm_type=11,'余氯','浊度')) as  "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        s.SCENE_NAME AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        p.parm_type AS "attributeType", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            from sms_year_report r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        max( r.COLLECT_DATE ) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_day_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene s on s.id=p.parent_scene_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE p.`STATUS`= 1 and p.parm_type in (8,11,10) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND r.YEAR = #{year}  and r.month=#{month}  and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and r.PARENT_SCENE_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            from sms_month_report r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            from sms_day_report r 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 5 or permissonType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ( d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                or 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 4 or permissonType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <include refid="MonitorDataReportJoins"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        where (da.ATTRIBUTE_TYPE=8 or da.ATTRIBUTE_TYPE=11  or da.ATTRIBUTE_TYPE=10) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.HOUR 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        order by r.`hour` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataQualityReportByMonth" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        r.`day` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(p.parm_type=8,'PH',if(p.parm_type=11,'余氯','浊度')) as  "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        s.SCENE_NAME AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        p.parm_type AS "attributeType", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        max( r.COLLECT_DATE ) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene s on s.id=p.parent_scene_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE p.`STATUS`= 1 and p.parm_type in (8,11,10) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND r.YEAR = #{year}  and r.month=#{month}  and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and r.PARENT_SCENE_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -269,21 +461,64 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and r.year=#{year} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE,da.unit,r.year,r.month 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE asc,r.`MONTH` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.day 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        order by r.`day` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="MonitorDataQualityReportByYear" resultMap="MonitorDataChartReportMap"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        r.`month` AS "dateLabel", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(p.parm_type=8,'PH',if(p.parm_type=11,'余氯','浊度')) as  "attributeName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        s.SCENE_NAME AS "deviceName", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        p.parm_type AS "attributeType", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        da.unit AS "unit", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        max( r.COLLECT_DATE ) AS "date" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM sms_device_parm p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_year_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_scene s on s.id=p.parent_scene_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE p.`STATUS`= 1 and p.parm_type in (8,11,10) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND r.YEAR = #{year}  and r.month=#{month}  and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and r.PARENT_SCENE_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and r.year=#{year}  and r.month=#{month} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE,da.unit,r.year,r.month,r.day 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE asc,r.`day` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="tenantId != null and tenantId != '' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            and d.tenant_id = #{tenantId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <if test="type != null and type ==3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and r.year=#{year}  and r.month=#{month} and r.day=#{day} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE,da.unit,r.year,r.month,r.day,r.hour 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            order by r.PARENT_SCENE_NAME,da.ATTRIBUTE_TYPE asc,r.`hour` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 5 or permissonType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ( d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                or 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 4 or permissonType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.DEPT_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="permissonType == 1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and d.COMPANY_ORG_ID in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach collection="programItems" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item.orgId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.month 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        order by r.`month` asc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -305,19 +540,17 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         <if test="dateType != null and dateType == 'hour'"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ,DATE_FORMAT(max(ad.ALARM_START_TIME),'%Y-%m-%d %H:00') as "dateStringLabel" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ,count(1) as "monitorData" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ,count(1) as "data" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ,ps.SCENE_NAME as "deviceName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ,ad.PARENT_SCENE_NAME as "deviceName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ,'报警次数' as "attributeName" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ,count(1) as "monitorData" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ,count(1) as "data" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             from sms_alarm_details ad 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             left join sms_device d on ad.DEVICE_ID=d.ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            left join sms_scene s on s.id = d.SCENE_ID and s.`STATUS` = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            left join sms_scene ps on s.PARENT_SCENE_IDS LIKE concat('%,', ps.id ,',%') and ps.PARENT_SCENE_ID ='0' and ps.`STATUS` = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             where ad.ALARM_START_TIME < #{endDate} and ad.ALARM_START_TIME >= #{beginDate} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             <if test="sceneIds != null and sceneIds.size()>0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                and ps.id  in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and ad.parent_scene_id  in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 <foreach collection="sceneIds" item="item" open="(" close=")" separator=","> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 </foreach> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -353,7 +586,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group by ps.SCENE_NAME,${dateType}(ad.ALARM_START_TIME) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            group by ad.PARENT_SCENE_NAME,${dateType}(ad.ALARM_START_TIME) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         )a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         order by deviceName,dateLabel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 |