<?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.foreverwin.mesnac.meapi.mapper.SfcBomMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.SfcBom">
        <result column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SFC_BO" property="sfcBo" />
        <result column="BOM_BO" property="bomBo" />
        <result column="PREV_SITE" property="prevSite" />
        <result column="ORIGINAL_TRANSFER_KEY" property="originalTransferKey" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="PARTITION_DATE" property="partitionDate" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SFC_BO, BOM_BO, PREV_SITE, ORIGINAL_TRANSFER_KEY, MODIFIED_DATE_TIME, CREATED_DATE_TIME, PARTITION_DATE
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM SFC_BOM
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </select>


    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM SFC_BOM
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
            <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
            <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
            <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
            <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                <if test="ew.entity.handle!=null">
                    HANDLE=#{ew.entity.handle}
                </if>
                <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMaps" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectObjs" resultType="Object">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectPage" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMapsPage" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <insert id="insert" parameterType="com.foreverwin.mesnac.meapi.model.SfcBom">
        INSERT INTO SFC_BOM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="sfcBo!=null">SFC_BO,</if>
            <if test="bomBo!=null">BOM_BO,</if>
            <if test="prevSite!=null">PREV_SITE,</if>
            <if test="originalTransferKey!=null">ORIGINAL_TRANSFER_KEY,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="partitionDate!=null">PARTITION_DATE,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="sfcBo!=null">#{sfcBo},</if>
            <if test="bomBo!=null">#{bomBo},</if>
            <if test="prevSite!=null">#{prevSite},</if>
            <if test="originalTransferKey!=null">#{originalTransferKey},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="partitionDate!=null">#{partitionDate},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.SfcBom">
        INSERT INTO SFC_BOM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{sfcBo},
            #{bomBo},
            #{prevSite},
            #{originalTransferKey},
            #{modifiedDateTime},
            #{createdDateTime},
            #{partitionDate},
        </trim>
    </insert>






    <update id="update">
        UPDATE SFC_BOM <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.changeStamp!=null">CHANGE_STAMP=#{et.changeStamp},</if>
        <if test="et.sfcBo!=null">SFC_BO=#{et.sfcBo},</if>
        <if test="et.bomBo!=null">BOM_BO=#{et.bomBo},</if>
        <if test="et.prevSite!=null">PREV_SITE=#{et.prevSite},</if>
        <if test="et.originalTransferKey!=null">ORIGINAL_TRANSFER_KEY=#{et.originalTransferKey},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.partitionDate!=null">PARTITION_DATE=#{et.partitionDate},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </update>


    <delete id="deleteByMap">
        DELETE FROM SFC_BOM
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </delete>

    <delete id="delete">
        DELETE FROM SFC_BOM
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </delete>

    <!-- BaseMapper标准查询/修改/删除 -->

</mapper>
