<?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.casic.dao.AlarmDeviceMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.casic.entity.Device"> <id column="DBID" property="id"/> <result column="DEVCODE" property="devCode"/> <result column="DEVNAME" property="devName"/> <result column="FACTORY" property="factory"/> <result column="SIMID" property="simid"/> <result column="PLACE" property="place"/> <result column="LATITUDE" property="latitude"/> <result column="LONGTITUDE" property="longtitude"/> </resultMap> <select id="listPage" resultType="com.casic.entity.Device"> select a0.DEVCODE AS devCode, a0.factory AS factory, a0.devname AS devName, t0.recordcode as status, a0.LATITUDE AS latitude, a0.LONGTITUDE as longtitude, a0.SIMID AS simid,a0.PLACE as place from (select a.device_code, a.recordcode from alarm_alarm_record a where a.dbid in (select max(t.dbid) from alarm_alarm_record t where t.active = 1 group by t.device_code)) t0 right join alarm_device a0 on t0.device_code = a0.devcode where a0.active = 1 and a0.DEVICETYPE_ID =30 <if test="factory != null and factory !='' "> and a0.factory like CONCAT(CONCAT('%',#{factory}),'%') </if> <if test="phone != null and phone !='' "> and a0.SIMID like CONCAT(CONCAT('%',#{phone}),'%') </if> <if test="devCode != null and devCode !='' "> and a0.DEVCODE =#{devCode} </if> <if test="type != null and type !='' "> <choose> <when test="type != 2"> and t0.recordcode = #{type} </when> <otherwise> AND t0.recordcode is null </otherwise> </choose> </if> </select> </mapper>