<?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.op.wms.mapper.BaseBomItemsTMapper">
	
	<resultMap type="BaseBomItemsT" id="BaseBomItemsTResult">
		<result property="bomItemId"	column="BOM_Item_Id"	/>
		<result property="bomItemDesc"	column="BOM_Item_Desc"	/>
		<result property="bomFormulationOrder"	column="BOM_Formulation_Order"	/>
		<result property="bomFormulationId"	column="Bom_Formulation_Id"	/>
		<result property="prodId"	column="Prod_Id"	/>
		<result property="Quantity"	column="Quantity"	/>
		<result property="Precision"	column="Precision"	/>
		<result property="euId"	column="EU_Id"	/>
		<result property="lowerTolerance"	column="Lower_Tolerance"	/>
		<result property="lowerTolerancePrecision"	column="Lower_Tolerance_Precision"	/>
		<result property="upperTolerance"	column="Upper_Tolerance"	/>
		<result property="upperTolerancePrecision"	column="Upper_Tolerance_Precision"	/>
		<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="Active"	column="Active"	/>
		<result property="siteId"	column="Site_id"	/>
		<result property="siteCode"	column="Site_code"	/>
		<result property="enterpriseId"	column="Enterprise_Id"	/>
		<result property="enterpriseCode"	column="Enterprise_Code"	/>
		<result property="FactoryNo"	column="FactoryNo"	/>
		<result property="BESKZ"	column="BESKZ"	/>
		<result property="SOBSL"	column="SOBSL"	/>
		<result property="STUFE"	column="STUFE"	/>
	</resultMap>

	<sql id="selectBaseBomItemsTVo">
		select BOM_Item_Id, BOM_Item_Desc, BOM_Formulation_Order, Bom_Formulation_Id, Prod_Id, Quantity, Precision, EU_Id, Lower_Tolerance, Lower_Tolerance_Precision, Upper_Tolerance, Upper_Tolerance_Precision, create_by, create_time, update_by, update_time, Active, Site_id, Site_code, Enterprise_Id, Enterprise_Code, FactoryNo, BESKZ, SOBSL, STUFE from base_bom_items_t
	</sql>

	<select id="selectBaseBomItemsTList" parameterType="BaseBomItemsT" resultMap="BaseBomItemsTResult">
		<include refid="selectBaseBomItemsTVo"/>
		<where>  
			<if test="bomItemDesc != null  and bomItemDesc != ''"> and BOM_Item_Desc = #{bomItemDesc}</if>
			<if test="bomFormulationOrder != null "> and BOM_Formulation_Order = #{bomFormulationOrder}</if>
			<if test="bomFormulationId != null  and bomFormulationId != ''"> and Bom_Formulation_Id = #{bomFormulationId}</if>
			<if test="prodId != null  and prodId != ''"> and Prod_Id = #{prodId}</if>
			<if test="Quantity != null "> and Quantity = #{Quantity}</if>
			<if test="Precision != null "> and Precision = #{Precision}</if>
			<if test="euId != null  and euId != ''"> and EU_Id = #{euId}</if>
			<if test="lowerTolerance != null "> and Lower_Tolerance = #{lowerTolerance}</if>
			<if test="lowerTolerancePrecision != null "> and Lower_Tolerance_Precision = #{lowerTolerancePrecision}</if>
			<if test="upperTolerance != null "> and Upper_Tolerance = #{upperTolerance}</if>
			<if test="upperTolerancePrecision != null "> and Upper_Tolerance_Precision = #{upperTolerancePrecision}</if>
			<if test="Active != null  and Active != ''"> and Active = #{Active}</if>
			<if test="siteId != null  and siteId != ''"> and Site_id = #{siteId}</if>
			<if test="siteCode != null  and siteCode != ''"> and Site_code = #{siteCode}</if>
			<if test="enterpriseId != null  and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
			<if test="enterpriseCode != null  and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
			<if test="FactoryNo != null  and FactoryNo != ''"> and FactoryNo = #{FactoryNo}</if>
			<if test="BESKZ != null  and BESKZ != ''"> and BESKZ = #{BESKZ}</if>
			<if test="SOBSL != null  and SOBSL != ''"> and SOBSL = #{SOBSL}</if>
			<if test="STUFE != null  and STUFE != ''"> and STUFE = #{STUFE}</if>
		</where>
	</select>
	
	<select id="selectBaseBomItemsTByBomItemId" parameterType="String" resultMap="BaseBomItemsTResult">
		<include refid="selectBaseBomItemsTVo"/>
		where BOM_Item_Id = #{bomItemId}
	</select>
		
	<insert id="insertBaseBomItemsT" parameterType="BaseBomItemsT">
		insert into base_bom_items_t
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="bomItemId != null">BOM_Item_Id,</if>
			<if test="bomItemDesc != null">BOM_Item_Desc,</if>
			<if test="bomFormulationOrder != null">BOM_Formulation_Order,</if>
			<if test="bomFormulationId != null">Bom_Formulation_Id,</if>
			<if test="prodId != null">Prod_Id,</if>
			<if test="Quantity != null">Quantity,</if>
			<if test="Precision != null">Precision,</if>
			<if test="euId != null">EU_Id,</if>
			<if test="lowerTolerance != null">Lower_Tolerance,</if>
			<if test="lowerTolerancePrecision != null">Lower_Tolerance_Precision,</if>
			<if test="upperTolerance != null">Upper_Tolerance,</if>
			<if test="upperTolerancePrecision != null">Upper_Tolerance_Precision,</if>
			<if test="createBy != null">create_by,</if>
			<if test="createTime != null">create_time,</if>
			<if test="updateBy != null">update_by,</if>
			<if test="updateTime != null">update_time,</if>
			<if test="Active != null">Active,</if>
			<if test="siteId != null">Site_id,</if>
			<if test="siteCode != null">Site_code,</if>
			<if test="enterpriseId != null">Enterprise_Id,</if>
			<if test="enterpriseCode != null">Enterprise_Code,</if>
			<if test="FactoryNo != null">FactoryNo,</if>
			<if test="BESKZ != null">BESKZ,</if>
			<if test="SOBSL != null">SOBSL,</if>
			<if test="STUFE != null">STUFE,</if>
		 </trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="bomItemId != null">#{bomItemId},</if>
			<if test="bomItemDesc != null">#{bomItemDesc},</if>
			<if test="bomFormulationOrder != null">#{bomFormulationOrder},</if>
			<if test="bomFormulationId != null">#{bomFormulationId},</if>
			<if test="prodId != null">#{prodId},</if>
			<if test="Quantity != null">#{Quantity},</if>
			<if test="Precision != null">#{Precision},</if>
			<if test="euId != null">#{euId},</if>
			<if test="lowerTolerance != null">#{lowerTolerance},</if>
			<if test="lowerTolerancePrecision != null">#{lowerTolerancePrecision},</if>
			<if test="upperTolerance != null">#{upperTolerance},</if>
			<if test="upperTolerancePrecision != null">#{upperTolerancePrecision},</if>
			<if test="createBy != null">#{createBy},</if>
			<if test="createTime != null">#{createTime},</if>
			<if test="updateBy != null">#{updateBy},</if>
			<if test="updateTime != null">#{updateTime},</if>
			<if test="Active != null">#{Active},</if>
			<if test="siteId != null">#{siteId},</if>
			<if test="siteCode != null">#{siteCode},</if>
			<if test="enterpriseId != null">#{enterpriseId},</if>
			<if test="enterpriseCode != null">#{enterpriseCode},</if>
			<if test="FactoryNo != null">#{FactoryNo},</if>
			<if test="BESKZ != null">#{BESKZ},</if>
			<if test="SOBSL != null">#{SOBSL},</if>
			<if test="STUFE != null">#{STUFE},</if>
		 </trim>
	</insert>

	<update id="updateBaseBomItemsT" parameterType="BaseBomItemsT">
		update base_bom_items_t
		<trim prefix="SET" suffixOverrides=",">
			<if test="bomItemDesc != null">BOM_Item_Desc = #{bomItemDesc},</if>
			<if test="bomFormulationOrder != null">BOM_Formulation_Order = #{bomFormulationOrder},</if>
			<if test="bomFormulationId != null">Bom_Formulation_Id = #{bomFormulationId},</if>
			<if test="prodId != null">Prod_Id = #{prodId},</if>
			<if test="Quantity != null">Quantity = #{Quantity},</if>
			<if test="Precision != null">Precision = #{Precision},</if>
			<if test="euId != null">EU_Id = #{euId},</if>
			<if test="lowerTolerance != null">Lower_Tolerance = #{lowerTolerance},</if>
			<if test="lowerTolerancePrecision != null">Lower_Tolerance_Precision = #{lowerTolerancePrecision},</if>
			<if test="upperTolerance != null">Upper_Tolerance = #{upperTolerance},</if>
			<if test="upperTolerancePrecision != null">Upper_Tolerance_Precision = #{upperTolerancePrecision},</if>
			<if test="createBy != null">create_by = #{createBy},</if>
			<if test="createTime != null">create_time = #{createTime},</if>
			<if test="updateBy != null">update_by = #{updateBy},</if>
			<if test="updateTime != null">update_time = #{updateTime},</if>
			<if test="Active != null">Active = #{Active},</if>
			<if test="siteId != null">Site_id = #{siteId},</if>
			<if test="siteCode != null">Site_code = #{siteCode},</if>
			<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
			<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
			<if test="FactoryNo != null">FactoryNo = #{FactoryNo},</if>
			<if test="BESKZ != null">BESKZ = #{BESKZ},</if>
			<if test="SOBSL != null">SOBSL = #{SOBSL},</if>
			<if test="STUFE != null">STUFE = #{STUFE},</if>
		</trim>
		where BOM_Item_Id = #{bomItemId}
	</update>

	<delete id="deleteBaseBomItemsTByBomItemId" parameterType="String">
		delete from base_bom_items_t where BOM_Item_Id = #{bomItemId}
	</delete>

	<delete id="deleteBaseBomItemsTByBomItemIds" parameterType="String">
		delete from base_bom_items_t where BOM_Item_Id in 
		<foreach item="bomItemId" collection="array" open="(" separator="," close=")">
			#{bomItemId}
		</foreach>
	</delete>
</mapper>