|  | @@ -3,64 +3,127 @@
 | 
	
		
			
				|  |  |  <mapper namespace="com.xunmei.iot.mapper.IotCommonSensorMapper">
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.SensorPageVo">
 | 
	
		
			
				|  |  | -        ( 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
 | 
	
		
			
				|  |  | -        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>
 | 
	
		
			
				|  |  | -        <if test="request.deviceTypeList!= null and request.deviceTypeList.size() > 0">
 | 
	
		
			
				|  |  | -            and s.device_type in
 | 
	
		
			
				|  |  | -            <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | -                #{item}
 | 
	
		
			
				|  |  | -            </foreach>
 | 
	
		
			
				|  |  | -        </if>
 | 
	
		
			
				|  |  | -        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
 | 
	
		
			
				|  |  | -        from iot_alarm_defence_area 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.defence_area_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>
 | 
	
		
			
				|  |  | -        <if test="request.inputTypeList!= null and request.inputTypeList.size() > 0">
 | 
	
		
			
				|  |  | -            and s.sensor_type in
 | 
	
		
			
				|  |  | -            <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | -                #{item}
 | 
	
		
			
				|  |  | -            </foreach>
 | 
	
		
			
				|  |  | -        </if>
 | 
	
		
			
				|  |  | -        order by ds.state_update_time desc )
 | 
	
		
			
				|  |  | +        <choose>
 | 
	
		
			
				|  |  | +            <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
 | 
	
		
			
				|  |  | +                        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
 | 
	
		
			
				|  |  | +                        <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
 | 
	
		
			
				|  |  | +                        from iot_alarm_defence_area 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.defence_area_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.sensor_type in
 | 
	
		
			
				|  |  | +                        <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                            #{item}
 | 
	
		
			
				|  |  | +                        </foreach>
 | 
	
		
			
				|  |  | +                        order by ds.state_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
 | 
	
		
			
				|  |  | +                        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
 | 
	
		
			
				|  |  | +                        <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                            #{item}
 | 
	
		
			
				|  |  | +                        </foreach>
 | 
	
		
			
				|  |  | +                        order by 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
 | 
	
		
			
				|  |  | +                from iot_alarm_defence_area 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.defence_area_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.sensor_type in
 | 
	
		
			
				|  |  | +                <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +                order by ds.state_update_time desc )
 | 
	
		
			
				|  |  | +            </otherwise>
 | 
	
		
			
				|  |  | +        </choose>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <select id="selectAppPageData" resultType="com.xunmei.iot.vo.sensor.SensorAppPageVo">
 | 
	
		
			
				|  |  |          select s.id, s.org_id, s.org_name, s.device_name, ds.device_type, ds.info as info, ds.state_update_time,ds.state
 | 
	
	
		
			
				|  | @@ -166,30 +229,125 @@
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="selectListData" resultType="com.xunmei.iot.vo.sensor.SensorExportVo">
 | 
	
		
			
				|  |  | -        select org_name, device_name, device_type, infos as info,update_time,state
 | 
	
		
			
				|  |  | -        from iot_sensor s
 | 
	
		
			
				|  |  | -        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 s.state = #{request.state}
 | 
	
		
			
				|  |  | -        </if>
 | 
	
		
			
				|  |  | -        <if test="request.deviceType!= null">
 | 
	
		
			
				|  |  | -            and s.device_type = #{request.deviceType}
 | 
	
		
			
				|  |  | -        </if>
 | 
	
		
			
				|  |  | -        <if test="request.startTime!= null">
 | 
	
		
			
				|  |  | -            and s.state_update_time >=#{request.startTime}
 | 
	
		
			
				|  |  | -        </if>
 | 
	
		
			
				|  |  | -        <if test="request.endTime!= null">
 | 
	
		
			
				|  |  | -            and s.state_update_time <![CDATA[<=]]>  #{request.endTime}
 | 
	
		
			
				|  |  | -        </if>
 | 
	
		
			
				|  |  | +        <choose>
 | 
	
		
			
				|  |  | +            <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
 | 
	
		
			
				|  |  | +                        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
 | 
	
		
			
				|  |  | +                        <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
 | 
	
		
			
				|  |  | +                        from iot_alarm_defence_area 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.defence_area_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.sensor_type in
 | 
	
		
			
				|  |  | +                        <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                            #{item}
 | 
	
		
			
				|  |  | +                        </foreach>
 | 
	
		
			
				|  |  | +                        order by ds.state_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
 | 
	
		
			
				|  |  | +                        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
 | 
	
		
			
				|  |  | +                        <foreach collection="request.deviceTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                            #{item}
 | 
	
		
			
				|  |  | +                        </foreach>
 | 
	
		
			
				|  |  | +                        order by state_update_time desc )
 | 
	
		
			
				|  |  | +                    </otherwise>
 | 
	
		
			
				|  |  | +                </choose>
 | 
	
		
			
				|  |  | +            </when>
 | 
	
		
			
				|  |  | +            <otherwise>
 | 
	
		
			
				|  |  | +                ( 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
 | 
	
		
			
				|  |  | +                <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.defence_area_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.sensor_type in
 | 
	
		
			
				|  |  | +                <foreach collection="request.inputTypeList" index="index" item="item" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +                order by ds.state_update_time desc )
 | 
	
		
			
				|  |  | +            </otherwise>
 | 
	
		
			
				|  |  | +        </choose>
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="selectListSensor" resultType="com.xunmei.common.core.domain.iot.domain.IotSensor">
 |