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

    <resultMap id="qfcbplanMap" type="com.tofly.xrtygis.entity.Qfcbplan">
        <id property="id" column="ID"/>
        <result property="year" column="YEAR"/>
        <result property="isState" column="IS_STATE"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="isGeneral" column="IS_GENERAL"/>
        <result property="copyDescript" column="COPY_DESCRIPT"/>
        <result property="isCopy" column="IS_COPY"/>
        <association property="isStateName" column="IS_STATE"
                     select="getIsStateName"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"/>
    </resultMap>

    <select id="getIsStateName" resultType="string">
        select decode(#{isState}, '0', '禁用', '1', '启用')
        from dual
    </select>
    <select id="getMaxId" resultType="java.lang.Long">
        select nvl(max(id), 0) + 1
        from TF_YWPN_QFCBPLANDETAILS_W
    </select>
    <select id="getCbry" resultType="java.util.Map">
        select a.CBRY , b.REAL_NAME
        from TF_YWPN_QFCBPLANDETAILS_W a left join TF_SMPN_USER_X b on a.CBRY = b.ID
        <if test="departId != null">
           where b.DEPARTMENT_ID = #{departId}
        </if>
        group by a.CBRY , b.REAL_NAME
    </select>

</mapper>
