<?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.elephant.framework.galaxy.aroad.module.traffic.mapper.TrafficSpotMapper">

	<resultMap id="trafficSpotMap" type="com.elephant.framework.galaxy.aroad.module.traffic.entity.TrafficSpot">
		<id property="rowId" column="id"/>
		<result property="spotCode" column="gczbh"/>
		<result property="spotName" column="gczmc"/>
		<result property="roadCode" column="lxbh"/>
		<result property="roadName" column="lxmc"/>
		<result property="xzqh" column="xzqh"/>
		<result property="spotType" column="gczlx"/>
		<result property="spotm" column="gczzh"/>
		<result property="startm" column="qdzh"/>
		<result property="endm" column="zdzh"/>
		<result property="length" column="gclc"/>
		<result property="startName" column="qdmc"/>
		<result property="endName" column="zdmc"/>
		<result property="techLevel" column="jsdj"/>
		<result property="carRows" column="xcds"/>
		<result property="faceType" column="mclx"/>
		<result property="width" column="lmkd"/>
		<result property="speed" column="sjss"/>
		<result property="landscape" column="dx"/>
		<result property="stopMonth" column="tcyf"/>
		<result property="year" column="nian"/>
		<result property="longitude" column="jd"/>
		<result property="latitude" column="wd"/>
	</resultMap>

	<resultMap id="CoordinateDtoMap"
	           type="com.elephant.framework.galaxy.aroad.module.traffic.dto.CoordinateDto">
		<id property="rowId" column="id"/>
		<result property="longitude" column="jd"/>
		<result property="latitude" column="wd"/>
	</resultMap>

	<select id="getTrafficSpotPage" resultMap="trafficSpotMap">
		select * from t_szgl_gsd_gcz
		<where>
			<if test="trafficSpot.roadName != null">
				lxmc like CONCAT('%',#{trafficSpot.roadName},'%')
				or
				lxbh like CONCAT('%',#{trafficSpot.roadName},'%')
				and
			</if>
			LENGTH(lxbh)=4
		</where>
	</select>

	<select id="getCoordinates" resultMap="CoordinateDtoMap">
		select id, jd, wd
		from t_szgl_gsd_gcz
		where LENGTH(lxbh)=4;
	</select>

	<select id="getById" resultMap="trafficSpotMap">
		select *
		from t_szgl_gsd_gcz
		where id=#{rowId} and LENGTH(lxbh)=4;
	</select>
</mapper>
