<?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.missiles.mapper.system.SystemRfidMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.casic.missiles.model.system.SystemRfid"> <id column="id" property="id" /> <result column="rfid" property="rfid" /> <result column="create_time" property="createTime" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, rfid, create_time </sql> <sql id="selectCommon"> with r1 as ( SELECT DISTINCT rfid, dept_id AS deptId FROM eqpt_equipment_info where is_del = 0 and rfid is not null ), r2 as ( SELECT DISTINCT rfid, create_user_dept AS deptId FROM eqpt_system_rfid where rfid not in (select rfid from r1) ), r AS ( SELECT DISTINCT rfid, deptId FROM r1 UNION ALL SELECT rfid, deptId FROM r2 ) SELECT r.rfid as rfid, r.deptId as deptId, if(e.id is null,"0","1") as usageStatus, e.equipment_no as equipmentNo, e.equipment_name as equipmentName, e.use_position as usePosition, e.director_name as directorName FROM r left join eqpt_equipment_info e on (r.rfid = e.rfid and e.is_del = 0) </sql> <select id="listScopePage" resultType="com.casic.missiles.dto.system.RfidListDTO"> select * from( <include refid="selectCommon"/> <where> <if test="ew != null"> ${ew.sqlSegment} </if> </where>) A </select> <select id="listScope" resultType="com.casic.missiles.dto.system.RfidListDTO"> select * from( <include refid="selectCommon"/> <where> <if test="ew != null"> ${ew.sqlSegment} </if> </where>) A </select> </mapper>