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

    <resultMap id="costrlfixedMap" type="com.tofly.xrtygis.entity.Costrlfixed">
        <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"/>
        <result property="otherzfy" column="OTHERZDY"/>
        <result property="othercb" column="OTHERCB"/>
        <result property="dfOneTotal" column="DF_ONE_TOTAL"/>
        <result property="dfTwoTotal" column="DF_TWO_TOTAL"/>
        <result property="dlOneTotal" column="DL_TWO_TOTAL"/>
        <result property="dlTwoTotal" column="DL_TWO_TOTAL"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"/>
    </resultMap>

    <select id="getWaterDataMonth" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy') YEAR, TO_CHAR(UP_DATE, 'MM') MONTH, nvl(${typet}, 0) reslutData
        FROM TF_YWPN_COSTRLFIXED_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') between #{startYear} and #{endYear}
          and MARK = '1'
        ORDER BY MONTH ASC
    </select>

    <select id="getWaterDataQuarter" resultType="java.util.Map">
        SELECT SUBSTR(quarter, 1, 4) YEAR, quarter MONTH, nvl(SUM(${typet}), 0) reslutData
        FROM (SELECT TO_CHAR(UP_DATE, 'yyyy') UP_DATE,
                     TO_CHAR(UP_DATE, 'yyyy-Q') quarter,
                     nvl(${typet}, 0) ${typet}
              FROM TF_YWPN_COSTRLFIXED_W
              WHERE TO_CHAR(UP_DATE, 'yyyy') between #{startYear} and #{endYear}
                and MARK = '1')
        GROUP BY quarter
        ORDER BY quarter ASC
    </select>

    <select id="getWaterDataYear" resultType="java.util.Map">
        SELECT UP_DATE YEAR, nvl(SUM(${typet}), 0) reslutData
        FROM (SELECT TO_CHAR(UP_DATE, 'yyyy') UP_DATE, nvl(${typet}, 0) ${typet}
              FROM TF_YWPN_COSTRLFIXED_W
              WHERE TO_CHAR(UP_DATE, 'yyyy') between #{startYear} and #{endYear}
                and MARK = '1')
        GROUP BY UP_DATE
        ORDER BY UP_DATE ASC
    </select>

    <select id="getUnitCostYear" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy') YEAR, TO_CHAR(UP_DATE, 'MM') MONTH, ${ccode}
        FROM TF_YWPN_COSTRLFIXED_W
        WHERE TO_CHAR(UP_DATE, 'yyyy') = #{year}
          and MARK = '1'
        ORDER BY MONTH ASC
    </select>
    <select id="getUnitCostYearMonth" resultType="java.util.Map">
        SELECT TO_CHAR(UP_DATE, 'yyyy') YEAR, TO_CHAR(UP_DATE, 'yyyy-MM') MONTH, ${ccode}
        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>
    <select id="getCodeByFId" resultType="map">
        select CCODE, CNAME, CCONTERT
        from TF_YWPN_SYSCHILDCODE_D
        where PCID = #{typeId}
    </select>

    <select id="getGetWater" resultType="com.tofly.xrtygis.custom.entity.dataquery.GetMongWater">
        SELECT TO_CHAR(UP_DATE, 'MM') MONTH, NVL(${value}, 0) GSL
        FROM TF_YWPN_COSTRLWATER_W
        WHERE MARK = '1'
          AND TO_CHAR(UP_DATE, 'yyyy') = #{year}
    </select>
    <select id="getCodeByIds" resultType="java.util.Map">
        select CCODE , CNAME , CCONTERT from TF_YWPN_SYSCHILDCODE_D where
        ID IN
        <foreach collection="ids" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
    </select>


</mapper>
