<?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="org.dromara.zjk.mapper.ZjkItemExtreationMapper">
    <update id="updateItem" parameterType="java.lang.Long">
        update zjk_item_extreation
        set is_sure           = 1,
            extraction_status = 2
        where review_id = #{reviewId}
    </update>

    <select id="selectListByItem" resultType="java.lang.Long">
        select ex."id"
        from zjk_item_extreation ex
                 left join zjk_review_phase re on ex.review_id = re."id"
        where re."id" = 3747
           or re.parent_id = 3747
    </select>
    <select id="selectExtreationList" resultType="org.dromara.zjk.domain.vo.ZjkItemExtreationVo">
        SELECT
        zie.* ,zp.*,zrp.*,zrp.id as reviewId
        FROM
        zjk_item_extreation zie
        LEFT JOIN zjk_product zp ON zp.ID = zie.item_id
        LEFT JOIN zjk_review_phase zrp ON zrp.item_extreation_id = zie."id"
        <where>
            <if test="bo.effective != null">
                AND zrp.effective = #{bo.effective}
            </if>
            <if test="bo.extractionStatus != null ">
                and zie.extraction_status = #{bo.extractionStatus}
            </if>
            <if test="bo.startExtractionTime != null ">
                and zie.extraction_time >= #{bo.startExtractionTime}
            </if>
            <if test="bo.endExtractionTime != null ">
                and zie.extraction_time &lt;= #{bo.endExtractionTime}
            </if>
            <if test="bo.itemCode != null and bo.itemCode != '' ">
                and zp.product_sn like '%' || #{bo.itemCode} || '%'
            </if>
            <if test="bo.itemName != null and bo.itemName != '' ">
                and zp.product_name like '%' || #{bo.itemName}
            </if>
            <if test="bo.reviewSn != null and bo.reviewSn != '' ">
                and zrp.review_sn = #{bo.reviewSn}
            </if>
        </where>
        order by zie.extraction_time desc
    </select>
</mapper>
