<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 5.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tofly.xrtygis.custom.mapper.WaterMakingMapper">

    <select id="getTableInfo" resultType="long">
        select ID
        from ${table}
        where MARK = #{mark}
        <if test="mark ==0">
            and to_char(up_date,'yyyy-mm-dd') = to_char(#{update},'yyyy-mm-dd')
        </if>
        <if test="mark == 1">
            and to_char(up_date,'yyyy-mm') = to_char(#{update},'yyyy-mm')
        </if>
    </select>

    <select id="getPriceID" resultType="long">
        select ID
        from TF_YWPN_COSTRLPRICE_W
        where ISNEW = '1'
          and YEAR = to_char(#{date}, 'yyyy')
    </select>

    <select id="simulationCorrection" resultType="map">
        select to_char(w.UP_DATE, 'yyyy-mm') 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,
               zysll_one,
               zysll_two,
               zysll_total,
               wspsl,
               cxc,
               lsl,
               pac_one,
               pac_two,
               sy_one,
               yl_two,
               pam,
               ft,
               cn,
               gmsjfhy,
               pam_wy,
               bcs,
               wnzl,
               dldl_one,
               dldl_two,
               dldl_total,
               jbdl_one,
               jbdl_two,
               jbdl_total,
               other,
               paczfy_one,
               paczfy_two,
               syzfy_one,
               ylzfy_two,
               pamzszfy,
               ftzfy,
               cnzfy,
               gmsjfhyzfy,
               pamwnzfy,
               bcszfy,
               wnzyf,
               jbdf_one,
               jbdf_two,
               jbdf_total,
               dldf_one,
               dldf_two,
               dldf_total,
               ysf,
               szysf_one,
               szysf_two,
               szysf_total,
               dfcb_one,
               dfcb_two,
               dfcb_total,
               paccb_one,
               sycb_one,
               cncb_one,
               bcscb_one,
               zsclcb_one,
               paccb_two,
               ylcb_two,
               pamzscb_two,
               ftcb_two,
               gmsjfhycb_two,
               pamwncb_two,
               wnzycb_two,
               zsclcb_two,
               zsclcb_total,
               ysfcb,
               szysfcb_one,
               szysfcb_two,
               szysfcb_total,
               zfy_one,
               zfy_two,
               dwcb_one,
               dwcb_two,
               dwcb_total,
               zzsclfy_one,
               zzsclfy_two,
               zfy,
               otherzfy,
               othercb,
               pacdh_one,
               pacdh_two,
               sydh_one,
               yldh_two,
               dh_one,
               dh_two,
               dh_total,
               cndh,
               gmsjfhydh,
               pamdh,
               pam_wydh,
               wnzldh,
               ftdh,
               bcsdh,
               otherdh
        from (TF_YWPN_COSTRLWATER_W w
            left join TF_YWPN_COSTRLFIXED_W f on
                    to_char(w.UP_DATE, 'yyyy-mm') = to_char(f.UP_DATE, 'yyyy-mm') and w.MARK = f.MARK)
                 left join TF_YWPN_COSTRLUNIT_W u
                           on to_char(w.UP_DATE, 'yyyy-mm') = to_char(u.UP_DATE, 'yyyy-mm') and w.MARK = u.MARK
        where w.MARK = 1
          and to_char(w.UP_DATE, 'yyyy-mm') = #{month}
    </select>

    <select id="simulationCorrectionYear" resultType="map">
        select extract(YEAR FROM w.UP_DATE)                                                         year,
               sum(gsl_one)                                                                         gsl_one,
               sum(gsl_two)                                                                         gsl_two,
               sum(gsl_qbj)                                                                         gsl_qbj,
               sum(gsl_total)                                                                       gsl_total,
               sum(zsl_one)                                                                         zsl_one,
               sum(zsl_two)                                                                         zsl_two,
               sum(zsl_hqsk)                                                                        zsl_hqsk,
               sum(zsl_total)                                                                       zsl_total,
               sum(ssl_total)                                                                       ssl_total,
               sum(zysl_one)                                                                        zysl_one,
               sum(zysl_two)                                                                        zysl_two,
               sum(zysl_total)                                                                      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_TOTAL) + sum(GSL_QBJ), 0)) *
                     100, 2)                                                                        cxc,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_TOTAL) + sum(GSL_QBJ), 0)) * 100, 2)                           lsl,
               sum(pac_one)                                                                         pac_one,
               sum(pac_two)                                                                         pac_two,
               sum(sy_one)                                                                          sy_one,
               sum(yl_two)                                                                          yl_two,
               sum(pam)                                                                             pam,
               sum(ft)                                                                              ft,
               sum(cn)                                                                              cn,
               sum(gmsjfhy)                                                                         gmsjfhy,
               sum(pam_wy)                                                                          pam_wy,
               sum(bcs)                                                                             bcs,
               sum(wnzl)                                                                            wnzl,
               sum(dldl_one)                                                                        dldl_one,
               sum(dldl_two)                                                                        dldl_two,
               sum(dldl_total)                                                                      dldl_total,
               sum(jbdl_one)                                                                        jbdl_one,
               sum(jbdl_two)                                                                        jbdl_two,
               sum(jbdl_total)                                                                      jbdl_total,
               sum(other)                                                                           other,
               sum(paczfy_one)                                                                      paczfy_one,
               sum(paczfy_two)                                                                      paczfy_two,
               sum(syzfy_one)                                                                       syzfy_one,
               sum(ylzfy_two)                                                                       ylzfy_two,
               sum(pamzszfy)                                                                        pamzszfy,
               sum(ftzfy)                                                                           ftzfy,
               sum(cnzfy)                                                                           cnzfy,
               sum(gmsjfhyzfy)                                                                      gmsjfhyzfy,
               sum(pamwnzfy)                                                                        pamwnzfy,
               sum(bcszfy)                                                                          bcszfy,
               sum(wnzyf)                                                                           wnzyf,
               sum(jbdf_one)                                                                        jbdf_one,
               sum(jbdf_two)                                                                        jbdf_two,
               sum(jbdf_total)                                                                      jbdf_total,
               sum(dldf_one)                                                                        dldf_one,
               sum(dldf_two)                                                                        dldf_two,
               sum(dldf_total)                                                                      dldf_total,
               sum(ysf)                                                                             ysf,
               sum(szysf_one)                                                                       szysf_one,
               sum(szysf_two)                                                                       szysf_two,
               sum(szysf_total)                                                                     szysf_total,
               round(((sum(JBDF_ONE) + sum(DLDF_ONE)) / nullif(sum(GSL_ONE), 0)) * 1000, 5)         dfcb_one,
               round(((sum(JBDF_TWO) + sum(DLDF_TWO)) / nullif(sum(GSL_TWO), 0)) * 1000, 5)         dfcb_two,
               round(((sum(JBDF_TOTAL) + sum(DLDF_TOTAL)) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)   dfcb_total,
               round((sum(PACZFY_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                         paccb_one,
               round((sum(SYZFY_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                          sycb_one,
               round((sum(CNZFY) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                              cncb_one,
               round((sum(BCSZFY) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                             bcscb_one,
               round((sum(ZZSCLFY_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                        zsclcb_one,
               round((sum(PACZFY_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                         paccb_two,
               round((sum(YLZFY_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                          ylcb_two,
               round((sum(PAMZSZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                           pamzscb_two,
               round((sum(FTZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                              ftcb_two,
               round((sum(GMSJFHYZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                         gmsjfhycb_two,
               round((sum(PAMWNZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                           pamwncb_two,
               round((sum(WNZYF) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                              wnzycb_two,
               round((sum(ZZSCLFY_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                        zsclcb_two,
               round(((sum(ZZSCLFY_ONE) + sum(ZZSCLFY_TWO)) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5) zsclcb_total,
               round((sum(YSF) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                                ysfcb,
               round((sum(SZYSF_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                          szysfcb_one,
               round((sum(SZYSF_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                          szysfcb_two,
               round((sum(SZYSF_TOTAL) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                      szysfcb_total,
               sum(ZFY_ONE)                                                                         zfy_one,
               sum(ZFY_TWO)                                                                         zfy_two,
               round((sum(ZFY_ONE) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                          dwcb_one,
               round((sum(ZFY_TWO) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                          dwcb_two,
               round((sum(ZFY) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                              dwcb_total,
               sum(zzsclfy_one)                                                                     zzsclfy_one,
               sum(zzsclfy_two)                                                                     zzsclfy_two,
               sum(ZFY)                                                                             zfy,
               sum(otherzfy)                                                                        otherzfy,
               round(sum(OTHER) / nullif(sum(GSL_TOTAL) * 10, 0), 5)                                othercb,
               round(sum(PAC_ONE) / nullif(sum(GSL_ONE) * 10, 0), 5)                                pacdh_one,
               round(sum(PAC_TWO) / nullif(sum(GSL_TWO) * 10, 0), 5)                                pacdh_two,
               round(sum(SY_ONE) / nullif(sum(GSL_ONE) * 10, 0), 5)                                 sydh_one,
               round(sum(YL_TWO) / nullif(sum(GSL_TWO) * 10, 0), 5)                                 yldh_two,
               round(sum(DLDL_ONE) / nullif(sum(GSL_ONE) * 10, 0), 5)                               dh_one,
               round(sum(DLDL_TWO) / nullif(sum(GSL_TWO) * 10, 0), 5)                               dh_two,
               round(sum(DLDL_TOTAL) / nullif(sum(GSL_TOTAL) * 10, 0), 5)                           dh_total,
               round(sum(CN) / nullif(sum(GSL_ONE) * 10, 0), 5)                                     cndh,
               round(sum(GMSJFHY) / nullif(sum(GSL_TWO) * 10, 0), 5)                                gmsjfhydh,
               round(sum(PAM) / nullif(sum(GSL_TWO) * 10, 0), 5)                                    pamdh,
               round(sum(PAM_WY) / nullif(sum(GSL_TWO) * 10, 0), 5)                                 pam_wydh,
               round(sum(GMSJFHY) / nullif(sum(GSL_TWO) * 10, 0), 5)                                wnzldh,
               round(sum(FT) / nullif(sum(GSL_TWO) * 10, 0), 5)                                     ftdh,
               round(sum(BCS) / nullif(sum(GSL_ONE) * 10, 0), 5)                                    bcsdh,
               round(sum(OTHER) / nullif(sum(GSL_TOTAL) * 10, 0), 5)                                otherdh
        from (TF_YWPN_COSTRLWATER_W w
                 left join TF_YWPN_COSTRLFIXED_W f on
                extract(year from w.UP_DATE) = extract(year from f.UP_DATE) and w.MARK = f.MARK)
        where w.MARK = 1
          and extract(year from w.UP_DATE) = #{year}
        group by extract(YEAR FROM w.UP_DATE)
    </select>

    <select id="getMonthPlanYear" resultType="map">
        select substr(w.MONTH, 1, 4)                                                                year,
               sum(gsl_one)                                                                         gsl_one,
               sum(gsl_two)                                                                         gsl_two,
               sum(gsl_qbj)                                                                         gsl_qbj,
               sum(gsl_total)                                                                       gsl_total,
               sum(zsl_one)                                                                         zsl_one,
               sum(zsl_two)                                                                         zsl_two,
               sum(zsl_hqsk)                                                                        zsl_hqsk,
               sum(zsl_total)                                                                       zsl_total,
               sum(ssl_total)                                                                       ssl_total,
               sum(zysl_one)                                                                        zysl_one,
               sum(zysl_two)                                                                        zysl_two,
               sum(zysl_total)                                                                      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_TOTAL) + sum(GSL_QBJ), 0)) *
                     100, 2)                                                                        cxc,
               round(((sum(GSL_TOTAL) + sum(GSL_QBJ) - sum(SSL_TOTAL) - sum(WSPSL)) /
                      nullif(sum(GSL_TOTAL) + sum(GSL_QBJ), 0)) * 100, 2)                           lsl,
               sum(pac_one)                                                                         pac_one,
               sum(pac_two)                                                                         pac_two,
               sum(sy_one)                                                                          sy_one,
               sum(yl_two)                                                                          yl_two,
               sum(pam)                                                                             pam,
               sum(ft)                                                                              ft,
               sum(cn)                                                                              cn,
               sum(gmsjfhy)                                                                         gmsjfhy,
               sum(pam_wn)                                                                          pam_wn,
               sum(bcs)                                                                             bcs,
               sum(wnzl)                                                                            wnzl,
               sum(dldl_one)                                                                        dldl_one,
               sum(dldl_two)                                                                        dldl_two,
               sum(dldl_total)                                                                      dldl_total,
               sum(jbdl_one)                                                                        jbdl_one,
               sum(jbdl_two)                                                                        jbdl_two,
               sum(jbdl_total)                                                                      jbdl_total,
               sum(other)                                                                           other,
               sum(paczfy_one)                                                                      paczfy_one,
               sum(paczfy_two)                                                                      paczfy_two,
               sum(syzfy_one)                                                                       syzfy_one,
               sum(ylzfy_two)                                                                       ylzfy_two,
               sum(pamzszfy)                                                                        pamzszfy,
               sum(ftzfy)                                                                           ftzfy,
               sum(cnzfy)                                                                           cnzfy,
               sum(gmsjfhyzfy)                                                                      gmsjfhyzfy,
               sum(pamwnzfy)                                                                        pamwnzfy,
               sum(bcszfy)                                                                          bcszfy,
               sum(wnzyf)                                                                           wnzyf,
               sum(jbdf_one)                                                                        jbdf_one,
               sum(jbdf_two)                                                                        jbdf_two,
               sum(jbdf_total)                                                                      jbdf_total,
               sum(dldf_one)                                                                        dldf_one,
               sum(dldf_two)                                                                        dldf_two,
               sum(dldf_total)                                                                      dldf_total,
               sum(ysf)                                                                             ysf,
               sum(szysf_one)                                                                       szysf_one,
               sum(szysf_two)                                                                       szysf_two,
               sum(szysf_total)                                                                     szysf_total,
               round(((sum(JBDF_ONE) + sum(DLDF_ONE)) / nullif(sum(GSL_ONE), 0)) * 1000, 5)         dfcb_one,
               round(((sum(JBDF_TWO) + sum(DLDF_TWO)) / nullif(sum(GSL_TWO), 0)) * 1000, 5)         dfcb_two,
               round(((sum(JBDF_TOTAL) + sum(DLDF_TOTAL)) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)   dfcb_total,
               round((sum(PACZFY_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                         paccb_one,
               round((sum(SYZFY_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                          sycb_one,
               round((sum(CNZFY) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                              cncb_one,
               round((sum(BCSZFY) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                             bcscb_one,
               round((sum(ZZSCLFY_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                        zsclcb_one,
               round((sum(PACZFY_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                         paccb_two,
               round((sum(YLZFY_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                          ylcb_two,
               round((sum(PAMZSZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                           pamzscb_two,
               round((sum(FTZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                              ftcb_two,
               round((sum(GMSJFHYZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                         gmsjfhycb_two,
               round((sum(PAMWNZFY) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                           pamwncb_two,
               round((sum(WNZYF) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                              wnzycb_two,
               round((sum(ZZSCLFY_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                        zsclcb_two,
               round(((sum(ZZSCLFY_ONE) + sum(ZZSCLFY_TWO)) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5) zsclcb_total,
               round((sum(YSF) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                                ysfcb,
               round((sum(SZYSF_ONE) / nullif(sum(GSL_ONE), 0)) * 1000, 5)                          szysfcb_one,
               round((sum(SZYSF_TWO) / nullif(sum(GSL_TWO), 0)) * 1000, 5)                          szysfcb_two,
               round((sum(SZYSF_TOTAL) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                      szysfcb_total,
               sum(ZFY_ONE)                                                                         zfy_one,
               sum(ZFY_TWO)                                                                         zfy_two,
               round((sum(ZFY_ONE) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                          dwcb_one,
               round((sum(ZFY_TWO) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                          dwcb_two,
               round((sum(ZFY) / nullif(sum(GSL_TOTAL), 0)) * 1000, 5)                              dwcb_total,
               sum(zzsclfy_one)                                                                     zzsclfy_one,
               sum(zzsclfy_two)                                                                     zzsclfy_two,
               sum(ZFY)                                                                             zfy,
               sum(otherzfy)                                                                        otherzfy,
               round(sum(OTHER) / nullif(sum(GSL_TOTAL) * 10, 0), 5)                                othercb,
               round(sum(PAC_ONE) / nullif(sum(GSL_ONE) * 10, 0), 5)                                pacdh_one,
               round(sum(PAC_TWO) / nullif(sum(GSL_TWO) * 10, 0), 5)                                pacdh_two,
               round(sum(SY_ONE) / nullif(sum(GSL_ONE) * 10, 0), 5)                                 sydh_one,
               round(sum(YL_TWO) / nullif(sum(GSL_TWO) * 10, 0), 5)                                 yldh_two,
               round(sum(DLDL_ONE) / nullif(sum(GSL_ONE) * 10, 0), 5)                               dh_one,
               round(sum(DLDL_TWO) / nullif(sum(GSL_TWO) * 10, 0), 5)                               dh_two,
               round(sum(DLDL_TOTAL) / nullif(sum(GSL_TOTAL) * 10, 0), 5)                           dh_total,
               round(sum(CN) / nullif(sum(GSL_ONE) * 10, 0), 5)                                     cndh,
               round(sum(GMSJFHY) / nullif(sum(GSL_TWO) * 10, 0), 5)                                gmsjfhydh,
               round(sum(PAM) / nullif(sum(GSL_TWO) * 10, 0), 5)                                    pamdh,
               round(sum(PAM_WN) / nullif(sum(GSL_TWO) * 10, 0), 5)                                 pam_wndh,
               round(sum(GMSJFHY) / nullif(sum(GSL_TWO) * 10, 0), 5)                                wnzldh,
               round(sum(FT) / nullif(sum(GSL_TWO) * 10, 0), 5)                                     ftdh,
               round(sum(BCS) / nullif(sum(GSL_ONE) * 10, 0), 5)                                    bcsdh,
               round(sum(OTHER) / nullif(sum(GSL_TOTAL) * 10, 0), 5)                                otherdh
        from TF_YWPN_COSTBGWATER_W w
                 left join TF_YWPN_COSTBGFIXED_W f on
            substr(w.MONTH, 1, 4) = substr(f.MOUTH, 1, 4)
                 left join TF_YWPN_COSTBGINDEX_W i
                           on substr(i.MONTH, 1, 4) = substr(w.MONTH, 1, 4)
        where substr(w.MONTH, 1, 4) = #{year}
        group by substr(w.MONTH, 1, 4)
    </select>

    <select id="getMonthPlan" resultType="map">
        SELECT a.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,
               zysll_one,
               zysll_two,
               zysll_total,
               wspsl,
               cxc,
               lsl,
               pac_one,
               pac_two,
               sy_one,
               yl_two,
               pam,
               ft,
               cn,
               gmsjfhy,
               pam_wn,
               bcs,
               wnzl,
               dldl_one,
               dldl_two,
               dldl_total,
               jbdl_one,
               jbdl_two,
               jbdl_total,
               other,
               paczfy_one,
               paczfy_two,
               syzfy_one,
               ylzfy_two,
               pamzszfy,
               ftzfy,
               cnzfy,
               gmsjfhyzfy,
               pamwnzfy,
               bcszfy,
               wnzyf,
               jbdf_one,
               jbdf_two,
               jbdf_total,
               dldf_one,
               dldf_two,
               dldf_total,
               ysf,
               szysf_one,
               szysf_two,
               szysf_total,
               dfcb_one,
               dfcb_two,
               dfcb_total,
               paccb_one,
               sycb_one,
               cncb_one,
               bcscb_one,
               zsclcb_one,
               paccb_two,
               ylcb_two,
               pamzscb_two,
               ftcb_two,
               gmsjfhycb_two,
               pamwncb_two,
               wnzycb_two,
               zsclcb_two,
               zsclcb_total,
               ysfcb,
               szysfcb_one,
               szysfcb_two,
               szysfcb_total,
               zfy_one,
               zfy_two,
               dwcb_one,
               dwcb_two,
               dwcb_total,
               zzsclfy_one,
               zzsclfy_two,
               zfy,
               otherzfy,
               othercb,
               pacdh_one,
               pacdh_two,
               sydh_one,
               yldh_two,
               dh_one,
               dh_two,
               dh_total,
               round(CN / (nullif(ZSL_TWO, 0) * 10), 5)      cndh,
               round(GMSJFHY / (nullif(ZSL_TWO, 0) * 10), 5) gmsjfhydh,
               round(PAM / (nullif(ZSL_TWO, 0) * 10), 5)     pamdh,
               round(PAM_WN / (nullif(ZSL_TWO, 0) * 10), 5)  pam_wydh,
               round(WNZL / (nullif(ZSL_TWO, 0) * 10), 5)    wnzldh,
               round(FT / (nullif(ZSL_TWO, 0) * 10), 5)      ftdh,
               round(BCS / (nullif(ZSL_ONE, 0) * 10), 5)     bcsdh,
               round(OTHER / (nullif(ZSL_TOTAL, 0) * 10), 5) otherdh
        FROM (select *
              from TF_YWPN_COSTBGWATER_W w
                       full join (TF_YWPN_COSTBGINDEX_W i full join TF_YWPN_COSTBGUNIT_W u on i.MONTH = u.MONTH)
                                 on w.MONTH = u.MONTH) a
                 LEFT JOIN TF_YWPN_COSTBGFIXED_W b ON a.MONTH = b.MOUTH
        where a.MONTH = #{month}
    </select>

    <select id="countWater" resultType="long">
        SELECT count(*)
        FROM TF_YWPN_COSTRLWATER_W
        WHERE to_char(up_date, 'yyyy-mm') = #{month}
          AND mark = 0
    </select>

    <select id="getWaterInfo" resultType="com.tofly.xrtygis.entity.Costrlwater">
        select up_date,
        gsl_one,
        gsl_two,
        gsl_qbj,
        gsl_total,
        zsl_one,
        zsl_two,
        zsl_hqsk,
        zsl_total,
        ssl_total,
        zysl_one,
        zysl_two,
        zysl_total,
        zysll_one,
        zysll_two,
        zysll_total,
        wspsl,
        cxc,
        lsl,
        pac_one,
        pac_two,
        sy_one,
        yl_two,
        pam,
        ft,
        cn,
        gmsjfhy,
        pam_wy,
        bcs,
        wnzl,
        dldl_one,
        dldl_two,
        dldl_total,
        jbdl_one,
        jbdl_two,
        jbdl_total,
        mark,
        other
        from TF_YWPN_COSTRLWATER_W
        where MARK = #{mark}
        <if test="mark == 0">
            and to_char(up_date,'yyyy-mm-dd') = to_char(#{update},'yyyy-mm-dd')
        </if>
        <if test="mark == 1">
            and to_char(up_date,'yyyy-mm') = to_char(#{update},'yyyy-mm')
        </if>
    </select>

    <select id="getWaterInfoSum" resultType="com.tofly.xrtygis.custom.entity.dto.WaterInfoDto">
        select sum(GSL_ONE)    gslOne,
               sum(GSL_TWO)    gslTwo,
               sum(GSL_TOTAL)  gslTotal,
               sum(SSL_TOTAL)  ssl,
               sum(WSPSL)      wspsl,
               sum(GSL_QBJ)    gslQbj,
               sum(JBDL_ONE)   jbdlOne,
               sum(JBDL_TWO)   jbdlTwo,
               sum(JBDL_TOTAL) jbdlTotal
        from TF_YWPN_COSTRLWATER_W
        where MARK = '0'
          and to_char(UP_DATE, 'yyyy-mm') = to_char(#{date}, 'yyyy-mm')
    </select>

    <select id="getWater" resultType="com.tofly.xrtygis.entity.Costrlwater">
        select *
        from TF_YWPN_COSTRLWATER_W
        where MARK = #{mark}
          and to_char(UP_DATE, 'yyyy-mm-dd') = to_char(#{date}, 'yyyy-mm-dd')
    </select>
</mapper>