<?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.scada.mapper.ScadaReportMapper">

    <resultMap id="BaseResultMap" type="com.tofly.scada.entity.ScadaReport">
            <id property="id" column="ID" jdbcType="DECIMAL"/>
            <result property="allocationId" column="ALLOCATION_ID" jdbcType="VARCHAR"/>
            <result property="reportLevel" column="REPORT_LEVEL" jdbcType="VARCHAR"/>
            <result property="reportUpper" column="REPORT_UPPER" jdbcType="VARCHAR"/>
            <result property="reportLower" column="REPORT_LOWER" jdbcType="VARCHAR"/>
            <result property="liaisonPeople" column="LIAISON_PEOPLE" jdbcType="DECIMAL"/>
            <result property="liaisonPhone" column="LIAISON_PHONE" jdbcType="VARCHAR"/>
            <result property="leaderPeople" column="LEADER_PEOPLE" jdbcType="DECIMAL"/>
            <result property="leaderPhone" column="LEADER_PHONE" jdbcType="VARCHAR"/>
            <result property="detail" column="DETAIL" jdbcType="VARCHAR"/>
            <result property="msgTemplate" column="MSG_TEMPLATE" jdbcType="VARCHAR"/>
            <result property="sort" column="SORT" jdbcType="DECIMAL"/>
            <result property="report" column="REPORT" jdbcType="DECIMAL"/>
            <result property="createUser" column="CREATE_USER" jdbcType="DECIMAL"/>
            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="updateUser" column="UPDATE_USER" jdbcType="DECIMAL"/>
            <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="isDel" column="IS_DEL" jdbcType="DECIMAL"/>
            <result property="noticeUser" column="NOTICE_USER" jdbcType="VARCHAR"/>
        <association property="liaisonName" column="LIAISON_PEOPLE"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
        <association property="leaderName" column="LEADER_PEOPLE"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
        <association property="dataTypeName" column="ALLOCATION_ID"
                     select="getTypeName"></association>
    </resultMap>

    <sql id="Base_Column_List">
        ID,ALLOCATION_ID,REPORT_LEVEL,
        REPORT_UPPER,REPORT_LOWER,LIAISON_PEOPLE,
        LIAISON_PHONE,LEADER_PEOPLE,LEADER_PHONE,
        DETAIL,MSG_TEMPLATE,SORT,
        REPORT,CREATE_USER,CREATE_TIME,
        UPDATE_USER,UPDATE_TIME,IS_DEL
    </sql>
    <select id="selectPageList" resultMap="BaseResultMap">
        select * from TF_SCADA_REPORT
        <where>
            ${ew.sqlSegment}
        </where>
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        select * from TF_SCADA_REPORT
    </select>

    <select id="getTypeName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
            PCID =60000
          AND
            CCODE = #{type}
    </select>
</mapper>
