<?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.willalp.yiqing.mapper.HsYiqingRnsResultMapper">

    <resultMap type="com.willalp.yiqing.domain.HsYiqingRnsResult" id="HsYiqingRnsResultResult">
        <result property="id" column="id"/>
        <result property="samplingTime" column="sampling_time"/>
        <result property="userDataId" column="user_data_id"/>
        <result property="sort" column="sort"/>
        <result property="resultTime" column="result_time"/>
        <result property="rnaResult" column="rna_result"/>
        <result property="ctValue" column="ct_value"/>
        <result property="antigenResult" column="antigen_result"/>
        <result property="excelT1" column="excel_t1"/>
        <result property="excelT2" column="excel_t2"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <resultMap type="com.willalp.yiqing.domain.vo.RnsResultVo" id="RnsResultResultVo">
        <result property="id" column="id"/>
        <result property="samplingTime" column="sampling_time"/>
        <result property="userName" column="user_name"/>
        <result property="otherAttest" column="other_attest"/>
        <result property="attestNo" column="attest_no"/>
        <result property="userDataId" column="user_data_id"/>
        <result property="sort" column="sort"/>
        <result property="resultTime" column="result_time"/>
        <result property="rnaResult" column="rna_result"/>
        <result property="ctValue" column="ct_value"/>
        <result property="antigenResult" column="antigen_result"/>
        <result property="excelT1" column="excel_t1"/>
        <result property="excelT2" column="excel_t2"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>
    <sql id="selectHsYiqingRnsResultVo">
        select id,
               sampling_time,
               hypcu.user_name    user_name,
               hypcu.other_attest other_attest,
               hypcu.attest_no    attest_no,
               user_data_id,
               sort,
               result_time,
               rna_result,
               ct_value,
               antigen_result,
               excel_t1,
               excel_t2,
               hyrr.create_time,
               hyrr.remark
        from hs_yiqing_rns_result hyrr,
             hs_yiqing_positive_contiguity_user hypcu
    </sql>

    <select id="selectHsYiqingRnsResultList" parameterType="RnsResultVo" resultMap="RnsResultResultVo">
        <include refid="selectHsYiqingRnsResultVo"/>
        <where>
            hyrr.is_delete = 0 and
            hypcu.is_delete = 0 and
            hyrr.user_data_id = hypcu.data_id
            <if test="userName != null  and userName != ''">
                  and hypcu.user_name like concat('%', #{userName}, '%')
            </if>
            <if test="samplingTime != null ">
                  and datediff(sampling_time, #{samplingTime}) = 0
            </if>
            <if test="userDataId != null  and userDataId != ''">
                  and user_data_id = #{userDataId}
            </if>
            <if test="sort != null  and sort != ''">
                  and sort = #{sort}
            </if>
            <if test="resultTime != null ">
                  and datediff(result_time, #{resultTime}) = 0
            </if>
            <if test="rnaResult != null  and rnaResult != ''">
                  and rna_result = #{rnaResult}
            </if>
            <if test="ctValue != null  and ctValue != ''">
                  and ct_value = #{ctValue}
            </if>
            <if test="antigenResult != null  and antigenResult != ''">
                  and antigen_result = #{antigenResult}
            </if>
        </where>
        order by sampling_time desc
    </select>
</mapper>
