|
@@ -197,11 +197,11 @@
|
|
|
|
|
|
</select>
|
|
|
<select id="findAttributeNameList" resultType="com.huaxu.dto.ReportAttributeDto">
|
|
|
- SELECT DISTINCT tab.attributeName,tab.attributeType
|
|
|
+ SELECT DISTINCT tab.attributeName,tab.attributeType,tab.SEQ
|
|
|
from
|
|
|
(SELECT
|
|
|
IFNULL(a.REMARK,b.`NAME`) AS "attributeName",
|
|
|
- a.parm_type as "attributeType"
|
|
|
+ a.parm_type as "attributeType",a.SEQ
|
|
|
FROM sms_device_parm a
|
|
|
INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
|
|
|
where
|
|
@@ -218,6 +218,7 @@
|
|
|
</foreach>
|
|
|
ORDER BY a.SEQ asc
|
|
|
) as tab
|
|
|
+ ORDER BY tab.SEQ asc
|
|
|
</select>
|
|
|
<select id="findBySceneDeviceId" resultType="com.huaxu.dto.DeviceParmInfoDto">
|
|
|
select a.id as "deviceId",b.id as "attributeId",b.`NAME` as "attributeName"
|
|
@@ -254,7 +255,9 @@
|
|
|
</foreach>
|
|
|
</select>
|
|
|
<select id="findAlarmCount" resultType="com.huaxu.dto.ParmTypeCountDto">
|
|
|
- select b.PARM_TYPE as "parmType",count(a.DEVICE_ID) as "totalCount",count(c.id) as "nbnormalCount"
|
|
|
+ select tab.parmType,sum(tab.nbnormalCount) as "nbnormalCount" from(
|
|
|
+ select b.PARENT_SCENE_ID,b.PARM_TYPE as "parmType",
|
|
|
+ case when count(c.id)>0 then 1 else 0 end as "nbnormalCount"
|
|
|
from sms_device_scene a
|
|
|
INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID
|
|
|
and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,8,9,11,18,19) and b.`STATUS`=1
|
|
@@ -266,14 +269,16 @@
|
|
|
</foreach>
|
|
|
and
|
|
|
a.`STATUS`=1
|
|
|
- group by b.PARM_TYPE
|
|
|
+ group by b.PARENT_SCENE_ID,b.PARM_TYPE )
|
|
|
+ as tab
|
|
|
+ GROUP BY tab.parmType
|
|
|
</select>
|
|
|
<select id="findAlarmTotalCount" resultType="com.huaxu.dto.ParmTypeCountDto">
|
|
|
select count(1) as "totalCount" ,sum(tab.nbnormalCount) as "nbnormalCount" from(
|
|
|
- select a.PARENT_SCENE_ID,a.DEVICE_ID as "deviceId",case when count(c.id)>0 then 1 else 0 end as "nbnormalCount"
|
|
|
+ select a.PARENT_SCENE_ID,case when count(c.id)>0 then 1 else 0 end as "nbnormalCount"
|
|
|
from sms_device_scene a
|
|
|
INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID
|
|
|
- and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,8,9,11,18,19) and b.`STATUS`=1
|
|
|
+ and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.`STATUS`=1
|
|
|
LEFT JOIN sms_alarm_details c on c.PARENT_SCENE_ID=b.PARENT_SCENE_ID
|
|
|
and c.ATTRIBUTE_ID=b.ATTRIBUTE_ID and c.STATE=1
|
|
|
where a.PARENT_SCENE_ID in
|
|
@@ -282,7 +287,24 @@
|
|
|
</foreach>
|
|
|
and
|
|
|
a.`STATUS`=1
|
|
|
- group by a.PARENT_SCENE_ID,a.DEVICE_ID
|
|
|
+ group by a.PARENT_SCENE_ID
|
|
|
+ ) as tab
|
|
|
+ </select>
|
|
|
+ <select id="findAlarmCountTotalCount" resultType="com.huaxu.dto.ParmTypeCountDto">
|
|
|
+ select count(1) as "totalCount" ,sum(tab.nbnormalCount) as "nbnormalCount" from(
|
|
|
+ select a.PARENT_SCENE_ID,case when count(c.id)>0 then 1 else 0 end as "nbnormalCount"
|
|
|
+ from sms_device_scene a
|
|
|
+ INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.PARM_TYPE in (15,8,9,11,18,19)
|
|
|
+ and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.`STATUS`=1
|
|
|
+ LEFT JOIN sms_alarm_details c on c.PARENT_SCENE_ID=b.PARENT_SCENE_ID
|
|
|
+ and c.ATTRIBUTE_ID=b.ATTRIBUTE_ID and c.STATE=1
|
|
|
+ where a.PARENT_SCENE_ID in
|
|
|
+ <foreach collection="info.sceneEntities" item="dramaId" open="(" close=")" separator=",">
|
|
|
+ #{dramaId.id}
|
|
|
+ </foreach>
|
|
|
+ and
|
|
|
+ a.`STATUS`=1
|
|
|
+ group by a.PARENT_SCENE_ID
|
|
|
) as tab
|
|
|
</select>
|
|
|
</mapper>
|