<?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.unis.examine.modular.assessmentManage.mapper.AssessmentManageMapper">

    <select id="selectMyMapsPage" resultType="java.util.Map">
--         SELECT DISTINCT
--             nam.id,
--             nam.assessment_year assessmentYear,
--             nam.assessment_name assessmentName,
--         DATE_FORMAT(nam.start_time, '%Y-%m-%d')AS startTime,
--         DATE_FORMAT(nam.end_time, '%Y-%m-%d')AS endTime,
--             bas.status sCstatus
--         FROM
--         biz_ne_assessment_score bas
--
--         left join  biz_ne_assessment_manage nam  on nam.id = bas.assessment_manage_id
--         LEFT  JOIN biz_ne_assessment_target nat ON nam.id = nat.assessment_manage_id
        SELECT DISTINCT
        nam.id,
        nam.assessment_year assessmentYear,
        nam.assessment_name assessmentName,
        DATE_FORMAT( nam.start_time, '%Y-%m-%d' ) AS startTime,
        DATE_FORMAT( nam.end_time, '%Y-%m-%d' ) AS endTime,
        COALESCE(bas.status, 0) AS sCstatus
        FROM
        biz_ne_assessment_manage nam
        LEFT JOIN biz_ne_assessment_target nat ON nam.id = nat.assessment_manage_id
        LEFT JOIN  biz_ne_assessment_score bas on bas.assessment_target_id =nat.id
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where ${ew.sqlSegment}
        </if>
    </select>


    <select id="selectMyPage" resultType="java.util.Map">
        SELECT DISTINCT
        nam.id,
        nam.assessment_year assessmentYear,
        nam.assessment_name assessmentName,
        nam.start_time startTime,
        nam.end_time endTime,
        bas.status sCstatus,
        SUM(bas.score) score,
        SUM(bas.deduction)deduction,
        bas.pc_type pcType
        FROM
            biz_ne_assessment_manage nam
                LEFT  JOIN biz_ne_assessment_target nat ON nam.id = nat.assessment_manage_id
                left join biz_ne_assessment_score bas on nam.id = bas.assessment_manage_id
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where ${ew.sqlSegment}
        </if>
        group by bas.pc_type
    </select>
    <select id="getAssessmentName" parameterType="string" resultType="map">
        SELECT
            id,
            assessment_name assessmentName
        FROM
            biz_ne_assessment_manage
        WHERE
            end_time &gt;= #{now}
    </select>
    <select id="getOnlyOrgInfo" parameterType="string" resultType="map">
        SELECT
            ID id,
            `NAME` orgName
        FROM
            sys_org
        WHERE
          DELETE_FLAG = 'NOT_DELETE'
        AND  PARENT_ID = #{parentId}
    </select>
</mapper>