|
@@ -41,7 +41,7 @@
|
|
|
<sql id="sceneDeviceJoins">
|
|
|
inner join sms_scene t2 on find_in_set(t1.id, t2.parent_scene_ids) and t2. status = 1
|
|
|
inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
|
|
|
- left join sms_device t4 on t4.scene_id=t2.id
|
|
|
+ left join sms_device t4 on t4.scene_id=t2.id and t4. status = 1 and t4.enable_state=1
|
|
|
</sql>
|
|
|
<sql id="attributeJoins">
|
|
|
select a1.device_id,a1.attribute_id,a1.remark,a1.seq,a2.name,a2.unit,a2.attribute_type
|
|
@@ -58,7 +58,7 @@
|
|
|
from sms_device a1
|
|
|
inner join sms_alarm_details a2 on a1.id=a2.device_id and a2.`status` = 1 and a2.state = 1
|
|
|
inner join sms_scene a3 on a3.id=a1.scene_id and a3.`status` = 1
|
|
|
- where a1.`status` = 1 group by one_scene_id
|
|
|
+ where a1.`status` = 1 and a1.enable_state=1 group by one_scene_id
|
|
|
)t7 on t7.one_scene_id=t1.id
|
|
|
</sql>
|
|
|
|
|
@@ -71,13 +71,16 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
<include refid="alarmDetailsJoins"/>
|
|
|
- where t1.parent_scene_id = 0 and t1. status = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
|
|
|
+ where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
|
|
|
<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="sceneName != null and sceneName != ''">
|
|
|
and t1.scene_name like concat('%',#{sceneName},'%')
|
|
|
</if>
|
|
@@ -94,13 +97,16 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
<include refid="alarmDetailsJoins"/>
|
|
|
- where t1.parent_scene_id = 0 and t1. status = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
|
|
|
+ where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
|
|
|
<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="sceneName != null and sceneName != ''">
|
|
|
and t1.scene_name like concat('%',#{sceneName},'%')
|
|
|
</if>
|
|
@@ -121,13 +127,16 @@
|
|
|
<include refid="attributeJoins"/> and a1.is_suspension = 1
|
|
|
)t5 on t5.device_id=t4.id
|
|
|
left join sms_alarm_details t6 on t6.device_id=t4.id and t6. status = 1 and t6.attribute_id = t5.attribute_id and t6.state = 1
|
|
|
- where t1.parent_scene_id = 0 and t1. status = 1 and t3.scene_type_name = #{sceneTypeName}
|
|
|
+ where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName}
|
|
|
<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="tenantId != null and tenantId != ''">
|
|
|
and t1.tenant_id = #{tenantId}
|
|
|
</if>
|
|
@@ -158,13 +167,16 @@
|
|
|
select t1.id scene_id,t1.scene_name,t1.address
|
|
|
from sms_scene t1
|
|
|
inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
|
|
|
- where t1.parent_scene_id = 0 and t1. status = 1 and t3.scene_type_name = #{onlineDataDto.sceneTypeName}
|
|
|
+ where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{onlineDataDto.sceneTypeName}
|
|
|
<if test="onlineDataDto.sceneIds != null and onlineDataDto.sceneIds.size() > 0">
|
|
|
and t1.id in
|
|
|
<foreach collection="onlineDataDto.sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="onlineDataDto.sceneIds == null or onlineDataDto.sceneIds.size() == 0">
|
|
|
+ and t1.id is null
|
|
|
+ </if>
|
|
|
<if test="onlineDataDto.sceneName != null and onlineDataDto.sceneName != ''">
|
|
|
and t1.scene_name like concat('%',#{onlineDataDto.sceneName},'%')
|
|
|
</if>
|
|
@@ -183,7 +195,7 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
<include refid="alarmDetailsJoins"/>
|
|
|
- where t1.parent_scene_id = 0 and t1. status = 1 and t1.id = #{id}
|
|
|
+ where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t1.id = #{id}
|
|
|
<if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
and t1.id in
|
|
|
<foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
|