<?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.testor.module.fives.dao.TFivesToolFocusDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.fives.model.domain.TFivesToolFocus">
        <id column="id" property="id"/>
        <id column="ref_id" property="refId"/>
        <id column="parent_id" property="parentId"/>
        <id column="tenant_id" property="tenantId"/>
        <id column="process_id" property="processId"/>
        <id column="process_status" property="processStatus"/>
        <id column="course_name" property="courseName"/>
        <id column="course_section" property="courseSection"/>
        <id column="course_principal" property="coursePrincipal"/>
        <id column="team_size" property="teamSize"/>
        <id column="course_direction" property="courseDirection"/>
        <id column="focus_obj" property="focusObj"/>
        <id column="begin_date" property="beginDate"/>
        <id column="end_date" property="endDate"/>
        <id column="boost_reason" property="boostReason"/>
        <id column="boost_content" property="boostContent"/>
        <id column="expect_target" property="expectTarget"/>
        <id column="last_result" property="lastResult"/>
    </resultMap>

    <select id="focusReport" resultType="com.testor.module.fives.model.excel.TFivesToolFocusReport">
        SELECT
            tftf.course_name AS theme_name,
            tsu.user_name AS create_by,
            tftu.create_by,
            tftu.create_date,
            tftu.grain_org_id,
            tftu.area_org_id,
            tftu.serial_number,
            tftf.course_principal,
            tftf.course_section,
            tftf.team_size,
            tftf.course_direction,
            tftf.focus_obj,
            CONCAT(tftf.begin_date,'至',tftf.end_date) AS begin_date,
            tftf.boost_reason,
            tftf.boost_content,
            tftf.expect_target,
            tftf.last_result,
            CASE
                tftu.score_type
                WHEN '7' THEN
                    '未评'
                WHEN '6' THEN
                    '评价中' ELSE tftu.score
                END AS score
        FROM
            t_fives_tool_use AS tftu
                LEFT JOIN t_fives_tool_focus AS tftf ON tftu.id = tftf.parent_id
                LEFT JOIN t_sys_user AS tsu ON tftu.create_by = tsu.user_id
        WHERE
            tftu.use_type = 2
          AND tftu.STATUS = '0'
    </select>
</mapper>