123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.huaxu.dao.OnlineMonitorMapper">
- <!-- 结果集 -->
- <resultMap type="com.huaxu.dto.MonitorDataCollectDto" id="monitorDataMap">
- <result property="sceneId" column="scene_id" jdbcType="INTEGER"/>
- <result property="sceneName" column="scene_name" jdbcType="VARCHAR"/>
- <result property="pointX" column="point_x" jdbcType="VARCHAR"/>
- <result property="pointY" column="point_y" jdbcType="VARCHAR"/>
- <result property="address" column="address" jdbcType="VARCHAR"/>
- <result property="sceneState" column="scene_state" jdbcType="INTEGER"/>
- <collection property="MonitorDataEntities" ofType="com.huaxu.dto.MonitorDataDto" javaType="list">
- <result property="deviceId" column="device_id" jdbcType="INTEGER"/>
- <result property="attributeId" column="attribute_id" jdbcType="INTEGER"/>
- <result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
- <result property="unit" column="unit" jdbcType="VARCHAR"/>
- <result property="isAlarm" column="is_Alarm" jdbcType="VARCHAR"/>
- <result property="attributeType" column="attribute_type" jdbcType="VARCHAR"/>
- <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
- <result property="latestValue" column="latest_value" jdbcType="VARCHAR"/>
- </collection>
- </resultMap>
- <!-- 设备结果集 -->
- <resultMap type="com.huaxu.dto.MonitorDataCollectDto" id="deviceDataMap">
- <result property="sceneId" column="scene_id" jdbcType="INTEGER"/>
- <result property="sceneName" column="scene_name" jdbcType="VARCHAR"/>
- <result property="deviceId" column="device_id" jdbcType="INTEGER"/>
- <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
- <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
- <result property="pointX" column="point_x" jdbcType="VARCHAR"/>
- <result property="pointY" column="point_y" jdbcType="VARCHAR"/>
- <result property="address" column="address" jdbcType="VARCHAR"/>
- <result property="sceneState" column="scene_state" jdbcType="INTEGER"/>
- <collection property="MonitorDataEntities" ofType="com.huaxu.dto.MonitorDataDto" javaType="list">
- <result property="attributeId" column="attribute_id" jdbcType="INTEGER"/>
- <result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
- <result property="unit" column="unit" jdbcType="VARCHAR"/>
- <result property="isAlarm" column="is_Alarm" jdbcType="VARCHAR"/>
- <result property="attributeType" column="attribute_type" jdbcType="VARCHAR"/>
- <result property="latestValue" column="latest_value" jdbcType="VARCHAR"/>
- </collection>
- </resultMap>
- <!-- 管网图层设备结果集 -->
- <resultMap type="com.huaxu.dto.PipeNetLayerDto" id="layerMap">
- <result property="sceneId" column="scene_id" jdbcType="INTEGER"/>
- <result property="sceneName" column="scene_name" jdbcType="VARCHAR"/>
- <collection property="deviceDataList" ofType="com.huaxu.dto.MonitorDataCollectDto" javaType="list">
- <result property="deviceId" column="device_id" jdbcType="INTEGER"/>
- <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
- <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
- <result property="pointX" column="point_x" jdbcType="VARCHAR"/>
- <result property="pointY" column="point_y" jdbcType="VARCHAR"/>
- <result property="address" column="address" jdbcType="VARCHAR"/>
- <result property="deviceState" column="device_state" jdbcType="INTEGER"/>
- </collection>
- </resultMap>
- <sql id="Base_Column_List">
- t1.id scene_Id,
- t1.scene_name ,
- t1.point_x ,
- t1.point_y,
- t1.address ,
- t5.device_id,
- t5.attribute_id ,
- ifnull(t5.remark, t9.`name`) attribute_name,
- t9.unit ,
- case when t5.attribute_id is null then null when t6.id is null then 0 else 1 end is_alarm,
- t5.parm_type attribute_type,
- if (t5.device_id is null, null, t4.device_code) device_code
- </sql>
- <sql id="sceneDeviceJoins">
- inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
- left join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1
- left join sms_device t4 on t2.device_id=t4.id and t4. status = 1 and t4. enable_state = 1
- left join sms_device_parm t5 on t5.scene_id = t2.scene_id and t5.device_id=t2.device_id and t5. status = 1
- <if test="type == 3 ">
- and t5.is_suspension = 1
- </if>
- <if test="type == 4 ">
- and t5.is_map = 1
- </if>
- left join sms_device_attribute t9 on t5.attribute_id=t9.id and t9.status = 1
- left join sms_alarm_details t6 on t6.scene_id=t2.scene_id and t6.device_id=t2.device_id
- and t6.attribute_id=t5.attribute_id and t6.status = 1 and t6.state=1
- </sql>
- <sql id="sceneAlarmJoins">
- left join (
- select parent_scene_id,count(1) alarm_count
- from sms_alarm_details a1
- where a1.`status` = 1 and a1.state = 1
- <if test="sceneIds != null and sceneIds.size() > 0">
- and a1.scene_id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by parent_scene_id
- )t7 on t7.parent_scene_id=t1.id
- </sql>
- <sql id="deviceInnerJoins">
- inner join sms_scene_type t3 on t1.scene_type_id=t3.id
- inner join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1
- inner join sms_device t6 on t2.device_id=t6.id and t6. status = 1
- inner join sms_scene t4 on t2.scene_id=t4.id
- inner join sms_scene_type t5 on t4.scene_type_id=t5.id and t5. status = 1
- </sql>
- <sql id="deviceLeftJoins">
- inner join sms_scene_type t3 on t1.scene_type_id=t3.id and t3. status = 1
- left join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1
- left join sms_device t6 on t2.device_id=t6.id and t6. status = 1
- left join sms_scene t4 on t2.scene_id=t4.id and t4. status = 1
- left join sms_scene_type t5 on t4.scene_type_id=t5.id and t5. status = 1 and t5.scene_type_name = #{sceneTypeName}
- </sql>
- <!--查询实时报警信息-->
- <select id="selectAlarmDetails" resultType="com.huaxu.dto.AlarmDetailsDto">
- select
- t1.scene_name as "sceneName",
- t6.alarm_content as "alarmContent",
- t6.alarm_start_time as "alarmStartTime"
- from sms_scene t1
- inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
- inner join sms_alarm_details t6 on t1.id=t6.parent_scene_id and t6.`status`=1
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="sceneName != null and sceneName != ''">
- and t1.scene_name like concat('%',#{sceneName},'%')
- </if>
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id = #{tenantId}
- </if>
- order by t6.alarm_start_time desc
- </select>
- <!--查询实时报警数量-->
- <select id="selectAlarmCount" resultType="java.util.Map">
- select
- t1.scene_name as "sceneName",
- count(1) as "alalmCount"
- from sms_scene t1
- inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
- inner join sms_alarm_details t6 on t1.id=t6.parent_scene_id and t6.`status`=1
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="sceneName != null and sceneName != ''">
- and t1.scene_name like concat('%',#{sceneName},'%')
- </if>
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id = #{tenantId}
- </if>
- group by t1.scene_name
- order by alalmCount desc
- </select>
- <!--查询地图悬浮数据-->
- <select id="selectMapSuspension" resultMap="monitorDataMap">
- select
- <include refid="Base_Column_List"/>,if (t7.alarm_count>0, 1, 0) scene_state
- from sms_scene t1
- <include refid="sceneDeviceJoins"/>
- <include refid="sceneAlarmJoins"/>
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName}
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id = #{tenantId}
- </if>
- order by t1.scene_name,t5.seq
- </select>
- <!--查询地图参数数据-->
- <select id="selectMapParam" resultMap="monitorDataMap">
- select
- <include refid="Base_Column_List"/>
- from sms_scene t1
- <include refid="sceneDeviceJoins"/>
- <include refid="sceneAlarmJoins"/>
- where t1.parent_scene_id = 0 and t1. status = 1 and t1.id = #{sceneId}
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- order by t1.scene_name,t5.seq
- </select>
- <!--查询实时数据列表-->
- <select id="selectPage" resultType="com.huaxu.dto.OnlineDataDto">
- select t1.id scene_id,t1.scene_name,t1.address
- from sms_scene t1
- inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{onlineDataDto.sceneTypeName}
- <if test="onlineDataDto.sceneIds != null and onlineDataDto.sceneIds.size() > 0">
- and t1.id in
- <foreach collection="onlineDataDto.sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="onlineDataDto.sceneIds == null or onlineDataDto.sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="onlineDataDto.sceneName != null and onlineDataDto.sceneName != ''">
- and t1.scene_name like concat('%',#{onlineDataDto.sceneName},'%')
- </if>
- <if test="onlineDataDto.tenantId != null and onlineDataDto.tenantId != ''">
- and t1.tenant_id = #{onlineDataDto.tenantId}
- </if>
- order by t1.date_create
- </select>
- <!--查询设备报警分析-->
- <select id="selectAlarmStats" resultType="java.util.Map">
- select
- t4.id,
- t4.device_name as "deviceName",
- count(1) as "alarmCount",
- sum(timestampdiff(minute,t6.alarm_start_time,ifnull(t6.alarm_end_time,now()))) as "alarmDuration"
- from sms_scene t1
- inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
- inner join sms_alarm_details t6 on t1.id=t6.parent_scene_id and t6.`status`=1
- inner join sms_device t4 on t4.id=t6.device_id and t4.`status`=1 and t4. enable_state = 1
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t1.id = #{id}
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="days != null">
- and t6.alarm_start_time>DATE(NOW() + INTERVAL-#{days}+1 DAY)
- </if>
- group by t4.id,t4.device_name
- </select>
- <!--查询场景对应参数数据-->
- <select id="selectSceneParam" resultMap="monitorDataMap">
- select
- <include refid="Base_Column_List"/>,t8.latest_value
- from sms_scene t1
- <include refid="sceneDeviceJoins"/>
- left join (
- select c1.device_id,c1.attribute_id,c1.latest_value
- from sms_day_report c1
- inner join (
- select b1.device_id,b1.attribute_id,max(b1.collect_date) collect_date
- from sms_day_report b1
- where b1.year = year(now() + interval-1 day) and b1.month = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day)
- group by b1.device_id,b1.attribute_id )c2 on c1.device_id=c2.device_id and c1.attribute_id=c2.attribute_id and c1.collect_date=c2.collect_date
- )t8 on t8.device_id=t2.device_id and t8.attribute_id =t5.attribute_id
- where t1.parent_scene_id = 0 and t1. status = 1
- <if test="type == 1 ">
- and t5.parm_type in(3,4,5,6)
- </if>
- <if test="type == 2 ">
- and t5.parm_type in(2,3,4,5,6,7,8,9,10,11,12,13,14)
- </if>
- <if test="sceneTypeName != null and sceneTypeName != '' ">
- and t3.scene_type_name = #{sceneTypeName}
- </if>
- <if test="sceneId != null and sceneId != '' ">
- and t1.id = #{sceneId}
- </if>
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id = #{tenantId}
- </if>
- order by t1.scene_name,t5.seq
- </select>
- <!--按管网名称分类查询设备数量-->
- <select id="selectDeviceCount" resultType="java.util.Map">
- select t1.id sceneId,t1.scene_name sceneName,sum(if(t5.id is null,0,1)) deviceCount
- from sms_scene t1
- <include refid="deviceLeftJoins"/>
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网'
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="sceneId != null">
- and t1.id = #{sceneId}
- </if>
- <if test="deviceName != null and deviceName != ''">
- and t6.device_name like concat('%', #{deviceName},'%')
- </if>
- group by t1.id,t1.scene_name
- </select>
- <!--查询设备地图参数数据-->
- <select id="selectDeviceMapParam" resultMap="deviceDataMap">
- select distinct t1.id device_id,t1.device_code,t1.device_name,t1.point_x,point_y,t1.address,t2.attribute_id, ifnull(t2.remark, t3.`name`) attribute_name,t3.unit,
- case when t2.attribute_id is null then null when t6.id is null then 0 else 1 end is_alarm, if (t4.alarm_count>0, 1, 0) scene_state
- from sms_device t1
- left join sms_device_parm t2 on t2.device_id=t1.id and t2.is_map=1
- left join sms_device_attribute t3 on t2.attribute_id=t3.id
- left join (
- select a1.device_id,count(1) alarm_count from sms_alarm_details a1 where a1.device_id= #{deviceId} and a1.`status` = 1 and a1.state = 1
- )t4 on t4.device_id=t1.id
- left join sms_alarm_details t6 on t6.device_id=t1.id and t6.attribute_id=t2.attribute_id and t6.status = 1 and t6.state=1
- where t1. status = 1 and t1. enable_state = 1 and t1.id= #{deviceId}
- </select>
- <!--统计设备合格数据-->
- <select id="statsDeviceQualified" resultType="com.huaxu.dto.DeviceCountStatsDto">
- select count(1) totalCount,sum(if(t7.device_id is null,0,1)) alarmCount,count(1)-sum(if(t7.device_id is null,0,1)) normalCount
- from sms_scene t1
- <include refid="deviceInnerJoins"/>
- left join(
- select a1.scene_id, a1.device_id from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
- )t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' and t5.scene_type_name = #{sceneTypeName}
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="sceneId != null">
- and t1.id = #{sceneId}
- </if>
- <if test="deviceName != null and deviceName != ''">
- and t6.device_name like concat('%', #{deviceName},'%')
- </if>
- </select>
- <!--统计设备属性合格数据-->
- <select id="statsParmQualified" resultType="com.huaxu.dto.DeviceCountStatsDto">
- select case t7.parm_type when '13' then '压力' when '7' then 'PH' when '9' then '浊度' when '11' then '余氯' end type,
- count(t8.device_id) alarmCount
- from sms_scene t1
- <include refid="deviceInnerJoins"/>
- inner join sms_device_parm t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
- <if test="sceneTypeName == '压力'">
- and t7.parm_type in(13)
- </if>
- <if test="sceneTypeName == '水质'">
- and t7.parm_type in(7,9,11)
- </if>
- inner join sms_alarm_details t8 on t8.attribute_id=t7.attribute_id and t8.device_id=t7.device_id and t8.scene_id=t7.scene_id and t8.`status` = 1 and t8.state = 1
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' and t5.scene_type_name = #{sceneTypeName}
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="sceneId != null">
- and t1.id = #{sceneId}
- </if>
- <if test="deviceName != null and deviceName != ''">
- and t6.device_name like concat('%', #{deviceName},'%')
- </if>
- group by t7.parm_type
- </select>
- <!-- 查询设备参数-->
- <select id="statsDeviceParm" resultMap="deviceDataMap">
- SELECT t6.id device_id,t6.device_code,t6.device_name,t7.attribute_id,t7.parm_type attribute_type,
- case when t7.attribute_id is null then null when t8.id is null then 0 else 1 end is_alarm
- <if test="type == 4 ">,t9.latest_value</if>
- from sms_scene t1
- <include refid="deviceInnerJoins"/>
- left join sms_device_parm t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
- <if test="type == 1 ">
- and t7.parm_type in(13)
- </if>
- <if test="type == 2 ">
- and t7.parm_type in(14,16)
- </if>
- <if test="type == 3">
- and t7.parm_type in(7,9,11,18)
- </if>
- <if test="type == 4 ">
- and t7.parm_type in(16)
- left join (
- select c1.device_id,c1.attribute_id,c1.latest_value
- from sms_day_report c1
- inner join (
- select b1.device_id,b1.attribute_id,max(b1.collect_date) collect_date
- from sms_day_report b1
- where b1.year = year(now() + interval-1 day) and b1.month = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day)
- group by b1.device_id,b1.attribute_id )c2 on c1.device_id=c2.device_id and c1.attribute_id=c2.attribute_id and c1.collect_date=c2.collect_date
- )t9 on t9.device_id=t2.device_id and t9.attribute_id =t7.attribute_id
- </if>
- <if test="type == 5 ">
- and t7.parm_type in(14)
- </if>
- left join sms_alarm_details t8 on t8.attribute_id=t7.attribute_id and t8.device_id=t7.device_id and t8.scene_id=t7.scene_id and t8.`status` = 1 and t8.state = 1
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' and t5.scene_type_name = #{sceneTypeName}
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="sceneId != null">
- and t1.id = #{sceneId}
- </if>
- <if test="deviceIds != null and deviceIds.size() > 0">
- and t6.id in
- <foreach collection="deviceIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deviceName != null and deviceName != ''">
- and t6.device_name like concat('%', #{deviceName},'%')
- </if>
- </select>
- <!--查询管网实时数据列表-->
- <select id="selectPipeNetPage" resultType="com.huaxu.dto.OnlineDataDto">
- select t1.id scene_id,t1.scene_name,t6.id device_id,t6.device_code,t6.device_name,t6.address,if (t7.alarm_count>0, 1, 0) deviceState
- from sms_scene t1
- <include refid="deviceInnerJoins"/>
- left join(
- select a1.scene_id, a1.device_id ,count(1) alarm_count from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
- )t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' and t5.scene_type_name = #{onlineDataDto.sceneTypeName}
- <if test="onlineDataDto.sceneIds != null and onlineDataDto.sceneIds.size() > 0">
- and t1.id in
- <foreach collection="onlineDataDto.sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="onlineDataDto.sceneIds == null or onlineDataDto.sceneIds.size() == 0">
- and t1.id is null
- </if>
- <if test="onlineDataDto.sceneId != null">
- and t1.id = #{onlineDataDto.sceneId}
- </if>
- <if test="onlineDataDto.deviceName != null and onlineDataDto.deviceName != ''">
- and t6.device_name like concat('%', #{onlineDataDto.deviceName},'%')
- </if>
- order by t6.date_create
- </select>
- <!--查询管网地图图层-->
- <select id="selectPipeNetLayer" resultMap="layerMap">
- select t4.id scene_id,t4.scene_name,t6.id device_id,t6.device_code,t6.device_name,t6.point_x,t6.point_y,t6.address,if (t7.alarm_count>0, 1, 0) device_state
- from sms_scene t1
- <include refid="deviceInnerJoins"/>
- left join(
- select a1.scene_id, a1.device_id ,count(1) alarm_count from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
- )t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网'
- and t5.scene_type_name in('压力','流量','水质')
- <if test="sceneIds != null and sceneIds.size() > 0">
- and t1.id in
- <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sceneIds == null or sceneIds.size() == 0">
- and t1.id is null
- </if>
- order by t4.scene_name,t6.date_create
- </select>
- </mapper>
|