<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.check.dao.ibatis.CheckWindowWorkmanPerformDaoImpl">
    <!-- 汇总已审核的核查记录 -->
    <select id="getSummaryCheckList" parameterType="com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery" resultType="com.mortals.xhx.module.check.model.vo.StaffCheckSummaryVo">
        SELECT
        p.`year`,p.`month`,d.staffId,d.staffName,s.deptId,s.deptName,sum(d.sumScore) as sumScore
        FROM
        mortals_xhx_check_window_workman_perform p,
        mortals_xhx_window_workman_perform w,
        mortals_xhx_window_workman_perform_detail d,
        mortals_xhx_staff s
        WHERE
        p.recordId = w.id
        AND d.performId = w.id
        AND s.id = d.staffId
        AND checkStatus = 2
        AND manageCheckResult = 1
        <if test="recordId != null and recordId!=''"> AND p.recordId = #{recordId} </if>
        <if test="year != null and year!=''"> AND p.`year` = #{year} </if>
        <if test="month != null and month!=''"> AND p.`month` = #{month} </if>
        GROUP BY p.`year`,p.`month`,d.staffId,d.staffName,s.deptId,s.deptName
    </select>

</mapper>