<?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.daywork.mapper.BizLotMapper">

    <resultMap type="cn.ezhizao.project.business.daywork.domain.BizLot" id="BizLotResult">
        <id column="id" property="id"/>
        <result column="product_id" property="productId"/>
    </resultMap>

    <select id="getList" parameterType="BizLot" resultMap="BizLotResult">
        SELECT * FROM biz_lot
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            AND id NOT IN(select lot_id from biz_daywork where biz_daywork.deleted = 0) and is_waste_recycling = 0 and is_amend=0
            <if test="id != null and id != ''"> AND id = #{id}</if>
            <if test="lotCode != null  and lotCode != ''"> AND lot_code = #{lotCode}</if>
            <if test="productionPlanDetailId != null and productionPlanDetailId!=''"> AND production_plan_detail_id = #{productionPlanDetailId}</if>
            <if test="productCode != null  and productCode != ''"> AND product_code = #{productCode}</if>
            <if test="specification != null  and specification != ''"> AND specification = #{specification}</if>
            <if test="drawingNumber != null  and drawingNumber != ''"> AND drawing_number = #{drawingNumber}</if>
        </trim>
    </select>

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