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

    <resultMap id="costbgwaterMap" type="com.tofly.xrtygis.entity.Costbgwater">
        <id property="id" column="ID"/>
        <result property="yearId" column="YEAR_ID"/>
        <result property="month" column="MONTH"/>
        <result property="gslOne" column="GSL_ONE"/>
        <result property="gslTwo" column="GSL_TWO"/>
        <result property="gslQbj" column="GSL_QBJ"/>
        <result property="gslTotal" column="GSL_TOTAL"/>
        <result property="zslOne" column="ZSL_ONE"/>
        <result property="zslTwo" column="ZSL_TWO"/>
        <result property="zslHqsk" column="ZSL_HQSK"/>
        <result property="zslTotal" column="ZSL_TOTAL"/>
        <result property="sslTotal" column="SSL_TOTAL"/>
        <result property="zyslOne" column="ZYSL_ONE"/>
        <result property="zyslTwo" column="ZYSL_TWO"/>
        <result property="zyslTotal" column="ZYSL_TOTAL"/>
        <result property="zysllOne" column="ZYSLL_ONE"/>
        <result property="zysllTwo" column="ZYSLL_TWO"/>
        <result property="zysllTotal" column="ZYSLL_TOTAL"/>
        <result property="wspsl" column="WSPSL"/>
        <result property="cxc" column="CXC"/>
        <result property="lsl" column="LSL"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="updateTime" column="UPDATE_TIME"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
    </resultMap>
    <select id="selectPlanYearData" resultType="java.util.Map">
        SELECT SUBSTR(MONTH, 1, 4)                                           MONTH,
               round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,

               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 cxc,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 lsl
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${startYear})
        GROUP BY SUBSTR(MONTH, 1, 4)
        ORDER BY SUBSTR(MONTH, 1, 4)
    </select>

    <select id="sumPlanYearData" resultType="map">
        SELECT round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 LSL
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${startYear})
    </select>

    <select id="selectPlanMonthByYearData" resultType="java.util.Map">
        SELECT id,
               month,
               round(gsl_one, 4)     gsl_one,
               round(gsl_two, 4)     gsl_two,
               round(gsl_qbj, 4)     gsl_qbj,
               round(gsl_total, 4)   gsl_total,
               round(zsl_one, 4)     zsl_one,
               round(zsl_two, 4)     zsl_two,
               round(zsl_hqsk, 4)    zsl_hqsk,
               round(zsl_total, 4)   zsl_total,
               round(ssl_total, 4)   ssl_total,
               round(zysl_one, 4)    zysl_one,
               round(zysl_two, 4)    zysl_two,
               round(zysl_total, 4)  zysl_total,
               round(zysll_one, 4)   zysll_one,
               round(zysll_two, 4)   zysll_two,
               round(zysll_total, 4) zysll_total,
               round(wspsl, 4)       wspsl,
               round(cxc, 4)         cxc,
               round(lsl, 4)         lsl
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) = #{year}
        ORDER BY MONTH
    </select>

    <select id="sumPlanMonthByYearData" resultType="map">
        SELECT round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 LSL
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) = #{year}
    </select>

    <select id="selectPlanMonthData" resultType="java.util.Map">
        SELECT id,
               month,
               round(gsl_one, 4)     gsl_one,
               round(gsl_two, 4)     gsl_two,
               round(gsl_qbj, 4)     gsl_qbj,
               round(gsl_total, 4)   gsl_total,
               round(zsl_one, 4)     zsl_one,
               round(zsl_two, 4)     zsl_two,
               round(zsl_hqsk, 4)    zsl_hqsk,
               round(zsl_total, 4)   zsl_total,
               round(ssl_total, 4)   ssl_total,
               round(zysl_one, 4)    zysl_one,
               round(zysl_two, 4)    zysl_two,
               round(zysl_total, 4)  zysl_total,
               round(zysll_one, 4)   zysll_one,
               round(zysll_two, 4)   zysll_two,
               round(zysll_total, 4) zysll_total,
               round(wspsl, 4)       wspsl,
               round(cxc, 4)         cxc,
               round(lsl, 4)         lsl
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${year})
          and SUBSTR(MONTH, -2) IN (${month})
        ORDER BY MONTH
    </select>

    <select id="sumPlanMonthData" resultType="map">
        SELECT round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 LSL
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${year})
          and SUBSTR(MONTH, -2) IN (${month})
    </select>

    <select id="selectRealityYearData" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy')                                                                             UP_DATE,
               round(SUM(GSL_ONE), 4)                                                                               GSL_ONE,
               round(SUM(GSL_TWO), 4)                                                                               GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                                                               GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                                                             GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                                                               ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                                                               ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                                                              ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                                                             ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                                                             SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                                                              ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                                                              ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                                                            ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)                                            ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)                                            ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2)                                        ZYSLL_TOTAL,
               round(SUM(WSPSL), 4)                                                                                 WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) * 100, 2) cxc,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) *
                     100, 2)                                                                                        lsl
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${startYear})
          and MARK = '1'
        GROUP BY TO_CHAR(UP_DATE, 'yyyy')
        ORDER BY UP_DATE
    </select>

    <select id="sumRealityYearData" resultType="map">
        SELECT round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 LSL
        FROM TF_YWPN_COSTRLWATER_W
        where MARK = 1
          and TO_CHAR(UP_DATE, 'yyyy') IN (${startYear})
    </select>

    <select id="selectRealityMonthByYearData" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy-MM')                                                                          UP_DATE,
               round(SUM(GSL_ONE), 4)                                                                               GSL_ONE,
               round(SUM(GSL_TWO), 4)                                                                               GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                                                               GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                                                             GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                                                               ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                                                               ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                                                              ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                                                             ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                                                             SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                                                              ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                                                              ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                                                            ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)                                            ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)                                            ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2)                                        ZYSLL_TOTAL,
               round(SUM(WSPSL), 4)                                                                                 WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) * 100, 2) cxc,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) *
                     100, 2)                                                                                        lsl
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') = #{year}
          and MARK = '1'
        GROUP BY TO_CHAR(UP_DATE, 'yyyy-MM')
        ORDER BY UP_DATE
    </select>

    <select id="sumRealityMonthByYearData" resultType="map">
        SELECT round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 LSL
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') = #{year}
          and MARK = '1'
    </select>

    <select id="selectRealityMonthData" resultType="java.util.Map">

        SELECT TO_CHAR(UP_DATE, 'yyyy-MM')                                                                          UP_DATE,
               round(SUM(GSL_ONE), 4)                                                                               GSL_ONE,
               round(SUM(GSL_TWO), 4)                                                                               GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                                                               GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                                                             GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                                                               ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                                                               ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                                                              ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                                                             ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                                                             SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                                                              ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                                                              ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                                                            ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)                                            ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)                                            ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2)                                        ZYSLL_TOTAL,
               round(SUM(WSPSL), 4)                                                                                 WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) * 100, 2) cxc,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) *
                     100, 2)                                                                                        lsl
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
          and TO_CHAR(UP_DATE, 'MM') IN (${month})
          and MARK = '1'
        GROUP BY TO_CHAR(UP_DATE, 'yyyy-MM')
        ORDER BY UP_DATE ASC
    </select>

    <select id="sumRealityMonthData" resultType="map">
        SELECT round(SUM(GSL_ONE), 4)                                        GSL_ONE,
               round(SUM(GSL_TWO), 4)                                        GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                        GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                      GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                        ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                        ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                       ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                      ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                      SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                       ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                       ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                     ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)     ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)     ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2) ZYSLL_TOTAL,
               SUM(WSPSL)                                                    WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_QBJ) + sum(GSL_TOTAL), 0)) *
                     100, 2)                                                 LSL
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
          and TO_CHAR(UP_DATE, 'MM') IN (${month})
          and MARK = '1'
    </select>

    <select id="selectPlanUnitYearData" resultType="map">
        SELECT SUBSTR(w.MONTH, 1, 4)                                      year,
               round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        FROM TF_YWPN_COSTBGWATER_W w
                 full join TF_YWPN_COSTBGINDEX_W i on w.MONTH = i.MONTH
        WHERE SUBSTR(w.MONTH, 1, 4) IN (${startYear})
        GROUP BY SUBSTR(w.MONTH, 1, 4)
        ORDER BY year
    </select>

    <select id="sumPlanUnitYearData" resultType="map">
        SELECT round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        FROM TF_YWPN_COSTBGWATER_W w
                 full join TF_YWPN_COSTBGINDEX_W i on w.MONTH = i.MONTH
        WHERE SUBSTR(w.MONTH, 1, 4) IN (${startYear})
    </select>

    <select id="selectPlanUnitMonthData" resultType="map">
        SELECT MONTH                  year,
               round(PACDH_ONE, 4)    PACDH_ONE,
               round(PACDH_TWO, 4)    PACDH_TWO,
               round(SYDH_ONE, 4)     SYDH_ONE,
               round(YLDH_TWO, 4)     YLDH_TWO,
               round(DH_ONE, 4)       DH_ONE,
               round(DH_TWO, 4)       DH_TWO,
               round(DH_TOTAL, 4)     DH_TOTAL,
               round(CNDH_TWO, 4)     CNDH_TWO,
               round(OTHERDH, 4)      OTHERDH,
               round(OTHER_ONE_DH, 4) OTHER_ONE_DH,
               round(OTHER_TWO_DH, 4) OTHER_TWO_DH
        FROM TF_YWPN_COSTBGUNIT_W
        WHERE SUBSTR(MONTH, 1, 4) = #{year}
        order by year
    </select>

    <select id="sumPlanUnitMonthData" resultType="map">
        SELECT round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        FROM TF_YWPN_COSTBGWATER_W w
                 full join TF_YWPN_COSTBGINDEX_W i on w.MONTH = i.MONTH
        WHERE SUBSTR(w.MONTH, 1, 4) = #{year}
    </select>

    <select id="selectPlanUnitData" resultType="map">
        SELECT MONTH                  year,
               round(PACDH_ONE, 4)    PACDH_ONE,
               round(PACDH_TWO, 4)    PACDH_TWO,
               round(SYDH_ONE, 4)     SYDH_ONE,
               round(YLDH_TWO, 4)     YLDH_TWO,
               round(DH_ONE, 4)       DH_ONE,
               round(DH_TWO, 4)       DH_TWO,
               round(DH_TOTAL, 4)     DH_TOTAL,
               round(CNDH_TWO, 4)     CNDH_TWO,
               round(OTHERDH, 4)      OTHERDH,
               round(OTHER_ONE_DH, 4) OTHER_ONE_DH,
               round(OTHER_TWO_DH, 4) OTHER_TWO_DH
        FROM TF_YWPN_COSTBGUNIT_W
        where SUBSTR(MONTH, 1, 4) IN (${year})
          and SUBSTR(MONTH, -2) IN (${month})
        order by year
    </select>

    <select id="sumPlanUnitData" resultType="map">
        SELECT round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        FROM TF_YWPN_COSTBGWATER_W w
                 full join TF_YWPN_COSTBGINDEX_W i on w.MONTH = i.MONTH
        where SUBSTR(w.MONTH, 1, 4) IN (${year})
          and SUBSTR(w.MONTH, -2) IN (${month})
    </select>

    <select id="selectRealUnitYearData" resultType="map">
        select to_char(UP_DATE, 'yyyy')                                   year,
               round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        from TF_YWPN_COSTRLWATER_W
        where MARK = 1
          and to_char(UP_DATE, 'yyyy') in (${startYear})
        group by to_char(UP_DATE, 'yyyy')
        order by year
    </select>

    <select id="sumRealUnitYearData" resultType="map">
        select round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        from TF_YWPN_COSTRLWATER_W
        where MARK = 1
          and to_char(UP_DATE, 'yyyy') in (${startYear})
    </select>

    <select id="selectRealUnitMonthData" resultType="map">
        select to_char(UP_DATE, 'yyyy-mm') year,
               round(PACDH_ONE, 4)         PACDH_ONE,
               round(PACDH_TWO, 4)         PACDH_TWO,
               round(SYDH_ONE, 4)          SYDH_ONE,
               round(YLDH_TWO, 4)          YLDH_TWO,
               round(DH_ONE, 4)            DH_ONE,
               round(DH_TWO, 4)            DH_TWO,
               round(DH_TOTAL, 4)          DH_TOTAL,
               round(CNDH_TWO, 4)          CNDH_TWO,
               round(OTHERDH, 4)           OTHERDH,
               round(OTHER_ONE_DH, 4)      OTHER_ONE_DH,
               round(OTHER_TWO_DH, 4)      OTHER_TWO_DH
        from TF_YWPN_COSTRLUNIT_W
        where MARK = 1
          and to_char(UP_DATE, 'yyyy') = #{year}
        order by year
    </select>

    <select id="sumRealUnitMonthData" resultType="map">
        select round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        from TF_YWPN_COSTRLWATER_W
        where MARK = 1
          and to_char(UP_DATE, 'yyyy') = #{year}
    </select>

    <select id="selectRealUnitData" resultType="map">
        select to_char(UP_DATE, 'yyyy-mm') year,
               round(PACDH_ONE, 4)         PACDH_ONE,
               round(PACDH_TWO, 4)         PACDH_TWO,
               round(SYDH_ONE, 4)          SYDH_ONE,
               round(YLDH_TWO, 4)          YLDH_TWO,
               round(DH_ONE, 4)            DH_ONE,
               round(DH_TWO, 4)            DH_TWO,
               round(DH_TOTAL, 4)          DH_TOTAL,
               round(CNDH_TWO, 4)          CNDH_TWO,
               round(OTHERDH, 4)           OTHERDH,
               round(OTHER_ONE_DH, 4)      OTHER_ONE_DH,
               round(OTHER_TWO_DH, 4)      OTHER_TWO_DH
        from TF_YWPN_COSTRLUNIT_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
          and TO_CHAR(UP_DATE, 'MM') IN (${month})
          and MARK = '1'
        order by year
    </select>

    <select id="sumRealUnitData" resultType="map">
        select round(sum(PAC_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)      PACDH_ONE,
               round(sum(PAC_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)      PACDH_TWO,
               round(sum(SY_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)       SYDH_ONE,
               round(sum(YL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       YLDH_TWO,
               round(sum(DLDL_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)     DH_ONE,
               round(sum(DLDL_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)     DH_TWO,
               round(sum(DLDL_TOTAL) / nullif(sum(ZSL_TOTAL) * 10, 0), 4) DH_TOTAL,
               round(sum(CN_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)       CNDH_TWO,
               round(sum(OTHER) / nullif(sum(ZSL_ONE) * 10, 0), 4)        OTHERDH,
               round(sum(OTHER_ONE) / nullif(sum(ZSL_ONE) * 10, 0), 4)    other_one_dh,
               round(sum(OTHER_TWO) / nullif(sum(ZSL_TWO) * 10, 0), 4)    other_two_dh
        from TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
          and TO_CHAR(UP_DATE, 'MM') IN (${month})
          and MARK = '1'
    </select>

    <select id="selectPlanProduceYearData" resultType="java.util.Map">
        SELECT SUBSTR(MONTH, 1, 4)       MONTH,
               round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(pam_wn), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(OTHER_ONE), 4)  other_one,
               round(sum(OTHER_TWO), 4)  other_two,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTBGINDEX_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${startYear})
        GROUP BY SUBSTR(MONTH, 1, 4)
        ORDER BY MONTH
    </select>

    <select id="sumPlanProduceYearData" resultType="map">
        SELECT round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(pam_wn), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(OTHER_ONE), 4)  other_one,
               round(sum(OTHER_TWO), 4)  other_two,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTBGINDEX_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${startYear})
    </select>

    <select id="selectPlanProduceMonthByYear" resultType="java.util.Map">
        SELECT id,
               month,
               round(pac_one, 4)        pac_one,
               round(pac_two, 4)        pac_two,
               round(sy_one, 4)         sy_one,
               round(yl_two, 4)         yl_two,
               round(pam, 4)            pam,
               round(ft, 4)             ft,
               round(cn, 4)             cn,
               round(gmsjfhy, 4)        gmsjfhy,
               round(pam_wn, 4)         pam_wn,
               round(bcs, 4)            bcs,
               round(wnzl, 4)           wnzl,
               round(dldl_one, 4)       dldl_one,
               round(dldl_two, 4)       dldl_two,
               round(dldl_total, 4)     dldl_total,
               round(other, 4)          other,
               round(OTHER_ONE, 4) other_one,
               round(OTHER_TWO, 4) other_two,
               round(jbdl_one, 4)       jbdl_one,
               round(jbdl_two, 4)       jbdl_two,
               round(jbdl_total, 4)     jbdl_total,
               round(cn_two, 4)         cn_two
        FROM TF_YWPN_COSTBGINDEX_W
        WHERE SUBSTR(MONTH, 1, 4) = #{year}
        ORDER BY MONTH
    </select>

    <select id="sumPlanProduceMonthByYear" resultType="map">
        SELECT round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(pam_wn), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(OTHER_ONE), 4)  other_one,
               round(sum(OTHER_TWO), 4)  other_two,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTBGINDEX_W
        WHERE SUBSTR(MONTH, 1, 4) = #{year}
    </select>

    <select id="selectPlanProduceMonthData" resultType="java.util.Map">
        SELECT id,
               month,
               round(pac_one, 4)    pac_one,
               round(pac_two, 4)    pac_two,
               round(sy_one, 4)     sy_one,
               round(yl_two, 4)     yl_two,
               round(pam, 4)        pam,
               round(ft, 4)         ft,
               round(cn, 4)         cn,
               round(gmsjfhy, 4)    gmsjfhy,
               round(pam_wn, 4)     pam_wn,
               round(bcs, 4)        bcs,
               round(wnzl, 4)       wnzl,
               round(dldl_one, 4)   dldl_one,
               round(dldl_two, 4)   dldl_two,
               round(dldl_total, 4) dldl_total,
               round(other, 4)      other,
               round(OTHER_ONE, 4)  other_one,
               round(OTHER_TWO, 4)  other_two,
               round(jbdl_one, 4)   jbdl_one,
               round(jbdl_two, 4)   jbdl_two,
               round(jbdl_total, 4) jbdl_total,
               round(cn_two, 4)     cn_two
        FROM TF_YWPN_COSTBGINDEX_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${year})
          and SUBSTR(MONTH, -2) IN (${month})
        ORDER BY MONTH
    </select>

    <select id="sumPlanProduceMonthData" resultType="map">
        SELECT round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(pam_wn), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTBGINDEX_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${year})
          and SUBSTR(MONTH, -2) IN (${month})
    </select>

    <select id="selectRealityProduceYearData" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy')  UP_DATE,
               round(sum(PAC_ONE), 4)    PAC_ONE,
               round(sum(PAC_TWO), 4)    PAC_TWO,
               round(sum(SY_ONE), 4)     SY_ONE,
               round(sum(YL_TWO), 4)     YL_TWO,
               round(sum(PAM), 4)        PAM,
               round(sum(FT), 4)         FT,
               round(sum(CN), 4)         CN,
               round(sum(CN_TWO), 4)     CN_TWO,
               round(sum(GMSJFHY), 4)    GMSJFHY,
               round(sum(PAM_WY), 4)     PAM_WN,
               round(sum(BCS), 4)        BCS,
               round(sum(WNZL), 4)       WNZL,
               round(sum(DLDL_ONE), 4)   DLDL_ONE,
               round(sum(DLDL_TWO), 4)   DLDL_TWO,
               round(sum(DLDL_TOTAL), 4) DLDL_TOTAL,
               round(sum(JBDL_ONE), 4)   JBDL_ONE,
               round(sum(JBDL_TWO), 4)   JBDL_TWO,
               round(sum(JBDL_TOTAL), 4) JBDL_TOTAL,
               round(sum(OTHER), 4)      OTHER,
               round(sum(OTHER_ONE), 4)  OTHER_ONE,
               round(sum(OTHER_TWO), 4)  OTHER_TWO
        FROM TF_YWPN_COSTRLWATER_W
        WHERE MARK = '1'
          and TO_CHAR(UP_DATE, 'yyyy') IN (${startYear})
        GROUP BY TO_CHAR(UP_DATE, 'yyyy')
        ORDER BY UP_DATE
    </select>

    <select id="sumRealityProduceYearData" resultType="map">
        SELECT round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(PAM_WY), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(OTHER_ONE), 4)  OTHER_ONE,
               round(sum(OTHER_TWO), 4)  OTHER_TWO,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTRLWATER_W
        WHERE MARK = '1'
          and TO_CHAR(UP_DATE, 'yyyy') IN (${startYear})
    </select>

    <select id="selectRealityProduceMonthByYear" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy-MM') UP_DATE,
               round(SUM(PAC_ONE), 4)      PAC_ONE,
               round(SUM(PAC_TWO), 4)      PAC_TWO,
               round(SUM(SY_ONE), 4)       SY_ONE,
               round(SUM(YL_TWO), 4)       YL_TWO,
               round(SUM(PAM), 4)          PAM,
               round(SUM(FT), 4)           FT,
               round(SUM(CN), 4)           CN,
               round(SUM(CN_TWO), 4)       CN_TWO,
               round(SUM(GMSJFHY), 4)      GMSJFHY,
               round(SUM(PAM_WY), 4)       PAM_WN,
               round(SUM(BCS), 4)          BCS,
               round(SUM(WNZL), 4)         WNZL,
               round(SUM(DLDL_ONE), 4)     DLDL_ONE,
               round(SUM(DLDL_TWO), 4)     DLDL_TWO,
               round(SUM(DLDL_TOTAL), 4)   DLDL_TOTAL,
               round(SUM(JBDL_ONE), 4)     JBDL_ONE,
               round(SUM(JBDL_TWO), 4)     JBDL_TWO,
               round(SUM(JBDL_TOTAL), 4)   JBDL_TOTAL,
               round(sum(other), 4)        other,
               round(sum(OTHER_ONE), 4)    OTHER_ONE,
               round(sum(OTHER_TWO), 4)    OTHER_TWO
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') = #{year}
          and MARK = '1'
        GROUP BY TO_CHAR(UP_DATE, 'yyyy-MM')
        ORDER BY UP_DATE
    </select>

    <select id="sumRealityProduceMonthByYear" resultType="map">
        SELECT round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(PAM_WY), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(OTHER_ONE), 4)  OTHER_ONE,
               round(sum(OTHER_TWO), 4)  OTHER_TWO,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') = #{year}
          and MARK = '1'
    </select>

    <select id="selectRealityProduceMonthData" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy-MM') UP_DATE,
               round(pac_one, 4)           pac_one,
               round(pac_two, 4)           pac_two,
               round(sy_one, 4)            sy_one,
               round(yl_two, 4)            yl_two,
               round(pam, 4)               pam,
               round(ft, 4)                ft,
               round(cn, 4)                cn,
               round(gmsjfhy, 4)           gmsjfhy,
               round(PAM_WY, 4)            pam_wn,
               round(bcs, 4)               bcs,
               round(wnzl, 4)              wnzl,
               round(dldl_one, 4)          dldl_one,
               round(dldl_two, 4)          dldl_two,
               round(dldl_total, 4)        dldl_total,
               round(other, 4)             other,
               round(OTHER_ONE, 4)         OTHER_ONE,
               round(OTHER_TWO, 4)         OTHER_TWO,
               round(jbdl_one, 4)          jbdl_one,
               round(jbdl_two, 4)          jbdl_two,
               round(jbdl_total, 4)        jbdl_total,
               round(cn_two, 4)            cn_two
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
          and TO_CHAR(UP_DATE, 'MM') IN (${month})
          and MARK = '1'
        ORDER BY UP_DATE ASC
    </select>

    <select id="sumRealityProduceMonthData" resultType="map">
        SELECT round(sum(pac_one), 4)    pac_one,
               round(sum(pac_two), 4)    pac_two,
               round(sum(sy_one), 4)     sy_one,
               round(sum(yl_two), 4)     yl_two,
               round(sum(pam), 4)        pam,
               round(sum(ft), 4)         ft,
               round(sum(cn), 4)         cn,
               round(sum(gmsjfhy), 4)    gmsjfhy,
               round(sum(PAM_WY), 4)     pam_wn,
               round(sum(bcs), 4)        bcs,
               round(sum(wnzl), 4)       wnzl,
               round(sum(dldl_one), 4)   dldl_one,
               round(sum(dldl_two), 4)   dldl_two,
               round(sum(dldl_total), 4) dldl_total,
               round(sum(other), 4)      other,
               round(sum(OTHER_ONE), 4)  OTHER_ONE,
               round(sum(OTHER_TWO), 4)  OTHER_TWO,
               round(sum(jbdl_one), 4)   jbdl_one,
               round(sum(jbdl_two), 4)   jbdl_two,
               round(sum(jbdl_total), 4) jbdl_total,
               round(sum(cn_two), 4)     cn_two
        FROM TF_YWPN_COSTRLWATER_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
          and TO_CHAR(UP_DATE, 'MM') IN (${month})
          and MARK = '1'
    </select>

    <sql id="fixedCalSql">
        round
            (sum(YSF), 4)
            YSF,
               round(sum(SZYSF_ONE), 4)                                                           SZYSF_ONE,
               round(sum(SZYSF_TWO), 4)                                                           SZYSF_TWO,
               round(sum(SZYSF_TOTAL), 4)                                                         SZYSF_TOTAL,
               round(sum(ZFY_ONE), 4)                                                             ZFY_ONE,
               round(sum(ZFY_TWO), 4)                                                             ZFY_TWO,
               round(sum(ZFY), 4)                                                                 ZFY,
               round(sum(CNZFY_TWO), 4)                                                           cnzfy_two,
               round(sum(PACZFY_ONE), 4)                                                          PACZFY_ONE,
               round(sum(SYZFY_ONE), 4)                                                           SYZFY_ONE,
               round(sum(PACZFY_TWO), 4)                                                          PACZFY_TWO,
               round(sum(YLZFY_TWO), 4)                                                           YLZFY_TWO,
               round(sum(PAMZSZFY), 4)                                                            PAMZSZFY,
               round(sum(FTZFY), 4)                                                               FTZFY,
               round(sum(CNZFY), 4)                                                               CNZFY,
               round(sum(GMSJFHYZFY), 4)                                                          GMSJFHYZFY,
               round(sum(PAMWNZFY), 4)                                                            PAMWNZFY,
               round(sum(BCSZFY), 4)                                                              BCSZFY,
               round(sum(WNZYF), 4)                                                               WNZYF,
               round(sum(JBDF_ONE), 4)                                                            JBDF_ONE,
               round(sum(JBDF_TWO), 4)                                                            JBDF_TWO,
               round(sum(JBDF_TOTAL), 4)                                                          JBDF_TOTAL,
               round(sum(DLDF_ONE), 4)                                                            DLDF_ONE,
               round(sum(DLDF_TWO), 4)                                                            DLDF_TWO,
               round(sum(DLDF_TOTAL), 4)                                                          DLDF_TOTAL,
               round(sum(SZYSF_TOTAL), 4)                                                         SZYSF_TOTAL,
               round(sum(OTHERZFY), 4)                                                            OTHERZFY,
               round(sum(OTHER_ONE_ZFY), 4)                                                       OTHER_ONE_ZFY,
               round(sum(OTHER_TWO_ZFY), 4)                                                       OTHER_TWO_ZFY,

               -- ---------成本计算-----------
               round((sum(JBDF_ONE) + sum(DLDF_ONE)) / nullif(sum(GSL_ONE), 0) * 1000, 4)         DFCB_ONE,
               round((sum(JBDF_TWO) + sum(DLDF_TWO)) / nullif(sum(GSL_TWO), 0) * 1000, 4)         DFCB_TWO,
               round((sum(JBDF_TOTAL) + sum(DLDF_TOTAL)) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)   DFCB_TOTAL,
               round(sum(PACZFY_ONE) / nullif(sum(GSL_ONE), 0) * 1000, 4)                         PACCB_ONE,
               round(sum(SYZFY_ONE) / nullif(sum(GSL_ONE), 0) * 1000, 4)                          SYCB_ONE,
               round(sum(BCSZFY) / nullif(sum(GSL_ONE), 0) * 1000, 4)                             BCSCB_ONE,
               round(sum(CNZFY) / nullif(sum(GSL_ONE), 0) * 1000, 4)                              CNCB_ONE,
               round(sum(CNZFY_TWO) / nullif(sum(GSL_TWO), 0) * 1000, 4)                          CNCB_TWO,
               round(sum(ZZSCLFY_ONE) / nullif(sum(GSL_ONE), 0) * 1000, 4)                        ZSCLCB_ONE,
               round(sum(PACZFY_TWO) / nullif(sum(GSL_TWO), 0) * 1000, 4)                         PACCB_TWO,
               round(sum(YLZFY_TWO) / nullif(sum(GSL_TWO), 0) * 1000, 4)                          YLCB_TWO,
               round(sum(PAMZSZFY) / nullif(sum(GSL_TWO), 0) * 1000, 4)                           PAMZSCB_TWO,
               round(sum(GMSJFHYZFY) / nullif(sum(GSL_TWO), 0) * 1000, 4)                         GMSJFHYCB_TWO,
               round(sum(PAMWNZFY) / nullif(sum(GSL_TWO), 0) * 1000, 4)                           PAMWNCB_TWO,
               round(sum(FTZFY) / nullif(sum(GSL_TWO), 0) * 1000, 4)                              FTCB_TWO,
               round(sum(WNZYF) / nullif(sum(GSL_TWO), 0) * 1000, 4)                              WNZYCB_TWO,
               round(sum(ZZSCLFY_TWO) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)                      ZSCLCB_TWO,
               round((sum(ZZSCLFY_ONE) + sum(ZZSCLFY_TWO)) / nullif(sum(GSL_TOTAL), 0) * 1000, 4) ZSCLCB_TOTAL,
               round(sum(YSF) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)                              YSFCB,
               round(sum(SZYSF_ONE) / nullif(sum(GSL_ONE), 0) * 1000, 4)                          SZYSFCB_ONE,
               round(sum(SZYSF_TWO) / nullif(sum(GSL_TWO), 0) * 1000, 4)                          SZYSFCB_TWO,
               round(sum(SZYSF_TOTAL) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)                      SZYSFCB_TOTAL,
               round(sum(ZFY_ONE) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)                          DWCB_ONE,
               round(sum(ZFY_TWO) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)                          DWCB_TWO,
               round(sum(ZFY) / nullif(sum(GSL_TOTAL), 0) * 1000, 4)                              DWCB_TOTAL,
               round(sum(OTHERZFY) / nullif(sum(GSL_ONE), 0) * 1000, 4)                           OTHERCB,
               round(sum(OTHER_ONE_ZFY) / nullif(sum(GSL_ONE), 0) * 1000, 4)                      OTHER_ONE_CB,
               round(sum(OTHER_TWO_ZFY) / nullif(sum(GSL_TWO), 0) * 1000, 4)                      OTHER_TWO_CB
    </sql>

    <sql id="fixedolumn">
        round
            (YSF, 4)
            YSF,
               round(SZYSF_ONE, 4)           SZYSF_ONE,
               round(SZYSF_TWO, 4)           SZYSF_TWO,
               round(SZYSF_TOTAL, 4)         SZYSF_TOTAL,
               round(ZFY_ONE, 4)             ZFY_ONE,
               round(ZFY_TWO, 4)             ZFY_TWO,
               round(ZFY, 4)                 ZFY,
               round(CNZFY_TWO, 4)           cnzfy_two,
               round(PACZFY_ONE, 4)          PACZFY_ONE,
               round(SYZFY_ONE, 4)           SYZFY_ONE,
               round(PACZFY_TWO, 4)          PACZFY_TWO,
               round(YLZFY_TWO, 4)           YLZFY_TWO,
               round(PAMZSZFY, 4)            PAMZSZFY,
               round(FTZFY, 4)               FTZFY,
               round(CNZFY, 4)               CNZFY,
               round(GMSJFHYZFY, 4)          GMSJFHYZFY,
               round(PAMWNZFY, 4)            PAMWNZFY,
               round(BCSZFY, 4)              BCSZFY,
               round(WNZYF, 4)               WNZYF,
               round(JBDF_ONE, 4)            JBDF_ONE,
               round(JBDF_TWO, 4)            JBDF_TWO,
               round(JBDF_TOTAL, 4)          JBDF_TOTAL,
               round(DLDF_ONE, 4)            DLDF_ONE,
               round(DLDF_TWO, 4)            DLDF_TWO,
               round(DLDF_TOTAL, 4)          DLDF_TOTAL,
               round(SZYSF_TOTAL, 4)         SZYSF_TOTAL,
               round(OTHERZFY, 4)            OTHERZFY,
               round(OTHER_ONE_ZFY, 4)       OTHER_ONE_ZFY,
               round(OTHER_TWO_ZFY, 4)       OTHER_TWO_ZFY,

               -- -----成本计算-----------
               round(DFCB_ONE, 4)            DFCB_ONE,
               round(DFCB_TWO, 4)            DFCB_TWO,
               round(DFCB_TOTAL, 4)          DFCB_TOTAL,
               round(PACCB_ONE, 4)           PACCB_ONE,
               round(SYCB_ONE, 4)            SYCB_ONE,
               round(BCSCB_ONE, 4)           BCSCB_ONE,
               round(CNCB_ONE, 4)            CNCB_ONE,
               round(CNCB_TWO, 4)            CNCB_TWO,
               round(ZSCLCB_ONE, 4)          ZSCLCB_ONE,
               round(PACCB_TWO, 4)           PACCB_TWO,
               round(YLCB_TWO, 4)            YLCB_TWO,
               round(PAMZSCB_TWO, 4)         PAMZSCB_TWO,
               round(GMSJFHYCB_TWO, 4)       GMSJFHYCB_TWO,
               round(PAMWNCB_TWO, 4)         PAMWNCB_TWO,
               round(FTCB_TWO, 4)            FTCB_TWO,
               round(WNZYCB_TWO, 4)          WNZYCB_TWO,
               round(ZSCLCB_TWO, 4)          ZSCLCB_TWO,
               round(ZSCLCB_TOTAL, 4)        ZSCLCB_TOTAL,
               round(YSFCB, 4)               YSFCB,
               round(SZYSFCB_ONE, 4)         SZYSFCB_ONE,
               round(SZYSFCB_TWO, 4)         SZYSFCB_TWO,
               round(SZYSFCB_TOTAL, 4)       SZYSFCB_TOTAL,
               round(DWCB_ONE, 4)            DWCB_ONE,
               round(DWCB_TWO, 4)            DWCB_TWO,
               round(DWCB_TOTAL, 4)          DWCB_TOTAL,
               round(OTHERCB, 4)             OTHERCB,
               round(OTHER_ONE_CB, 4)        OTHER_ONE_CB,
               round(OTHER_TWO_CB, 4)        OTHER_TWO_CB
    </sql>

    <select id="selectPlanCostYearData" resultType="java.util.Map">
        SELECT SUBSTR(f.MOUTH, 1, 4) MONTH,
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTBGFIXED_W f
        left join TF_YWPN_COSTBGWATER_W w on f.MOUTH = w.MONTH
        WHERE SUBSTR(f.MOUTH, 1, 4) IN (${startYear})
        group by SUBSTR(f.MOUTH, 1, 4)
        order by SUBSTR(f.MOUTH, 1, 4)
    </select>

    <select id="sumPlanCostYearData" resultType="map">
        SELECT
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTBGFIXED_W f
        left join TF_YWPN_COSTBGWATER_W w on f.MOUTH = w.MONTH
        WHERE SUBSTR(f.MOUTH, 1, 4) IN (${startYear})
    </select>

    <select id="selectPlanCostMonthByYear" resultType="java.util.Map">
        SELECT MOUTH MONTH,
        id,
        <include refid="fixedolumn"/>
        FROM TF_YWPN_COSTBGFIXED_W
        WHERE SUBSTR(MOUTH, 1, 4) = #{year}
        ORDER BY MONTH
    </select>

    <select id="sumPlanCostMonthByYear" resultType="map">
        SELECT
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTBGFIXED_W f
        left join TF_YWPN_COSTBGWATER_W w on f.MOUTH = w.MONTH
        WHERE SUBSTR(MOUTH, 1, 4) = #{year}
    </select>

    <select id="selectPlanCostMonthData" resultType="java.util.Map">
        SELECT MOUTH MONTH,
        <include refid="fixedolumn"/>
        FROM TF_YWPN_COSTBGFIXED_W
        WHERE SUBSTR(MOUTH, 1, 4) IN (${year})
        and SUBSTR(MOUTH, -2) IN (${month})
        ORDER BY MONTH
    </select>

    <select id="sumPlanCostMonthData" resultType="map">
        SELECT
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTBGFIXED_W f
        left join TF_YWPN_COSTBGWATER_W w on f.MOUTH = w.MONTH
        WHERE SUBSTR(MOUTH, 1, 4) IN (${year})
        and SUBSTR(MOUTH, -2) IN (${month})
    </select>
    <select id="selectRealityCostYearData" resultType="java.util.Map">
        SELECT TO_CHAR(f.UP_DATE, 'yyyy') UP_DATE,
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTRLFIXED_W f
        left join TF_YWPN_COSTRLWATER_W w
        on to_char(f.UP_DATE, 'yyyy-mm') = to_char(w.UP_DATE, 'yyyy-mm') and f.MARK = w.MARK
        WHERE TO_CHAR(f.UP_DATE, 'yyyy') IN (${startYear})
        and f.MARK = '1'
        GROUP BY TO_CHAR(f.UP_DATE, 'yyyy')
        order by UP_DATE
    </select>

    <select id="sumRealityCostYearData" resultType="map">
        SELECT
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTRLFIXED_W f
        left join TF_YWPN_COSTRLWATER_W w
        on to_char(f.UP_DATE, 'yyyy-mm') = to_char(w.UP_DATE, 'yyyy-mm') and f.MARK = w.MARK
        WHERE TO_CHAR(f.UP_DATE, 'yyyy') IN (${startYear})
        and f.MARK = '1'
    </select>

    <select id="selectRealityCostMonthByYear" resultType="java.util.Map">
        SELECT TO_CHAR(f.UP_DATE, 'yyyy-MM') UP_DATE,
        <include refid="fixedolumn"/>
        FROM TF_YWPN_COSTRLFIXED_W f
        WHERE TO_CHAR(f.UP_DATE, 'yyyy') = #{year}
        and f.MARK = '1'
        ORDER BY UP_DATE
    </select>

    <select id="sumRealityCostMonthByYear" resultType="map">
        SELECT
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTRLFIXED_W f
        left join TF_YWPN_COSTRLWATER_W w
        on to_char(f.UP_DATE, 'yyyy-mm') = to_char(w.UP_DATE, 'yyyy-mm') and f.MARK = w.MARK
        WHERE TO_CHAR(f.UP_DATE, 'yyyy') = #{year}
        and f.MARK = '1'
    </select>

    <select id="selectRealityCostMonthData" resultType="java.util.Map">

        SELECT TO_CHAR(UP_DATE, 'yyyy-MM') UP_DATE,
        <include refid="fixedolumn"/>
        FROM TF_YWPN_COSTRLFIXED_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${year})
        and TO_CHAR(UP_DATE, 'MM') IN (${month})
        and MARK = '1'
        ORDER BY UP_DATE
    </select>

    <select id="sumRealityCostMonthData" resultType="map">
        SELECT
        <include refid="fixedCalSql"/>
        FROM TF_YWPN_COSTRLFIXED_W f
        left join TF_YWPN_COSTRLWATER_W w
        on to_char(f.UP_DATE, 'yyyy-mm') = to_char(w.UP_DATE, 'yyyy-mm') and f.MARK = w.MARK
        WHERE TO_CHAR(f.UP_DATE, 'yyyy') IN (${year})
        and TO_CHAR(f.UP_DATE, 'MM') IN (${month})
        and f.MARK = '1'
    </select>

    <sql id="priceReslut">
        YEAR,TO_CHAR(UP_DATE , 'yyyy-MM') CREATE_TIME,
        PACDJ,YLDJ,PAM_ZSDJ,PAM_WNDJ,FTDJ,CNDJ,GMSJFHYDJ,SYDJ,DLDDJ_ONE,DLDDJ_TWO,WNZYDJ,YSFDJ,SZYSDJ,BCSDJ,OTHERDJ, OTHER_ONE_DJ,OTHER_TWO_DJ
    </sql>

    <select id="selectPlanPriceYearData" resultType="java.util.Map">
        <!--        SELECT-->
        <!--        <include refid="priceReslut"></include>-->
        <!--        FROM TF_YWPN_COSTBGPRICE_W-->
        <!--        WHERE YEAR IN  (${startYear}) and SNEW = '1'-->
        <!--        ORDER BY CREATE_TIME ASC-->
        <!--由于在单价计划值中没有使用SNEW这一字段标识单价是否最新单价，所以只能使用以下方式查询年度单价数据-->
        SELECT
        <include refid="priceReslut"/>
        FROM TF_YWPN_COSTBGPRICE_W WHERE ID IN ( SELECT
        MAX(ID)
        FROM TF_YWPN_COSTBGPRICE_W
        WHERE YEAR IN (${startYear})
        GROUP BY YEAR)
    </select>
    <select id="selectPlanPriceMonthByYear" resultType="java.util.Map">
        SELECT
        <include refid="priceReslut"/>
        FROM TF_YWPN_COSTBGPRICE_W WHERE ID IN
        (SELECT MAX(ID) FROM (SELECT ID,TO_CHAR(UP_DATE , 'yyyy-MM') UP_DATE FROM TF_YWPN_COSTBGPRICE_W WHERE
        YEAR = #{year}) GROUP BY UP_DATE)
        AND YEAR = #{year}
        ORDER BY UP_DATE ASC
        <!--        SELECT <include refid="priceReslut"></include> FROM TF_YWPN_COSTBGPRICE_W WHERE-->
        <!--        YEAR = #{year}-->
        <!--        ORDER BY CREATE_TIME ASC-->
    </select>
    <select id="selectPlanPriceMonthData" resultType="java.util.Map">
        SELECT
        <include refid="priceReslut"/>
        FROM TF_YWPN_COSTBGPRICE_W WHERE ID IN
        (SELECT MAX(ID) FROM (SELECT ID, YEAR,TO_CHAR(UP_DATE , 'yyyy-MM') UP_DATE FROM TF_YWPN_COSTBGPRICE_W
        WHERE YEAR IN (${year}) and
        TO_CHAR(UP_DATE,'MM') IN (${month}) ) GROUP BY UP_DATE)
        AND YEAR IN (${year})
        ORDER BY UP_DATE ASC
    </select>

    <select id="selectRealityPriceYearData" resultType="java.util.Map">
        SELECT
        <include refid="priceReslut"/>
        FROM TF_YWPN_COSTRLPRICE_W
        WHERE YEAR IN (${startYear})
        and ISNEW = '1' ORDER BY UP_DATE ASC
    </select>
    <select id="selectRealityPriceMonthByYear" resultType="java.util.Map">
        SELECT
        <include refid="priceReslut"/>
        FROM
        TF_YWPN_COSTRLPRICE_W WHERE ID IN (SELECT MAX(ID) FROM (SELECT ID,TO_CHAR(UP_DATE , 'yyyy-MM') UP_DATE
        FROM TF_YWPN_COSTRLPRICE_W WHERE
        YEAR = #{year} ) GROUP BY UP_DATE)
        AND YEAR = #{year}
        ORDER BY UP_DATE ASC
    </select>
    <select id="selectRealityPriceMonthData" resultType="java.util.Map">
        SELECT
        <include refid="priceReslut"/>
        FROM
        TF_YWPN_COSTRLPRICE_W WHERE ID IN
        (SELECT MAX(ID) FROM (SELECT ID, YEAR,TO_CHAR(UP_DATE , 'yyyy-MM') UP_DATE FROM TF_YWPN_COSTRLPRICE_W
        WHERE YEAR IN (${year}) and
        TO_CHAR(UP_DATE,'MM') IN (${month}) )
        GROUP BY UP_DATE)
        AND YEAR IN (${year})
        ORDER BY UP_DATE ASC
    </select>

    <select id="selectPriceMonthByYear" resultType="java.util.Map">
        SELECT
        <include refid="priceReslut"/>
        FROM
        ${tableName} WHERE ID IN (SELECT MAX(ID) FROM (SELECT ID , YEAR FROM ${tableName}
        WHERE
        TO_CHAR(CREATE_TIME,'yyyy') IN
        <foreach collection="fileterYear" item="fileteryear" open="(" close=")" separator=",">
            #{fileteryear}
        </foreach>
        and TO_CHAR(CREATE_TIME,'MM') <![CDATA[ <= ]]> #{monthStr} ) GROUP BY YEAR)
        ORDER BY YEAR ASC
    </select>
    <select id="getProduceDataYearPlan" resultMap="costbgwaterMap">
        SELECT MONTH,
               round(SUM(GSL_ONE), 4)                                                                               GSL_ONE,
               round(SUM(GSL_TWO), 4)                                                                               GSL_TWO,
               round(SUM(GSL_QBJ), 4)                                                                               GSL_QBJ,
               round(SUM(GSL_TOTAL), 4)                                                                             GSL_TOTAL,
               round(SUM(ZSL_ONE), 4)                                                                               ZSL_ONE,
               round(SUM(ZSL_TWO), 4)                                                                               ZSL_TWO,
               round(SUM(ZSL_HQSK), 4)                                                                              ZSL_HQSK,
               round(SUM(ZSL_TOTAL), 4)                                                                             ZSL_TOTAL,
               round(SUM(SSL_TOTAL), 4)                                                                             SSL_TOTAL,
               round(SUM(ZYSL_ONE), 4)                                                                              ZYSL_ONE,
               round(SUM(ZYSL_TWO), 4)                                                                              ZYSL_TWO,
               round(SUM(ZYSL_TOTAL), 4)                                                                            ZYSL_TOTAL,
               round((SUM(ZYSL_ONE) / nullif(sum(ZSL_ONE), 0)) * 100, 2)                                            ZYSLL_ONE,
               round((SUM(ZYSL_TWO) / nullif(sum(ZSL_TWO), 0)) * 100, 2)                                            ZYSLL_TWO,
               round((SUM(ZYSL_TOTAL) / nullif(sum(ZSL_TOTAL), 0)) * 100, 2)                                        ZYSLL_TOTAL,
               round(SUM(WSPSL), 4)                                                                                 WSPSL,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) * 100, 2) CXC,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) / (sum(GSL_QBJ) + sum(GSL_TOTAL))) *
                     100, 2)                                                                                        LSL
        FROM (SELECT SUBSTR(MONTH, 1, 4) MONTH,
                     GSL_ONE,
                     GSL_TWO,
                     GSL_QBJ,
                     GSL_TOTAL,
                     ZSL_ONE,
                     ZSL_TWO,
                     ZSL_HQSK,
                     ZSL_TOTAL,
                     SSL_TOTAL,
                     ZYSL_ONE,
                     ZYSL_TWO,
                     ZYSL_TOTAL,
                     WSPSL
              FROM TF_YWPN_COSTBGWATER_W
              WHERE SUBSTR(MONTH, 1, 4) IN (${startYear}))
        GROUP BY MONTH
        order by month
    </select>
    <select id="egtProduceDataMonthByYaerPlan" resultMap="costbgwaterMap">
        SELECT MONTH,
               round(GSL_ONE, 4)     GSL_ONE,
               round(GSL_TWO, 4)     GSL_TWO,
               round(GSL_QBJ, 4)     GSL_QBJ,
               round(GSL_TOTAL, 4)   GSL_TOTAL,
               round(ZSL_ONE, 4)     ZSL_ONE,
               round(ZSL_TWO, 4)     ZSL_TWO,
               round(ZSL_HQSK, 4)    ZSL_HQSK,
               round(ZSL_TOTAL, 4)   ZSL_TOTAL,
               round(SSL_TOTAL, 4)   SSL_TOTAL,
               round(ZYSL_ONE, 4)    ZYSL_ONE,
               round(ZYSL_TWO, 4)    ZYSL_TWO,
               round(ZYSL_TOTAL, 4)  ZYSL_TOTAL,
               round(ZYSLL_ONE, 4)   ZYSLL_ONE,
               round(ZYSLL_TWO, 4)   ZYSLL_TWO,
               round(ZYSLL_TOTAL, 4) ZYSLL_TOTAL,
               round(WSPSL, 4)       WSPSL,
               round(CXC, 4)         CXC,
               round(LSL, 4)         LSL
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) = #{year}
        order by month
    </select>

    <select id="getProduceDataMonthPlan" resultMap="costbgwaterMap">
        SELECT MONTH,
               round(GSL_ONE, 4)     GSL_ONE,
               round(GSL_TWO, 4)     GSL_TWO,
               round(GSL_QBJ, 4)     GSL_QBJ,
               round(GSL_TOTAL, 4)   GSL_TOTAL,
               round(ZSL_ONE, 4)     ZSL_ONE,
               round(ZSL_TWO, 4)     ZSL_TWO,
               round(ZSL_HQSK, 4)    ZSL_HQSK,
               round(ZSL_TOTAL, 4)   ZSL_TOTAL,
               round(SSL_TOTAL, 4)   SSL_TOTAL,
               round(ZYSL_ONE, 4)    ZYSL_ONE,
               round(ZYSL_TWO, 4)    ZYSL_TWO,
               round(ZYSL_TOTAL, 4)  ZYSL_TOTAL,
               round(ZYSLL_ONE, 4)   ZYSLL_ONE,
               round(ZYSLL_TWO, 4)   ZYSLL_TWO,
               round(ZYSLL_TOTAL, 4) ZYSLL_TOTAL,
               round(WSPSL, 4)       WSPSL,
               round(CXC, 4)         CXC,
               round(LSL, 4)         LSL
        FROM TF_YWPN_COSTBGWATER_W
        WHERE SUBSTR(MONTH, 1, 4) IN (${year})
          and SUBSTR(MONTH, -2) IN (${month})
        order by MONTH
    </select>


</mapper>
