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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.Operation">
        <result column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SITE" property="site" />
        <result column="OPERATION" property="operation" />
        <result column="TYPE" property="type" />
        <result column="SPECIAL_ROUTER_BO" property="specialRouterBo" />
        <result column="STATUS_BO" property="statusBo" />
        <result column="RESOURCE_TYPE_BO" property="resourceTypeBo" />
        <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="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="PCA_DASHBOARD_MODE" property="pcaDashboardMode" />
        <result column="DEFAULT_NC_CODE_BO" property="defaultNcCodeBo" />
        <result column="FAILURE_TRACKING_CONFIG_BO" property="failureTrackingConfigBo" />
        <result column="RESOURCE_BO" property="resourceBo" />
        <result column="MAX_LOOP" property="maxLoop" />
        <result column="REQUIRED_TIME_IN_PROCESS" property="requiredTimeInProcess" />
        <result column="REPORTING_STEP" property="reportingStep" />
        <result column="PREV_SITE" property="prevSite" />
        <result column="ORIGINAL_TRANSFER_KEY" property="originalTransferKey" />
        <result column="SPECIAL_INSTRUCTION" property="specialInstruction" />
        <result column="REPORTING_CENTER_BO" property="reportingCenterBo" />
        <result column="ERP_CONTROL_KEY_BO" property="erpControlKeyBo" />
        <result column="ERP_WORK_CENTER_BO" property="erpWorkCenterBo" />
        <result column="DESCRIPTION" property="description"/>
        <result column="STEP_ID" property="stepId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SITE, OPERATION, TYPE, SPECIAL_ROUTER_BO, STATUS_BO, RESOURCE_TYPE_BO, REVISION, CURRENT_REVISION, EFF_START_DATE, EFF_END_DATE, CREATED_DATE_TIME, MODIFIED_DATE_TIME, PCA_DASHBOARD_MODE, DEFAULT_NC_CODE_BO, FAILURE_TRACKING_CONFIG_BO, RESOURCE_BO, MAX_LOOP, REQUIRED_TIME_IN_PROCESS, REPORTING_STEP, PREV_SITE, ORIGINAL_TRANSFER_KEY, SPECIAL_INSTRUCTION, REPORTING_CENTER_BO, ERP_CONTROL_KEY_BO, ERP_WORK_CENTER_BO
    </sql>

    <sql id="FULL_Column_List">
        O.HANDLE, O.CHANGE_STAMP, O.SITE, O.OPERATION, OT.DESCRIPTION, O.TYPE, O.SPECIAL_ROUTER_BO, O.STATUS_BO, O.RESOURCE_TYPE_BO, O.REVISION, O.CURRENT_REVISION, O.EFF_START_DATE, O.EFF_END_DATE, O.CREATED_DATE_TIME, O.MODIFIED_DATE_TIME, O.PCA_DASHBOARD_MODE, O.DEFAULT_NC_CODE_BO, O.FAILURE_TRACKING_CONFIG_BO, O.RESOURCE_BO, O.MAX_LOOP, O.REQUIRED_TIME_IN_PROCESS, O.REPORTING_STEP, O.PREV_SITE, O.ORIGINAL_TRANSFER_KEY, O.SPECIAL_INSTRUCTION, O.REPORTING_CENTER_BO, O.ERP_CONTROL_KEY_BO, O.ERP_WORK_CENTER_BO
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM OPERATION
        <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 OPERATION
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
            <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
            <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
            <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
            <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
            <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
            <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
            <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
            <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
            <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
            <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
            <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
            <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
            <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
            <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
            <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
            <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM OPERATION
        <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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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 OPERATION
        <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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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 OPERATION
        <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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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 OPERATION
        <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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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 <include refid="FULL_Column_List" ></include>
        FROM OPERATION O
        LEFT JOIN OPERATION_T OT ON O.HANDLE = OT.OPERATION_BO AND OT.LOCALE = 'zh'
        <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 O.CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND O.SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.operation!=null"> AND O.OPERATION LIKE '%'||#{ew.entity.operation}||'%'</if>
                    <if test="ew.entity.type!=null"> AND O.TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND O.SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND O.STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND O.RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</if>
                    <if test="ew.entity.revision!=null"> AND O.REVISION=#{ew.entity.revision}</if>
                    <if test="ew.entity.currentRevision!=null"> AND O.CURRENT_REVISION=#{ew.entity.currentRevision}</if>
                    <if test="ew.entity.effStartDate!=null"> AND O.EFF_START_DATE=#{ew.entity.effStartDate}</if>
                    <if test="ew.entity.effEndDate!=null"> AND O.EFF_END_DATE=#{ew.entity.effEndDate}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND O.CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND O.MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.pcaDashboardMode!=null"> AND O.PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND O.DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND O.FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND O.RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND O.MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND O.REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND O.REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND O.PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND O.ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND O.SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND O.REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND O.ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND O.ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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 OPERATION
        <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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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.Operation">
        INSERT INTO OPERATION
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="site!=null">SITE,</if>
            <if test="operation!=null">OPERATION,</if>
            <if test="type!=null">TYPE,</if>
            <if test="specialRouterBo!=null">SPECIAL_ROUTER_BO,</if>
            <if test="statusBo!=null">STATUS_BO,</if>
            <if test="resourceTypeBo!=null">RESOURCE_TYPE_BO,</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="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="pcaDashboardMode!=null">PCA_DASHBOARD_MODE,</if>
            <if test="defaultNcCodeBo!=null">DEFAULT_NC_CODE_BO,</if>
            <if test="failureTrackingConfigBo!=null">FAILURE_TRACKING_CONFIG_BO,</if>
            <if test="resourceBo!=null">RESOURCE_BO,</if>
            <if test="maxLoop!=null">MAX_LOOP,</if>
            <if test="requiredTimeInProcess!=null">REQUIRED_TIME_IN_PROCESS,</if>
            <if test="reportingStep!=null">REPORTING_STEP,</if>
            <if test="prevSite!=null">PREV_SITE,</if>
            <if test="originalTransferKey!=null">ORIGINAL_TRANSFER_KEY,</if>
            <if test="specialInstruction!=null">SPECIAL_INSTRUCTION,</if>
            <if test="reportingCenterBo!=null">REPORTING_CENTER_BO,</if>
            <if test="erpControlKeyBo!=null">ERP_CONTROL_KEY_BO,</if>
            <if test="erpWorkCenterBo!=null">ERP_WORK_CENTER_BO,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="site!=null">#{site},</if>
            <if test="operation!=null">#{operation},</if>
            <if test="type!=null">#{type},</if>
            <if test="specialRouterBo!=null">#{specialRouterBo},</if>
            <if test="statusBo!=null">#{statusBo},</if>
            <if test="resourceTypeBo!=null">#{resourceTypeBo},</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="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="pcaDashboardMode!=null">#{pcaDashboardMode},</if>
            <if test="defaultNcCodeBo!=null">#{defaultNcCodeBo},</if>
            <if test="failureTrackingConfigBo!=null">#{failureTrackingConfigBo},</if>
            <if test="resourceBo!=null">#{resourceBo},</if>
            <if test="maxLoop!=null">#{maxLoop},</if>
            <if test="requiredTimeInProcess!=null">#{requiredTimeInProcess},</if>
            <if test="reportingStep!=null">#{reportingStep},</if>
            <if test="prevSite!=null">#{prevSite},</if>
            <if test="originalTransferKey!=null">#{originalTransferKey},</if>
            <if test="specialInstruction!=null">#{specialInstruction},</if>
            <if test="reportingCenterBo!=null">#{reportingCenterBo},</if>
            <if test="erpControlKeyBo!=null">#{erpControlKeyBo},</if>
            <if test="erpWorkCenterBo!=null">#{erpWorkCenterBo},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.Operation">
        INSERT INTO OPERATION
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{site},
            #{operation},
            #{type},
            #{specialRouterBo},
            #{statusBo},
            #{resourceTypeBo},
            #{revision},
            #{currentRevision},
            #{effStartDate},
            #{effEndDate},
            #{createdDateTime},
            #{modifiedDateTime},
            #{pcaDashboardMode},
            #{defaultNcCodeBo},
            #{failureTrackingConfigBo},
            #{resourceBo},
            #{maxLoop},
            #{requiredTimeInProcess},
            #{reportingStep},
            #{prevSite},
            #{originalTransferKey},
            #{specialInstruction},
            #{reportingCenterBo},
            #{erpControlKeyBo},
            #{erpWorkCenterBo},
        </trim>
    </insert>

    <update id="update">
        UPDATE OPERATION <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.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.type!=null">TYPE=#{et.type},</if>
        <if test="et.specialRouterBo!=null">SPECIAL_ROUTER_BO=#{et.specialRouterBo},</if>
        <if test="et.statusBo!=null">STATUS_BO=#{et.statusBo},</if>
        <if test="et.resourceTypeBo!=null">RESOURCE_TYPE_BO=#{et.resourceTypeBo},</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.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.pcaDashboardMode!=null">PCA_DASHBOARD_MODE=#{et.pcaDashboardMode},</if>
        <if test="et.defaultNcCodeBo!=null">DEFAULT_NC_CODE_BO=#{et.defaultNcCodeBo},</if>
        <if test="et.failureTrackingConfigBo!=null">FAILURE_TRACKING_CONFIG_BO=#{et.failureTrackingConfigBo},</if>
        <if test="et.resourceBo!=null">RESOURCE_BO=#{et.resourceBo},</if>
        <if test="et.maxLoop!=null">MAX_LOOP=#{et.maxLoop},</if>
        <if test="et.requiredTimeInProcess!=null">REQUIRED_TIME_IN_PROCESS=#{et.requiredTimeInProcess},</if>
        <if test="et.reportingStep!=null">REPORTING_STEP=#{et.reportingStep},</if>
        <if test="et.prevSite!=null">PREV_SITE=#{et.prevSite},</if>
        <if test="et.originalTransferKey!=null">ORIGINAL_TRANSFER_KEY=#{et.originalTransferKey},</if>
        <if test="et.specialInstruction!=null">SPECIAL_INSTRUCTION=#{et.specialInstruction},</if>
        <if test="et.reportingCenterBo!=null">REPORTING_CENTER_BO=#{et.reportingCenterBo},</if>
        <if test="et.erpControlKeyBo!=null">ERP_CONTROL_KEY_BO=#{et.erpControlKeyBo},</if>
        <if test="et.erpWorkCenterBo!=null">ERP_WORK_CENTER_BO=#{et.erpWorkCenterBo},</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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 OPERATION
        <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 OPERATION
        <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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.specialRouterBo!=null"> AND SPECIAL_ROUTER_BO=#{ew.entity.specialRouterBo}</if>
                    <if test="ew.entity.statusBo!=null"> AND STATUS_BO=#{ew.entity.statusBo}</if>
                    <if test="ew.entity.resourceTypeBo!=null"> AND RESOURCE_TYPE_BO=#{ew.entity.resourceTypeBo}</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.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.pcaDashboardMode!=null"> AND PCA_DASHBOARD_MODE=#{ew.entity.pcaDashboardMode}</if>
                    <if test="ew.entity.defaultNcCodeBo!=null"> AND DEFAULT_NC_CODE_BO=#{ew.entity.defaultNcCodeBo}</if>
                    <if test="ew.entity.failureTrackingConfigBo!=null"> AND FAILURE_TRACKING_CONFIG_BO=#{ew.entity.failureTrackingConfigBo}</if>
                    <if test="ew.entity.resourceBo!=null"> AND RESOURCE_BO=#{ew.entity.resourceBo}</if>
                    <if test="ew.entity.maxLoop!=null"> AND MAX_LOOP=#{ew.entity.maxLoop}</if>
                    <if test="ew.entity.requiredTimeInProcess!=null"> AND REQUIRED_TIME_IN_PROCESS=#{ew.entity.requiredTimeInProcess}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.prevSite!=null"> AND PREV_SITE=#{ew.entity.prevSite}</if>
                    <if test="ew.entity.originalTransferKey!=null"> AND ORIGINAL_TRANSFER_KEY=#{ew.entity.originalTransferKey}</if>
                    <if test="ew.entity.specialInstruction!=null"> AND SPECIAL_INSTRUCTION=#{ew.entity.specialInstruction}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.erpControlKeyBo!=null"> AND ERP_CONTROL_KEY_BO=#{ew.entity.erpControlKeyBo}</if>
                    <if test="ew.entity.erpWorkCenterBo!=null"> AND ERP_WORK_CENTER_BO=#{ew.entity.erpWorkCenterBo}</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="selectOperationBySfcBo" resultMap="BaseResultMap">
        SELECT OP.HANDLE, OP.OPERATION,OT.DESCRIPTION ,SS.STEP_ID FROM SFC_ROUTING SR
        JOIN SFC_ROUTER SR2 ON SR.HANDLE =SR2.SFC_ROUTING_BO  AND SR2.IN_USE = 'true'
        JOIN  SFC_STEP SS ON SR2.HANDLE =SS.SFC_ROUTER_BO
        JOIN OPERATION OP  ON 'OperationBO:'|| OP.SITE ||','|| OP.OPERATION||',#'=SS.OPERATION_BO
        LEFT JOIN OPERATION_T OT ON OP.HANDLE = OT.OPERATION_BO AND OT.LOCALE = #{locale}
        WHERE SR.SFC_BO =#{sfcBo} AND (SS.QTY_IN_QUEUE>0 or SS.QTY_IN_WORK>0)
    </select>

    <select id="getCurrentRevisionRef" resultMap="BaseResultMap">
        SELECT
            O.HANDLE,O.OPERATION,
            O.REVISION,OT.DESCRIPTION
        FROM OPERATION O
        LEFT JOIN OPERATION_T OT ON O.HANDLE = OT.OPERATION_BO AND OT.LOCALE = 'zh'
        WHERE O.SITE = #{site}
              AND O.OPERATION = #{operation}
              AND O.CURRENT_REVISION = 'true'
    </select>

    <select id="queryOperationByErpWorkCenter" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM OPERATION
        WHERE SITE = #{site} AND OPERATION LIKE '%_'||#{erpWorkCenter}
    </select>

    <select id="selectOperationStep" resultMap="BaseResultMap">
        SELECT DISTINCT O.OPERATION,RS.STEP_ID,OT.DESCRIPTION
        FROM OPERATION O
        LEFT JOIN OPERATION_T OT ON O.HANDLE = OT.OPERATION_BO AND OT.LOCALE = #{locale}
        INNER JOIN ROUTER_OPERATION RO ON (RO.OPERATION_BO = O.HANDLE or 'OperationBO:'|| O.SITE ||','|| O.OPERATION||',#'=RO.OPERATION_BO )
        INNER JOIN ROUTER_STEP RS ON rs.HANDLE = RO.ROUTER_STEP_BO
        where O.SITE = #{ew.entity.site}
        <if test="ew.entity.operation!=null and ew.entity.operation!='' "  >
            AND (O.OPERATION LIKE '%${ew.entity.operation}%'  OR O.REVISION LIKE '%${ew.entity.operation}%'   OR OT.DESCRIPTION LIKE '%${ew.entity.operation}%')
        </if>
        ORDER BY RS.STEP_ID
    </select>

    <select id="selectOperationByRouterStepId" resultMap="BaseResultMap">
        SELECT OP.HANDLE, OP.CHANGE_STAMP, OP.SITE, OP.OPERATION, OP.TYPE, OP.SPECIAL_ROUTER_BO, OP.STATUS_BO, OP.RESOURCE_TYPE_BO, OP.REVISION, OP.CURRENT_REVISION, OP.EFF_START_DATE, OP.EFF_END_DATE, OP.CREATED_DATE_TIME, OP.MODIFIED_DATE_TIME, OP.PCA_DASHBOARD_MODE, OP.DEFAULT_NC_CODE_BO, OP.FAILURE_TRACKING_CONFIG_BO, OP.RESOURCE_BO, OP.MAX_LOOP, OP.REQUIRED_TIME_IN_PROCESS, OP.REPORTING_STEP, OP.PREV_SITE, OP.ORIGINAL_TRANSFER_KEY, OP.SPECIAL_INSTRUCTION, OP.REPORTING_CENTER_BO, OP.ERP_CONTROL_KEY_BO, OP.ERP_WORK_CENTER_BO
        FROM ROUTER RT
        INNER JOIN ROUTER_STEP RS ON RS.ROUTER_BO = RT.HANDLE AND RT.CURRENT_REVISION = 'true'
        INNER JOIN ROUTER_OPERATION RO ON RO.ROUTER_STEP_BO = RS.HANDLE
        INNER JOIN OPERATION OP ON RO.OPERATION_BO = 'OperationBO:' ||OP.SITE||','||OP.OPERATION||',#' AND OP.CURRENT_REVISION = 'true'
        WHERE RT.SITE = #{site} AND RT.ROUTER = #{router} AND RS.STEP_ID = #{stepId}
    </select>
</mapper>
