<?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.ZhjcGhjhMapper">

  <resultMap id="zhjcGhjhMap" type="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjh">
        <id property="id" column="id"/>
        <result property="crowid" column="crowid"/>
        <result property="xmid" column="xmid"/>
        <result property="xmbm" column="xmbm"/>
        <result property="xmmc" column="xmmc"/>
        <result property="tbdwdm" column="tbdwdm"/>
        <result property="tbdwmc" column="tbdwmc"/>
        <result property="xmlxdm" column="xmlxdm"/>
        <result property="xmlx" column="xmlx"/>
        <result property="xmjd" column="xmjd"/>
        <result property="xmjdhy" column="xmjdhy"/>
        <result property="jsxzdm" column="jsxzdm"/>
        <result property="jsxz" column="jsxz"/>
        <result property="jsgm" column="jsgm"/>
        <result property="jsnx" column="jsnx"/>
        <result property="ztz" column="ztz"/>
        <result property="zytz" column="zytz"/>
        <result property="stz" column="stz"/>
        <result property="sfzxzt" column="sfzxzt"/>
        <result property="createtime" column="createtime"/>
  </resultMap>
    <select id="queryLxGhjh" resultType="HashMap">
        SELECT xmbm FROM `t_szgl_ghjh_gcxm` where gcxm_id = #{gcxmId} limit 0,1
      </select>
      <select id="getFourDataWctzMonth" resultType="java.lang.Double">
            select sum(WCTZMonth) from t_zhjc_ghjh_tzzh where xmid=#{xmid}
      </select>

      <select id="getFourDataTbsj" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTzzh">
            select * from t_zhjc_ghjh_tzzh where xmid=#{xmid} ORDER BY tbsj desc
      </select>

      <select id="getTableBnZJData"  resultType="java.lang.Double">
            select sum(YXDTZ) from t_zhjc_ghjh_tzzh where xmid in (select xmid from t_zhjc_ghjh where xmbm in (select xmbm from t_zhjc_ghjh
            where xmid=#{xmid}))
            and xmjd='30'
            and tzly=#{tzly}
            and tznf=#{tznf}
      </select>

      <select id="getTableZsnZJData" resultType="java.lang.Double">
            select sum(YXDTZ) from t_zhjc_ghjh_tzzh where xmid in (select xmid from t_zhjc_ghjh where xmbm in (select xmbm from t_zhjc_ghjh
            where xmid=#{xmid}))
            and xmjd='30'
            and tzly=#{tzly}
            and tznf &lt; #{tznf}
      </select>

      <select id="getGhjhOneData" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select tbdwmc as city,count(*) as number  from t_zhjc_ghjh
            <where>
                  xmjd='10'
                  <if test="xmlxdm!=null and xmlxdm!=''">
                        and  xmlxdm=#{xmlxdm}
                  </if>
                  <if test="jhnf!=null and jhnf!=''">
                        and jhnf=#{jhnf}
                  </if>
            </where>
            GROUP BY tbdwmc
      </select>

      <select id="getGhjhTwoData" resultType="java.lang.Integer">
            select count(*) as number from t_zhjc_ghjh
            <where>
                  sfzxzt='1'
                  <if test="xmlxdm!=null and xmlxdm!=''">
                        and xmlxdm=#{xmlxdm}
                  </if>
                  <if test="xmjd!=null and xmjd!=''">
                        and xmjd=#{xmjd}
                  </if>
                  <if test="year!=null and year!=''">
                        and left(CreateTime,4)=#{year}
                  </if>
            </where>
      </select>

      <select id="getGhjhTwoDatatwo" resultType="java.lang.Integer">
            select count(*) as number from t_zhjc_ghjh
            <where>
                  sfzxzt='1' and xmlxdm='02' and xmjd not in('22','24')
                  <if test="year!=null and year!=''">
                        and left(CreateTime,4)=#{year}
                  </if>
            </where>
      </select>

      <select id="getGhjhThreeData" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select h.tbdwmc as city,sum(h.zytz) as number,sum(h.stz) as numbertwo,(sum(h.ztz)-sum(h.zytz)-sum(h.stz)) as numberthree,sum(t.ZYTZYAP) as numberfour,sum(t.STZYAP) as numberfive from t_zhjc_ghjh h left join t_zhjc_ghjh_tzzh t on h.xmid=t.xmid and h.xmjd=t.xmjd
            <where>
                  h.xmjd='30'
                  <if test="year!=null and year!=''">
                        and tznf=#{year}
                  </if>
            </where>
            GROUP BY h.tbdwmc
      </select>

      <select id="getGhjhFourData" resultType="com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhTjfxDzxAndXgj">
            select h.tbdwmc as city,sum(t.wctzmonth) as number from t_zhjc_ghjh h left join t_zhjc_ghjh_tzzh t on h.xmid=t.xmid and h.xmjd=t.xmjd
            <where>
                  h.xmjd='40'
                  <if test="code==1">
                        <if test="xmlxdm!=null and xmlxdm!=''">
                              and h.xmlxdm=#{xmlxdm}
                        </if>
                  </if>
                  <if test="code==2">
                        and h.xmlxdm!='01' and h.xmlxdm!='02'
                  </if>
                  <if test="year!=null and year!=''">
                        and left(t.tbsj,4)=#{year}
                  </if>
            </where>
            GROUP BY h.tbdwmc
      </select>
</mapper>
