<?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.BomMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.Bom">
        <id column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SITE" property="site" />
        <result column="BOM" property="bom" />
        <result column="BOM_TYPE" property="bomType" />
        <result column="DESCRIPTION" property="description" />
        <result column="STATUS_BO" property="statusBo" />
        <result column="TMP_BOM" property="tmpBom" />
        <result column="COPIED_FROM_BOM_BO" property="copiedFromBomBo" />
        <result column="REVISION" property="revision" />
        <result column="CURRENT_REVISION" property="currentRevision" />
        <result column="BOM_TEMPLATE" property="bomTemplate" />
        <result column="HAS_BEEN_RELEASED" property="hasBeenReleased" />
        <result column="EFF_START_DATE" property="effStartDate" />
        <result column="EFF_END_DATE" property="effEndDate" />
        <result column="EFFECTIVITY_CONTROL" property="effectivityControl" />
        <result column="PREV_SITE" property="prevSite" />
        <result column="ORIGINAL_TRANSFER_KEY" property="originalTransferKey" />
        <result column="ERP_BILL_OF_MATERIAL" property="erpBillOfMaterial" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="PARTITION_DATE" property="partitionDate" />
        <result column="MODEL" property="model" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SITE, BOM, BOM_TYPE, DESCRIPTION, STATUS_BO, TMP_BOM, COPIED_FROM_BOM_BO, REVISION, CURRENT_REVISION, BOM_TEMPLATE, HAS_BEEN_RELEASED, EFF_START_DATE, EFF_END_DATE, EFFECTIVITY_CONTROL, PREV_SITE, ORIGINAL_TRANSFER_KEY, ERP_BILL_OF_MATERIAL, CREATED_DATE_TIME, MODIFIED_DATE_TIME, PARTITION_DATE, MODEL
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="selectById" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM BOM WHERE HANDLE=#{handle}
    </select>

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM 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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
            <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
            <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
            <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
            <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
            <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
            <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
            <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
            <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
            <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
            <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
            <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
            <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
            <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
            <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</if>
            <if test="ew.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.changeStamp!=null"> AND CHANGE_STAMP=#{ew.changeStamp}</if>
            <if test="ew.site!=null"> AND SITE=#{ew.site}</if>
            <if test="ew.bom!=null"> AND BOM=#{ew.bom}</if>
            <if test="ew.bomType!=null"> AND BOM_TYPE=#{ew.bomType}</if>
            <if test="ew.description!=null"> AND DESCRIPTION=#{ew.description}</if>
            <if test="ew.statusBo!=null"> AND STATUS_BO=#{ew.statusBo}</if>
            <if test="ew.tmpBom!=null"> AND TMP_BOM=#{ew.tmpBom}</if>
            <if test="ew.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.copiedFromBomBo}</if>
            <if test="ew.revision!=null"> AND REVISION=#{ew.revision}</if>
            <if test="ew.currentRevision!=null"> AND CURRENT_REVISION=#{ew.currentRevision}</if>
            <if test="ew.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.bomTemplate}</if>
            <if test="ew.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.hasBeenReleased}</if>
            <if test="ew.effStartDate!=null"> AND EFF_START_DATE=#{ew.effStartDate}</if>
            <if test="ew.effEndDate!=null"> AND EFF_END_DATE=#{ew.effEndDate}</if>
            <if test="ew.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.effectivityControl}</if>
            <if test="ew.prevSite!=null"> AND PREV_SITE=#{ew.prevSite}</if>
            <if test="ew.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.originalTransferKey}</if>
            <if test="ew.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.erpBillOfMaterial}</if>
            <if test="ew.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.createdDateTime}</if>
            <if test="ew.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.modifiedDateTime}</if>
            <if test="ew.partitionDate!=null"> AND PARTITION_DATE=#{ew.partitionDate}</if>
            <if test="ew.model!=null"> AND MODEL=#{ew.model}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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.Bom">
        INSERT INTO BOM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="site!=null">SITE,</if>
            <if test="bom!=null">BOM,</if>
            <if test="bomType!=null">BOM_TYPE,</if>
            <if test="description!=null">DESCRIPTION,</if>
            <if test="statusBo!=null">STATUS_BO,</if>
            <if test="tmpBom!=null">TMP_BOM,</if>
            <if test="copiedFromBomBo!=null">COPIED_FROM_BOM_BO,</if>
            <if test="revision!=null">REVISION,</if>
            <if test="currentRevision!=null">CURRENT_REVISION,</if>
            <if test="bomTemplate!=null">BOM_TEMPLATE,</if>
            <if test="hasBeenReleased!=null">HAS_BEEN_RELEASED,</if>
            <if test="effStartDate!=null">EFF_START_DATE,</if>
            <if test="effEndDate!=null">EFF_END_DATE,</if>
            <if test="effectivityControl!=null">EFFECTIVITY_CONTROL,</if>
            <if test="prevSite!=null">PREV_SITE,</if>
            <if test="originalTransferKey!=null">ORIGINAL_TRANSFER_KEY,</if>
            <if test="erpBillOfMaterial!=null">ERP_BILL_OF_MATERIAL,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="partitionDate!=null">PARTITION_DATE,</if>
            <if test="model!=null">MODEL,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="site!=null">#{site},</if>
            <if test="bom!=null">#{bom},</if>
            <if test="bomType!=null">#{bomType},</if>
            <if test="description!=null">#{description},</if>
            <if test="statusBo!=null">#{statusBo},</if>
            <if test="tmpBom!=null">#{tmpBom},</if>
            <if test="copiedFromBomBo!=null">#{copiedFromBomBo},</if>
            <if test="revision!=null">#{revision},</if>
            <if test="currentRevision!=null">#{currentRevision},</if>
            <if test="bomTemplate!=null">#{bomTemplate},</if>
            <if test="hasBeenReleased!=null">#{hasBeenReleased},</if>
            <if test="effStartDate!=null">#{effStartDate},</if>
            <if test="effEndDate!=null">#{effEndDate},</if>
            <if test="effectivityControl!=null">#{effectivityControl},</if>
            <if test="prevSite!=null">#{prevSite},</if>
            <if test="originalTransferKey!=null">#{originalTransferKey},</if>
            <if test="erpBillOfMaterial!=null">#{erpBillOfMaterial},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="partitionDate!=null">#{partitionDate},</if>
            <if test="model!=null">#{model},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.Bom">
        INSERT INTO BOM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{site},
            #{bom},
            #{bomType},
            #{description},
            #{statusBo},
            #{tmpBom},
            #{copiedFromBomBo},
            #{revision},
            #{currentRevision},
            #{bomTemplate},
            #{hasBeenReleased},
            #{effStartDate},
            #{effEndDate},
            #{effectivityControl},
            #{prevSite},
            #{originalTransferKey},
            #{erpBillOfMaterial},
            #{createdDateTime},
            #{modifiedDateTime},
            #{partitionDate},
            #{model},
        </trim>
    </insert>

    <update id="update">
        UPDATE 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.site!=null">SITE=#{et.site},</if>
        <if test="et.bom!=null">BOM=#{et.bom},</if>
        <if test="et.bomType!=null">BOM_TYPE=#{et.bomType},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.statusBo!=null">STATUS_BO=#{et.statusBo},</if>
        <if test="et.tmpBom!=null">TMP_BOM=#{et.tmpBom},</if>
        <if test="et.copiedFromBomBo!=null">COPIED_FROM_BOM_BO=#{et.copiedFromBomBo},</if>
        <if test="et.revision!=null">REVISION=#{et.revision},</if>
        <if test="et.currentRevision!=null">CURRENT_REVISION=#{et.currentRevision},</if>
        <if test="et.bomTemplate!=null">BOM_TEMPLATE=#{et.bomTemplate},</if>
        <if test="et.hasBeenReleased!=null">HAS_BEEN_RELEASED=#{et.hasBeenReleased},</if>
        <if test="et.effStartDate!=null">EFF_START_DATE=#{et.effStartDate},</if>
        <if test="et.effEndDate!=null">EFF_END_DATE=#{et.effEndDate},</if>
        <if test="et.effectivityControl!=null">EFFECTIVITY_CONTROL=#{et.effectivityControl},</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.erpBillOfMaterial!=null">ERP_BILL_OF_MATERIAL=#{et.erpBillOfMaterial},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.partitionDate!=null">PARTITION_DATE=#{et.partitionDate},</if>
        <if test="et.model!=null">MODEL=#{et.model},</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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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 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 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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.bom!=null"> AND BOM=#{ew.entity.bom}</if>
                    <if test="ew.entity.bomType!=null"> AND BOM_TYPE=#{ew.entity.bomType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.tmpBom!=null"> AND TMP_BOM=#{ew.entity.tmpBom}</if>
                    <if test="ew.entity.copiedFromBomBo!=null"> AND COPIED_FROM_BOM_BO=#{ew.entity.copiedFromBomBo}</if>
                    <if test="ew.entity.revision!=null"> AND REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.hasBeenReleased!=null"> AND HAS_BEEN_RELEASED=#{ew.entity.hasBeenReleased}</if>
                    <if test="ew.entity.effStartDate!=null"> AND EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.effectivityControl!=null"> AND EFFECTIVITY_CONTROL=#{ew.entity.effectivityControl}</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.erpBillOfMaterial!=null"> AND ERP_BILL_OF_MATERIAL=#{ew.entity.erpBillOfMaterial}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.partitionDate!=null"> AND PARTITION_DATE=#{ew.entity.partitionDate}</if>
                    <if test="ew.entity.model!=null"> AND MODEL=#{ew.entity.model}</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标准查询/修改/删除 -->
    <select id="selectBomList4RevisionDesc" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM BOM
        WHERE SITE = #{site} AND BOM = #{bom}
        ORDER BY TO_NUMBER(REVISION) DESC
    </select>

    <select id="getBomByItem" resultMap="BaseResultMap">
        SELECT HANDLE FROM BOM
        WHERE SITE = #{site} AND BOM LIKE '%' || #{item} || '%' AND BOM_TYPE = 'U'
        AND REVISION LIKE '%-%'
        ORDER BY MODIFIED_DATE_TIME DESC
    </select>
</mapper>
