lizijie
2021-11-11 40f616cb7b272efa6693585303cc98802827e8e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?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.moral.api.mapper.AlarmInfoMapper">
 
        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.moral.api.entity.AlarmInfo">
                    <id column="id" property="id" />
                    <result column="alarm_time" property="alarmTime" />
                    <result column="index" property="index" />
                    <result column="device_id" property="deviceId" />
                    <result column="alarm_type" property="alarmType" />
                    <result column="alarm_information" property="alarmInformation" />
                    <result column="create_time" property="createTime" />
        </resultMap>
 
    <select id="selectDataByCondition" resultType="java.util.Map">
        select ai.id alarmInfoId,ai.index,ai.alarm_type,ai.alarm_information,d.id deviceId,d.name deviceName,d.longitude,d.latitude
        from alarm_info ai, device d
        where ai.device_id in
        <foreach collection="deviceIds" item="deviceId" index="index" open="(" close=")" separator=",">
            #{deviceId}
        </foreach>
        and d.id = ai.device_id
        <if test="index != null">
            and ai.index = #{index}
        </if>
        <if test="alarmType != null">
            and ai.alarm_type = #{alarmType}
        </if>
        and alarm_time between #{startTime} and #{endTime}
        ORDER by ai.create_time DESC
        limit #{start},#{size}
    </select>
</mapper>