<?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.neassessmentScoreSum.mapper.BizNeAssessmentScoreSumMapper">
    <select id="selectMyMapPage" resultType="com.unis.examine.modular.neassessmentScoreSum.entity.BizNeAssessmentScoreSum">
<!--    SELECT DISTINCT-->
<!--    nam .id assessmentManageId, &#45;&#45; 任务ID-->
<!--    nat.id assessmentTargetId,    &#45;&#45;  指标id-->
<!--    nam.assessment_type pcType, &#45;&#45; 考核类型；1：国考-->
<!--    nam.assessment_year assessmentYear,-->
<!--    nam.assessment_name assessmentName,-->
<!--    nam.start_time startTime,-->
<!--    nam.end_time endTime,-->
<!--    nat.target_no targetNo,  &#45;&#45; 指标编号-->
<!--    nat.score sumScore, &#45;&#45;  指标评分-->
<!--    bas.score,  &#45;&#45;  得分-->
<!--    bas.deduction,  &#45;&#45; 扣分-->
<!--    bas.reason_for_deduction,-->
<!--    bas.evidence_material,-->
<!--    bss.sum_score ss,-->
<!--    COALESCE(-->
<!--    (-->
<!--    SELECT bal_inner.name-->
<!--    FROM biz_ne_assessment_level bal_inner-->
<!--    WHERE bal_inner.min_value &lt;= bss.sum_score-->
<!--    AND bal_inner.max_value >= bss.sum_score-->
<!--    AND bal_inner.assessment_manage_id = nam.id-->
<!--    ),'无') AS name-->
<!--    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-->
<!--    LEFT  JOIN biz_ne_assessment_score_sum bss ON nam.id = bss.assessment_manage_id-->
        SELECT DISTINCT
        bas.STATUS sCstatus,
        SUM( bas.score ) score,
        SUM( bas.deduction ) deduction,
        bas.pc_type pcType,
        nat.target_no targetNo,
        nat.score  targetScore,
        reason_for_deduction reasonDeduction


        FROM
        biz_ne_assessment_score bas
        LEFT JOIN biz_ne_assessment_target nat ON nat.id = bas.assessment_target_id
        LEFT JOIN biz_ne_assessment_manage nam ON nam.id = bas.assessment_manage_id
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where ${ew.sqlSegment}
        </if>
            group by bas.assessment_target_id
    </select>

</mapper>