Ver código fonte

物联设备信息模块,导出优化

humingshi-7@163.com 1 ano atrás
pai
commit
8bcfe161de

+ 3 - 3
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/iot/BaseDeviceTypeEnum.java

@@ -23,13 +23,13 @@ public enum BaseDeviceTypeEnum {
     FSU_TemperatureAndHumidity("8", "温湿度传感器"),
     FSU_DoorMagnetic("9", "门磁传感器"),
     FSU_Gas("10", "燃气传感器"),
-    FSU_RollingShutterDoor("11", "卷帘门传感器"),
+    //FSU_RollingShutterDoor("11", "卷帘门传感器"),
     FSU_Water("12", "水浸传感器"),
-    FSU_SmartMeter("13", "智能电表"),
+    //FSU_SmartMeter("13", "智能电表"),
     FSU_AirConditioner("14", "空调"),
     FSU_Ups("15", "UPS"),
     FSU_DoPowerControl("16", "DO8小时控电"),
-    FSU_ThreePhaseACVoltage("17", "三相电电压传感器"),
+    //FSU_ThreePhaseACVoltage("17", "三相电电压传感器"),
     FSU_Theft("18", "防盗传感器"),
     subsystem("19", "报警控制器"),
     sensor("20", "报警防区"),

+ 46 - 20
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotCommonSensorServiceImpl.java

@@ -285,30 +285,56 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
             }
         }else{
             List<String> inputList = Lists.newArrayList();
+            if(dataType == null){//1.设置deviceTypeList和inputTypeList
+                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;
+                    }
 
-            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);
+            }else if(dataType == 1){//2.设置inputTypeList
+                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);
+                    if (StringUtils.isNotEmpty(typeCode)) {
+                        inputList.add(typeCode);
+                    }
                 }
-            }
-            request.setInputTypeList(inputList);
+                request.setInputTypeList(inputList);
+                request.setDeviceTypeList(null);
+            }//3.设置deviceTypeList
         }
     }
 

+ 59 - 101
soc-modules/soc-modules-iot/src/main/resources/mapper/IotSensorMapper.xml

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