<?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.zhjc.mapper.ZhjcGhjhGhxmMapper">

  <resultMap id="ZhjcGhjhGhxmMap" type="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhGhxm">
        <id property="id" column="id"/>
        <result property="xmlx" column="xmlx"/>
        <result property="lxbh" column="lxbh"/>
        <result property="xmmc" column="xmmc"/>
        <result property="city" column="city"/>
        <result property="tzqbh" column="tzqbh"/>
        <result property="jsxz" column="jsxz"/>
        <result property="lc" column="lc"/>
        <result property="ztz" column="ztz"/>
        <result property="ztzZyhstz" column="ztz_zyhstz"/>
        <result property="wnjhtz" column="wnjhtz"/>
        <result property="wnjhtzZyhstz" column="wnjhtz_zyhstz"/>
        <result property="qzdzh" column="qzdzh"/>
        <result property="jsdj" column="jsdj"/>
        <result property="ljkd" column="ljkd"/>
        <result property="lmkd" column="lmkd"/>
        <result property="gjjdzxsj" column="gjjdzxsj"/>
        <result property="jtl" column="jtl"/>
        <result property="pci" column="pci"/>
        <result property="ncyJsdj" column="ncy_jsdj"/>
        <result property="ncyLjkd" column="ncy_ljkd"/>
        <result property="jsnxQsn" column="jsnx_qsn"/>
        <result property="jsnxJcn" column="jsnx_jcn"/>
        <result property="jzqk" column="jzqk"/>
        <result property="bz" column="bz"/>
        <result property="snBstz" column="sn_bstz"/>
        <result property="snZytz" column="sn_zytz"/>
        <result property="bnBstz" column="bn_bstz"/>
        <result property="bnZytz" column="bn_zytz"/>
        <result property="ncljwctz" column="ncljwctz"/>
        <result property="tjsj" column="tjsj"/>
        <result property="ghmc" column="ghmc"/>
        <result property="createTime" column="create_time"/>
  </resultMap>
      
      <select id="getZhjcGhjhTjfxOneDzxAndXgjByYear" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select city,count(*) as number from t_zhjc_xmjc_ghxm
            <where>
                  <if test="lx!=null and lx!=''">
                      xmlx like concat('%',#{lx},'%')
                  </if>
                  <if test="year!=null and year!=''">
                      and tjsj=#{year}
                  </if>
            </where>
            GROUP BY city
      </select>

      <select id="getZhjcGhjhTjfxFourByYear" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select city,sum(ncljwctz) as number from t_zhjc_xmjc_ghxm
            <where>
                  <if test="lx!=null and lx!=''">
                        xmlx like concat('%',#{lx},'%')
                  </if>
                  <if test="year!=null and year!=''">
                        and tjsj=#{year}
                  </if>
            </where>
            GROUP BY city
      </select>

      <select id="getZhjcGhjhTjfxFourQtByYear" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select city,sum(ncljwctz) as number from t_zhjc_xmjc_ghxm
            <where>
                  xmlx not like '%大中修%' and xmlx not like '%新改建%'
                  <if test="year!=null and year!=''">
                        and tjsj=#{year}
                  </if>
            </where>
            GROUP BY city
      </select>

      <select id="getZhjcGhjhTjfxThreeDataByYear" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select
              city,
              (case when sum(bn_zytz) is null then 0 else sum(bn_zytz) end) as number,
              ((case when sum(bn_bstz) is null then 0 else sum(bn_bstz) end)-(case when sum(bn_zytz) is null then 0 else sum(bn_zytz) end)) as numbertwo,
              (case when sum(ztz_zyhstz) is null then 0 else sum(ztz_zyhstz) end) as numberthree,
              ((case when sum(ztz) is null then 0 else sum(ztz) end)-(case when sum(ztz_zyhstz) is null then 0 else sum(ztz_zyhstz) end)) as numberfour
            from t_zhjc_xmjc_ghxm
            <where>
                  <if test="year!=null and year!=''">
                        tjsj=#{year}
                  </if>
            </where>
            GROUP BY city
      </select>
</mapper>
