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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.RouterStep">
        <result column="HANDLE" property="handle" />
        <result column="ROUTER_BO" property="routerBo" />
        <result column="STEP_ID" property="stepId" />
        <result column="DESCRIPTION" property="description" />
        <result column="REWORK" property="rework" />
        <result column="QUEUE_DECISION_TYPE" property="queueDecisionType" />
        <result column="ROUTER_COMP_GBO" property="routerCompGbo" />
        <result column="REPORTING_STEP" property="reportingStep" />
        <result column="SEQUENCE" property="sequence" />
        <result column="REPORTING_CENTER_BO" property="reportingCenterBo" />
        <result column="TABULAR_STEP_TYPE" property="tabularStepType" />
        <result column="SCRAP_REPORTING_STEP" property="scrapReportingStep" />
        <result column="IS_LAST_REPORTING_STEP" property="isLastReportingStep" />
        <result column="ERP_SEQUENCE" property="erpSequence" />
        <result column="ERP_CONTROL_KEY_BO" property="erpControlKeyBo" />
        <result column="ERP_WORK_CENTER_BO" property="erpWorkCenterBo" />
        <result column="ERP_INSPECTION_COMPLETE" property="erpInspectionComplete" />
        <result column="ERP_OPERATION" property="erpOperation" />
        <result column="OPERATION_ACTIVITY_ID" property="operationActivityId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, ROUTER_BO, STEP_ID, DESCRIPTION, REWORK, QUEUE_DECISION_TYPE, ROUTER_COMP_GBO, REPORTING_STEP, SEQUENCE, REPORTING_CENTER_BO, TABULAR_STEP_TYPE, SCRAP_REPORTING_STEP, IS_LAST_REPORTING_STEP, ERP_SEQUENCE, ERP_CONTROL_KEY_BO, ERP_WORK_CENTER_BO, ERP_INSPECTION_COMPLETE, ERP_OPERATION, OPERATION_ACTIVITY_ID
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM ROUTER_STEP
        <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 ROUTER_STEP
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
            <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
            <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
            <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
            <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
            <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
            <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
            <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
            <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
            <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
            <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
            <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
            <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
            <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
            <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</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 ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</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 ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</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 ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectPage" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMapsPage" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</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.RouterStep">
        INSERT INTO ROUTER_STEP
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="routerBo!=null">ROUTER_BO,</if>
            <if test="stepId!=null">STEP_ID,</if>
            <if test="description!=null">DESCRIPTION,</if>
            <if test="rework!=null">REWORK,</if>
            <if test="queueDecisionType!=null">QUEUE_DECISION_TYPE,</if>
            <if test="routerCompGbo!=null">ROUTER_COMP_GBO,</if>
            <if test="reportingStep!=null">REPORTING_STEP,</if>
            <if test="sequence!=null">SEQUENCE,</if>
            <if test="reportingCenterBo!=null">REPORTING_CENTER_BO,</if>
            <if test="tabularStepType!=null">TABULAR_STEP_TYPE,</if>
            <if test="scrapReportingStep!=null">SCRAP_REPORTING_STEP,</if>
            <if test="isLastReportingStep!=null">IS_LAST_REPORTING_STEP,</if>
            <if test="erpSequence!=null">ERP_SEQUENCE,</if>
            <if test="erpControlKeyBo!=null">ERP_CONTROL_KEY_BO,</if>
            <if test="erpWorkCenterBo!=null">ERP_WORK_CENTER_BO,</if>
            <if test="erpInspectionComplete!=null">ERP_INSPECTION_COMPLETE,</if>
            <if test="erpOperation!=null">ERP_OPERATION,</if>
            <if test="operationActivityId!=null">OPERATION_ACTIVITY_ID,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="routerBo!=null">#{routerBo},</if>
            <if test="stepId!=null">#{stepId},</if>
            <if test="description!=null">#{description},</if>
            <if test="rework!=null">#{rework},</if>
            <if test="queueDecisionType!=null">#{queueDecisionType},</if>
            <if test="routerCompGbo!=null">#{routerCompGbo},</if>
            <if test="reportingStep!=null">#{reportingStep},</if>
            <if test="sequence!=null">#{sequence},</if>
            <if test="reportingCenterBo!=null">#{reportingCenterBo},</if>
            <if test="tabularStepType!=null">#{tabularStepType},</if>
            <if test="scrapReportingStep!=null">#{scrapReportingStep},</if>
            <if test="isLastReportingStep!=null">#{isLastReportingStep},</if>
            <if test="erpSequence!=null">#{erpSequence},</if>
            <if test="erpControlKeyBo!=null">#{erpControlKeyBo},</if>
            <if test="erpWorkCenterBo!=null">#{erpWorkCenterBo},</if>
            <if test="erpInspectionComplete!=null">#{erpInspectionComplete},</if>
            <if test="erpOperation!=null">#{erpOperation},</if>
            <if test="operationActivityId!=null">#{operationActivityId},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.RouterStep">
        INSERT INTO ROUTER_STEP
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{routerBo},
            #{stepId},
            #{description},
            #{rework},
            #{queueDecisionType},
            #{routerCompGbo},
            #{reportingStep},
            #{sequence},
            #{reportingCenterBo},
            #{tabularStepType},
            #{scrapReportingStep},
            #{isLastReportingStep},
            #{erpSequence},
            #{erpControlKeyBo},
            #{erpWorkCenterBo},
            #{erpInspectionComplete},
            #{erpOperation},
            #{operationActivityId},
        </trim>
    </insert>






    <update id="update">
        UPDATE ROUTER_STEP <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.rework!=null">REWORK=#{et.rework},</if>
        <if test="et.queueDecisionType!=null">QUEUE_DECISION_TYPE=#{et.queueDecisionType},</if>
        <if test="et.routerCompGbo!=null">ROUTER_COMP_GBO=#{et.routerCompGbo},</if>
        <if test="et.reportingStep!=null">REPORTING_STEP=#{et.reportingStep},</if>
        <if test="et.sequence!=null">SEQUENCE=#{et.sequence},</if>
        <if test="et.reportingCenterBo!=null">REPORTING_CENTER_BO=#{et.reportingCenterBo},</if>
        <if test="et.tabularStepType!=null">TABULAR_STEP_TYPE=#{et.tabularStepType},</if>
        <if test="et.scrapReportingStep!=null">SCRAP_REPORTING_STEP=#{et.scrapReportingStep},</if>
        <if test="et.isLastReportingStep!=null">IS_LAST_REPORTING_STEP=#{et.isLastReportingStep},</if>
        <if test="et.erpSequence!=null">ERP_SEQUENCE=#{et.erpSequence},</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>
        <if test="et.erpInspectionComplete!=null">ERP_INSPECTION_COMPLETE=#{et.erpInspectionComplete},</if>
        <if test="et.erpOperation!=null">ERP_OPERATION=#{et.erpOperation},</if>
        <if test="et.operationActivityId!=null">OPERATION_ACTIVITY_ID=#{et.operationActivityId},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</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 ROUTER_STEP
        <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 ROUTER_STEP
        <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.routerBo!=null"> AND ROUTER_BO=#{ew.entity.routerBo}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.rework!=null"> AND REWORK=#{ew.entity.rework}</if>
                    <if test="ew.entity.queueDecisionType!=null"> AND QUEUE_DECISION_TYPE=#{ew.entity.queueDecisionType}</if>
                    <if test="ew.entity.routerCompGbo!=null"> AND ROUTER_COMP_GBO=#{ew.entity.routerCompGbo}</if>
                    <if test="ew.entity.reportingStep!=null"> AND REPORTING_STEP=#{ew.entity.reportingStep}</if>
                    <if test="ew.entity.sequence!=null"> AND SEQUENCE=#{ew.entity.sequence}</if>
                    <if test="ew.entity.reportingCenterBo!=null"> AND REPORTING_CENTER_BO=#{ew.entity.reportingCenterBo}</if>
                    <if test="ew.entity.tabularStepType!=null"> AND TABULAR_STEP_TYPE=#{ew.entity.tabularStepType}</if>
                    <if test="ew.entity.scrapReportingStep!=null"> AND SCRAP_REPORTING_STEP=#{ew.entity.scrapReportingStep}</if>
                    <if test="ew.entity.isLastReportingStep!=null"> AND IS_LAST_REPORTING_STEP=#{ew.entity.isLastReportingStep}</if>
                    <if test="ew.entity.erpSequence!=null"> AND ERP_SEQUENCE=#{ew.entity.erpSequence}</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 test="ew.entity.erpInspectionComplete!=null"> AND ERP_INSPECTION_COMPLETE=#{ew.entity.erpInspectionComplete}</if>
                    <if test="ew.entity.erpOperation!=null"> AND ERP_OPERATION=#{ew.entity.erpOperation}</if>
                    <if test="ew.entity.operationActivityId!=null"> AND OPERATION_ACTIVITY_ID=#{ew.entity.operationActivityId}</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="findRouterOperationByRouterBo" resultType="com.foreverwin.mesnac.meapi.dto.RouterStepDto">
        SELECT
            STEP.STEP_ID ,
            STEP."SEQUENCE",
            STEP.REPORTING_CENTER_BO,
            STEP.ERP_OPERATION ,
            OP.HANDLE AS OPERATION_BO,
            OP.OPERATION ,
            OPT.DESCRIPTION OPERATION_DESC
        FROM ROUTER R
        JOIN ROUTER_STEP STEP ON R.HANDLE = STEP.ROUTER_BO
        JOIN ROUTER_OPERATION RO ON STEP.HANDLE = RO.ROUTER_STEP_BO
        JOIN OPERATION OP ON 'OperationBO:' || #{site} || ',' || OP.OPERATION  || ',#' = RO.OPERATION_BO AND OP.CURRENT_REVISION = 'true'
        JOIN OPERATION_T OPT ON OP.HANDLE = OPT.OPERATION_BO AND OPT.LOCALE = #{locale}
        WHERE R.HANDLE = #{routerBo}
              AND OP.SITE = #{site}
        ORDER BY STEP."SEQUENCE"
    </select>

</mapper>
