| | |
| | | <?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.SensorMapper" > |
| | | <resultMap id="BaseResultMap" type="com.moral.entity.Sensor" > |
| | | <id column="id" property="id" jdbcType="INTEGER" /> |
| | | <result column="name" property="name" jdbcType="VARCHAR" /> |
| | | <result column="sensor_key" property="sensorKey" jdbcType="VARCHAR" /> |
| | | <result column="upper" property="upper" jdbcType="DOUBLE" /> |
| | | <result column="lower" property="lower" jdbcType="DOUBLE" /> |
| | | <result column="unit" property="unit" jdbcType="VARCHAR" /> |
| | | <result column="description" property="description" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List" > |
| | | <mapper namespace="com.moral.mapper.SensorMapper"> |
| | | <resultMap id="BaseResultMap" type="com.moral.entity.Sensor"> |
| | | <id column="id" property="id" jdbcType="INTEGER"/> |
| | | <result column="name" property="name" jdbcType="VARCHAR"/> |
| | | <result column="sensor_key" property="sensorKey" jdbcType="VARCHAR"/> |
| | | <result column="upper" property="upper" jdbcType="DOUBLE"/> |
| | | <result column="lower" property="lower" jdbcType="DOUBLE"/> |
| | | <result column="unit" property="unit" jdbcType="VARCHAR"/> |
| | | <result column="description" property="description" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, name, sensor_key, upper, lower, unit, description |
| | | </sql> |
| | | <select id="selectByVersionId" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from sensor sen |
| | | where EXISTS |
| | | ( select id |
| | | from device_version_sensor dvs |
| | | where sen.id = dvs.sensor_id and dvs.device_version_id = #{deviceVersionId,jdbcType=INTEGER} |
| | | ) |
| | | </select> |
| | | <select id="selectByVersionNo" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from sensor sen |
| | | where EXISTS |
| | | ( select id |
| | | from device_version_sensor dvs |
| | | where sen.id = dvs.sensor_id |
| | | and dvs.device_version_id in |
| | | ( |
| | | select dev.id from device_version dev |
| | | where dev.version = #{deviceVersionNo,jdbcType=INTEGER} |
| | | ) |
| | | ) |
| | | </select> |
| | | <select id="selectByVersionNos" resultMap="BaseResultMap" parameterType="java.util.List" > |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from sensor sen |
| | | where EXISTS |
| | | ( select id |
| | | from device_version_sensor dvs |
| | | where sen.id = dvs.sensor_id |
| | | and dvs.device_version_id in |
| | | ( |
| | | select dev.id from device_version dev |
| | | <where> |
| | | 1 > 1 |
| | | <if test="versionNos!=null and versionNos.size() > 0"> |
| | | or dev.version in |
| | | <foreach collection="versionNos" item="versionNo" open="(" close=")" separator=","> |
| | | #{versionNo,jdbcType=INTEGER} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | ) |
| | | ) |
| | | </select> |
| | | |
| | | <select id="getSensorsByDeviceVersionId" resultType="java.util.Map"> |
| | | <select id="selectByVersionId" resultMap="BaseResultMap" parameterType="java.lang.Integer"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from sensor sen |
| | | where EXISTS |
| | | ( select id |
| | | from device_version_sensor dvs |
| | | where sen.id = dvs.sensor_id and dvs.device_version_id = #{deviceVersionId,jdbcType=INTEGER} |
| | | ) |
| | | </select> |
| | | <select id="selectByVersionNo" resultMap="BaseResultMap" parameterType="java.lang.Integer"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from sensor sen |
| | | where EXISTS |
| | | ( select id |
| | | from device_version_sensor dvs |
| | | where sen.id = dvs.sensor_id |
| | | and dvs.device_version_id in |
| | | ( |
| | | select dev.id from device_version dev |
| | | where dev.version = #{deviceVersionNo,jdbcType=INTEGER} |
| | | ) |
| | | ) |
| | | </select> |
| | | <select id="selectByVersionNos" resultMap="BaseResultMap" parameterType="java.util.List"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from sensor sen |
| | | where EXISTS |
| | | ( select id |
| | | from device_version_sensor dvs |
| | | where sen.id = dvs.sensor_id |
| | | and dvs.device_version_id in |
| | | ( |
| | | select dev.id from device_version dev |
| | | <where> |
| | | 1 > 1 |
| | | <if test="versionNos!=null and versionNos.size() > 0"> |
| | | or dev.version in |
| | | <foreach collection="versionNos" item="versionNo" open="(" close=")" separator=","> |
| | | #{versionNo,jdbcType=INTEGER} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | ) |
| | | ) |
| | | </select> |
| | | |
| | | <select id="getSensorsByDeviceVersionId" resultType="java.util.Map"> |
| | | SELECT |
| | | s.* |
| | | FROM |
| | |
| | | AND dvs.device_version_id = #{deviceVersionId} |
| | | </select> |
| | | |
| | | <select id="getSensorsByCriteria" resultMap="BaseResultMap"> |
| | | SELECT |
| | | DISTINCT s.* |
| | | FROM |
| | | sensor s, |
| | | device_version_sensor dvs, |
| | | device d, |
| | | monitor_point mp |
| | | WHERE |
| | | s.id = dvs.sensor_id |
| | | AND dvs.device_version_id = d.device_version_id |
| | | AND d.monitor_point_id = mp.id |
| | | <if test="provinceCode != null"> |
| | | AND mp.province_code = #{provinceCode} |
| | | </if> |
| | | <if test="cityCode != null"> |
| | | AND mp.city_code = #{cityCode} |
| | | </if> |
| | | <if test="areaCode != null"> |
| | | AND mp.area_code = #{areaCode} |
| | | </if> |
| | | <if test="monitorPointId != null"> |
| | | AND mp.id = #{monitorPointId} |
| | | </if> |
| | | <if test="mac != null"> |
| | | AND d.mac = #{mac} |
| | | </if> |
| | | <if test="professionId != null"> |
| | | AND d.profession_id = #{professionId} |
| | | </if> |
| | | </select> |
| | | <select id="selectByOrgId" resultMap="BaseResultMap"> |
| | | <select id="getSensorsByCriteria" resultMap="BaseResultMap"> |
| | | SELECT |
| | | DISTINCT s.* |
| | | FROM |
| | | sensor s, |
| | | device_version_sensor dvs, |
| | | device d, |
| | | monitor_point mp |
| | | WHERE |
| | | s.id = dvs.sensor_id |
| | | AND dvs.device_version_id = d.device_version_id |
| | | AND d.monitor_point_id = mp.id |
| | | <if test="provinceCode != null"> |
| | | AND mp.province_code = #{provinceCode} |
| | | </if> |
| | | <if test="cityCode != null"> |
| | | AND mp.city_code = #{cityCode} |
| | | </if> |
| | | <if test="areaCode != null"> |
| | | AND mp.area_code = #{areaCode} |
| | | </if> |
| | | <if test="monitorPointId != null"> |
| | | AND mp.id = #{monitorPointId} |
| | | </if> |
| | | <if test="mac != null"> |
| | | AND d.mac = #{mac} |
| | | </if> |
| | | <if test="professionId != null"> |
| | | AND d.profession_id = #{professionId} |
| | | </if> |
| | | </select> |
| | | <select id="selectByOrgId" resultMap="BaseResultMap"> |
| | | select * from sensor sen where sen.id in |
| | | ( |
| | | select DISTINCT sensor_id from device_version_sensor dvs |
| | |
| | | ) |
| | | order by sen.id asc |
| | | </select> |
| | | |
| | | <select id="getSensorBySensorKey" resultType="java.util.Map"> |
| | | |
| | | <select id="getSensorBySensorKey" resultType="java.util.Map"> |
| | | SELECT * |
| | | FROM sensor |
| | | WHERE sensor_key = #{sensor_key} |
| | | </select> |
| | | |
| | | <select id="getSensorByDeviceId" resultType="java.util.Map"> |
| | | |
| | | <select id="getSensorByDeviceId" resultType="java.util.Map"> |
| | | SELECT DISTINCT d.id,d.monitor_point_id,s.* |
| | | FROM device d,device_version dv,device_version_sensor dvs,sensor s |
| | | WHERE d.device_version_id = dvs.device_version_id |
| | | AND dvs.sensor_id = s.id |
| | | AND d.id = #{id} |
| | | </select> |
| | | |
| | | <select id="getSensorByMonitorPointId" resultType="java.util.Map"> |
| | | |
| | | <select id="getSensorByMonitorPointId" resultType="java.util.Map"> |
| | | SELECT DISTINCT s.sensor_key sensorKey,s.unit,s.name,s.description,s.id |
| | | FROM device d,device_version dv,device_version_sensor dvs,sensor s |
| | | WHERE d.device_version_id = dvs.device_version_id |
| | |
| | | s.id = dvs.sensor_id |
| | | AND dvs.device_version_id = d.device_version_id |
| | | <if test="mac != null"> |
| | | AND d.mac = #{mac} |
| | | AND d.mac = #{mac} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getSensorsByMacOnly" resultMap="BaseResultMap"> |
| | | <select id="getSensorsInfoByMac" resultMap="BaseResultMap"> |
| | | SELECT |
| | | DISTINCT s.* |
| | | FROM |
| | |
| | | s.id = dvs.sensor_id |
| | | AND dvs.device_version_id = d.device_version_id |
| | | <if test="mac != null"> |
| | | AND d.mac = #{mac} |
| | | AND d.mac = #{mac} |
| | | </if> |
| | | </select> |
| | | </mapper> |