| <?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.mapper.DeviceVersionMapper"> | 
|   <resultMap id="BaseResultMap" type="com.moral.entity.DeviceVersion"> | 
|     <id column="id" jdbcType="INTEGER" property="id" /> | 
|     <result column="name" jdbcType="VARCHAR" property="name" /> | 
|     <result column="version" jdbcType="INTEGER" property="version" /> | 
|     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | 
|     <result column="description" jdbcType="VARCHAR" property="description" /> | 
|   </resultMap> | 
|   <select id="selectListByOrgId" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | 
|           SELECT | 
|               * | 
|           FROM | 
|               device_version dvn | 
|           WHERE | 
|               dvn.id IN ( | 
|           SELECT DISTINCT | 
|               dev.device_version_id | 
|           FROM | 
|               device dev | 
|           WHERE | 
|               dev.monitor_point_id IN | 
|                 ( | 
|                    SELECT id FROM monitor_point mpt | 
|                    WHERE mpt.organization_id = #{orgId,jdbcType=INTEGER} | 
|                         or EXISTS ( | 
|                         SELECT * from dictionary_data where dict_data_key = 'auth_config_super_org' and dict_data_value = #{orgId,jdbcType=INTEGER} | 
|                         ) | 
|   | 
|                 ) | 
|               ) | 
|           order by dvn.create_time desc | 
|   </select> | 
|     <select id="selectListByMpointId" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | 
|         SELECT | 
|         * | 
|         FROM | 
|         device_version dvn | 
|         WHERE | 
|         dvn.id IN ( | 
|         SELECT DISTINCT | 
|         dev.device_version_id | 
|         FROM | 
|         device dev | 
|         WHERE | 
|         dev.monitor_point_id = #{mpointId,jdbcType=VARCHAR} | 
|         ) | 
|         order by dvn.create_time desc | 
|     </select> | 
| </mapper> |