<?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="cn.ezhizao.project.business.mapper.BizProcessInspectionDetailMapper">

    <resultMap type="cn.ezhizao.project.business.domain.BizProcessInspectionDetail" id="BizProcessInspectionDetailResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizProcessInspectionDetail" resultMap="BizProcessInspectionDetailResult">
        SELECT * FROM biz_process_inspection_detail
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="nickName != null  and nickName != ''"> AND nick_name like concat('%', #{nickName}, '%')</if>
            <if test="lotCode != null  and lotCode != ''"> AND lot_code = #{lotCode}</if>
            <if test="productDescription != null  and productDescription != ''"> AND product_description = #{productDescription}</if>
            <if test="type != null "> AND type = #{type}</if>
            <if test="checkStandard != null  and checkStandard != ''"> AND check_standard = #{checkStandard}</if>
            <if test="checkResult != null  and checkResult != ''"> AND check_result = #{checkResult}</if>
            <if test="exceedLimits != null  and exceedLimits != ''"> AND exceed_limits = #{exceedLimits}</if>
            <if test="rejectNum != null "> AND reject_num = #{rejectNum}</if>
            <if test="disqualificationNum != null "> AND disqualification_num = #{disqualificationNum}</if>
            <if test="examiningNum != null "> AND examining_num = #{examiningNum}</if>
        </trim>
    </select>
    <select id="getDetailByProcessInspectionId" resultMap="BizProcessInspectionDetailResult">
        select t1.reject_num ,t2.standard as check_standard,t1.check_result,t1.examining_num,t1.disqualification_num from biz_process_inspection_detail t1
        left join biz_inspection_standards t2 on t1.inspection_standards_id = t2.id
        where t1.process_inspection_id = #{processInspectionId} and t1.deleted = 0 and t2.deleted = 0
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_process_inspection_detail
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
