<?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.tofly.xrtygis.custom.mapper.CustomTheMapMapper">

    <select id="getAreaUseWater" resultType="map" fetchSize="1000">
        select to_char(CBRQ,'yyyy-mm') month,
        nvl((select PQMC from TF_YWPN_QFCBCBPQ_W where PQBM = CBPQ),'无') pqmc,
        nvl(sum(BCDS),0) ysl
        from TF_YWPN_QFCBQFMXLS_W
        <where>
            <if test="strTime != null and endTime != null">
                to_char(cbrq,'yyyy-mm') between #{strTime} and #{endTime}
            </if>
            <if test="strTime == null and endTime == null">
                cbrq between add_months(sysdate,-3) and sysdate
            </if>
        </where>
        group by CBPQ, CBRQ
        order by month
    </select>

    <select id="getContrastWater" resultType="map">
        select *
        from (
                 select to_char(CBRQ, 'yyyy-mm')                                          month,
                        nvl((select PQMC from TF_YWPN_QFCBCBPQ_W where PQBM = CBPQ), '无') pqmc,
                        nvl(sum(BCDS), 0)                                                 ysl
                 from TF_YWPN_QFCBQFMXLS_W
                 where to_char(cbrq, 'yyyy-mm') between #{strTime} and #{endTime}
                 group by CBPQ, CBRQ
                 order by month
             )
        where month like #{month}
    </select>

    <select id="groupByCreateTime" resultType="date">
        select create_time
        from TF_YWPN_ITEMRATO_W_VIEW
        where to_char(CREATE_TIME, 'yyyy-mm-dd HH24:mi:ss') between #{start} and #{end}
        group by create_time
        order by create_time
    </select>

    <select id="getItVal" resultType="double">
        select ITVAL
        from TF_YWPN_ITEMRATO_W_VIEW
        where CREATE_TIME = #{time}
          and itcd = #{itcd}
          and tycd = #{tycd}
    </select>

    <select id="getStartTime" resultType="date">
        select min(CREATE_TIME)
        from TF_YWPN_ITEMRATO_W_VIEW
        where to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') between #{start} and #{end}
        and itcd in
        <foreach collection="list" item="itcd" open="(" separator="," close=")">
            #{itcd}
        </foreach>
    </select>

    <select id="getPartition" resultType="map">
        select id, dma_gid
        from TF_YWPN_DMAREGION_W
        where partition_level = #{level}
    </select>

    <select id="getAllUseWater" resultType="map">
        ${sql}
    </select>

</mapper>