<?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.jeeplus.human.practice.reimburseRegister.mapper.ReimburseRegisterMapper">

    <sql id="Base_Column_List">
        a.id,
        a.create_by_id,
        a.create_time,
        a.update_by_id,
        a.update_time,
        a.del_flag,
        a.type,
        a.proc_ins_id,
        a.process_definition_id,
        a.project_manager,
        a.bank_card_number,
        a.remarks,
        a.complete_practice,
        a.all_reimbursement_amount,
        a.reimbuser_name
    </sql>
    <update id="updateStatusById">
        UPDATE human_resources_practice_reimburse_register SET type = #{type}
		WHERE id = #{id}
    </update>
    <update id="removeById">
        update human_resources_practice_reimburse_register set del_flag = '1' where id = #{id}
    </update>

    <select id="findList" resultType="com.jeeplus.human.practice.reimburseRegister.domain.ReimburseRegister">
        select
        <include refid="Base_Column_List"></include>,
        d.ID_ AS task_id,
        su.name as createName,
        su2.name as projectManagerName,
        hbank.bank_card_number as bankCardNumber
        from human_resources_practice_reimburse_register a
        LEFT JOIN act_ru_task d ON a.proc_ins_id = d.PROC_INST_ID_
        left join sys_user su on a.create_by_id = su.id
        left join sys_user su2 on a.project_manager = su2.id
        left join human_resources_practice_registration_bank hbank on a.create_by_id = hbank.user_id
        ${ew.customSqlSegment}
        ORDER BY a.create_time DESC
    </select>
    <select id="getById" resultType="com.jeeplus.human.practice.reimburseRegister.domain.ReimburseRegister">
        select
        <include refid="Base_Column_List"></include>,
        d.ID_ AS task_id,
        su.name as createName,
        su.mobile as mobilePhone
        from human_resources_practice_reimburse_register a
        LEFT JOIN act_ru_task d ON a.proc_ins_id = d.PROC_INST_ID_
        LEFT JOIN sys_user su on a.create_by_id = su.id
        where a.id = #{id} and a.del_flag = '0'
    </select>
    <select id="findList2" resultType="com.jeeplus.human.practice.reimburseRegister.domain.ReimburseRegister">
        select
        <include refid="Base_Column_List"></include>,
        d.ID_ AS task_id,
        su.name as createName,
        su2.name as projectManagerName,
        hbank.bank_card_number as bankCardNumber
        from human_resources_practice_reimburse_register a
        LEFT JOIN act_ru_task d ON a.proc_ins_id = d.PROC_INST_ID_
        left join sys_user su on a.create_by_id = su.id
        left join sys_user su2 on a.project_manager = su2.id
        left join human_resources_practice_registration_bank hbank on a.create_by_id = hbank.user_id
        ${ew.customSqlSegment}
        and a.id not in (
        select DISTINCT a.human_reimburse_register_id from human_reimbursement_detail_info_procured a
        LEFT JOIN cw_reimbursement_info b on a.info_id = b.id
        WHERE a.del_flag = '0' and b.del_flag = '0' and a.human_reimburse_register_id is not NULL
        )
        ORDER BY a.create_time DESC
    </select>
</mapper>