ソースを参照

物联设备信息模块,添加设备分类查询优化

humingshi-7@163.com 1 年間 前
コミット
c5c0194b12

+ 1 - 1
project_data/sql/0.1.1/soc/soc.sql

@@ -1156,7 +1156,7 @@ BEGIN
 END??
 DELIMITER ;
 CALL schema_change();
-update iot_alarm_system_field set alarm_rule_property = 0 where source_type in (415,500);
+update iot_alarm_system_field set alarm_rule_property = 0 where source_type in (415,4186,41861) or source_type like '5%';
 
 
 

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/sensor/SensorPageDto.java

@@ -38,6 +38,6 @@ public class SensorPageDto extends PageRequest {
     @ApiModelProperty(value = "报警主机传感器设备类型")
     private List<String> inputTypeList;
 
-
+    private Integer dataType;
 
 }

+ 68 - 80
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotCommonSensorServiceImpl.java

@@ -75,84 +75,6 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
     @Override
     public TableDataInfo<SensorPageVo> selectSensorDataPage(SensorPageDto request) {
         dealPageParam(request);
-        if (ObjectUtil.isEmpty(request.getDeviceTypeList())) {
-            List<String> list = Lists.newArrayList(
-                    // BaseDeviceTypeEnum.FSU.getCode(),
-                    BaseDeviceTypeEnum.FSU_Smoke.getCode(),
-                    BaseDeviceTypeEnum.FSU_Infrared.getCode(),
-                    BaseDeviceTypeEnum.FSU_TemperatureAndHumidity.getCode(),
-                    BaseDeviceTypeEnum.FSU_DoorMagnetic.getCode(),
-                    BaseDeviceTypeEnum.FSU_Gas.getCode(),
-                    BaseDeviceTypeEnum.FSU_RollingShutterDoor.getCode(),
-                    BaseDeviceTypeEnum.FSU_Water.getCode(),
-                    BaseDeviceTypeEnum.FSU_SmartMeter.getCode(),
-                    BaseDeviceTypeEnum.FSU_AirConditioner.getCode(),
-                    BaseDeviceTypeEnum.FSU_Ups.getCode(),
-                    BaseDeviceTypeEnum.FSU_DoPowerControl.getCode(),
-                    BaseDeviceTypeEnum.FSU_ThreePhaseACVoltage.getCode(),
-                    BaseDeviceTypeEnum.FSU_Theft.getCode(),
-                    BaseDeviceTypeEnum.FSU_DoPowerCollection.getCode(),
-
-                    BaseDeviceTypeEnum.AlarmHostInput_Other.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Displacement.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Broken.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Shock.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Tamper.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Intrusion.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_IMDualIdentification.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Microwave.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_EmergencyButton.getCode()
-
-            );
-
-            List<String> inputList = Lists.newArrayList(
-                    BaseDeviceTypeEnum.AlarmHostInput_Humidity.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Temperature.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Smoke.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Infrared.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Soaking.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_DoorSensor.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Other.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Displacement.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Broken.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Shock.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Tamper.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Intrusion.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_IMDualIdentification.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_Microwave.getCode(),
-                    BaseDeviceTypeEnum.AlarmHostInput_EmergencyButton.getCode()
-
-            );
-            request.setDeviceTypeList(list);
-            request.setInputTypeList(inputList);
-        }else{
-            List<String> inputList = Lists.newArrayList();
-
-            for(String code:request.getDeviceTypeList()){
-                String typeCode = null;
-                if(code.equals(BaseDeviceTypeEnum.FSU_TemperatureAndHumidity.getCode())){
-                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Humidity.getCode();
-                    inputList.add(typeCode);
-                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Temperature.getCode();
-                }else  if(code.equals(BaseDeviceTypeEnum.FSU_Smoke.getCode())){
-                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Smoke.getCode();
-                }else  if(code.equals(BaseDeviceTypeEnum.FSU_Infrared.getCode())){
-                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Infrared.getCode();
-                }else  if(code.equals(BaseDeviceTypeEnum.FSU_Water.getCode())){
-                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Soaking.getCode();
-                }else  if(code.equals(BaseDeviceTypeEnum.FSU_DoorMagnetic.getCode())){
-                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_DoorSensor.getCode();
-                }else if(!NumberUtil.isNumber(code)){
-                    typeCode = code;
-                }
-
-                if(StringUtils.isNotEmpty(typeCode)){
-                    inputList.add(typeCode);
-                }
-            }
-            request.setInputTypeList(inputList);
-        }
-
         Page<SensorPageVo> page = sensorMapper.selectPageData(request.getPageRequest(), request);
         final List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
 
@@ -210,7 +132,7 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         for (SensorExportVo record : data) {
             final String info = record.getInfo();
             record.setInfo(dealInfoData(info));
-            record.setDeviceType(DictUtils.getDictLabel(DictConstants.SENSOR_DEVICE_TYPE, Integer.parseInt(record.getDeviceType())));
+            record.setDeviceType(BaseDeviceTypeEnum.getDescByCode(record.getDeviceType()));
             record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, record.getState()));
         }
         try {
@@ -333,6 +255,61 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
             request.setStartTime(DateUtil.beginOfDay(request.getDateRange()[0]));
             request.setEndTime(DateUtil.endOfDay(request.getDateRange()[1]));
         }
