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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.BomComponent">
        <result column="HANDLE" property="handle"/>
        <result column="BOM_BO" property="bomBo"/>
        <result column="COMPONENT_GBO" property="componentGbo"/>
        <result column="SEQUENCE" property="sequence"/>
        <result column="ENABLED" property="enabled"/>
        <result column="VALID_START" property="validStart"/>
        <result column="VALID_END" property="validEnd"/>
        <result column="USE_ITEM_DEFAULTS" property="useItemDefaults"/>
        <result column="PRE_ASSEMBLED" property="preAssembled"/>
        <result column="ASSY_DATA_TYPE_BO" property="assyDataTypeBo"/>
        <result column="QTY" property="qty"/>
        <result column="TEST_PART" property="testPart"/>
        <result column="BOM_TEMPLATE" property="bomTemplate"/>
        <result column="DISASSEMBLE_OPERATION_BO" property="disassembleOperationBo"/>
        <result column="CREATE_TRACKABLE_SFC" property="createTrackableSfc"/>
        <result column="MAXIMUM_USAGE" property="maximumUsage"/>
        <result column="MAXIMUM_NC" property="maximumNc"/>
        <result column="ASSEMBLE_AS_REQ" property="assembleAsReq"/>
        <result column="AUTO_CONSUME_KIT" property="autoConsumeKit"/>
        <result column="CREATED_DATE_TIME" property="createdDateTime"/>
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime"/>
        <result column="BOM_COMPONENT_TYPE" property="bomComponentType"/>
        <result column="PARENT_SEQUENCE" property="parentSequence"/>
        <result column="ERP_SEQUENCE" property="erpSequence"/>
        <result column="ORDER_ITEM_NUMBER" property="orderItemNumber"/>
        <result column="ERP_CHANGE_NUMBER" property="erpChangeNumber"/>
        <result column="IDENTIFIER" property="identifier"/>
        <result column="STORAGE_LOCATION_BO" property="storageLocationBo"/>
        <result column="STEP_ID" property="stepId"/>
        <result column="ACCESSORY_TYPE" property="accessoryType"/>
        <result column="OPERATION" property="operation"/>
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, BOM_BO, COMPONENT_GBO, SEQUENCE, ENABLED, VALID_START, VALID_END, USE_ITEM_DEFAULTS, PRE_ASSEMBLED, ASSY_DATA_TYPE_BO, QTY, TEST_PART, BOM_TEMPLATE, DISASSEMBLE_OPERATION_BO, CREATE_TRACKABLE_SFC, MAXIMUM_USAGE, MAXIMUM_NC, ASSEMBLE_AS_REQ, AUTO_CONSUME_KIT, CREATED_DATE_TIME, MODIFIED_DATE_TIME, BOM_COMPONENT_TYPE, PARENT_SEQUENCE, ERP_SEQUENCE, ORDER_ITEM_NUMBER, ERP_CHANGE_NUMBER, IDENTIFIER, STORAGE_LOCATION_BO
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM BOM_COMPONENT
        <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_COMPONENT
        <where>
            <if test="ew.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.bomBo!=null"> AND BOM_BO=#{ew.bomBo}</if>
            <if test="ew.componentGbo!=null"> AND COMPONENT_GBO=#{ew.componentGbo}</if>
            <if test="ew.sequence!=null"> AND SEQUENCE=#{ew.sequence}</if>
            <if test="ew.enabled!=null"> AND ENABLED=#{ew.enabled}</if>
            <if test="ew.validStart!=null"> AND VALID_START=#{ew.validStart}</if>
            <if test="ew.validEnd!=null"> AND VALID_END=#{ew.validEnd}</if>
            <if test="ew.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.useItemDefaults}</if>
            <if test="ew.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.preAssembled}</if>
            <if test="ew.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.assyDataTypeBo}</if>
            <if test="ew.qty!=null"> AND QTY=#{ew.qty}</if>
            <if test="ew.testPart!=null"> AND TEST_PART=#{ew.testPart}</if>
            <if test="ew.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.bomTemplate}</if>
            <if test="ew.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.disassembleOperationBo}</if>
            <if test="ew.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.createTrackableSfc}</if>
            <if test="ew.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.maximumUsage}</if>
            <if test="ew.maximumNc!=null"> AND MAXIMUM_NC=#{ew.maximumNc}</if>
            <if test="ew.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.assembleAsReq}</if>
            <if test="ew.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.bomComponentType}</if>
            <if test="ew.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.parentSequence}</if>
            <if test="ew.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.erpSequence}</if>
            <if test="ew.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.orderItemNumber}</if>
            <if test="ew.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.erpChangeNumber}</if>
            <if test="ew.identifier!=null"> AND IDENTIFIER=#{ew.identifier}</if>
            <if test="ew.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.storageLocationBo}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM BOM_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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.BomComponent">
        INSERT INTO BOM_COMPONENT
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="bomBo!=null">BOM_BO,</if>
            <if test="componentGbo!=null">COMPONENT_GBO,</if>
            <if test="sequence!=null">SEQUENCE,</if>
            <if test="enabled!=null">ENABLED,</if>
            <if test="validStart!=null">VALID_START,</if>
            <if test="validEnd!=null">VALID_END,</if>
            <if test="useItemDefaults!=null">USE_ITEM_DEFAULTS,</if>
            <if test="preAssembled!=null">PRE_ASSEMBLED,</if>
            <if test="assyDataTypeBo!=null">ASSY_DATA_TYPE_BO,</if>
            <if test="qty!=null">QTY,</if>
            <if test="testPart!=null">TEST_PART,</if>
            <if test="bomTemplate!=null">BOM_TEMPLATE,</if>
            <if test="disassembleOperationBo!=null">DISASSEMBLE_OPERATION_BO,</if>
            <if test="createTrackableSfc!=null">CREATE_TRACKABLE_SFC,</if>
            <if test="maximumUsage!=null">MAXIMUM_USAGE,</if>
            <if test="maximumNc!=null">MAXIMUM_NC,</if>
            <if test="assembleAsReq!=null">ASSEMBLE_AS_REQ,</if>
            <if test="autoConsumeKit!=null">AUTO_CONSUME_KIT,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="bomComponentType!=null">BOM_COMPONENT_TYPE,</if>
            <if test="parentSequence!=null">PARENT_SEQUENCE,</if>
            <if test="erpSequence!=null">ERP_SEQUENCE,</if>
            <if test="orderItemNumber!=null">ORDER_ITEM_NUMBER,</if>
            <if test="erpChangeNumber!=null">ERP_CHANGE_NUMBER,</if>
            <if test="identifier!=null">IDENTIFIER,</if>
            <if test="storageLocationBo!=null">STORAGE_LOCATION_BO,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="bomBo!=null">#{bomBo},</if>
            <if test="componentGbo!=null">#{componentGbo},</if>
            <if test="sequence!=null">#{sequence},</if>
            <if test="enabled!=null">#{enabled},</if>
            <if test="validStart!=null">#{validStart},</if>
            <if test="validEnd!=null">#{validEnd},</if>
            <if test="useItemDefaults!=null">#{useItemDefaults},</if>
            <if test="preAssembled!=null">#{preAssembled},</if>
            <if test="assyDataTypeBo!=null">#{assyDataTypeBo},</if>
            <if test="qty!=null">#{qty},</if>
            <if test="testPart!=null">#{testPart},</if>
            <if test="bomTemplate!=null">#{bomTemplate},</if>
            <if test="disassembleOperationBo!=null">#{disassembleOperationBo},</if>
            <if test="createTrackableSfc!=null">#{createTrackableSfc},</if>
            <if test="maximumUsage!=null">#{maximumUsage},</if>
            <if test="maximumNc!=null">#{maximumNc},</if>
            <if test="assembleAsReq!=null">#{assembleAsReq},</if>
            <if test="autoConsumeKit!=null">#{autoConsumeKit},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="bomComponentType!=null">#{bomComponentType},</if>
            <if test="parentSequence!=null">#{parentSequence},</if>
            <if test="erpSequence!=null">#{erpSequence},</if>
            <if test="orderItemNumber!=null">#{orderItemNumber},</if>
            <if test="erpChangeNumber!=null">#{erpChangeNumber},</if>
            <if test="identifier!=null">#{identifier},</if>
            <if test="storageLocationBo!=null">#{storageLocationBo},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.BomComponent">
        INSERT INTO BOM_COMPONENT
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{bomBo},
            #{componentGbo},
            #{sequence},
            #{enabled},
            #{validStart},
            #{validEnd},
            #{useItemDefaults},
            #{preAssembled},
            #{assyDataTypeBo},
            #{qty},
            #{testPart},
            #{bomTemplate},
            #{disassembleOperationBo},
            #{createTrackableSfc},
            #{maximumUsage},
            #{maximumNc},
            #{assembleAsReq},
            #{autoConsumeKit},
            #{createdDateTime},
            #{modifiedDateTime},
            #{bomComponentType},
            #{parentSequence},
            #{erpSequence},
            #{orderItemNumber},
            #{erpChangeNumber},
            #{identifier},
            #{storageLocationBo},
        </trim>
    </insert>






    <update id="update">
        UPDATE BOM_COMPONENT <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.bomBo!=null">BOM_BO=#{et.bomBo},</if>
        <if test="et.componentGbo!=null">COMPONENT_GBO=#{et.componentGbo},</if>
        <if test="et.sequence!=null">SEQUENCE=#{et.sequence},</if>
        <if test="et.enabled!=null">ENABLED=#{et.enabled},</if>
        <if test="et.validStart!=null">VALID_START=#{et.validStart},</if>
        <if test="et.validEnd!=null">VALID_END=#{et.validEnd},</if>
        <if test="et.useItemDefaults!=null">USE_ITEM_DEFAULTS=#{et.useItemDefaults},</if>
        <if test="et.preAssembled!=null">PRE_ASSEMBLED=#{et.preAssembled},</if>
        <if test="et.assyDataTypeBo!=null">ASSY_DATA_TYPE_BO=#{et.assyDataTypeBo},</if>
        <if test="et.qty!=null">QTY=#{et.qty},</if>
        <if test="et.testPart!=null">TEST_PART=#{et.testPart},</if>
        <if test="et.bomTemplate!=null">BOM_TEMPLATE=#{et.bomTemplate},</if>
        <if test="et.disassembleOperationBo!=null">DISASSEMBLE_OPERATION_BO=#{et.disassembleOperationBo},</if>
        <if test="et.createTrackableSfc!=null">CREATE_TRACKABLE_SFC=#{et.createTrackableSfc},</if>
        <if test="et.maximumUsage!=null">MAXIMUM_USAGE=#{et.maximumUsage},</if>
        <if test="et.maximumNc!=null">MAXIMUM_NC=#{et.maximumNc},</if>
        <if test="et.assembleAsReq!=null">ASSEMBLE_AS_REQ=#{et.assembleAsReq},</if>
        <if test="et.autoConsumeKit!=null">AUTO_CONSUME_KIT=#{et.autoConsumeKit},</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.bomComponentType!=null">BOM_COMPONENT_TYPE=#{et.bomComponentType},</if>
        <if test="et.parentSequence!=null">PARENT_SEQUENCE=#{et.parentSequence},</if>
        <if test="et.erpSequence!=null">ERP_SEQUENCE=#{et.erpSequence},</if>
        <if test="et.orderItemNumber!=null">ORDER_ITEM_NUMBER=#{et.orderItemNumber},</if>
        <if test="et.erpChangeNumber!=null">ERP_CHANGE_NUMBER=#{et.erpChangeNumber},</if>
        <if test="et.identifier!=null">IDENTIFIER=#{et.identifier},</if>
        <if test="et.storageLocationBo!=null">STORAGE_LOCATION_BO=#{et.storageLocationBo},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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_COMPONENT
        <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_COMPONENT
        <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.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGbo!=null"> AND COMPONENT_GBO=#{ew.entity.componentGbo}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.enabled!=null"> AND ENABLED=#{ew.entity.enabled}</if>
                    <if test="ew.entity.validStart!=null"> AND VALID_START=#{ew.entity.validStart}</if>
                    <if test="ew.entity.validEnd!=null"> AND VALID_END=#{ew.entity.validEnd}</if>
                    <if test="ew.entity.useItemDefaults!=null"> AND USE_ITEM_DEFAULTS=#{ew.entity.useItemDefaults}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.testPart!=null"> AND TEST_PART=#{ew.entity.testPart}</if>
                    <if test="ew.entity.bomTemplate!=null"> AND BOM_TEMPLATE=#{ew.entity.bomTemplate}</if>
                    <if test="ew.entity.disassembleOperationBo!=null"> AND DISASSEMBLE_OPERATION_BO=#{ew.entity.disassembleOperationBo}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.maximumNc!=null"> AND MAXIMUM_NC=#{ew.entity.maximumNc}</if>
                    <if test="ew.entity.assembleAsReq!=null"> AND ASSEMBLE_AS_REQ=#{ew.entity.assembleAsReq}</if>
                    <if test="ew.entity.autoConsumeKit!=null"> AND AUTO_CONSUME_KIT=#{ew.entity.autoConsumeKit}</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.bomComponentType!=null"> AND BOM_COMPONENT_TYPE=#{ew.entity.bomComponentType}</if>
                    <if test="ew.entity.parentSequence!=null"> AND PARENT_SEQUENCE=#{ew.entity.parentSequence}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</if>
                    <if test="ew.entity.orderItemNumber!=null"> AND ORDER_ITEM_NUMBER=#{ew.entity.orderItemNumber}</if>
                    <if test="ew.entity.erpChangeNumber!=null"> AND ERP_CHANGE_NUMBER=#{ew.entity.erpChangeNumber}</if>
                    <if test="ew.entity.identifier!=null"> AND IDENTIFIER=#{ew.entity.identifier}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</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="selectBomComponentByOperation" resultMap="BaseResultMap">
        SELECT BC.*  FROM BOM_COMPONENT BC
        JOIN BOM_OPERATION BO ON BO.BOM_COMPONENT_BO =BC.HANDLE AND BO.OPERATION_BO =#{operationBo}
        WHERE BC.BOM_BO =#{bomBo}
    </select>

    <select id="selectByBomBo" resultMap="BaseResultMap">
        SELECT BC.*
        FROM BOM_COMPONENT BC
        INNER JOIN ITEM I ON I.HANDLE=BC.COMPONENT_GBO
        LEFT JOIN ITEM_T IT
          ON IT.ITEM_BO = I.HANDLE AND IT.LOCALE = #{locale}
        LEFT JOIN BOM_OPERATION BO
          ON BO.BOM_COMPONENT_BO = BC.HANDLE
        WHERE BC.BOM_BO = #{bomBo}
    </select>

    <select id="getBomComponentMainFlag" resultMap="com.foreverwin.mesnac.meapi.mapper.CustomFieldsMapper.BaseResultMap">
        SELECT
            BEIKZ.VALUE
        FROM BOM BOM
        JOIN BOM_COMPONENT BC ON BOM.HANDLE = BC.BOM_BO
        JOIN CUSTOM_FIELDS BEIKZ ON BC.HANDLE = BEIKZ.HANDLE AND BEIKZ."ATTRIBUTE" = 'BEIKZ'
        WHERE BC.COMPONENT_GBO = #{componentBo}
              AND BOM.HANDLE = #{bomBo}
    </select>

    <select id="selectNeedAssemblyQty" resultType="java.lang.Integer">
    SELECT SUM(bc.QTY) qty FROM BOM_COMPONENT BC
    JOIN ITEM IT ON ((BC.COMPONENT_GBO='ItemBO:'||IT.SITE||','||IT.ITEM||',#'  AND IT.CURRENT_REVISION='true') OR IT.HANDLE=BC.COMPONENT_GBO)
    JOIN CUSTOM_FIELDS CFS ON IT.HANDLE = CFS.HANDLE AND CFS.ATTRIBUTE = 'ZZTRACEABIITY_TYPE' AND CFS.VALUE = '1'
    JOIN BOM_OPERATION BO ON BC.HANDLE =BO.BOM_COMPONENT_BO AND OPERATION_BO=#{operationBo}
    WHERE  BC.BOM_BO =#{bomBo}
    </select>
    <select id="selectListBySfcBoOAndOperationBo"  resultMap="BaseResultMap">
        SELECT BO.*
        FROM SFC_BOM S
        INNER JOIN BOM_COMPONENT M ON S.BOM_BO=M.BOM_BO
        INNER JOIN BOM_OPERATION BO ON BO.BOM_COMPONENT_BO=M.HANDLE
        INNER JOIN SFC SF ON SF.HANDLE=S.SFC_BO
        WHERE S.SFC_BO =#{sfcBo}
        <if test="operationBo != null and operationBo != ''">
            AND BO.OPERATION_BO =#{operationBo}
        </if>
    </select>

    <select id="selectListByBomBoAndBomItemNo"  resultMap="BaseResultMap">
        SELECT *
        FROM BOM_COMPONENT
        WHERE BOM_BO = #{bomBo}
        AND SEQUENCE IN
        (
          <foreach item="item" index="index" collection="bomItemNoList" separator=",">#{item}</foreach>
        )
    </select>

    <select id="selectListByShopOrderBo" resultMap="BaseResultMap">
        SELECT BC.*
        FROM SHOP_ORDER SO
        INNER JOIN BOM_COMPONENT BC
        ON CASE WHEN SO.BOM_BO IS NULL THEN SO.PLANNED_BOM_BO ELSE SO.BOM_BO END = BC.BOM_BO
        WHERE SO.HANDLE = #{shopOrderBo}
    </select>

    <select id="selectListByShopOrderBoItemBo" resultMap="BaseResultMap">
        SELECT BC.*
        FROM SHOP_ORDER SO
        INNER JOIN BOM_COMPONENT BC
        ON CASE WHEN SO.BOM_BO IS NULL THEN SO.PLANNED_BOM_BO ELSE SO.BOM_BO END = BC.BOM_BO
        WHERE SO.HANDLE = #{shopOrderBo} AND (COMPONENT_GBO = #{itemBo} OR COMPONENT_GBO = 'ItemBO:' || SO.SITE || ',' || #{item} || ',#')
    </select>

    <select id="selectShopOrderBomComponentByWorkCenterBo" resultMap="BaseResultMap">
        SELECT DISTINCT BC.COMPONENT_GBO
        FROM SHOP_ORDER S
        JOIN BOM_COMPONENT bc ON s.PLANNED_BOM_BO =bc.BOM_BO
        JOIN CUSTOM_FIELDS CF ON S.HANDLE = CF.HANDLE AND CF.ATTRIBUTE = 'WORK_ORDER_STATUS' AND CF.VALUE != '已完成' AND CF.VALUE != '取消'
        WHERE PLANNED_WORK_CENTER_BO = #{workCenterBO}
    </select>

    <select id = "getSfcBomComponent" resultMap="BaseResultMap">
        SELECT RS.STEP_ID,OP.OPERATION,BC.COMPONENT_GBO,TP.VALUE ACCESSORY_TYPE
   		FROM SFC SFC
   		JOIN SFC_ROUTING SRI ON SRI.SFC_BO =SFC.HANDLE
   		JOIN SFC_ROUTER SR ON SRI.HANDLE =SR.SFC_ROUTING_BO
        JOIN ROUTER_STEP rs ON RS.ROUTER_BO =SR.ROUTER_BO
        JOIN ROUTER_OPERATION ro ON rs.HANDLE =ro.ROUTER_STEP_BO
        JOIN SFC_BOM SB ON SFC.HANDLE =SB.SFC_BO
        JOIN BOM_COMPONENT BC ON SB.BOM_BO =BC.BOM_BO
        LEFT JOIN CUSTOM_FIELDS TP ON BC.COMPONENT_GBO =TP.HANDLE AND TP."ATTRIBUTE"='ACCESSORY_TYPE'
        LEFT JOIN CUSTOM_FIELDS CF ON BC.HANDLE =CF.HANDLE AND RS.STEP_ID=CF.VALUE AND CF."ATTRIBUTE"='STEP_ID'
        JOIN BOM_OPERATION BO ON BC.HANDLE =BO.BOM_COMPONENT_BO AND BO.OPERATION_BO = RO.OPERATION_BO
        JOIN OPERATION OP ON OP.HANDLE= BO.OPERATION_BO OR ('OperationBO:' || #{site}  || ',' || OP.OPERATION  || ',#' = BO.OPERATION_BO AND OP.CURRENT_REVISION = 'true')
        WHERE SFC.HANDLE=#{sfcBo}
    </select>
</mapper>
