|
@@ -26,6 +26,7 @@
|
|
|
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="MonitorDataChartReportByDay" resultMap="MonitorDataChartReportMap">
|
|
|
SELECT
|
|
|
r.`HOUR` AS "dateLabel",
|
|
@@ -184,7 +185,7 @@
|
|
|
ORDER BY r.`month` ASC
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
+ <!-- 对比————用水量、耗电量 -->
|
|
|
<select id="MonitorDataEnergyReportByDay" resultMap="MonitorDataChartReportMap">
|
|
|
SELECT
|
|
|
r.`HOUR` AS "dateLabel",
|
|
@@ -354,7 +355,7 @@
|
|
|
order by r.`month` asc
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
+ <!-- 对比————PH、余氯、浊度 -->
|
|
|
<select id="MonitorDataQualityReportByDay" resultMap="MonitorDataChartReportMap">
|
|
|
SELECT
|
|
|
r.`HOUR` AS "dateLabel",
|
|
@@ -524,9 +525,7 @@
|
|
|
order by r.`month` asc
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ <!-- 对比————报警 -->
|
|
|
<select id="DeviceAlarmReport" resultMap="MonitorDataChartReportMap">
|
|
|
select
|
|
|
a.*,DATE_ADD(#{beginDate},INTERVAL a.dateLabel-1 ${dateType}) as "date"
|
|
@@ -593,5 +592,258 @@
|
|
|
)a
|
|
|
order by deviceName,dateLabel
|
|
|
</select>
|
|
|
+ <!-- 根据场景类型查询设备-->
|
|
|
+ <select id="getDeviceBySceneTypeName" resultType="com.huaxu.entity.DeviceEntity">
|
|
|
+ select
|
|
|
+ distinct d.DEVICE_NAME as "deviceName",d.id
|
|
|
+ from sms_scene_type st
|
|
|
+ left join sms_scene s on s.SCENE_TYPE_ID =st.id
|
|
|
+ left join sms_device_scene ds on ds.SCENE_ID=s.ID
|
|
|
+ left join sms_device d on d.id=ds.DEVICE_ID
|
|
|
+ where st.SCENE_TYPE_NAME=#{sceneTypeName}
|
|
|
+ <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>
|
|
|
+
|
|
|
+</select>
|
|
|
+
|
|
|
+ <!-- 设备报表 -->
|
|
|
+ <select id="MonitorDataDeviceReportByDay" resultMap="MonitorDataChartReportMap">
|
|
|
+ SELECT
|
|
|
+ d.DEVICE_NAME AS "deviceName",
|
|
|
+ p.parm_type AS "attributeType",
|
|
|
+ IF( p.parm_type = 13, '压力',
|
|
|
+ IF( p.parm_type = 14, '瞬时流量',
|
|
|
+ IF( p.parm_type = 16, '流速',
|
|
|
+ IF( p.parm_type = 7, 'PH',
|
|
|
+ IF( p.parm_type = 15, 'COD',
|
|
|
+ IF( p.parm_type = 9, '浊度',
|
|
|
+ IF( p.parm_type = 11, '余氯', '' )))))))
|
|
|
+ AS "attributeName",
|
|
|
+ da.unit AS "unit",
|
|
|
+ r.`HOUR` AS "dateLabel",
|
|
|
+ ifnull( ROUND( sum( r.AVG_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_device_attribute da ON da.id = p.ATTRIBUTE_ID
|
|
|
+ LEFT JOIN sms_device d ON d.id = p.DEVICE_ID
|
|
|
+ WHERE p.`STATUS`= 1 and d.ENABLE_STATE = 1
|
|
|
+ AND r.YEAR = #{year} and r.month=#{month} and r.day=#{day}
|
|
|
+ <if test="searchType != null and searchType == 1">
|
|
|
+ and p.parm_type = 13
|
|
|
+ </if>
|
|
|
+ <if test="searchType != null and searchType == 2">
|
|
|
+ and p.parm_type in (14,16)
|
|
|
+ </if>
|
|
|
+ <if test="searchType != null and searchType == 3">
|
|
|
+ and p.parm_type in (7,9,11,15)
|
|
|
+ </if>
|
|
|
+ <if test="deviceIds != null and deviceIds.size()>0">
|
|
|
+ and d.id in
|
|
|
+ <foreach collection="deviceIds" 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>
|
|
|
+ GROUP BY d.id, p.parm_type,da.unit,r.HOUR
|
|
|
+ order by r.`hour` asc
|
|
|
+ </select>
|
|
|
+ <select id="MonitorDataDeviceReportByMonth" resultMap="MonitorDataChartReportMap">
|
|
|
+ SELECT
|
|
|
+ d.DEVICE_NAME AS "deviceName",
|
|
|
+ p.parm_type AS "attributeType",
|
|
|
+ IF( p.parm_type = 13, '压力',
|
|
|
+ IF( p.parm_type = 14, '瞬时流量',
|
|
|
+ IF( p.parm_type = 16, '流速',
|
|
|
+ IF( p.parm_type = 7, 'PH',
|
|
|
+ IF( p.parm_type = 15, 'COD',
|
|
|
+ IF( p.parm_type = 9, '浊度',
|
|
|
+ IF( p.parm_type = 11, '余氯', '' )))))))
|
|
|
+ AS "attributeName",
|
|
|
+ da.unit AS "unit",
|
|
|
+ r.`day` AS "dateLabel",
|
|
|
+ ifnull( ROUND( sum( r.AVG_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_device_attribute da ON da.id = p.ATTRIBUTE_ID
|
|
|
+ LEFT JOIN sms_device d ON d.id = p.DEVICE_ID
|
|
|
+ WHERE p.`STATUS`= 1 and d.ENABLE_STATE = 1
|
|
|
+ AND r.YEAR = #{year} and r.month=#{month}
|
|
|
+ <if test="searchType != null and searchType == 1">
|
|
|
+ and p.parm_type = 13
|
|
|
+ </if>
|
|
|
+ <if test="searchType != null and searchType == 2">
|
|
|
+ and p.parm_type in (14,16)
|
|
|
+ </if>
|
|
|
+ <if test="searchType != null and searchType == 3">
|
|
|
+ and p.parm_type in (7,9,11,15)
|
|
|
+ </if>
|
|
|
+ <if test="deviceIds != null and deviceIds.size()>0">
|
|
|
+ and d.id in
|
|
|
+ <foreach collection="deviceIds" 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>
|
|
|
+ GROUP BY d.id, p.parm_type,r.day
|
|
|
+ order by r.day asc
|
|
|
+ </select>
|
|
|
+ <select id="MonitorDataDeviceReportByYear" resultMap="MonitorDataChartReportMap">
|
|
|
+ SELECT
|
|
|
+ d.DEVICE_NAME AS "deviceName",
|
|
|
+ p.parm_type AS "attributeType",
|
|
|
+ IF( p.parm_type = 13, '压力',
|
|
|
+ IF( p.parm_type = 14, '瞬时流量',
|
|
|
+ IF( p.parm_type = 16, '流速',
|
|
|
+ IF( p.parm_type = 7, 'PH',
|
|
|
+ IF( p.parm_type = 15, 'COD',
|
|
|
+ IF( p.parm_type = 9, '浊度',
|
|
|
+ IF( p.parm_type = 11, '余氯', '' )))))))
|
|
|
+ AS "attributeName",
|
|
|
+ da.unit AS "unit",
|
|
|
+ r.month AS "dateLabel",
|
|
|
+ ifnull( ROUND( sum( r.AVG_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_device_attribute da ON da.id = p.ATTRIBUTE_ID
|
|
|
+ LEFT JOIN sms_device d ON d.id = p.DEVICE_ID
|
|
|
+ WHERE p.`STATUS`= 1 and d.ENABLE_STATE = 1
|
|
|
+ AND r.YEAR = #{year}
|
|
|
+ <if test="searchType != null and searchType == 1">
|
|
|
+ and p.parm_type = 13
|
|
|
+ </if>
|
|
|
+ <if test="searchType != null and searchType == 2">
|
|
|
+ and p.parm_type in (14,16)
|
|
|
+ </if>
|
|
|
+ <if test="searchType != null and searchType == 3">
|
|
|
+ and p.parm_type in (7,9,11,15)
|
|
|
+ </if>
|
|
|
+ <if test="deviceIds != null and deviceIds.size()>0">
|
|
|
+ and d.id in
|
|
|
+ <foreach collection="deviceIds" 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>
|
|
|
+ GROUP BY d.id, p.parm_type,r.month
|
|
|
+ order by r.`month` asc
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|