<?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.lz.modules.sys.dao.app.ResultRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.lz.modules.sys.entity.app.ResultRecord">
        <id column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="month_time" property="monthTime"/>
        <result column="status" property="status"/>
        <result column="last_score" property="lastScore"/>
        <result column="all_score" property="allScore"/>
        <result column="remark" property="remark"/>
        <result column="staff_id" property="staffId"/>
        <result column="type" property="type"/>
        <result column="flow_staff_id_role" property="flowStaffIdRole"/>
        <result column="department_id" property="departmentId"/>
        <result column="department_name" property="departmentName"/>
        <result column="staff_name" property="staffName"/>
        <result column="current_approval_staff_id" property="currentApprovalStaffId"/>
        <result column="current_approval_staff_name" property="currentApprovalStaffName"/>
        <result column="score_level" property="scoreLevel"/>
        <result column="start_id" property="startId"/>
        <result column="flow_process" property="flowProcess"/>
        <result column="evaluation_id" property="evaluationId"/>
    </resultMap>


    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, month_time AS monthTime, status AS status, last_score AS lastScore, all_score AS allScore, remark AS remark, staff_id AS staffId, type AS type, flow_staff_id_role AS flowStaffIdRole, department_id AS departmentId, department_name AS departmentName, staff_name AS staffName, current_approval_staff_id AS currentApprovalStaffId, current_approval_staff_name AS currentApprovalStaffName, score_level AS scoreLevel, start_id AS startId, flow_process AS flowProcess, evaluation_id AS evaluationId
    </sql>




    <select id="selectResultRecordById" resultType="ResultRecord" >
        select * from lz_result_record  where id=#{id} and is_delete = 0 limit 1
    </select>


    <insert id="insertResultRecord" parameterType="ResultRecord" useGeneratedKeys="true" keyProperty="id" >
        insert into lz_result_record(
        <if test="monthTime != null">month_time, </if>
        <if test="status != null">status, </if>
        <if test="lastScore != null">last_score, </if>
        <if test="allScore != null">all_score, </if>
        <if test="remark != null">remark, </if>
        <if test="staffId != null">staff_id, </if>
        <if test="type != null">type, </if>
        <if test="flowStaffIdRole != null">flow_staff_id_role, </if>
        <if test="departmentId != null">department_id, </if>
        <if test="departmentName != null">department_name, </if>
        <if test="staffName != null">staff_name, </if>
        <if test="currentApprovalStaffId != null">current_approval_staff_id, </if>
        <if test="currentApprovalStaffName != null">current_approval_staff_name, </if>
        <if test="scoreLevel != null">score_level, </if>
        <if test="startId != null">start_id, </if>
        <if test="flowProcess != null">flow_process, </if>
        <if test="evaluationId != null">evaluation_id, </if>
        is_delete,
        gmt_create,
        gmt_modified
        )values(
        <if test="monthTime != null">#{ monthTime}, </if>
        <if test="status != null">#{ status}, </if>
        <if test="lastScore != null">#{ lastScore}, </if>
        <if test="allScore != null">#{ allScore}, </if>
        <if test="remark != null">#{ remark}, </if>
        <if test="staffId != null">#{ staffId}, </if>
        <if test="type != null">#{ type}, </if>
        <if test="flowStaffIdRole != null">#{ flowStaffIdRole}, </if>
        <if test="departmentId != null">#{ departmentId}, </if>
        <if test="departmentName != null">#{ departmentName}, </if>
        <if test="staffName != null">#{ staffName}, </if>
        <if test="currentApprovalStaffId != null">#{ currentApprovalStaffId}, </if>
        <if test="currentApprovalStaffName != null">#{ currentApprovalStaffName}, </if>
        <if test="scoreLevel != null">#{ scoreLevel}, </if>
        <if test="startId != null">#{ startId}, </if>
        <if test="flowProcess != null">#{ flowProcess}, </if>
        <if test="evaluationId != null">#{ evaluationId}, </if>
        0,
        now(),
        now()
        )
    </insert>


    <update id="updateResultRecordById" parameterType="ResultRecord" >
        update
        lz_result_record
        <trim prefix="set" suffixOverrides=",">
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
            <if test="monthTime != null">month_time = #{monthTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="lastScore != null">last_score = #{lastScore},</if>
            <if test="allScore != null">all_score = #{allScore},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="staffId != null">staff_id = #{staffId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="flowStaffIdRole != null">flow_staff_id_role = #{flowStaffIdRole},</if>
            <if test="departmentId != null">department_id = #{departmentId},</if>
            <if test="departmentName != null">department_name = #{departmentName},</if>
            <if test="staffName != null">staff_name = #{staffName},</if>
            <if test="currentApprovalStaffId != null">current_approval_staff_id = #{currentApprovalStaffId},</if>
            <if test="currentApprovalStaffName != null">current_approval_staff_name = #{currentApprovalStaffName},</if>
            <if test="scoreLevel != null">score_level = #{scoreLevel},</if>
            <if test="startId != null">start_id = #{startId},</if>
            <if test="flowProcess != null">flow_process = #{flowProcess},</if>
            <if test="evaluationId != null">evaluation_id = #{evaluationId}</if>
        </trim>
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="updateCoverResultRecordById" parameterType="ResultRecord" >
        update
            lz_result_record
        set
            is_delete = #{isDelete},
            gmt_create = #{gmtCreate},
            month_time = #{monthTime},
            status = #{status},
            last_score = #{lastScore},
            all_score = #{allScore},
            remark = #{remark},
            staff_id = #{staffId},
            type = #{type},
            flow_staff_id_role = #{flowStaffIdRole},
            department_id = #{departmentId},
            department_name = #{departmentName},
            staff_name = #{staffName},
            current_approval_staff_id = #{currentApprovalStaffId},
            current_approval_staff_name = #{currentApprovalStaffName},
            score_level = #{scoreLevel},
            start_id = #{startId},
            flow_process = #{flowProcess},
            evaluation_id = #{evaluationId}
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="deleteResultRecordById" parameterType="java.lang.Long">
        update lz_result_record set is_delete = 1 where id=#{id} limit 1
    </update>

    <update id="deleteResultRecordById2" parameterType="java.lang.Long">
        update lz_result_record set is_delete = 2 where id=#{id} limit 1
    </update>





    <select id="selectByCondition" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from lz_result_record  where  is_delete = 0
        <if test="req.monthBeginDate != null and req.monthBeginDate != '' ">
            AND DATE_FORMAT(month_time, '%Y-%m-%d %H:%i:%S')  <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthBeginDate}, '%Y-%m-%d %H:%i:%S')
        </if>
        <if test="req.monthEndDate != null and req.monthEndDate != '' ">
            AND DATE_FORMAT(month_time, '%Y-%m-%d %H:%i:%S')  <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthEndDate}, '%Y-%m-%d %H:%i:%S')
        </if>
        <if test="req.status != null">
            and status = #{req.status}
        </if>
        <if test="req.remark != null and req.remark !='' ">
            AND remark LIKE CONCAT('%',#{req.remark},'%')
        </if>

        <if test="req.name != null and req.name !='' ">
            AND staff_name LIKE CONCAT('%',#{req.name},'%')
        </if>

        <if test="req.departmentIds != null and req.departmentIds.size() > 0 ">
            and department_id in
            <foreach collection="req.departmentIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>

        <if test="req.staffId != null and req.staffId !='' ">
            and staff_id = #{req.staffId}
        </if>
        order by id desc
    </select>


    <select id="selectByConditionTest" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from lz_result_record  where  is_delete = 0
        <if test="monthBeginDate != null and monthBeginDate != '' ">
            AND DATE_FORMAT(month_time, '%Y-%m-%d %H:%i:%S')  <![CDATA[ >= ]]> DATE_FORMAT(#{monthBeginDate}, '%Y-%m-%d %H:%i:%S')
        </if>

        <if test="monthEndDate != null and monthEndDate != '' ">
            AND DATE_FORMAT(month_time, '%Y-%m-%d %H:%i:%S')  <![CDATA[ >= ]]> DATE_FORMAT(#{monthEndDate}, '%Y-%m-%d %H:%i:%S')
        </if>
        order by id desc
    </select>

    <select id="selectResultRecordByStaffId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
       select * from  lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = 1 order by id desc limit 1
    </select>

    <select id="selectByConditionByLeader" resultType="com.lz.modules.flow.model.ResultRecordDto">
        select * from (
        select rd.*,department_level,approval_staff_id,approval_staff_name,flow_name,flow_id,flow_index
        from lz_flow_record fr left join lz_result_record rd on fr.record_id= rd.id
        where  fr.status = 0 and rd.is_delete = 0 and fr.is_delete = 0
        <if test="req.departmentLevel != null and req.departmentLevel != '' ">
            and department_level = #{req.departmentLevel}
        </if>

        <if test="req.monthBeginDate != null and req.monthBeginDate != '' ">
            AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S')  <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthBeginDate},
            '%Y-%m-%d %H:%i:%S')
        </if>
        <if test="req.monthEndDate != null and req.monthEndDate != '' ">
            AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S')  <![CDATA[ <= ]]> DATE_FORMAT(#{req.monthEndDate},
            '%Y-%m-%d %H:%i:%S')
        </if>

        <if test="req.status != null">
            and rd.status = #{req.status}
        </if>

        <if test="req.remark != null and req.remark !='' ">
            AND rd.remark LIKE CONCAT('%',#{req.remark},'%')
        </if>

        <if test="req.name != null and req.name !='' ">
            AND rd.staff_name LIKE CONCAT('%',#{req.name},'%')
        </if>
        <if test="req.departmentIds != null and req.departmentIds.size() > 0 ">
            and rd.department_id in
            <foreach collection="req.departmentIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="req.statusList != null and req.statusList.size() > 0 ">
            and rd.status in
            <foreach collection="req.statusList" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="req.staffId != null and req.staffId !='' ">
            and rd.staff_id = #{req.staffId}
        </if>

        <if test="req.approvalStaffId !=null and req.approvalStaffId !='' " >
            and rd.current_approval_staff_id = #{req.approvalStaffId}
        </if>
        order by fr.id desc )
        a GROUP by id
        <choose>
            <when test="req.statusList != null and req.statusList.size() > 0">
                order by department_id desc
            </when>
            <otherwise>
                order by id desc
            </otherwise>
        </choose>


    </select>

    <update id="updateFlowStaffIdRoleToNull">
        update lz_result_record set flow_staff_id_role = '[]',status = #{status},current_approval_staff_id = null ,current_approval_staff_name = null   where id = #{id}
    </update>

    <select id="selectResultRecordByIds" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from lz_result_record where is_delete = 0 and id in
        <foreach collection="recordIds" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>


    <select id="ownResult" resultType="com.lz.modules.app.resp.OwnResultResp">
        SELECT all_score,CONCAT_WS('至',DATE_FORMAT(start_time,'%Y.%m'),DATE_FORMAT(end_time,'%Y.%m')) as 'name' FROM lz_result_record r
        LEFT JOIN lz_flow_start f
        ON r.start_id = f.id
        where r.is_delete = 0 and f.is_delete = 0 and flow_process = 5 and staff_id = #{req.userId}
        <if test="req.startTime != null and req.endTime!=null">
            and (
            (DATE_FORMAT(start_time,'%Y-%m')   &lt;= #{req.startTime} and DATE_FORMAT(end_time,'%Y-%m') &gt;= #{req.endTime})
            or (DATE_FORMAT(end_time,'%Y-%m')  &lt;= #{req.endTime} and DATE_FORMAT(end_time,'%Y-%m') &gt;= #{req.startTime})
            or (DATE_FORMAT(start_time,'%Y-%m')   &lt;= #{req.endTime} and DATE_FORMAT(start_time,'%Y-%m') &gt;= #{req.startTime})
            )
        </if>
        order by start_id desc limit #{req.size}


</select>

    <select id="staffDistribution" resultType="com.lz.modules.app.dto.GraphicsStatisticalDto">
        SELECT count(score_level) number ,score_level category from lz_result_record where
        is_delete = 0 and status =4 and type =2 and score_level !=0 and DATE_FORMAT(month_time,'%Y-%m') = #{monthTime}
        <if test="staffIds !=null and staffIds.size()>0">
            and staff_id in
            <foreach collection="staffIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY score_level
    </select>



    <select id="selectResultRecordByStaffIdStatus" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from  lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = 1 and status = #{status} order by id desc limit 1
    </select>


    <select id="targetReportList" resultType="com.lz.modules.app.dto.ReportProgressListDto">
        SELECT max(r.id) id,r.staff_id ,staff_name,position,department_name from lz_result_record r
        LEFT JOIN lz_staff_occupation o
        on r.staff_id = o.staff_id
        where o.is_delete=0
        <if test="req.type !=null ">
            <if test="req.type == 1">
                and r.is_delete=2
            </if>
            <if test="req.type == 2">
                and r.is_delete=0
            </if>
            and type = #{req.type}
        </if>
        <if test="staffIds !=null and staffIds.size() !=0">
            and r.staff_id in
            <foreach collection="staffIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="req.staffName !=null and req.staffName != ''">
            and r.staff_name like concat('%',#{req.staffName},'%')
        </if>
        <if test="req.level !=null and req.level != ''">
            and r.score_level  = #{req.level}
        </if>
        <if test="req.selectMonthTime !=null and req.selectMonthTime !=''">
            and month_time like CONCAT('', #{req.selectMonthTime}, '%')
        </if>
        <if test="req.realStatus !=null and req.realStatus.size() !=0">
            and r.status in
            <foreach collection="req.realStatus" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY r.staff_id

    </select>
    <select id="selectLastResultRecordByStaffIdType" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from  lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = #{type} order by id desc limit 1
    </select>

    <select id="selectCurrentMonthResultRecordByStaffIdType"  resultType="com.lz.modules.sys.entity.app.ResultRecord">
         select * from  lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = #{type} and DATE_FORMAT(month_time,'%Y-%m') = DATE_FORMAT(now(),'%Y-%m')  order by id desc limit 1
    </select>
    <select id="selectResultRecordAllByStaffId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from lz_result_record  where staff_id = #{staffId}
    </select>

    <select id="countNumByFlowProcess" resultType="com.lz.modules.performance.res.ChartStatistical">
        SELECT count(flow_process) num,flow_process as 'desc' from lz_result_record where is_delete=0
        and start_id =#{startId}
        <if test="evaluationIds !=null and evaluationIds.size()!=0">
            and evaluation_id in (
            <foreach collection="evaluationIds" item="evaluation_id" separator=",">
                #{evaluation_id}
            </foreach>
            )
        </if>
        <if test="departmentIds !=null and departmentIds.size()!=0">
            and department_id in (
            <foreach collection="departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
        GROUP BY flow_process
    </select>

    <select id="countNumByScoreLevel" resultType="com.lz.modules.performance.res.ChartStatistical">
        SELECT count(1) num,case score_level is null WHEN true THEN '' ELSE score_level END score_level,case score_level is null WHEN true THEN '无等级' ELSE score_level END 'desc' from lz_result_record where is_delete=0
        and start_id =#{startId}
        <if test="evaluationIds !=null and evaluationIds.size()!=0">
            and evaluation_id in (
            <foreach collection="evaluationIds" item="evaluation_id" separator=",">
                #{evaluation_id}
            </foreach>
            )
        </if>
        <if test="departmentIds !=null and departmentIds.size()!=0">
            and department_id in (
            <foreach collection="departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
        GROUP BY score_level
    </select>

    <select id="selectChartDetailList" resultType="com.lz.modules.performance.res.ResultRankListRes">
        SELECT r.id recordId,all_score,department_name,staff_name,score_level,job_number staffNo from lz_result_record r
        LEFT JOIN lz_staff s
        on r.staff_id = s.id
        where r.is_delete =0 and s.is_delete=0
        and r.start_id = #{startId}
        <if test="departmentIds!=null and  departmentIds.size()!=0">
            and r.department_id in (
            <foreach collection="departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
        <if test="scoreLevel !=null">
            <if test="scoreLevel == ''">
                and r.score_level is null
            </if>
            <if test="scoreLevel != ''">
                and r.score_level = #{scoreLevel}
            </if>
        </if>
        ORDER BY all_score desc
    </select>


    <update id="batchDeleteByStartId">
        update lz_result_record set is_delete = 1 where
        is_delete = 0
        and start_id = #{startId}
    </update>

    <select id="countStartAndGroupNum" resultType="int">
        select COUNT(1) from lz_result_record  where is_delete = 0 and start_id = #{startId}
        <if test="departmentIds !=null and departmentIds.size()!=0">
            and department_id in (
            <foreach collection="departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
    </select>

    <select id="selectOneByStartId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
        select * from lz_result_record  where is_delete = 0 and start_id = #{startId}
        <if test="departmentIds !=null and departmentIds.size()!=0">
            and department_id in (
            <foreach collection="departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
        limit 1
    </select>

    <select id="selectAssessListByStartId" resultType="com.lz.modules.performance.res.AssessManagerDetailRes">
        select DISTINCT (r.id),r.staff_id,staff_name,department_name,all_score,score_level,evaluation_name from lz_result_record  r
        LEFT JOIN lz_evaluation_start_staff s
        ON r.start_id = s.start_id and r.staff_id = s.staff_id
        where r.is_delete = 0 and s.is_delete = 0
        and r.start_id = #{req.startId}
        <if test="req.copyEvaluationIds !=null and req.copyEvaluationIds !=''">
            and r.evaluation_id in(
            <foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" separator=",">
                #{evaluation_id}
            </foreach>
            )
        </if>
        <if test="req.flowProcess !=null">
            and r.flow_process = #{req.flowProcess}
        </if>
        <if test="req.staffName !=null and req.staffName!=''">
            and r.staff_name LIKE CONCAT('%',#{req.staffName},'%')
        </if>
        <if test="req.staffIds !=null and req.staffIds !=''">
            and r.staff_id in(
            <foreach collection="req.staffIds.split(',')" item="staff_id"  separator=",">
                #{staff_id}
            </foreach>
            )
        </if>
        <if test="req.departmentIds !=null and req.departmentIds.size()!=0">
            and r.department_id in (
            <foreach collection="req.departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
        order by r.id desc
    </select>

    <select id="countAssessNumByFlowProcess" resultType="com.lz.modules.performance.res.ChartStatistical">
        SELECT count(flow_process) num,flow_process as 'desc' from lz_result_record r
        LEFT JOIN lz_evaluation_start_staff s
        ON r.start_id = s.start_id and r.staff_id = s.staff_id
        where r.is_delete = 0 and s.is_delete = 0
        and r.start_id =#{req.startId}
        <if test="req.copyEvaluationIds !=null and req.copyEvaluationIds !=''">
            and r.evaluation_id in(
            <foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" separator=",">
                #{evaluation_id}
            </foreach>
            )
        </if>
        <if test="req.flowProcess !=null">
            and r.flow_process = #{req.flowProcess}
        </if>
        <if test="req.staffName !=null and req.staffName!=''">
            and r.staff_name LIKE CONCAT('%',#{req.staffName},'%')
        </if>
        <if test="req.staffIds !=null and req.staffIds !=''">
            and r.staff_id in(
            <foreach collection="req.staffIds.split(',')" item="staff_id" separator=",">
                #{staff_id}
            </foreach>
            )
        </if>
        <if test="req.departmentIds !=null and req.departmentIds.size()!=0">
            and r.department_id in (
            <foreach collection="req.departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
        GROUP BY r.flow_process
    </select>


    <select id="countAssessNumJoin" resultType="int">
        SELECT count(1) num from lz_result_record r
        LEFT JOIN lz_evaluation_start_staff s
        ON r.start_id = s.start_id and r.staff_id = s.staff_id
        where r.is_delete = 0 and s.is_delete = 0
        and r.start_id =#{req.startId}
        <if test="req.copyEvaluationIds !=null and req.copyEvaluationIds !=''">
            and r.evaluation_id in(
            <foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id"  separator=",">
                #{evaluation_id}
            </foreach>
            )
        </if>
        <if test="req.flowProcess !=null">
            and r.flow_process = #{req.flowProcess}
        </if>
        <if test="req.staffName !=null and req.staffName!=''">
            and r.staff_name LIKE CONCAT('%',#{req.staffName},'%')
        </if>
        <if test="req.staffIds !=null and req.staffIds !=''">
            and r.staff_id in(
            <foreach collection="req.staffIds.split(',')" item="staff_id"  separator="," >
                #{staff_id}
            </foreach>
            )
        </if>
        <if test="req.departmentIds !=null and req.departmentIds.size()!=0">
            and r.department_id in (
            <foreach collection="req.departmentIds" item="department_id" separator=",">
                #{department_id}
            </foreach>
            )
        </if>
    </select>


    <update id="batchDeleteByStartIdAndStaffId">
        update lz_result_record set is_delete = 1,gmt_modified = now()
        where
        is_delete = 0
        and start_id = #{startId}
        and staff_id in (
        <foreach collection="staffIds" item="staff_id" separator=",">
            #{staff_id}
        </foreach>
        )
    </update>

    <select id="selectToScoreList" resultType="com.lz.modules.performance.dto.ToScoreDingTalkDto">
        select id,staff_id from lz_result_record  where is_delete = 0
        and start_id = #{startId}
        and flow_process = 2
        and evaluation_id = #{evaluationId}
    </select>

    <select id="selectLastResultRecordByUserId" resultType="ResultRecord" >
        select * from lz_result_record  where staff_id=#{userId} and is_delete = 0 order by id desc limit 1
    </select>

    <select id="selectResultRecordByStaffIdAndStartId" resultType="ResultRecord" >
        select * from lz_result_record  where staff_id=#{userId} and is_delete = 0 and start_id = #{startId} order by id desc limit 1
    </select>
</mapper>

