<?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.zhtj.mapper.ZhtjGljsdjqkMapper">

  <resultMap id="zhtjGljsdjqkMap" type="com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk">
        <id property="id" column="id"/>
        <result property="year" column="year"/>
        <result property="area" column="area"/>
        <result property="type" column="type"/>
        <result property="xzdj" column="xzdj"/>
        <result property="total" column="total"/>
        <result property="totalSmall" column="total_small"/>
        <result property="highRoad" column="high_road"/>
        <result property="firstRoad" column="first_road"/>
        <result property="secondRoad" column="second_road"/>
        <result property="threeRoad" column="three_road"/>
        <result property="fourRoad" column="four_road"/>
        <result property="otherRoad" column="other_road"/>
        <result property="sort" column="sort"/>
        <result property="creator" column="creator"/>
        <result property="createTime" column="create_time"/>
        <result property="updatePerson" column="update_person"/>
        <result property="updateTime" column="update_time"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="remarks" column="remarks"/>
  </resultMap>
      <sql id="maxYear">
        select max(year) maxyear from `t_zhtj_gljsdjqk`
    </sql>
      <select id="selectZhtjGljsdjqk" resultMap="zhtjGljsdjqkMap">
            SELECT * FROM `t_zhtj_gljsdjqk` as tsd where area=#{area} and type in (${type}) and year=#{year}
      </select>

      <select id="newYear" resultType="string">
            <include refid="maxYear"/>
            <if test="type != null and type != ''">
                  where type in (${type})
            </if>
      </select>
      <select id="getZhyhZhzsGlOne" resultType="com.elephant.framework.galaxy.aroad.module.zhyh.entity.ZhyhZhzsKeyValue">
            select type as `key`,total as `value`
            from t_zhtj_gllmqk
            <where>
                  area='合计' and year=#{year} and (type="国道" or type="省道")
            </where>
      </select>


    <select id="selectJsdjForPtgsd" resultMap="zhtjGljsdjqkMap">
        SELECT * FROM t_zhtj_gljsdjqk_ptgsd
        <where>
            <if test="lm.year!=null and lm.year!=''">
                and year=#{lm.year}
            </if>
            <if test="lm.area!=null and lm.area!=''">
                and area=#{lm.area}
            </if>
            <if test="lm.type!=null and lm.type!=''">
                and type=#{lm.type}
            </if>
        </where>
    </select>
</mapper>
