|
|
@@ -7,65 +7,51 @@
|
|
|
<when test=" request.deviceTypeList!= null and request.deviceTypeList.size() > 0 ">
|
|
|
<choose>
|
|
|
<when test=" request.inputTypeList!= null and request.inputTypeList.size() > 0">
|
|
|
- ( select s.id,ds.id as deviceStatusId, s.org_id, s.org_name,s.org_path, s.device_name, s.device_type, ds.info as info,s.device_code, ds.state_update_time as updateTime,ds.state
|
|
|
+ select c.* from
|
|
|
+ ( select s.id,ds.id as device_status_id, s.org_id, s.org_name,s.org_path, s.device_name,
|
|
|
+ s.device_type, ds.info as info,s.device_code, ds.state_update_time as update_time,ds.state
|
|
|
from iot_device_info s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
- <if test="request.orgId!= null">
|
|
|
- and s.org_id=#{request.orgId}
|
|
|
- </if>
|
|
|
- <if test="request.orgPath!= null">
|
|
|
- and s.org_path like CONCAT(#{request.orgPath}, '%')
|
|
|
- </if>
|
|
|
- <if test="request.deviceName != null and request.deviceName!= ''">
|
|
|
- and s.device_name like CONCAT('%',#{request.deviceName},'%')
|
|
|
- </if>
|
|
|
- <if test="request.state!= null">
|
|
|
- and ds.state = #{request.state}
|
|
|
- </if>
|
|
|
- <if test="request.startTime!= null">
|
|
|
- and ds.state_update_time >=#{request.startTime}
|
|
|
- </if>
|
|
|
- <if test="request.endTime!= null">
|
|
|
- and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
- </if>
|
|
|
- and s.device_type in
|
|
|
+ where s.deleted=0 and s.device_type in
|
|
|
<foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- order by state_update_time desc )
|
|
|
union all
|
|
|
- ( select s.id,ds.id as deviceStatusId, s.org_id, s.org_name,s.org_path, concat(s.defence_area_name,'(报警主机)') as device_name,
|
|
|
- s.sensor_type as device_type, ds.info as info,s.alarm_host_code as device_code, ds.state_update_time as updateTime,ds.state
|
|
|
+ select s.id,ds.id as device_status_id, s.org_id, s.org_name,s.org_path, s.defence_area_name as device_name,
|
|
|
+ s.sensor_type as device_type, ds.info as info,s.alarm_host_code as device_code,ds.state_update_time as update_time,ds.state
|
|
|
from iot_alarm_defence_area s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
+ where s.deleted=0 and s.sensor_type in
|
|
|
+ <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator=","
|
|
|
+ close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>) c where 1=1
|
|
|
<if test="request.orgId!= null">
|
|
|
- and s.org_id=#{request.orgId}
|
|
|
+ and c.org_id=#{request.orgId}
|
|
|
</if>
|
|
|
<if test="request.orgPath!= null">
|
|
|
- and s.org_path like CONCAT(#{request.orgPath}, '%')
|
|
|
+ and c.org_path like CONCAT(#{request.orgPath}, '%')
|
|
|
</if>
|
|
|
<if test="request.deviceName != null and request.deviceName!= ''">
|
|
|
- and s.defence_area_name like CONCAT('%',#{request.deviceName},'%')
|
|
|
+ and c.device_name like CONCAT('%',#{request.deviceName},'%')
|
|
|
</if>
|
|
|
<if test="request.state!= null">
|
|
|
- and ds.state = #{request.state}
|
|
|
+ and c.state = #{request.state}
|
|
|
</if>
|
|
|
<if test="request.startTime!= null">
|
|
|
- and ds.state_update_time >=#{request.startTime}
|
|
|
+ and c.update_time >=#{request.startTime}
|
|
|
</if>
|
|
|
<if test="request.endTime!= null">
|
|
|
- and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
+ and c.update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
</if>
|
|
|
- and s.sensor_type in
|
|
|
- <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- order by ds.state_update_time desc )
|
|
|
+ order by c.update_time desc
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- ( select s.id,ds.id as deviceStatusId, s.org_id, s.org_name,s.org_path, s.device_name, s.device_type, ds.info as info,s.device_code, ds.state_update_time as updateTime,ds.state
|
|
|
+ select s.id,ds.id as device_status_id, s.org_id, s.org_name,s.org_path, s.device_name,
|
|
|
+ s.device_type, ds.info as info,s.device_code, ds.state_update_time as update_time,ds.state
|
|
|
from iot_device_info s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
+ where s.deleted=0 and s.device_type in
|
|
|
+ <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
<if test="request.orgId!= null">
|
|
|
and s.org_id=#{request.orgId}
|
|
|
</if>
|
|
|
@@ -84,20 +70,19 @@
|
|
|
<if test="request.endTime!= null">
|
|
|
and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
</if>
|
|
|
- and s.device_type in
|
|
|
- <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- order by state_update_time desc )
|
|
|
+ order by ds.state_update_time desc
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- ( select s.id,ds.id as deviceStatusId, s.org_id, s.org_name,s.org_path, concat(s.defence_area_name,'(报警主机)') as device_name,
|
|
|
- s.sensor_type as device_type, ds.info as info,s.alarm_host_code as device_code, ds.state_update_time as updateTime,ds.state
|
|
|
+ select s.id,ds.id as device_status_id, s.org_id, s.org_name,s.org_path, s.defence_area_name as device_name,
|
|
|
+ s.sensor_type as device_type, ds.info as info,s.alarm_host_code as device_code, ds.state_update_time as update_time,ds.state
|
|
|
from iot_alarm_defence_area s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
+ where s.deleted=0 and s.sensor_type in
|
|
|
+ <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
<if test="request.orgId!= null">
|
|
|
and s.org_id=#{request.orgId}
|
|
|
</if>
|
|
|
@@ -116,11 +101,7 @@
|
|
|
<if test="request.endTime!= null">
|
|
|
and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
</if>
|
|
|
- and s.sensor_type in
|
|
|
- <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- order by ds.state_update_time desc )
|
|
|
+ order by ds.state_update_time desc
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
|
|
|
@@ -233,65 +214,47 @@
|
|
|
<when test=" request.deviceTypeList!= null and request.deviceTypeList.size() > 0 ">
|
|
|
<choose>
|
|
|
<when test=" request.inputTypeList!= null and request.inputTypeList.size() > 0">
|
|
|
- ( select s.org_name,s.device_name, s.device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
+ select c.* from
|
|
|
+ ( select s.org_id,s.org_path,s.org_name,s.device_name, s.device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
from iot_device_info s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
- <if test="request.orgId!= null">
|
|
|
- and s.org_id=#{request.orgId}
|
|
|
- </if>
|
|
|
- <if test="request.orgPath!= null">
|
|
|
- and s.org_path like CONCAT(#{request.orgPath}, '%')
|
|
|
- </if>
|
|
|
- <if test="request.deviceName != null and request.deviceName!= ''">
|
|
|
- and s.device_name like CONCAT('%',#{request.deviceName},'%')
|
|
|
- </if>
|
|
|
- <if test="request.state!= null">
|
|
|
- and ds.state = #{request.state}
|
|
|
- </if>
|
|
|
- <if test="request.startTime!= null">
|
|
|
- and ds.state_update_time >=#{request.startTime}
|
|
|
- </if>
|
|
|
- <if test="request.endTime!= null">
|
|
|
- and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
- </if>
|
|
|
- and s.device_type in
|
|
|
+ where s.deleted=0 and s.device_type in
|
|
|
<foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- order by state_update_time desc )
|
|
|
union all
|
|
|
- ( select s.org_name,s.defence_area_name as device_name,
|
|
|
- s.sensor_type as device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
+ select s.org_id,s.org_path,s.org_name,s.defence_area_name as device_name,s.sensor_type as device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
from iot_alarm_defence_area s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
+ where s.deleted=0 and s.sensor_type in
|
|
|
+ <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach> ) c where 1=1
|
|
|
<if test="request.orgId!= null">
|
|
|
- and s.org_id=#{request.orgId}
|
|
|
+ and c.org_id=#{request.orgId}
|
|
|
</if>
|
|
|
<if test="request.orgPath!= null">
|
|
|
- and s.org_path like CONCAT(#{request.orgPath}, '%')
|
|
|
+ and c.org_path like CONCAT(#{request.orgPath}, '%')
|
|
|
</if>
|
|
|
<if test="request.deviceName != null and request.deviceName!= ''">
|
|
|
- and s.defence_area_name like CONCAT('%',#{request.deviceName},'%')
|
|
|
+ and c.device_name like CONCAT('%',#{request.deviceName},'%')
|
|
|
</if>
|
|
|
<if test="request.state!= null">
|
|
|
- and ds.state = #{request.state}
|
|
|
+ and c.state = #{request.state}
|
|
|
</if>
|
|
|
<if test="request.startTime!= null">
|
|
|
- and ds.state_update_time >=#{request.startTime}
|
|
|
+ and c.update_time >=#{request.startTime}
|
|
|
</if>
|
|
|
<if test="request.endTime!= null">
|
|
|
- and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
+ and c.update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
</if>
|
|
|
- and s.sensor_type in
|
|
|
- <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- order by ds.state_update_time desc )
|
|
|
+ order by c.update_time desc
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- ( select s.org_name,s.device_name, s.device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
+ select s.org_name,s.device_name, s.device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
from iot_device_info s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
+ where s.deleted=0 and s.device_type in
|
|
|
+ <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
<if test="request.orgId!= null">
|
|
|
and s.org_id=#{request.orgId}
|
|
|
</if>
|
|
|
@@ -310,19 +273,18 @@
|
|
|
<if test="request.endTime!= null">
|
|
|
and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
</if>
|
|
|
- and s.device_type in
|
|
|
- <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- order by state_update_time desc )
|
|
|
+ order by ds.state_update_time desc
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- ( select s.org_name,s.defence_area_name as device_name,
|
|
|
+ select s.org_name,s.defence_area_name as device_name,
|
|
|
s.sensor_type as device_type, ds.info as info,ds.state_update_time as update_time,ds.state
|
|
|
from iot_alarm_defence_area s left join iot_device_status ds on s.id=ds.device_id
|
|
|
- where s.deleted=0
|
|
|
+ where s.deleted=0 and s.sensor_type in
|
|
|
+ <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
<if test="request.orgId!= null">
|
|
|
and s.org_id=#{request.orgId}
|
|
|
</if>
|
|
|
@@ -341,11 +303,7 @@
|
|
|
<if test="request.endTime!= null">
|
|
|
and ds.state_update_time <![CDATA[<=]]> #{request.endTime}
|
|
|
</if>
|
|
|
- and s.sensor_type in
|
|
|
- <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- order by ds.state_update_time desc )
|
|
|
+ order by ds.state_update_time desc
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</select>
|