<?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="digital.laboratory.platform.imr.mapper.SampleOutboundRecordMapper">

    <resultMap id="sampleOutboundRecordMap" type="digital.laboratory.platform.imr.entity.SampleOutboundRecord">
        <id property="id" column="id"/>
        <result property="sampleId" column="sample_id"/>
        <result property="recipientId" column="recipient_id"/>
        <result property="reason" column="reason"/>
        <result property="name" column="name"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="outboundType" column="outbound_type"/>
        <result property="outboundDate" column="outbound_date"/>
    </resultMap>


    <resultMap id="outboundMap" type="digital.laboratory.platform.imr.vo.OutboundRecordVO" extends="sampleOutboundRecordMap">
        <result property="recipientName" column="recipient_Name"/>
        <result property="sampleNo" column="sample_no"/>
    </resultMap>



    <sql id="outboundMap">
        select outbound.*,
               sample.sample_no,
               (
                   SELECT user.name
                   FROM dlp_base.sys_user user
                   WHERE user.user_id=outbound.recipient_id
               ) AS recipient_Name
        from dlp_identification_material_repository.sample_outbound_record outbound
        join dlp_identification_material_transfer.b_sample sample
        on outbound.sample_id = sample.id
    </sql>


    <select id="outboundRecord" resultMap="outboundMap">
        <include refid="outboundMap"/>
        ${ew.customSqlSegment}
    </select>
</mapper>