<?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.entrustment.mapper.EntrustmentIdentificationMaterialMapper">

  <resultMap id="entrustmentIdentificationMaterialMap" type="digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial">
    <id property="id" column="id"/>
    <result property="imNo" column="im_no"/>
    <result property="evidenceId" column="evidence_id"/>
    <result property="caseId" column="case_id"/>
    <result property="entrustmentId" column="entrustment_id"/>
    <result property="name" column="name"/>
    <result property="type" column="type"/>
    <result property="color" column="color"/>
    <result property="form" column="form"/>
    <result property="fundName" column="fund_name"/>
    <result property="fundQuantity" column="fund_quantity"/>
    <result property="fundUnit" column="fund_unit"/>
    <result property="quantity" column="quantity"/>
    <result property="unit" column="unit"/>
    <result property="additionalProperties" column="additional_properties" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
    <result property="drawWay" column="draw_way"/>
    <result property="personName" column="person_name"/>
    <result property="personCert" column="person_cert"/>
    <result property="personId" column="person_id"/>
    <result property="personGender" column="person_gender"/>
    <result property="personNationality" column="person_nationality"/>
    <result property="personNation" column="person_nation"/>
    <result property="personAddress" column="person_address"/>
    <result property="personAge" column="person_age"/>
<!--    <result property="take1UserId" column="take1_user_id"/>-->
    <result property="take1Name" column="take1_name"/>
    <result property="take1Position" column="take1_position"/>
    <result property="take1Cert" column="take1_cert"/>
    <result property="take1Id" column="take1_id"/>
    <result property="take1Phone" column="take1_phone"/>
<!--    <result property="take2UserId" column="take2_user_id"/>-->
    <result property="take2Name" column="take2_name"/>
    <result property="take2Position" column="take2_position"/>
    <result property="take2Cert" column="take2_cert"/>
    <result property="take2Id" column="take2_id"/>
    <result property="take2Phone" column="take2_phone"/>
    <result property="takeTime" column="take_time"/>
    <result property="witnessName" column="witness_name"/>
    <result property="witnessCert" column="witness_cert"/>
    <result property="witnessId" column="witness_id"/>
    <result property="pack" column="pack"/>
    <result property="storageMethod" column="storage_method"/>
    <result property="candidateDrugs" column="candidate_drugs" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
    <result property="description" column="description"/>
    <result property="checkTime" column="check_time"/>
    <result property="checkPassed" column="check_passed"/>
    <result property="approveTime" column="approve_time"/>
    <result property="approvePassed" column="approve_passed"/>
    <result property="acceptTime" column="accept_time"/>
<!--    <result property="acceptPassed" column="accept_passed"/>-->
<!--    <result property="providedSample1Present" column="provided_sample1_present"/>-->
    <result property="providedSample1No" column="provided_sample1_no"/>
    <result property="providedSample1FundQuantity" column="provided_sample1_fund_quantity"/>
    <result property="providedSample1Quantity" column="provided_sample1_quantity"/>
    <result property="providedSample2Present" column="provided_sample2_present"/>
    <result property="providedSample2No" column="provided_sample2_no"/>
    <result property="providedSample2FundQuantity" column="provided_sample2_fund_quantity"/>
    <result property="providedSample2Quantity" column="provided_sample2_quantity"/>
    <result property="splitedSample" column="splited_sample"/>
<!--    <result property="sample1Present" column="sample1_present"/>-->
    <result property="sample1No" column="sample1_no"/>
    <result property="sample1FundQuantity" column="sample1_fund_quantity"/>
    <result property="sample1Quantity" column="sample1_quantity"/>
    <result property="sample1BoxId" column="sample1_box_id"/>
    <result property="sample2Present" column="sample2_present"/>
    <result property="sample2No" column="sample2_no"/>
    <result property="sample2FundQuantity" column="sample2_fund_quantity"/>
    <result property="sample2Quantity" column="sample2_quantity"/>
    <result property="sample2BoxId" column="sample2_box_id"/>
    <result property="sample1RepeatWeigh" column="sample1_repeat_weigh"/>
    <result property="sample2RepeatWeigh" column="sample2_repeat_weigh"/>
    <result property="createTime" column="create_time"/>
    <result property="createBy" column="create_by"/>
    <result property="updateTime" column="update_time"/>
    <result property="updateBy" column="update_by"/>
    <result property="materialAge" column="material_age"/>
    <result property="imEntrustNumber" column="im_entrust_number"/>
    <result property="biologyType" column="biology_type"/>
    <result property="biologyGender" column="biology_gender"/>
  </resultMap>

  <resultMap id="entrustmentIdentificationMaterialVO" type="digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO" extends="entrustmentIdentificationMaterialMap">
    <result property="formName" column ="form_name"/>
    <result property="sample1Type" column ="sample1_type"/>
    <result property="sample2Type" column ="sample2_type"/>
  </resultMap>

  <!-- 根据条件取 entrustmentIdentificationMaterialVO 列表 -->
  <select id="getEntrustmentIdentificationMaterialVOList" resultMap="entrustmentIdentificationMaterialVO" resultType="digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO">
    SELECT im.*,
           (SELECT dict.label FROM dlp_base.sys_dictionary dict WHERE dict.type="wzxz" AND dict.id=im.form) AS form_name,
           (SELECT sb.sample_type FROM b_sample_box sb WHERE sb.id=im.sample1_box_id ) AS sample1_type,
           (SELECT sb.sample_type FROM b_sample_box sb WHERE sb.id=im.sample2_box_id ) AS sample2_type
    FROM b_entrustment_identification_material im
    ${ew.customSqlSegment}
  </select>


  <!-- 取最大检材号, 目的是为了生成新的检材号 -->
  <select id="getMaxIdentificationMaterialNo" parameterType="String" resultType="java.lang.String">
    SELECT MAX(im_no) AS maxno
    FROM b_entrustment_identification_material
    WHERE im_no LIKE concat(#{prefix}, '%')
  </select>
<!-- 生成受理编号-->
  <select id="getMaxMaterialAcceptNo"  parameterType="String" resultType="java.lang.String">
    SELECT MAX(accept_no) AS maxno
    FROM b_entrustment_identification_material
    where accept_no LIKE concat(#{prefix}, '%')
  </select>

</mapper>
