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

  <resultMap id="tfKpiStandardManageMap" type="com.tofly.xrtygis.entity.TfKpiStandardManage">
                <id property="id" column="ID"/>
                      <result property="assessType" column="ASSESS_TYPE"/>
                      <result property="assessStandard" column="ASSESS_STANDARD"/>
                      <result property="assessContent" column="ASSESS_CONTENT"/>
                      <result property="remark" column="REMARK"/>
                      <result property="createUser" column="CREATE_USER"/>
                      <result property="createTime" column="CREATE_TIME"/>
                      <association property="createUserName"  column="CREATE_USER" select="com.tofly.xrtygis.mapper.IFileMapper.getUserName" ></association>
                      <association property="assessContentName"  column="ASSESS_CONTENT" select="getAssessContentName" ></association>
                      <association property="assessTypeName" column="ASSESS_TYPE" select="getAssessTypeName"></association>
  </resultMap>

    <select id="getAssessTypeName" resultType="string">
        SELECT decode(#{assessType},'1','按季度','2','按年度') as assessTypeName FROM dual
    </select>

    <select id="getAssessStandard" resultType="java.lang.String">
        select ASSESS_STANDARD
        from TF_KPI_STANDARD_MANAGE
        where
              1=1
        <if test="assessType != null and assessType.trim() != ''">
            and ASSESS_TYPE = #{assessType}
        </if>
        <if test="assessContent != null and assessContent.trim() != ''">
            and ASSESS_CONTENT = #{assessContent}
        </if>
    </select>

    <select id="getAssessStandardById" resultMap="tfKpiStandardManageMap">
        select *
        from TF_KPI_STANDARD_MANAGE
        where
        1=1
        <if test="id != null and id.trim() != ''">
            and ID = #{id}
        </if>
    </select>

    <select id="getAssessContentName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
            PCID =1001
          AND
            CCODE = #{assessContent}
    </select>
                                            
</mapper>
