| | |
| | | <resultMap id="BaseResultMap" type="com.moral.entity.Sensor" > |
| | | <id column="id" property="id" jdbcType="INTEGER" /> |
| | | <result column="name" property="name" jdbcType="VARCHAR" /> |
| | | <result column="key" property="key" 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, key, upper, lower, unit, description |
| | | 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="getSensorsByDeviceVersionId" resultType="java.util.Map"> |
| | | SELECT |
| | | s.* |
| | | FROM |
| | | device_version_sensor dvs, |
| | | sensor s |
| | | WHERE |
| | | dvs.sensor_id = s.id |
| | | 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> |
| | | </select> |
| | | |
| | | </mapper> |