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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.Item">
        <result column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SITE" property="site" />
        <result column="ITEM" property="item" />
        <result column="DESCRIPTION" property="description" />
        <result column="STATUS_BO" property="statusBo" />
        <result column="ITEM_TYPE" property="itemType" />
        <result column="ERP_GTIN" property="erpGtin" />
        <result column="AIN_MODEL_EXTERNAL_ID" property="ainModelExternalId" />
        <result column="EFF_START_SEQ" property="effStartSeq" />
        <result column="EFF_END_SEQ" property="effEndSeq" />
        <result column="LOT_SIZE" property="lotSize" />
        <result column="QUANTITY_RESTRICTION" property="quantityRestriction" />
        <result column="ROUTER_BO" property="routerBo" />
        <result column="BOM_BO" property="bomBo" />
        <result column="COMPONENT_GROUP_BO" property="componentGroupBo" />
        <result column="ITEM_GROUP_BO" property="itemGroupBo" />
        <result column="LAST_RELEASED_DATE" property="lastReleasedDate" />
        <result column="ASSY_DATA_TYPE_BO" property="assyDataTypeBo" />
        <result column="PRE_ASSEMBLED" property="preAssembled" />
        <result column="REVISION" property="revision" />
        <result column="CURRENT_REVISION" property="currentRevision" />
        <result column="EFF_START_DATE" property="effStartDate" />
        <result column="EFF_END_DATE" property="effEndDate" />
        <result column="SELECTOR_ACTIVITY_BO" property="selectorActivityBo" />
        <result column="SELECTOR_NOTE" property="selectorNote" />
        <result column="ASSIGN_SERIAL_AT_RELEASE" property="assignSerialAtRelease" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="DRAWING_NAME" property="drawingName" />
        <result column="MAXIMUM_USAGE" property="maximumUsage" />
        <result column="USE_COMP_FROM_DRAWING" property="useCompFromDrawing" />
        <result column="PANEL" property="panel" />
        <result column="REMOVAL_ASSY_DATA_TYPE_BO" property="removalAssyDataTypeBo" />
        <result column="INV_ASSY_DATA_TYPE_BO" property="invAssyDataTypeBo" />
        <result column="ORIGINAL_STATUS_BO" property="originalStatusBo" />
        <result column="QTY_MULTIPLIER" property="qtyMultiplier" />
        <result column="CREATE_TRACKABLE_SFC" property="createTrackableSfc" />
        <result column="MASK_GROUP_BO" property="maskGroupBo" />
        <result column="TRANSFER_ITEM_GROUP_BO" property="transferItemGroupBo" />
        <result column="UNIT_OF_MEASURE" property="unitOfMeasure" />
        <result column="HOLD_ID" property="holdId" />
        <result column="COLLECT_PARENT_SERIAL" property="collectParentSerial" />
        <result column="REQ_SERIAL_CHANGE" property="reqSerialChange" />
        <result column="IS_COLLECTOR" property="isCollector" />
        <result column="INC_BATCH_NUMBER" property="incBatchNumber" />
        <result column="TIME_SENSITIVE" property="timeSensitive" />
        <result column="MAX_SHELF_LIFE" property="maxShelfLife" />
        <result column="MAX_SHELF_LIFE_UNITS" property="maxShelfLifeUnits" />
        <result column="MAX_FLOOR_LIFE" property="maxFloorLife" />
        <result column="MAX_FLOOR_LIFE_UNITS" property="maxFloorLifeUnits" />
        <result column="NOTES" property="notes" />
        <result column="TB_COMP_TYPE" property="tbCompType" />
        <result column="CONSUMPTION_TOL" property="consumptionTol" />
        <result column="ERP_BACKFLUSHING" property="erpBackflushing" />
        <result column="STORAGE_LOCATION_BO" property="storageLocationBo" />
        <result column="ERP_PUTAWAY_STORLOC" property="erpPutawayStorloc" />
        <result column="PRODUCTION_SUPPLY_AREA" property="productionSupplyArea" />
        <result column="USE_ORDER_ID_REL1" property="useOrderIdRel1" />
        <result column="MATERIAL_TYPE" property="materialType" />
        <result column="PROCUREMENT_TYPE" property="procurementType" />
        <result column="ORIGIN" property="origin" />
        <result column="MAP_NO" property="mapNo" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SITE, ITEM, STATUS_BO, ITEM_TYPE, ERP_GTIN, AIN_MODEL_EXTERNAL_ID, EFF_START_SEQ, EFF_END_SEQ, LOT_SIZE, QUANTITY_RESTRICTION, ROUTER_BO, BOM_BO, COMPONENT_GROUP_BO, ITEM_GROUP_BO, LAST_RELEASED_DATE, ASSY_DATA_TYPE_BO, PRE_ASSEMBLED, REVISION, CURRENT_REVISION, EFF_START_DATE, EFF_END_DATE, SELECTOR_ACTIVITY_BO, SELECTOR_NOTE, ASSIGN_SERIAL_AT_RELEASE, CREATED_DATE_TIME, MODIFIED_DATE_TIME, DRAWING_NAME, MAXIMUM_USAGE, USE_COMP_FROM_DRAWING, PANEL, REMOVAL_ASSY_DATA_TYPE_BO, INV_ASSY_DATA_TYPE_BO, ORIGINAL_STATUS_BO, QTY_MULTIPLIER, CREATE_TRACKABLE_SFC, MASK_GROUP_BO, TRANSFER_ITEM_GROUP_BO, UNIT_OF_MEASURE, HOLD_ID, COLLECT_PARENT_SERIAL, REQ_SERIAL_CHANGE, IS_COLLECTOR, INC_BATCH_NUMBER, TIME_SENSITIVE, MAX_SHELF_LIFE, MAX_SHELF_LIFE_UNITS, MAX_FLOOR_LIFE, MAX_FLOOR_LIFE_UNITS, NOTES, TB_COMP_TYPE, CONSUMPTION_TOL, ERP_BACKFLUSHING, STORAGE_LOCATION_BO, ERP_PUTAWAY_STORLOC, PRODUCTION_SUPPLY_AREA, USE_ORDER_ID_REL1, MATERIAL_TYPE, PROCUREMENT_TYPE, ORIGIN
    </sql>

    <sql id="Full_Column_List">
        I.HANDLE, I.CHANGE_STAMP, I.SITE, I.ITEM, IT.DESCRIPTION, I.STATUS_BO, I.ITEM_TYPE, I.MATERIAL_TYPE, I.ERP_GTIN, I.AIN_MODEL_EXTERNAL_ID, I.EFF_START_SEQ, I.EFF_END_SEQ, I.LOT_SIZE, I.QUANTITY_RESTRICTION, I.ROUTER_BO, I.BOM_BO, I.COMPONENT_GROUP_BO, I.ITEM_GROUP_BO, I.LAST_RELEASED_DATE, I.ASSY_DATA_TYPE_BO, I.PRE_ASSEMBLED, I.REVISION, I.CURRENT_REVISION, I.EFF_START_DATE, I.EFF_END_DATE, I.SELECTOR_ACTIVITY_BO, I.SELECTOR_NOTE, I.ASSIGN_SERIAL_AT_RELEASE, I.CREATED_DATE_TIME, I.MODIFIED_DATE_TIME, I.DRAWING_NAME, I.MAXIMUM_USAGE, I.USE_COMP_FROM_DRAWING, I.PANEL, I.REMOVAL_ASSY_DATA_TYPE_BO, I.INV_ASSY_DATA_TYPE_BO, I.ORIGINAL_STATUS_BO, I.QTY_MULTIPLIER, I.CREATE_TRACKABLE_SFC, I.MASK_GROUP_BO, I.TRANSFER_ITEM_GROUP_BO, I.UNIT_OF_MEASURE, I.HOLD_ID, I.COLLECT_PARENT_SERIAL, I.REQ_SERIAL_CHANGE, I.IS_COLLECTOR, I.INC_BATCH_NUMBER, I.TIME_SENSITIVE, I.MAX_SHELF_LIFE, I.MAX_SHELF_LIFE_UNITS, I.MAX_FLOOR_LIFE, I.MAX_FLOOR_LIFE_UNITS, I.NOTES, I.TB_COMP_TYPE, I.CONSUMPTION_TOL, I.ERP_BACKFLUSHING, I.STORAGE_LOCATION_BO, I.ERP_PUTAWAY_STORLOC, I.PRODUCTION_SUPPLY_AREA, I.USE_ORDER_ID_REL1
    </sql>
    <!-- BaseMapper标准查询/修改/删除 -->

    <select id="selectById" resultMap="BaseResultMap">
        SELECT I.*, IT.DESCRIPTION,MAP.VALUE MAP_NO
        FROM ITEM I
        LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = #{locale}
        LEFT JOIN CUSTOM_FIELDS MAP ON MAP.HANDLE = I.HANDLE AND MAP."ATTRIBUTE" = 'DWG_NO'
        WHERE I.HANDLE=#{handle}
    </select>

    <select id="selectCurrentRevision" resultMap="BaseResultMap">
        SELECT I.*, IT.DESCRIPTION
        FROM ITEM I
        LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = 'zh'
        WHERE I.SITE = #{site} AND I.ITEM = #{item} AND I.CURRENT_REVISION = 'true'
    </select>

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM ITEM
        <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 ITEM
        <where>
            <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.item!=null"> AND ITEM=#{ew.item}</if>
            <if test="ew.statusBo!=null"> AND STATUS_BO=#{ew.statusBo}</if>
            <if test="ew.itemType!=null"> AND ITEM_TYPE=#{ew.itemType}</if>
            <if test="ew.erpGtin!=null"> AND ERP_GTIN=#{ew.erpGtin}</if>
            <if test="ew.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.ainModelExternalId}</if>
            <if test="ew.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.effStartSeq}</if>
            <if test="ew.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.effEndSeq}</if>
            <if test="ew.lotSize!=null"> AND LOT_SIZE=#{ew.lotSize}</if>
            <if test="ew.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.quantityRestriction}</if>
            <if test="ew.routerBo!=null"> AND ROUTER_BO=#{ew.routerBo}</if>
            <if test="ew.bomBo!=null"> AND BOM_BO=#{ew.bomBo}</if>
            <if test="ew.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.componentGroupBo}</if>
            <if test="ew.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.itemGroupBo}</if>
            <if test="ew.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.lastReleasedDate}</if>
            <if test="ew.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.assyDataTypeBo}</if>
            <if test="ew.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.preAssembled}</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.effStartDate!=null"> AND EFF_START_DATE=#{ew.effStartDate}</if>
            <if test="ew.effEndDate!=null"> AND EFF_END_DATE=#{ew.effEndDate}</if>
            <if test="ew.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.selectorActivityBo}</if>
            <if test="ew.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.selectorNote}</if>
            <if test="ew.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.drawingName}</if>
            <if test="ew.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.maximumUsage}</if>
            <if test="ew.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.useCompFromDrawing}</if>
            <if test="ew.panel!=null"> AND PANEL=#{ew.panel}</if>
            <if test="ew.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.removalAssyDataTypeBo}</if>
            <if test="ew.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.invAssyDataTypeBo}</if>
            <if test="ew.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.originalStatusBo}</if>
            <if test="ew.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.qtyMultiplier}</if>
            <if test="ew.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.createTrackableSfc}</if>
            <if test="ew.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.maskGroupBo}</if>
            <if test="ew.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.transferItemGroupBo}</if>
            <if test="ew.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.unitOfMeasure}</if>
            <if test="ew.holdId!=null"> AND HOLD_ID=#{ew.holdId}</if>
            <if test="ew.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.collectParentSerial}</if>
            <if test="ew.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.reqSerialChange}</if>
            <if test="ew.isCollector!=null"> AND IS_COLLECTOR=#{ew.isCollector}</if>
            <if test="ew.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.incBatchNumber}</if>
            <if test="ew.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.timeSensitive}</if>
            <if test="ew.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.maxShelfLife}</if>
            <if test="ew.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.maxShelfLifeUnits}</if>
            <if test="ew.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.maxFloorLife}</if>
            <if test="ew.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.maxFloorLifeUnits}</if>
            <if test="ew.notes!=null"> AND NOTES=#{ew.notes}</if>
            <if test="ew.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.tbCompType}</if>
            <if test="ew.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.consumptionTol}</if>
            <if test="ew.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.erpBackflushing}</if>
            <if test="ew.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.storageLocationBo}</if>
            <if test="ew.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.erpPutawayStorloc}</if>
            <if test="ew.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.productionSupplyArea}</if>
            <if test="ew.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.useOrderIdRel1}</if>
            <if test="ew.materialType!=null"> AND MATERIAL_TYPE=#{ew.materialType}</if>
            <if test="ew.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.procurementType}</if>
            <if test="ew.origin!=null"> AND ORIGIN=#{ew.origin}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM ITEM
        <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.item!=null"> AND ITEM=#{ew.entity.item}</if>
                <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                <if test="ew.entity.itemType!=null"> AND ITEM_TYPE=#{ew.entity.itemType}</if>
                <if test="ew.entity.erpGtin!=null"> AND ERP_GTIN=#{ew.entity.erpGtin}</if>
                <if test="ew.entity.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.entity.ainModelExternalId}</if>
                <if test="ew.entity.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.entity.effStartSeq}</if>
                <if test="ew.entity.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.entity.effEndSeq}</if>
                <if test="ew.entity.lotSize!=null"> AND LOT_SIZE=#{ew.entity.lotSize}</if>
                <if test="ew.entity.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                <if test="ew.entity.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                <if test="ew.entity.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                <if test="ew.entity.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.entity.lastReleasedDate}</if>
                <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</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.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.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.entity.selectorActivityBo}</if>
                <if test="ew.entity.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.entity.selectorNote}</if>
                <if test="ew.entity.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.entity.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.entity.drawingName}</if>
                <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                <if test="ew.entity.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.entity.useCompFromDrawing}</if>
                <if test="ew.entity.panel!=null"> AND PANEL=#{ew.entity.panel}</if>
                <if test="ew.entity.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.entity.removalAssyDataTypeBo}</if>
                <if test="ew.entity.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.entity.invAssyDataTypeBo}</if>
                <if test="ew.entity.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.entity.originalStatusBo}</if>
                <if test="ew.entity.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.entity.qtyMultiplier}</if>
                <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                <if test="ew.entity.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.entity.maskGroupBo}</if>
                <if test="ew.entity.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.entity.transferItemGroupBo}</if>
                <if test="ew.entity.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.entity.unitOfMeasure}</if>
                <if test="ew.entity.holdId!=null"> AND HOLD_ID=#{ew.entity.holdId}</if>
                <if test="ew.entity.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.entity.collectParentSerial}</if>
                <if test="ew.entity.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.entity.reqSerialChange}</if>
                <if test="ew.entity.isCollector!=null"> AND IS_COLLECTOR=#{ew.entity.isCollector}</if>
                <if test="ew.entity.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.entity.incBatchNumber}</if>
                <if test="ew.entity.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.entity.timeSensitive}</if>
                <if test="ew.entity.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.entity.maxShelfLife}</if>
                <if test="ew.entity.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.entity.maxShelfLifeUnits}</if>
                <if test="ew.entity.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.entity.maxFloorLife}</if>
                <if test="ew.entity.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.entity.maxFloorLifeUnits}</if>
                <if test="ew.entity.notes!=null"> AND NOTES=#{ew.entity.notes}</if>
                <if test="ew.entity.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.entity.tbCompType}</if>
                <if test="ew.entity.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.entity.consumptionTol}</if>
                <if test="ew.entity.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.entity.erpBackflushing}</if>
                <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</if>
                <if test="ew.entity.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.entity.erpPutawayStorloc}</if>
                <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                <if test="ew.entity.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.entity.useOrderIdRel1}</if>
                <if test="ew.entity.materialType!=null"> AND MATERIAL_TYPE=#{ew.entity.materialType}</if>
                <if test="ew.entity.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.entity.procurementType}</if>
                <if test="ew.entity.origin!=null"> AND ORIGIN=#{ew.entity.origin}</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="Full_Column_List"></include>
                </otherwise>
            </choose>
        FROM ITEM I
        LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = 'zh'
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">I.HANDLE=#{ew.entity.handle}</if>
                    <if test="ew.entity.site!=null"> AND I.SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.item!=null"> AND I.ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND I.STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND I.ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.lotSize!=null"> AND I.LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND I.QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND I.ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND I.BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND I.COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND I.ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.revision!=null"> AND I.REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND I.CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    AND ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            AND ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectItemBo" resultMap="BaseResultMap">
        SELECT * FROM ITEM i WHERE SITE = #{site} AND ITEM = #{item} AND CURRENT_REVISION = TRUE
    </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 ITEM
        <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.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.erpGtin!=null"> AND ERP_GTIN=#{ew.entity.erpGtin}</if>
                    <if test="ew.entity.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.entity.ainModelExternalId}</if>
                    <if test="ew.entity.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.entity.effStartSeq}</if>
                    <if test="ew.entity.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.entity.effEndSeq}</if>
                    <if test="ew.entity.lotSize!=null"> AND LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.entity.lastReleasedDate}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</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.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.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.entity.selectorActivityBo}</if>
                    <if test="ew.entity.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.entity.selectorNote}</if>
                    <if test="ew.entity.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.entity.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.entity.drawingName}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.entity.useCompFromDrawing}</if>
                    <if test="ew.entity.panel!=null"> AND PANEL=#{ew.entity.panel}</if>
                    <if test="ew.entity.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.entity.removalAssyDataTypeBo}</if>
                    <if test="ew.entity.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.entity.invAssyDataTypeBo}</if>
                    <if test="ew.entity.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.entity.originalStatusBo}</if>
                    <if test="ew.entity.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.entity.qtyMultiplier}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.entity.maskGroupBo}</if>
                    <if test="ew.entity.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.entity.transferItemGroupBo}</if>
                    <if test="ew.entity.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.entity.unitOfMeasure}</if>
                    <if test="ew.entity.holdId!=null"> AND HOLD_ID=#{ew.entity.holdId}</if>
                    <if test="ew.entity.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.entity.collectParentSerial}</if>
                    <if test="ew.entity.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.entity.reqSerialChange}</if>
                    <if test="ew.entity.isCollector!=null"> AND IS_COLLECTOR=#{ew.entity.isCollector}</if>
                    <if test="ew.entity.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.entity.incBatchNumber}</if>
                    <if test="ew.entity.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.entity.timeSensitive}</if>
                    <if test="ew.entity.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.entity.maxShelfLife}</if>
                    <if test="ew.entity.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.entity.maxShelfLifeUnits}</if>
                    <if test="ew.entity.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.entity.maxFloorLife}</if>
                    <if test="ew.entity.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.entity.maxFloorLifeUnits}</if>
                    <if test="ew.entity.notes!=null"> AND NOTES=#{ew.entity.notes}</if>
                    <if test="ew.entity.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.entity.tbCompType}</if>
                    <if test="ew.entity.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.entity.consumptionTol}</if>
                    <if test="ew.entity.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.entity.erpBackflushing}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</if>
                    <if test="ew.entity.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.entity.erpPutawayStorloc}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.entity.useOrderIdRel1}</if>
                    <if test="ew.entity.materialType!=null"> AND MATERIAL_TYPE=#{ew.entity.materialType}</if>
                    <if test="ew.entity.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.entity.procurementType}</if>
                    <if test="ew.entity.origin!=null"> AND ORIGIN=#{ew.entity.origin}</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 ITEM
        <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.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.erpGtin!=null"> AND ERP_GTIN=#{ew.entity.erpGtin}</if>
                    <if test="ew.entity.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.entity.ainModelExternalId}</if>
                    <if test="ew.entity.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.entity.effStartSeq}</if>
                    <if test="ew.entity.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.entity.effEndSeq}</if>
                    <if test="ew.entity.lotSize!=null"> AND LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.entity.lastReleasedDate}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</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.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.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.entity.selectorActivityBo}</if>
                    <if test="ew.entity.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.entity.selectorNote}</if>
                    <if test="ew.entity.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.entity.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.entity.drawingName}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.entity.useCompFromDrawing}</if>
                    <if test="ew.entity.panel!=null"> AND PANEL=#{ew.entity.panel}</if>
                    <if test="ew.entity.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.entity.removalAssyDataTypeBo}</if>
                    <if test="ew.entity.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.entity.invAssyDataTypeBo}</if>
                    <if test="ew.entity.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.entity.originalStatusBo}</if>
                    <if test="ew.entity.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.entity.qtyMultiplier}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.entity.maskGroupBo}</if>
                    <if test="ew.entity.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.entity.transferItemGroupBo}</if>
                    <if test="ew.entity.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.entity.unitOfMeasure}</if>
                    <if test="ew.entity.holdId!=null"> AND HOLD_ID=#{ew.entity.holdId}</if>
                    <if test="ew.entity.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.entity.collectParentSerial}</if>
                    <if test="ew.entity.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.entity.reqSerialChange}</if>
                    <if test="ew.entity.isCollector!=null"> AND IS_COLLECTOR=#{ew.entity.isCollector}</if>
                    <if test="ew.entity.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.entity.incBatchNumber}</if>
                    <if test="ew.entity.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.entity.timeSensitive}</if>
                    <if test="ew.entity.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.entity.maxShelfLife}</if>
                    <if test="ew.entity.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.entity.maxShelfLifeUnits}</if>
                    <if test="ew.entity.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.entity.maxFloorLife}</if>
                    <if test="ew.entity.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.entity.maxFloorLifeUnits}</if>
                    <if test="ew.entity.notes!=null"> AND NOTES=#{ew.entity.notes}</if>
                    <if test="ew.entity.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.entity.tbCompType}</if>
                    <if test="ew.entity.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.entity.consumptionTol}</if>
                    <if test="ew.entity.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.entity.erpBackflushing}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</if>
                    <if test="ew.entity.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.entity.erpPutawayStorloc}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.entity.useOrderIdRel1}</if>
                    <if test="ew.entity.materialType!=null"> AND MATERIAL_TYPE=#{ew.entity.materialType}</if>
                    <if test="ew.entity.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.entity.procurementType}</if>
                    <if test="ew.entity.origin!=null"> AND ORIGIN=#{ew.entity.origin}</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 I.HANDLE,item,IT.description,revision
        FROM ITEM I
        LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = 'zh'
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null"> I.HANDLE=#{ew.entity.handle}</if>
                    <if test="ew.entity.site!=null"> AND I.SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.item!=null"> AND I.ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND I.STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND I.ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.lotSize!=null"> AND I.LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND I.QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND I.ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND I.BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND I.COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND I.ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.revision!=null"> AND I.REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND I.CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    AND ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            AND ${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 ITEM
        <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.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.erpGtin!=null"> AND ERP_GTIN=#{ew.entity.erpGtin}</if>
                    <if test="ew.entity.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.entity.ainModelExternalId}</if>
                    <if test="ew.entity.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.entity.effStartSeq}</if>
                    <if test="ew.entity.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.entity.effEndSeq}</if>
                    <if test="ew.entity.lotSize!=null"> AND LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.entity.lastReleasedDate}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</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.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.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.entity.selectorActivityBo}</if>
                    <if test="ew.entity.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.entity.selectorNote}</if>
                    <if test="ew.entity.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.entity.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.entity.drawingName}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.entity.useCompFromDrawing}</if>
                    <if test="ew.entity.panel!=null"> AND PANEL=#{ew.entity.panel}</if>
                    <if test="ew.entity.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.entity.removalAssyDataTypeBo}</if>
                    <if test="ew.entity.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.entity.invAssyDataTypeBo}</if>
                    <if test="ew.entity.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.entity.originalStatusBo}</if>
                    <if test="ew.entity.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.entity.qtyMultiplier}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.entity.maskGroupBo}</if>
                    <if test="ew.entity.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.entity.transferItemGroupBo}</if>
                    <if test="ew.entity.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.entity.unitOfMeasure}</if>
                    <if test="ew.entity.holdId!=null"> AND HOLD_ID=#{ew.entity.holdId}</if>
                    <if test="ew.entity.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.entity.collectParentSerial}</if>
                    <if test="ew.entity.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.entity.reqSerialChange}</if>
                    <if test="ew.entity.isCollector!=null"> AND IS_COLLECTOR=#{ew.entity.isCollector}</if>
                    <if test="ew.entity.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.entity.incBatchNumber}</if>
                    <if test="ew.entity.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.entity.timeSensitive}</if>
                    <if test="ew.entity.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.entity.maxShelfLife}</if>
                    <if test="ew.entity.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.entity.maxShelfLifeUnits}</if>
                    <if test="ew.entity.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.entity.maxFloorLife}</if>
                    <if test="ew.entity.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.entity.maxFloorLifeUnits}</if>
                    <if test="ew.entity.notes!=null"> AND NOTES=#{ew.entity.notes}</if>
                    <if test="ew.entity.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.entity.tbCompType}</if>
                    <if test="ew.entity.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.entity.consumptionTol}</if>
                    <if test="ew.entity.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.entity.erpBackflushing}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</if>
                    <if test="ew.entity.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.entity.erpPutawayStorloc}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.entity.useOrderIdRel1}</if>
                    <if test="ew.entity.materialType!=null"> AND MATERIAL_TYPE=#{ew.entity.materialType}</if>
                    <if test="ew.entity.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.entity.procurementType}</if>
                    <if test="ew.entity.origin!=null"> AND ORIGIN=#{ew.entity.origin}</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.Item">
        INSERT INTO ITEM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="site!=null">SITE,</if>
            <if test="item!=null">ITEM,</if>
            <if test="statusBo!=null">STATUS_BO,</if>
            <if test="itemType!=null">ITEM_TYPE,</if>
            <if test="erpGtin!=null">ERP_GTIN,</if>
            <if test="ainModelExternalId!=null">AIN_MODEL_EXTERNAL_ID,</if>
            <if test="effStartSeq!=null">EFF_START_SEQ,</if>
            <if test="effEndSeq!=null">EFF_END_SEQ,</if>
            <if test="lotSize!=null">LOT_SIZE,</if>
            <if test="quantityRestriction!=null">QUANTITY_RESTRICTION,</if>
            <if test="routerBo!=null">ROUTER_BO,</if>
            <if test="bomBo!=null">BOM_BO,</if>
            <if test="componentGroupBo!=null">COMPONENT_GROUP_BO,</if>
            <if test="itemGroupBo!=null">ITEM_GROUP_BO,</if>
            <if test="lastReleasedDate!=null">LAST_RELEASED_DATE,</if>
            <if test="assyDataTypeBo!=null">ASSY_DATA_TYPE_BO,</if>
            <if test="preAssembled!=null">PRE_ASSEMBLED,</if>
            <if test="revision!=null">REVISION,</if>
            <if test="currentRevision!=null">CURRENT_REVISION,</if>
            <if test="effStartDate!=null">EFF_START_DATE,</if>
            <if test="effEndDate!=null">EFF_END_DATE,</if>
            <if test="selectorActivityBo!=null">SELECTOR_ACTIVITY_BO,</if>
            <if test="selectorNote!=null">SELECTOR_NOTE,</if>
            <if test="assignSerialAtRelease!=null">ASSIGN_SERIAL_AT_RELEASE,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="drawingName!=null">DRAWING_NAME,</if>
            <if test="maximumUsage!=null">MAXIMUM_USAGE,</if>
            <if test="useCompFromDrawing!=null">USE_COMP_FROM_DRAWING,</if>
            <if test="panel!=null">PANEL,</if>
            <if test="removalAssyDataTypeBo!=null">REMOVAL_ASSY_DATA_TYPE_BO,</if>
            <if test="invAssyDataTypeBo!=null">INV_ASSY_DATA_TYPE_BO,</if>
            <if test="originalStatusBo!=null">ORIGINAL_STATUS_BO,</if>
            <if test="qtyMultiplier!=null">QTY_MULTIPLIER,</if>
            <if test="createTrackableSfc!=null">CREATE_TRACKABLE_SFC,</if>
            <if test="maskGroupBo!=null">MASK_GROUP_BO,</if>
            <if test="transferItemGroupBo!=null">TRANSFER_ITEM_GROUP_BO,</if>
            <if test="unitOfMeasure!=null">UNIT_OF_MEASURE,</if>
            <if test="holdId!=null">HOLD_ID,</if>
            <if test="collectParentSerial!=null">COLLECT_PARENT_SERIAL,</if>
            <if test="reqSerialChange!=null">REQ_SERIAL_CHANGE,</if>
            <if test="isCollector!=null">IS_COLLECTOR,</if>
            <if test="incBatchNumber!=null">INC_BATCH_NUMBER,</if>
            <if test="timeSensitive!=null">TIME_SENSITIVE,</if>
            <if test="maxShelfLife!=null">MAX_SHELF_LIFE,</if>
            <if test="maxShelfLifeUnits!=null">MAX_SHELF_LIFE_UNITS,</if>
            <if test="maxFloorLife!=null">MAX_FLOOR_LIFE,</if>
            <if test="maxFloorLifeUnits!=null">MAX_FLOOR_LIFE_UNITS,</if>
            <if test="notes!=null">NOTES,</if>
            <if test="tbCompType!=null">TB_COMP_TYPE,</if>
            <if test="consumptionTol!=null">CONSUMPTION_TOL,</if>
            <if test="erpBackflushing!=null">ERP_BACKFLUSHING,</if>
            <if test="storageLocationBo!=null">STORAGE_LOCATION_BO,</if>
            <if test="erpPutawayStorloc!=null">ERP_PUTAWAY_STORLOC,</if>
            <if test="productionSupplyArea!=null">PRODUCTION_SUPPLY_AREA,</if>
            <if test="useOrderIdRel1!=null">USE_ORDER_ID_REL1,</if>
            <if test="materialType!=null">MATERIAL_TYPE,</if>
            <if test="procurementType!=null">PROCUREMENT_TYPE,</if>
            <if test="origin!=null">ORIGIN,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="site!=null">#{site},</if>
            <if test="item!=null">#{item},</if>
            <if test="statusBo!=null">#{statusBo},</if>
            <if test="itemType!=null">#{itemType},</if>
            <if test="erpGtin!=null">#{erpGtin},</if>
            <if test="ainModelExternalId!=null">#{ainModelExternalId},</if>
            <if test="effStartSeq!=null">#{effStartSeq},</if>
            <if test="effEndSeq!=null">#{effEndSeq},</if>
            <if test="lotSize!=null">#{lotSize},</if>
            <if test="quantityRestriction!=null">#{quantityRestriction},</if>
            <if test="routerBo!=null">#{routerBo},</if>
            <if test="bomBo!=null">#{bomBo},</if>
            <if test="componentGroupBo!=null">#{componentGroupBo},</if>
            <if test="itemGroupBo!=null">#{itemGroupBo},</if>
            <if test="lastReleasedDate!=null">#{lastReleasedDate},</if>
            <if test="assyDataTypeBo!=null">#{assyDataTypeBo},</if>
            <if test="preAssembled!=null">#{preAssembled},</if>
            <if test="revision!=null">#{revision},</if>
            <if test="currentRevision!=null">#{currentRevision},</if>
            <if test="effStartDate!=null">#{effStartDate},</if>
            <if test="effEndDate!=null">#{effEndDate},</if>
            <if test="selectorActivityBo!=null">#{selectorActivityBo},</if>
            <if test="selectorNote!=null">#{selectorNote},</if>
            <if test="assignSerialAtRelease!=null">#{assignSerialAtRelease},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="drawingName!=null">#{drawingName},</if>
            <if test="maximumUsage!=null">#{maximumUsage},</if>
            <if test="useCompFromDrawing!=null">#{useCompFromDrawing},</if>
            <if test="panel!=null">#{panel},</if>
            <if test="removalAssyDataTypeBo!=null">#{removalAssyDataTypeBo},</if>
            <if test="invAssyDataTypeBo!=null">#{invAssyDataTypeBo},</if>
            <if test="originalStatusBo!=null">#{originalStatusBo},</if>
            <if test="qtyMultiplier!=null">#{qtyMultiplier},</if>
            <if test="createTrackableSfc!=null">#{createTrackableSfc},</if>
            <if test="maskGroupBo!=null">#{maskGroupBo},</if>
            <if test="transferItemGroupBo!=null">#{transferItemGroupBo},</if>
            <if test="unitOfMeasure!=null">#{unitOfMeasure},</if>
            <if test="holdId!=null">#{holdId},</if>
            <if test="collectParentSerial!=null">#{collectParentSerial},</if>
            <if test="reqSerialChange!=null">#{reqSerialChange},</if>
            <if test="isCollector!=null">#{isCollector},</if>
            <if test="incBatchNumber!=null">#{incBatchNumber},</if>
            <if test="timeSensitive!=null">#{timeSensitive},</if>
            <if test="maxShelfLife!=null">#{maxShelfLife},</if>
            <if test="maxShelfLifeUnits!=null">#{maxShelfLifeUnits},</if>
            <if test="maxFloorLife!=null">#{maxFloorLife},</if>
            <if test="maxFloorLifeUnits!=null">#{maxFloorLifeUnits},</if>
            <if test="notes!=null">#{notes},</if>
            <if test="tbCompType!=null">#{tbCompType},</if>
            <if test="consumptionTol!=null">#{consumptionTol},</if>
            <if test="erpBackflushing!=null">#{erpBackflushing},</if>
            <if test="storageLocationBo!=null">#{storageLocationBo},</if>
            <if test="erpPutawayStorloc!=null">#{erpPutawayStorloc},</if>
            <if test="productionSupplyArea!=null">#{productionSupplyArea},</if>
            <if test="useOrderIdRel1!=null">#{useOrderIdRel1},</if>
            <if test="materialType!=null">#{materialType},</if>
            <if test="procurementType!=null">#{procurementType},</if>
            <if test="origin!=null">#{origin},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.Item">
        INSERT INTO ITEM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{site},
            #{item},
            #{statusBo},
            #{itemType},
            #{erpGtin},
            #{ainModelExternalId},
            #{effStartSeq},
            #{effEndSeq},
            #{lotSize},
            #{quantityRestriction},
            #{routerBo},
            #{bomBo},
            #{componentGroupBo},
            #{itemGroupBo},
            #{lastReleasedDate},
            #{assyDataTypeBo},
            #{preAssembled},
            #{revision},
            #{currentRevision},
            #{effStartDate},
            #{effEndDate},
            #{selectorActivityBo},
            #{selectorNote},
            #{assignSerialAtRelease},
            #{createdDateTime},
            #{modifiedDateTime},
            #{drawingName},
            #{maximumUsage},
            #{useCompFromDrawing},
            #{panel},
            #{removalAssyDataTypeBo},
            #{invAssyDataTypeBo},
            #{originalStatusBo},
            #{qtyMultiplier},
            #{createTrackableSfc},
            #{maskGroupBo},
            #{transferItemGroupBo},
            #{unitOfMeasure},
            #{holdId},
            #{collectParentSerial},
            #{reqSerialChange},
            #{isCollector},
            #{incBatchNumber},
            #{timeSensitive},
            #{maxShelfLife},
            #{maxShelfLifeUnits},
            #{maxFloorLife},
            #{maxFloorLifeUnits},
            #{notes},
            #{tbCompType},
            #{consumptionTol},
            #{erpBackflushing},
            #{storageLocationBo},
            #{erpPutawayStorloc},
            #{productionSupplyArea},
            #{useOrderIdRel1},
            #{materialType},
            #{procurementType},
            #{origin},
        </trim>
    </insert>






    <update id="update">
        UPDATE ITEM <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.item!=null">ITEM=#{et.item},</if>
        <if test="et.statusBo!=null">STATUS_BO=#{et.statusBo},</if>
        <if test="et.itemType!=null">ITEM_TYPE=#{et.itemType},</if>
        <if test="et.erpGtin!=null">ERP_GTIN=#{et.erpGtin},</if>
        <if test="et.ainModelExternalId!=null">AIN_MODEL_EXTERNAL_ID=#{et.ainModelExternalId},</if>
        <if test="et.effStartSeq!=null">EFF_START_SEQ=#{et.effStartSeq},</if>
        <if test="et.effEndSeq!=null">EFF_END_SEQ=#{et.effEndSeq},</if>
        <if test="et.lotSize!=null">LOT_SIZE=#{et.lotSize},</if>
        <if test="et.quantityRestriction!=null">QUANTITY_RESTRICTION=#{et.quantityRestriction},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.bomBo!=null">BOM_BO=#{et.bomBo},</if>
        <if test="et.componentGroupBo!=null">COMPONENT_GROUP_BO=#{et.componentGroupBo},</if>
        <if test="et.itemGroupBo!=null">ITEM_GROUP_BO=#{et.itemGroupBo},</if>
        <if test="et.lastReleasedDate!=null">LAST_RELEASED_DATE=#{et.lastReleasedDate},</if>
        <if test="et.assyDataTypeBo!=null">ASSY_DATA_TYPE_BO=#{et.assyDataTypeBo},</if>
        <if test="et.preAssembled!=null">PRE_ASSEMBLED=#{et.preAssembled},</if>
        <if test="et.revision!=null">REVISION=#{et.revision},</if>
        <if test="et.currentRevision!=null">CURRENT_REVISION=#{et.currentRevision},</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.selectorActivityBo!=null">SELECTOR_ACTIVITY_BO=#{et.selectorActivityBo},</if>
        <if test="et.selectorNote!=null">SELECTOR_NOTE=#{et.selectorNote},</if>
        <if test="et.assignSerialAtRelease!=null">ASSIGN_SERIAL_AT_RELEASE=#{et.assignSerialAtRelease},</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.drawingName!=null">DRAWING_NAME=#{et.drawingName},</if>
        <if test="et.maximumUsage!=null">MAXIMUM_USAGE=#{et.maximumUsage},</if>
        <if test="et.useCompFromDrawing!=null">USE_COMP_FROM_DRAWING=#{et.useCompFromDrawing},</if>
        <if test="et.panel!=null">PANEL=#{et.panel},</if>
        <if test="et.removalAssyDataTypeBo!=null">REMOVAL_ASSY_DATA_TYPE_BO=#{et.removalAssyDataTypeBo},</if>
        <if test="et.invAssyDataTypeBo!=null">INV_ASSY_DATA_TYPE_BO=#{et.invAssyDataTypeBo},</if>
        <if test="et.originalStatusBo!=null">ORIGINAL_STATUS_BO=#{et.originalStatusBo},</if>
        <if test="et.qtyMultiplier!=null">QTY_MULTIPLIER=#{et.qtyMultiplier},</if>
        <if test="et.createTrackableSfc!=null">CREATE_TRACKABLE_SFC=#{et.createTrackableSfc},</if>
        <if test="et.maskGroupBo!=null">MASK_GROUP_BO=#{et.maskGroupBo},</if>
        <if test="et.transferItemGroupBo!=null">TRANSFER_ITEM_GROUP_BO=#{et.transferItemGroupBo},</if>
        <if test="et.unitOfMeasure!=null">UNIT_OF_MEASURE=#{et.unitOfMeasure},</if>
        <if test="et.holdId!=null">HOLD_ID=#{et.holdId},</if>
        <if test="et.collectParentSerial!=null">COLLECT_PARENT_SERIAL=#{et.collectParentSerial},</if>
        <if test="et.reqSerialChange!=null">REQ_SERIAL_CHANGE=#{et.reqSerialChange},</if>
        <if test="et.isCollector!=null">IS_COLLECTOR=#{et.isCollector},</if>
        <if test="et.incBatchNumber!=null">INC_BATCH_NUMBER=#{et.incBatchNumber},</if>
        <if test="et.timeSensitive!=null">TIME_SENSITIVE=#{et.timeSensitive},</if>
        <if test="et.maxShelfLife!=null">MAX_SHELF_LIFE=#{et.maxShelfLife},</if>
        <if test="et.maxShelfLifeUnits!=null">MAX_SHELF_LIFE_UNITS=#{et.maxShelfLifeUnits},</if>
        <if test="et.maxFloorLife!=null">MAX_FLOOR_LIFE=#{et.maxFloorLife},</if>
        <if test="et.maxFloorLifeUnits!=null">MAX_FLOOR_LIFE_UNITS=#{et.maxFloorLifeUnits},</if>
        <if test="et.notes!=null">NOTES=#{et.notes},</if>
        <if test="et.tbCompType!=null">TB_COMP_TYPE=#{et.tbCompType},</if>
        <if test="et.consumptionTol!=null">CONSUMPTION_TOL=#{et.consumptionTol},</if>
        <if test="et.erpBackflushing!=null">ERP_BACKFLUSHING=#{et.erpBackflushing},</if>
        <if test="et.storageLocationBo!=null">STORAGE_LOCATION_BO=#{et.storageLocationBo},</if>
        <if test="et.erpPutawayStorloc!=null">ERP_PUTAWAY_STORLOC=#{et.erpPutawayStorloc},</if>
        <if test="et.productionSupplyArea!=null">PRODUCTION_SUPPLY_AREA=#{et.productionSupplyArea},</if>
        <if test="et.useOrderIdRel1!=null">USE_ORDER_ID_REL1=#{et.useOrderIdRel1},</if>
        <if test="et.materialType!=null">MATERIAL_TYPE=#{et.materialType},</if>
        <if test="et.procurementType!=null">PROCUREMENT_TYPE=#{et.procurementType},</if>
        <if test="et.origin!=null">ORIGIN=#{et.origin},</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.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.erpGtin!=null"> AND ERP_GTIN=#{ew.entity.erpGtin}</if>
                    <if test="ew.entity.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.entity.ainModelExternalId}</if>
                    <if test="ew.entity.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.entity.effStartSeq}</if>
                    <if test="ew.entity.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.entity.effEndSeq}</if>
                    <if test="ew.entity.lotSize!=null"> AND LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.entity.lastReleasedDate}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</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.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.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.entity.selectorActivityBo}</if>
                    <if test="ew.entity.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.entity.selectorNote}</if>
                    <if test="ew.entity.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.entity.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.entity.drawingName}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.entity.useCompFromDrawing}</if>
                    <if test="ew.entity.panel!=null"> AND PANEL=#{ew.entity.panel}</if>
                    <if test="ew.entity.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.entity.removalAssyDataTypeBo}</if>
                    <if test="ew.entity.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.entity.invAssyDataTypeBo}</if>
                    <if test="ew.entity.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.entity.originalStatusBo}</if>
                    <if test="ew.entity.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.entity.qtyMultiplier}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.entity.maskGroupBo}</if>
                    <if test="ew.entity.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.entity.transferItemGroupBo}</if>
                    <if test="ew.entity.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.entity.unitOfMeasure}</if>
                    <if test="ew.entity.holdId!=null"> AND HOLD_ID=#{ew.entity.holdId}</if>
                    <if test="ew.entity.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.entity.collectParentSerial}</if>
                    <if test="ew.entity.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.entity.reqSerialChange}</if>
                    <if test="ew.entity.isCollector!=null"> AND IS_COLLECTOR=#{ew.entity.isCollector}</if>
                    <if test="ew.entity.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.entity.incBatchNumber}</if>
                    <if test="ew.entity.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.entity.timeSensitive}</if>
                    <if test="ew.entity.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.entity.maxShelfLife}</if>
                    <if test="ew.entity.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.entity.maxShelfLifeUnits}</if>
                    <if test="ew.entity.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.entity.maxFloorLife}</if>
                    <if test="ew.entity.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.entity.maxFloorLifeUnits}</if>
                    <if test="ew.entity.notes!=null"> AND NOTES=#{ew.entity.notes}</if>
                    <if test="ew.entity.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.entity.tbCompType}</if>
                    <if test="ew.entity.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.entity.consumptionTol}</if>
                    <if test="ew.entity.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.entity.erpBackflushing}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</if>
                    <if test="ew.entity.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.entity.erpPutawayStorloc}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.entity.useOrderIdRel1}</if>
                    <if test="ew.entity.materialType!=null"> AND MATERIAL_TYPE=#{ew.entity.materialType}</if>
                    <if test="ew.entity.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.entity.procurementType}</if>
                    <if test="ew.entity.origin!=null"> AND ORIGIN=#{ew.entity.origin}</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 ITEM
        <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 ITEM
        <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.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.itemType!=null"> AND ITEM_TYPE=#{ew.entity.itemType}</if>
                    <if test="ew.entity.erpGtin!=null"> AND ERP_GTIN=#{ew.entity.erpGtin}</if>
                    <if test="ew.entity.ainModelExternalId!=null"> AND AIN_MODEL_EXTERNAL_ID=#{ew.entity.ainModelExternalId}</if>
                    <if test="ew.entity.effStartSeq!=null"> AND EFF_START_SEQ=#{ew.entity.effStartSeq}</if>
                    <if test="ew.entity.effEndSeq!=null"> AND EFF_END_SEQ=#{ew.entity.effEndSeq}</if>
                    <if test="ew.entity.lotSize!=null"> AND LOT_SIZE=#{ew.entity.lotSize}</if>
                    <if test="ew.entity.quantityRestriction!=null"> AND QUANTITY_RESTRICTION=#{ew.entity.quantityRestriction}</if>
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.bomBo!=null"> AND BOM_BO=#{ew.entity.bomBo}</if>
                    <if test="ew.entity.componentGroupBo!=null"> AND COMPONENT_GROUP_BO=#{ew.entity.componentGroupBo}</if>
                    <if test="ew.entity.itemGroupBo!=null"> AND ITEM_GROUP_BO=#{ew.entity.itemGroupBo}</if>
                    <if test="ew.entity.lastReleasedDate!=null"> AND LAST_RELEASED_DATE=#{ew.entity.lastReleasedDate}</if>
                    <if test="ew.entity.assyDataTypeBo!=null"> AND ASSY_DATA_TYPE_BO=#{ew.entity.assyDataTypeBo}</if>
                    <if test="ew.entity.preAssembled!=null"> AND PRE_ASSEMBLED=#{ew.entity.preAssembled}</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.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.selectorActivityBo!=null"> AND SELECTOR_ACTIVITY_BO=#{ew.entity.selectorActivityBo}</if>
                    <if test="ew.entity.selectorNote!=null"> AND SELECTOR_NOTE=#{ew.entity.selectorNote}</if>
                    <if test="ew.entity.assignSerialAtRelease!=null"> AND ASSIGN_SERIAL_AT_RELEASE=#{ew.entity.assignSerialAtRelease}</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.drawingName!=null"> AND DRAWING_NAME=#{ew.entity.drawingName}</if>
                    <if test="ew.entity.maximumUsage!=null"> AND MAXIMUM_USAGE=#{ew.entity.maximumUsage}</if>
                    <if test="ew.entity.useCompFromDrawing!=null"> AND USE_COMP_FROM_DRAWING=#{ew.entity.useCompFromDrawing}</if>
                    <if test="ew.entity.panel!=null"> AND PANEL=#{ew.entity.panel}</if>
                    <if test="ew.entity.removalAssyDataTypeBo!=null"> AND REMOVAL_ASSY_DATA_TYPE_BO=#{ew.entity.removalAssyDataTypeBo}</if>
                    <if test="ew.entity.invAssyDataTypeBo!=null"> AND INV_ASSY_DATA_TYPE_BO=#{ew.entity.invAssyDataTypeBo}</if>
                    <if test="ew.entity.originalStatusBo!=null"> AND ORIGINAL_STATUS_BO=#{ew.entity.originalStatusBo}</if>
                    <if test="ew.entity.qtyMultiplier!=null"> AND QTY_MULTIPLIER=#{ew.entity.qtyMultiplier}</if>
                    <if test="ew.entity.createTrackableSfc!=null"> AND CREATE_TRACKABLE_SFC=#{ew.entity.createTrackableSfc}</if>
                    <if test="ew.entity.maskGroupBo!=null"> AND MASK_GROUP_BO=#{ew.entity.maskGroupBo}</if>
                    <if test="ew.entity.transferItemGroupBo!=null"> AND TRANSFER_ITEM_GROUP_BO=#{ew.entity.transferItemGroupBo}</if>
                    <if test="ew.entity.unitOfMeasure!=null"> AND UNIT_OF_MEASURE=#{ew.entity.unitOfMeasure}</if>
                    <if test="ew.entity.holdId!=null"> AND HOLD_ID=#{ew.entity.holdId}</if>
                    <if test="ew.entity.collectParentSerial!=null"> AND COLLECT_PARENT_SERIAL=#{ew.entity.collectParentSerial}</if>
                    <if test="ew.entity.reqSerialChange!=null"> AND REQ_SERIAL_CHANGE=#{ew.entity.reqSerialChange}</if>
                    <if test="ew.entity.isCollector!=null"> AND IS_COLLECTOR=#{ew.entity.isCollector}</if>
                    <if test="ew.entity.incBatchNumber!=null"> AND INC_BATCH_NUMBER=#{ew.entity.incBatchNumber}</if>
                    <if test="ew.entity.timeSensitive!=null"> AND TIME_SENSITIVE=#{ew.entity.timeSensitive}</if>
                    <if test="ew.entity.maxShelfLife!=null"> AND MAX_SHELF_LIFE=#{ew.entity.maxShelfLife}</if>
                    <if test="ew.entity.maxShelfLifeUnits!=null"> AND MAX_SHELF_LIFE_UNITS=#{ew.entity.maxShelfLifeUnits}</if>
                    <if test="ew.entity.maxFloorLife!=null"> AND MAX_FLOOR_LIFE=#{ew.entity.maxFloorLife}</if>
                    <if test="ew.entity.maxFloorLifeUnits!=null"> AND MAX_FLOOR_LIFE_UNITS=#{ew.entity.maxFloorLifeUnits}</if>
                    <if test="ew.entity.notes!=null"> AND NOTES=#{ew.entity.notes}</if>
                    <if test="ew.entity.tbCompType!=null"> AND TB_COMP_TYPE=#{ew.entity.tbCompType}</if>
                    <if test="ew.entity.consumptionTol!=null"> AND CONSUMPTION_TOL=#{ew.entity.consumptionTol}</if>
                    <if test="ew.entity.erpBackflushing!=null"> AND ERP_BACKFLUSHING=#{ew.entity.erpBackflushing}</if>
                    <if test="ew.entity.storageLocationBo!=null"> AND STORAGE_LOCATION_BO=#{ew.entity.storageLocationBo}</if>
                    <if test="ew.entity.erpPutawayStorloc!=null"> AND ERP_PUTAWAY_STORLOC=#{ew.entity.erpPutawayStorloc}</if>
                    <if test="ew.entity.productionSupplyArea!=null"> AND PRODUCTION_SUPPLY_AREA=#{ew.entity.productionSupplyArea}</if>
                    <if test="ew.entity.useOrderIdRel1!=null"> AND USE_ORDER_ID_REL1=#{ew.entity.useOrderIdRel1}</if>
                    <if test="ew.entity.materialType!=null"> AND MATERIAL_TYPE=#{ew.entity.materialType}</if>
                    <if test="ew.entity.procurementType!=null"> AND PROCUREMENT_TYPE=#{ew.entity.procurementType}</if>
                    <if test="ew.entity.origin!=null"> AND ORIGIN=#{ew.entity.origin}</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="selectListByCriteria" resultMap="BaseResultMap">
        select * from (
            SELECT I.*, IT.DESCRIPTION FROM ITEM I
            LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = #{locale}
        )I
        <where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
          ${ew.sqlSegment}
        </if>
        </where>
    </select>
    <select id="findMapByItem" resultType="Map">
        SELECT DWG.VALUE DWG_NO
        FROM ITEM I
        LEFT JOIN CUSTOM_FIELDS DWG ON DWG.HANDLE = I.HANDLE AND DWG."ATTRIBUTE" = 'DWG_NO'
        WHERE I.HANDLE = #{itemBo}
    </select>
</mapper>