+
+        Integer dataType = request.getDataType();
+        if (ObjectUtil.isEmpty(request.getDeviceTypeList())) {
+            List<String> list = Lists.newArrayList(
+                    BaseDeviceTypeEnum.FSU_Smoke.getCode(),BaseDeviceTypeEnum.FSU_Infrared.getCode(),
+                    BaseDeviceTypeEnum.FSU_TemperatureAndHumidity.getCode(),BaseDeviceTypeEnum.FSU_DoorMagnetic.getCode(),
+                    BaseDeviceTypeEnum.FSU_Gas.getCode(),BaseDeviceTypeEnum.FSU_Water.getCode(),
+                    BaseDeviceTypeEnum.FSU_AirConditioner.getCode(),BaseDeviceTypeEnum.FSU_Ups.getCode(),
+                    BaseDeviceTypeEnum.FSU_Theft.getCode(),BaseDeviceTypeEnum.FSU_DoPowerCollection.getCode());
+
+            List<String> inputList = Lists.newArrayList(
+                    BaseDeviceTypeEnum.AlarmHostInput_Humidity.getCode(),BaseDeviceTypeEnum.AlarmHostInput_Temperature.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_Smoke.getCode(),BaseDeviceTypeEnum.AlarmHostInput_Infrared.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_Soaking.getCode(),BaseDeviceTypeEnum.AlarmHostInput_DoorSensor.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_Other.getCode(), BaseDeviceTypeEnum.AlarmHostInput_Displacement.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_Broken.getCode(),BaseDeviceTypeEnum.AlarmHostInput_Shock.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_Tamper.getCode(),BaseDeviceTypeEnum.AlarmHostInput_Intrusion.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_IMDualIdentification.getCode(),BaseDeviceTypeEnum.AlarmHostInput_Microwave.getCode(),
+                    BaseDeviceTypeEnum.AlarmHostInput_EmergencyButton.getCode());
+
+            if(dataType == null) {
+                request.setDeviceTypeList(list);
+                request.setInputTypeList(inputList);
+            }else if(dataType == 0){
+                request.setDeviceTypeList(list);
+            }else{
+                request.setInputTypeList(inputList);
+            }
+        }else{
+            List<String> inputList = Lists.newArrayList();
+
+            for(String code:request.getDeviceTypeList()){
+                String typeCode = null;
+                if(code.equals(BaseDeviceTypeEnum.FSU_TemperatureAndHumidity.getCode())){
+                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Humidity.getCode();
+                    inputList.add(typeCode);
+                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Temperature.getCode();
+                }else  if(code.equals(BaseDeviceTypeEnum.FSU_Smoke.getCode())){
+                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Smoke.getCode();
+                }else  if(code.equals(BaseDeviceTypeEnum.FSU_Infrared.getCode())){
+                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Infrared.getCode();
+                }else  if(code.equals(BaseDeviceTypeEnum.FSU_Water.getCode())){
+                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_Soaking.getCode();
+                }else  if(code.equals(BaseDeviceTypeEnum.FSU_DoorMagnetic.getCode())){
+                    typeCode = BaseDeviceTypeEnum.AlarmHostInput_DoorSensor.getCode();
+                }else if(!NumberUtil.isNumber(code)){
+                    typeCode = code;
+                }
+
+                if(StringUtils.isNotEmpty(typeCode)){
+                    inputList.add(typeCode);
+                }
+            }
+            request.setInputTypeList(inputList);
+        }
     }
 
     private String dealInfoData(String info) {
@@ -396,9 +373,19 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         if ("FSU".equals(type)) {
             for (BaseDeviceTypeEnum value : BaseDeviceTypeEnum.values()) {
                 Map<String, String> map = new HashMap<String, String>();
-                if (value.name().contains(type) && !value.name().equals(type)) {
+                if (value.name().contains(type) && !value.name().equals(type)
+                        && !value.getCode().equals(BaseDeviceTypeEnum.FSU_DoPowerControl.getCode())) {
                     map.put("code", value.getCode());
                     map.put("name", value.getDesc());
+                    if(value.getCode().equals(BaseDeviceTypeEnum.FSU_Infrared.getCode())
+                            ||value.getCode().equals(BaseDeviceTypeEnum.FSU_Smoke.getCode())
+                            ||value.getCode().equals(BaseDeviceTypeEnum.FSU_TemperatureAndHumidity.getCode())
+                            ||value.getCode().equals(BaseDeviceTypeEnum.FSU_Water.getCode())
+                            ||value.getCode().equals(BaseDeviceTypeEnum.FSU_DoorMagnetic.getCode())){
+                        map.put("type", "0_1");
+                    }else{
+                        map.put("type", "0");
+                    }
                     list.add(map);
                 }else if(value.getCode().equals(BaseDeviceTypeEnum.AlarmHostInput_Other.getCode())
                         ||value.getCode().equals(BaseDeviceTypeEnum.AlarmHostInput_Displacement.getCode())
@@ -411,6 +398,7 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
                         ||value.getCode().equals(BaseDeviceTypeEnum.AlarmHostInput_EmergencyButton.getCode())){
                     map.put("code", value.getCode());
                     map.put("name", value.getDesc());
+                    map.put("type", "1");
                     list.add(map);
                 }
             }

+ 240 - 82
soc-modules/soc-modules-iot/src/main/resources/mapper/IotSensorMapper.xml

@@ -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">