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

    <resultMap id="costbgpriceMap" type="com.tofly.xrtygis.entity.Costbgprice">
        <id property="id" column="ID"/>
        <result property="year" column="YEAR"/>
        <result property="pacdj" column="PACDJ"/>
        <result property="yldj" column="YLDJ"/>
        <result property="pamZsdj" column="PAM_ZSDJ"/>
        <result property="pamWndj" column="PAM_WNDJ"/>
        <result property="ftdj" column="FTDJ"/>
        <result property="cndj" column="CNDJ"/>
        <result property="gmsjfhydj" column="GMSJFHYDJ"/>
        <result property="sydj" column="SYDJ"/>
        <result property="dlddjOne" column="DLDDJ_ONE"/>
        <result property="dlddjTwo" column="DLDDJ_TWO"/>
        <result property="wnzydj" column="WNZYDJ"/>
        <result property="ysfdj" column="YSFDJ"/>
        <result property="szysdj" column="SZYSDJ"/>
        <result property="bcsdj" column="BCSDJ"/>
        <result property="snew" column="SNEW"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="pac2dj" column="PAC2DJ"/>
        <result property="qbjzgdj" column="QBJZGDJ"/>
        <result property="otherdj" column="OTHERDJ"/>
        <result property="jbdldjOne" column="JBDLDJ_ONE"/>
        <result property="jbdldjTwo" column="JBDLDJ_TWO"/>
        <result property="upDate" column="UP_DATE"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"/>
    </resultMap>

    <!--    成本数据的字段 -->
    <sql id="costDataSql">
        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
    </sql>

    <select id="getCostDataYearPlan" resultMap="costbgfixedMap">
        SELECT MOUTH,
               nvl(SUM (PACZFY_ONE)    ,0) PACZFY_ONE,
               nvl(SUM (PACZFY_TWO)    ,0) PACZFY_TWO,
               nvl(SUM (SYZFY_ONE)     ,0) SYZFY_ONE,
               nvl(SUM (YLZFY_TWO)     ,0) YLZFY_TWO,
               nvl(SUM (PAMZSZFY)      ,0) PAMZSZFY,
               nvl(SUM (FTZFY)         ,0) FTZFY,
               nvl(SUM (CNZFY)         ,0) CNZFY,
               nvl(SUM (GMSJFHYZFY)    ,0) GMSJFHYZFY,
               nvl(SUM (PAMWNZFY)      ,0) PAMWNZFY,
               nvl(SUM (BCSZFY)        ,0) BCSZFY,
               nvl(SUM (WNZYF)         ,0) WNZYF,
               nvl(SUM (JBDF_ONE)      ,0) JBDF_ONE,
               nvl(SUM (JBDF_TWO)      ,0) JBDF_TWO,
               nvl(SUM (JBDF_TOTAL)    ,0) JBDF_TOTAL,
               nvl(SUM (DLDF_ONE)      ,0) DLDF_ONE,
               nvl(SUM (DLDF_TWO)      ,0) DLDF_TWO,
               nvl(SUM (DLDF_TOTAL)    ,0) DLDF_TOTAL,
               nvl(SUM (YSF)           ,0) YSF,
               nvl(SUM (SZYSF_ONE)     ,0) SZYSF_ONE,
               nvl(SUM (SZYSF_TWO)     ,0) SZYSF_TWO,
               nvl(SUM (SZYSF_TOTAL)   ,0) SZYSF_TOTAL,
               nvl(SUM (DFCB_ONE)      ,0) DFCB_ONE,
               nvl(SUM (DFCB_TWO)      ,0) DFCB_TWO,
               nvl(SUM (DFCB_TOTAL)    ,0) DFCB_TOTAL,
               nvl(SUM (PACCB_ONE)     ,0) PACCB_ONE,
               nvl(SUM (SYCB_ONE)      ,0) SYCB_ONE,
               nvl(SUM (CNCB_ONE)      ,0) CNCB_ONE,
               nvl(SUM (BCSCB_ONE)     ,0) BCSCB_ONE,
               nvl(SUM (ZSCLCB_ONE)    ,0) ZSCLCB_ONE,
               nvl(SUM (PACCB_TWO)     ,0) PACCB_TWO,
               nvl(SUM (YLCB_TWO)      ,0) YLCB_TWO,
               nvl(SUM (PAMZSCB_TWO)   ,0) PAMZSCB_TWO,
               nvl(SUM (FTCB_TWO)      ,0) FTCB_TWO,
               nvl(SUM (GMSJFHYCB_TWO) ,0) GMSJFHYCB_TWO,
               nvl(SUM (PAMWNCB_TWO)   ,0) PAMWNCB_TWO,
               nvl(SUM (WNZYCB_TWO)    ,0) WNZYCB_TWO,
               nvl(SUM (ZSCLCB_TWO)    ,0) ZSCLCB_TWO,
               nvl(SUM (ZSCLCB_TOTAL)  ,0) ZSCLCB_TOTAL,
               nvl(SUM (YSFCB)         ,0) YSFCB,
               nvl(SUM (SZYSFCB_ONE)   ,0) SZYSFCB_ONE,
               nvl(SUM (SZYSFCB_TWO)   ,0) SZYSFCB_TWO,
               nvl(SUM (SZYSFCB_TOTAL) ,0) SZYSFCB_TOTAL,
               nvl(SUM (ZFY_ONE)       ,0) ZFY_ONE,
               nvl(SUM (ZFY_TWO)       ,0) ZFY_TWO,
               nvl(SUM (DWCB_ONE)      ,0) DWCB_ONE,
               nvl(SUM (DWCB_TWO)      ,0) DWCB_TWO,
               nvl(SUM (DWCB_TOTAL)    ,0) DWCB_TOTAL,
               nvl(SUM (ZZSCLFY_ONE)   ,0) ZZSCLFY_ONE,
               nvl(SUM (ZZSCLFY_TWO)   ,0) ZZSCLFY_TWO,
               nvl(SUM (ZFY)           ,0) ZFY
        FROM (SELECT
        SUBSTR(MOUTH, 1, 4) MOUTH,
        <include refid="costDataSql"></include>
        FROM TF_YWPN_COSTBGFIXED_W WHERE SUBSTR(MOUTH, 1, 4) IN (${startYear}))
        GROUP BY MOUTH ORDER BY MOUTH ASC
    </select>


    <select id="getCostDataYearReality" resultMap="costrlfixedMap">
        SELECT UP_DATE,
        nvl(SUM(PACZFY_ONE)     ,0) PACZFY_ONE,
        nvl(SUM(PACZFY_TWO)     ,0) PACZFY_TWO,
        nvl(SUM(SYZFY_ONE)      ,0) SYZFY_ONE,
        nvl(SUM(YLZFY_TWO)      ,0) YLZFY_TWO,
        nvl(SUM(PAMZSZFY)       ,0) PAMZSZFY,
        nvl(SUM(FTZFY)          ,0) FTZFY,
        nvl(SUM(CNZFY)          ,0) CNZFY,
        nvl(SUM(GMSJFHYZFY)     ,0) GMSJFHYZFY,
        nvl(SUM(PAMWNZFY)       ,0) PAMWNZFY,
        nvl(SUM(BCSZFY)         ,0) BCSZFY,
        nvl(SUM(WNZYF)          ,0) WNZYF,
        nvl(SUM(JBDF_ONE)       ,0) JBDF_ONE,
        nvl(SUM(JBDF_TWO)       ,0) JBDF_TWO,
        nvl(SUM(JBDF_TOTAL)     ,0) JBDF_TOTAL,
        nvl(SUM(DLDF_ONE)       ,0) DLDF_ONE,
        nvl(SUM(DLDF_TWO)       ,0) DLDF_TWO,
        nvl(SUM(DLDF_TOTAL)     ,0) DLDF_TOTAL,
        nvl(SUM(YSF)            ,0) YSF,
        nvl(SUM(SZYSF_ONE)      ,0) SZYSF_ONE,
        nvl(SUM(SZYSF_TWO)      ,0) SZYSF_TWO,
        nvl(SUM(SZYSF_TOTAL)    ,0) SZYSF_TOTAL,
        nvl(SUM(DFCB_ONE)       ,0) DFCB_ONE,
        nvl(SUM(DFCB_TWO)       ,0) DFCB_TWO,
        nvl(SUM(DFCB_TOTAL)     ,0) DFCB_TOTAL,
        nvl(SUM(PACCB_ONE)      ,0) PACCB_ONE,
        nvl(SUM(SYCB_ONE)       ,0) SYCB_ONE,
        nvl(SUM(CNCB_ONE)       ,0) CNCB_ONE,
        nvl(SUM(BCSCB_ONE)      ,0) BCSCB_ONE,
        nvl(SUM(ZSCLCB_ONE)     ,0) ZSCLCB_ONE,
        nvl(SUM(PACCB_TWO)      ,0) PACCB_TWO,
        nvl(SUM(YLCB_TWO)       ,0) YLCB_TWO,
        nvl(SUM(PAMZSCB_TWO)    ,0) PAMZSCB_TWO,
        nvl(SUM(FTCB_TWO)       ,0) FTCB_TWO,
        nvl(SUM(GMSJFHYCB_TWO)  ,0) GMSJFHYCB_TWO,
        nvl(SUM(PAMWNCB_TWO)    ,0) PAMWNCB_TWO,
        nvl(SUM(WNZYCB_TWO)     ,0) WNZYCB_TWO,
        nvl(SUM(ZSCLCB_TWO)     ,0) ZSCLCB_TWO,
        nvl(SUM(ZSCLCB_TOTAL)   ,0) ZSCLCB_TOTAL,
        nvl(SUM(YSFCB)          ,0) YSFCB,
        nvl(SUM(SZYSFCB_ONE)    ,0) SZYSFCB_ONE,
        nvl(SUM(SZYSFCB_TWO)    ,0) SZYSFCB_TWO,
        nvl(SUM(SZYSFCB_TOTAL)  ,0) SZYSFCB_TOTAL,
        nvl(SUM(ZFY_ONE)        ,0) ZFY_ONE,
        nvl(SUM(ZFY_TWO)        ,0) ZFY_TWO,
        nvl(SUM(DWCB_ONE)       ,0) DWCB_ONE,
        nvl(SUM(DWCB_TWO)       ,0) DWCB_TWO,
        nvl(SUM(DWCB_TOTAL)     ,0) DWCB_TOTAL,
        nvl(SUM(ZZSCLFY_ONE)    ,0) ZZSCLFY_ONE,
        nvl(SUM(ZZSCLFY_TWO)    ,0) ZZSCLFY_TWO,
        nvl(SUM(ZFY)            ,0) ZFY
        FROM (SELECT TO_CHAR(UP_DATE, 'yyyy') UP_DATE ,
        <include refid="costDataSql"></include>
        FROM TF_YWPN_COSTRLFIXED_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') IN (${startYear})
        and MARK = '1')
        GROUP BY UP_DATE
        ORDER BY UP_DATE ASC
    </select>

    <select id="getCostDataMonthByYearPlan" resultMap="costbgfixedMap">
        SELECT MOUTH,
        <include refid="costDataSql"></include>
        FROM TF_YWPN_COSTBGFIXED_W
        WHERE SUBSTR(MOUTH, 1, 4) = #{year} ORDER BY MOUTH ASC
    </select>
    <select id="getCostDataMonthByYearReality" resultMap="costrlfixedMap">
        SELECT TO_CHAR(UP_DATE, 'yyyy-MM') UP_DATE,
        <include refid="costDataSql"></include>
        FROM TF_YWPN_COSTRLFIXED_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') = #{year}
        and MARK = '1' ORDER BY UP_DATE ASC
    </select>
    <select id="getCostDataMonthPlan" resultMap="costbgfixedMap">
        SELECT MOUTH,
        <include refid="costDataSql"></include>
        FROM TF_YWPN_COSTBGFIXED_W
        WHERE SUBSTR(MOUTH, 1, 4) IN (${year})
        and SUBSTR(MOUTH, -2) IN (${month}) ORDER BY MOUTH ASC
    </select>
    <select id="getCostDataMonthReality" resultMap="costrlfixedMap">
        SELECT TO_CHAR(UP_DATE, 'yyyy-MM') UP_DATE,
        <include refid="costDataSql"></include>
        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 ASC
    </select>





    <resultMap id="costrlfixedMap" type="com.tofly.xrtygis.custom.entity.dataquery.FixedReality">
        <id property="id" column="ID"/>
        <result property="upDate" column="UP_DATE"/>
        <result property="paczfyOne" column="PACZFY_ONE"/>
        <result property="paczfyTwo" column="PACZFY_TWO"/>
        <result property="syzfyOne" column="SYZFY_ONE"/>
        <result property="ylzfyTwo" column="YLZFY_TWO"/>
        <result property="pamzszfy" column="PAMZSZFY"/>
        <result property="ftzfy" column="FTZFY"/>
        <result property="cnzfy" column="CNZFY"/>
        <result property="gmsjfhyzfy" column="GMSJFHYZFY"/>
        <result property="pamwnzfy" column="PAMWNZFY"/>
        <result property="bcszfy" column="BCSZFY"/>
        <result property="wnzyf" column="WNZYF"/>
        <result property="jbdfOne" column="JBDF_ONE"/>
        <result property="jbdfTwo" column="JBDF_TWO"/>
        <result property="jbdfTotal" column="JBDF_TOTAL"/>
        <result property="dldfOne" column="DLDF_ONE"/>
        <result property="dldfTwo" column="DLDF_TWO"/>
        <result property="dldfTotal" column="DLDF_TOTAL"/>
        <result property="ysf" column="YSF"/>
        <result property="szysfOne" column="SZYSF_ONE"/>
        <result property="szysfTwo" column="SZYSF_TWO"/>
        <result property="szysfTotal" column="SZYSF_TOTAL"/>
        <result property="dfcbOne" column="DFCB_ONE"/>
        <result property="dfcbTwo" column="DFCB_TWO"/>
        <result property="dfcbTotal" column="DFCB_TOTAL"/>
        <result property="paccbOne" column="PACCB_ONE"/>
        <result property="sycbOne" column="SYCB_ONE"/>
        <result property="cncbOne" column="CNCB_ONE"/>
        <result property="bcscbOne" column="BCSCB_ONE"/>
        <result property="zsclcbOne" column="ZSCLCB_ONE"/>
        <result property="paccbTwo" column="PACCB_TWO"/>
        <result property="ylcbTwo" column="YLCB_TWO"/>
        <result property="pamzscbTwo" column="PAMZSCB_TWO"/>
        <result property="ftcbTwo" column="FTCB_TWO"/>
        <result property="gmsjfhycbTwo" column="GMSJFHYCB_TWO"/>
        <result property="pamwncbTwo" column="PAMWNCB_TWO"/>
        <result property="wnzycbTwo" column="WNZYCB_TWO"/>
        <result property="zsclcbTwo" column="ZSCLCB_TWO"/>
        <result property="zsclcbTotal" column="ZSCLCB_TOTAL"/>
        <result property="ysfcb" column="YSFCB"/>
        <result property="szysfcbOne" column="SZYSFCB_ONE"/>
        <result property="szysfcbTwo" column="SZYSFCB_TWO"/>
        <result property="szysfcbTotal" column="SZYSFCB_TOTAL"/>
        <result property="zfyOne" column="ZFY_ONE"/>
        <result property="zfyTwo" column="ZFY_TWO"/>
        <result property="dwcbOne" column="DWCB_ONE"/>
        <result property="dwcbTwo" column="DWCB_TWO"/>
        <result property="dwcbTotal" column="DWCB_TOTAL"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="zzsclfyOne" column="ZZSCLFY_ONE"/>
        <result property="zzsclfyTwo" column="ZZSCLFY_TWO"/>
        <result property="zfy" column="ZFY"/>
        <result property="mark" column="MARK"/>
    </resultMap>
    <resultMap id="costbgfixedMap" type="com.tofly.xrtygis.custom.entity.dataquery.FixedPlan">
        <id property="id" column="ID"/>
        <result property="yearId" column="YEAR_ID"/>
        <result property="upDate" column="MOUTH"/>
        <result property="paczfyOne" column="PACZFY_ONE"/>
        <result property="paczfyTwo" column="PACZFY_TWO"/>
        <result property="syzfyOne" column="SYZFY_ONE"/>
        <result property="ylzfyTwo" column="YLZFY_TWO"/>
        <result property="pamzszfy" column="PAMZSZFY"/>
        <result property="ftzfy" column="FTZFY"/>
        <result property="cnzfy" column="CNZFY"/>
        <result property="gmsjfhyzfy" column="GMSJFHYZFY"/>
        <result property="pamwnzfy" column="PAMWNZFY"/>
        <result property="bcszfy" column="BCSZFY"/>
        <result property="wnzyf" column="WNZYF"/>
        <result property="jbdfOne" column="JBDF_ONE"/>
        <result property="jbdfTwo" column="JBDF_TWO"/>
        <result property="jbdfTotal" column="JBDF_TOTAL"/>
        <result property="dldfOne" column="DLDF_ONE"/>
        <result property="dldfTwo" column="DLDF_TWO"/>
        <result property="dldfTotal" column="DLDF_TOTAL"/>
        <result property="ysf" column="YSF"/>
        <result property="szysfOne" column="SZYSF_ONE"/>
        <result property="szysfTwo" column="SZYSF_TWO"/>
        <result property="szysfTotal" column="SZYSF_TOTAL"/>
        <result property="dfcbOne" column="DFCB_ONE"/>
        <result property="dfcbTwo" column="DFCB_TWO"/>
        <result property="dfcbTotal" column="DFCB_TOTAL"/>
        <result property="paccbOne" column="PACCB_ONE"/>
        <result property="sycbOne" column="SYCB_ONE"/>
        <result property="cncbOne" column="CNCB_ONE"/>
        <result property="bcscbOne" column="BCSCB_ONE"/>
        <result property="zsclcbOne" column="ZSCLCB_ONE"/>
        <result property="paccbTwo" column="PACCB_TWO"/>
        <result property="ylcbTwo" column="YLCB_TWO"/>
        <result property="pamzscbTwo" column="PAMZSCB_TWO"/>
        <result property="ftcbTwo" column="FTCB_TWO"/>
        <result property="gmsjfhycbTwo" column="GMSJFHYCB_TWO"/>
        <result property="pamwncbTwo" column="PAMWNCB_TWO"/>
        <result property="wnzycbTwo" column="WNZYCB_TWO"/>
        <result property="zsclcbTwo" column="ZSCLCB_TWO"/>
        <result property="zsclcbTotal" column="ZSCLCB_TOTAL"/>
        <result property="ysfcb" column="YSFCB"/>
        <result property="szysfcbOne" column="SZYSFCB_ONE"/>
        <result property="szysfcbTwo" column="SZYSFCB_TWO"/>
        <result property="szysfcbTotal" column="SZYSFCB_TOTAL"/>
        <result property="zfyOne" column="ZFY_ONE"/>
        <result property="zfyTwo" column="ZFY_TWO"/>
        <result property="dwcbOne" column="DWCB_ONE"/>
        <result property="dwcbTwo" column="DWCB_TWO"/>
        <result property="dwcbTotal" column="DWCB_TOTAL"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="zzsclfyOne" column="ZZSCLFY_ONE"/>
        <result property="zzsclfyTwo" column="ZZSCLFY_TWO"/>
        <result property="zfy" column="ZFY"/>
    </resultMap>


</mapper>
