<?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.dispatch.mapper.SfcDispatchMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.dispatch.model.SfcDispatch">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="SHOP_ORDER" property="shopOrder" />
        <result column="SFC" property="sfc" />
        <result column="BLANKING_SIZE" property="blankingSize" />
        <result column="DISPATCH_SEQ" property="dispatchSeq" />
        <result column="DISPATCH_NO" property="dispatchNo" />
        <result column="DISPATCH_STATUS" property="dispatchStatus" />
        <result column="DRAWINGS_NO" property="drawingsNo" />
        <result column="DRAWINGS_REVISION" property="drawingsRevision" />
        <result column="IS_LOCK" property="isLock" />
        <result column="ROUTER_BO" property="routerBo" />
        <result column="STEP_ID" property="stepId" />
        <result column="OPERATION" property="operation" />
        <result column="RESOURCE_TYPE" property="resourceType" />
        <result column="WORK_CENTER" property="workCenter" />
        <result column="RESRCE" property="resrce" />
        <result column="EMPLOYEE" property="employee" />
        <result column="TURN_OPERATION" property="turnOperation" />
        <result column="DISPATCH_QTY" property="dispatchQty" />
        <result column="PROD_HOURS" property="prodHours" />
        <result column="PLANNED_START_DATE" property="plannedStartDate" />
        <result column="PLANNED_COMP_DATE" property="plannedCompDate" />
        <result column="EARLIEST_START_DATE" property="earliestStartDate" />
        <result column="LATEST_END_DATE" property="latestEndDate" />
        <result column="SO_RELEASED_DATE" property="soReleasedDate" />
        <result column="SFC_RELEASED_DATE" property="sfcReleasedDate" />
        <result column="RELEASED_COMPLETE_DATE" property="releasedCompleteDate" />
        <result column="ACTUAL_START_DATE" property="actualStartDate" />
        <result column="ACTUAL_COMPLETE_DATE" property="actualCompleteDate" />
        <result column="IS_DISPATCH" property="isDispatch" />
        <result column="IS_IMPORT" property="isImport" />
        <result column="REMARK" property="remark" />
        <result column="PREPOSITION_OPERATION" property="prepositionOperation" />
        <result column="IS_FIRST_OPERATION" property="isFirstOperation" />
        <result column="CREATE_USER" property="createUser" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFY_USER" property="modifyUser" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
        <result column="OTHER_1" property="other1" />
        <result column="OTHER_2" property="other2" />
        <result column="OTHER_3" property="other3" />
        <result column="OTHER_4" property="other4" />
        <result column="OTHER_5" property="other5" />
    </resultMap>

    <resultMap id="FullResultMap" type="com.foreverwin.mesnac.dispatch.model.ShopOrderRelease">
        <result column="IS_COMPLETED" property="isCompleted" />
        <result column="ITEM" property="item" />
        <result column="STATUS_NAME" property="statusName" />
        <result column="IS_MAJOR" property="isMajor" />
        <result column="COMMENTS" property="comments" />
        <result column="WORK_ORDER" property="workOrder" />
        <result column="SHOP_ORDER_TYPE" property="shopOrderType" />
        <result column="ITEM_DESCRIPTION" property="itemDescription" />
        <result column="COMPONENT" property="component" />
        <result column="COMPLETED_QTY" property="completedQty" />
        <result column="USER_NAME" property="userName" />
        <result column="COMPONENT_DESCRIPTION" property="componentDescription" />
        <result column="OPERATION_DESCRIPTION" property="operationDescription" />
    </resultMap>


    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, SHOP_ORDER, SFC, BLANKING_SIZE, DISPATCH_SEQ, DISPATCH_NO, DISPATCH_STATUS, DRAWINGS_NO, DRAWINGS_REVISION, IS_LOCK, ROUTER_BO, STEP_ID, OPERATION, RESOURCE_TYPE, WORK_CENTER, RESRCE, EMPLOYEE, TURN_OPERATION, DISPATCH_QTY, PROD_HOURS, PLANNED_START_DATE, PLANNED_COMP_DATE, EARLIEST_START_DATE, LATEST_END_DATE, SO_RELEASED_DATE, SFC_RELEASED_DATE, RELEASED_COMPLETE_DATE, ACTUAL_START_DATE, ACTUAL_COMPLETE_DATE, IS_DISPATCH, IS_IMPORT, REMARK, PREPOSITION_OPERATION, IS_FIRST_OPERATION, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME, OTHER_1, OTHER_2, OTHER_3, OTHER_4, OTHER_5
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_SFC_DISPATCH
        <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="selectBatchIds" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_SFC_DISPATCH WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </select>

    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM Z_SFC_DISPATCH
        <where>
            <if test="ew.entity.handle!=null">
                HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
            <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
            <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
            <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
            <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
            <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
            <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
            <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
            <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
            <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
            <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
            <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
            <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
            <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
            <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
            <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
            <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
            <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
            <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
            <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
            <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
            <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
            <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
            <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
            <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
            <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
            <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
            <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
            <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
            <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
            <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
            <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
            <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
            <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
            <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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 Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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 Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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 Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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 Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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 Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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.dispatch.model.SfcDispatch">
        INSERT INTO Z_SFC_DISPATCH
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="shopOrder!=null">SHOP_ORDER,</if>
            <if test="sfc!=null">SFC,</if>
            <if test="blankingSize!=null">BLANKING_SIZE,</if>
            <if test="dispatchSeq!=null">DISPATCH_SEQ,</if>
            <if test="dispatchNo!=null">DISPATCH_NO,</if>
            <if test="dispatchStatus!=null">DISPATCH_STATUS,</if>
            <if test="drawingsNo!=null">DRAWINGS_NO,</if>
            <if test="drawingsRevision!=null">DRAWINGS_REVISION,</if>
            <if test="isLock!=null">IS_LOCK,</if>
            <if test="routerBo!=null">ROUTER_BO,</if>
            <if test="stepId!=null">STEP_ID,</if>
            <if test="operation!=null">OPERATION,</if>
            <if test="resourceType!=null">RESOURCE_TYPE,</if>
            <if test="workCenter!=null">WORK_CENTER,</if>
            <if test="resrce!=null">RESRCE,</if>
            <if test="employee!=null">EMPLOYEE,</if>
            <if test="turnOperation!=null">TURN_OPERATION,</if>
            <if test="dispatchQty!=null">DISPATCH_QTY,</if>
            <if test="prodHours!=null">PROD_HOURS,</if>
            <if test="plannedStartDate!=null">PLANNED_START_DATE,</if>
            <if test="plannedCompDate!=null">PLANNED_COMP_DATE,</if>
            <if test="earliestStartDate!=null">EARLIEST_START_DATE,</if>
            <if test="latestEndDate!=null">LATEST_END_DATE,</if>
            <if test="soReleasedDate!=null">SO_RELEASED_DATE,</if>
            <if test="sfcReleasedDate!=null">SFC_RELEASED_DATE,</if>
            <if test="releasedCompleteDate!=null">RELEASED_COMPLETE_DATE,</if>
            <if test="actualStartDate!=null">ACTUAL_START_DATE,</if>
            <if test="actualCompleteDate!=null">ACTUAL_COMPLETE_DATE,</if>
            <if test="isDispatch!=null">IS_DISPATCH,</if>
            <if test="isImport!=null">IS_IMPORT,</if>
            <if test="remark!=null">REMARK,</if>
            <if test="prepositionOperation!=null">PREPOSITION_OPERATION,</if>
            <if test="isFirstOperation!=null">IS_FIRST_OPERATION,</if>
            <if test="createUser!=null">CREATE_USER,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifyUser!=null">MODIFY_USER,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
            <if test="other1!=null">OTHER_1,</if>
            <if test="other2!=null">OTHER_2,</if>
            <if test="other3!=null">OTHER_3,</if>
            <if test="other4!=null">OTHER_4,</if>
            <if test="other5!=null">OTHER_5,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="shopOrder!=null">#{shopOrder},</if>
            <if test="sfc!=null">#{sfc},</if>
            <if test="blankingSize!=null">#{blankingSize},</if>
            <if test="dispatchSeq!=null">#{dispatchSeq},</if>
            <if test="dispatchNo!=null">#{dispatchNo},</if>
            <if test="dispatchStatus!=null">#{dispatchStatus},</if>
            <if test="drawingsNo!=null">#{drawingsNo},</if>
            <if test="drawingsRevision!=null">#{drawingsRevision},</if>
            <if test="isLock!=null">#{isLock},</if>
            <if test="routerBo!=null">#{routerBo},</if>
            <if test="stepId!=null">#{stepId},</if>
            <if test="operation!=null">#{operation},</if>
            <if test="resourceType!=null">#{resourceType},</if>
            <if test="workCenter!=null">#{workCenter},</if>
            <if test="resrce!=null">#{resrce},</if>
            <if test="employee!=null">#{employee},</if>
            <if test="turnOperation!=null">#{turnOperation},</if>
            <if test="dispatchQty!=null">#{dispatchQty},</if>
            <if test="prodHours!=null">#{prodHours},</if>
            <if test="plannedStartDate!=null">#{plannedStartDate},</if>
            <if test="plannedCompDate!=null">#{plannedCompDate},</if>
            <if test="earliestStartDate!=null">#{earliestStartDate},</if>
            <if test="latestEndDate!=null">#{latestEndDate},</if>
            <if test="soReleasedDate!=null">#{soReleasedDate},</if>
            <if test="sfcReleasedDate!=null">#{sfcReleasedDate},</if>
            <if test="releasedCompleteDate!=null">#{releasedCompleteDate},</if>
            <if test="actualStartDate!=null">#{actualStartDate},</if>
            <if test="actualCompleteDate!=null">#{actualCompleteDate},</if>
            <if test="isDispatch!=null">#{isDispatch},</if>
            <if test="isImport!=null">#{isImport},</if>
            <if test="remark!=null">#{remark},</if>
            <if test="prepositionOperation!=null">#{prepositionOperation},</if>
            <if test="isFirstOperation!=null">#{isFirstOperation},</if>
            <if test="createUser!=null">#{createUser},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifyUser!=null">#{modifyUser},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
            <if test="other1!=null">#{other1},</if>
            <if test="other2!=null">#{other2},</if>
            <if test="other3!=null">#{other3},</if>
            <if test="other4!=null">#{other4},</if>
            <if test="other5!=null">#{other5},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.dispatch.model.SfcDispatch">
        INSERT INTO Z_SFC_DISPATCH
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{shopOrder},
            #{sfc},
            #{blankingSize},
            #{dispatchSeq},
            #{dispatchNo},
            #{dispatchStatus},
            #{drawingsNo},
            #{drawingsRevision},
            #{isLock},
            #{routerBo},
            #{stepId},
            #{operation},
            #{resourceType},
            #{workCenter},
            #{resrce},
            #{employee},
            #{turnOperation},
            #{dispatchQty},
            #{prodHours},
            #{plannedStartDate},
            #{plannedCompDate},
            #{earliestStartDate},
            #{latestEndDate},
            #{soReleasedDate},
            #{sfcReleasedDate},
            #{releasedCompleteDate},
            #{actualStartDate},
            #{actualCompleteDate},
            #{isDispatch},
            #{isImport},
            #{remark},
            #{prepositionOperation},
            #{isFirstOperation},
            #{createUser},
            #{createdDateTime},
            #{modifyUser},
            #{modifiedDateTime},
            #{other1},
            #{other2},
            #{other3},
            #{other4},
            #{other5},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_SFC_DISPATCH <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.shopOrder!=null">SHOP_ORDER=#{et.shopOrder},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.blankingSize!=null">BLANKING_SIZE=#{et.blankingSize},</if>
        <if test="et.dispatchSeq!=null">DISPATCH_SEQ=#{et.dispatchSeq},</if>
        <if test="et.dispatchNo!=null">DISPATCH_NO=#{et.dispatchNo},</if>
        <if test="et.dispatchStatus!=null">DISPATCH_STATUS=#{et.dispatchStatus},</if>
        <if test="et.drawingsNo!=null">DRAWINGS_NO=#{et.drawingsNo},</if>
        <if test="et.drawingsRevision!=null">DRAWINGS_REVISION=#{et.drawingsRevision},</if>
        <if test="et.isLock!=null">IS_LOCK=#{et.isLock},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.resourceType!=null">RESOURCE_TYPE=#{et.resourceType},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.employee!=null">EMPLOYEE=#{et.employee},</if>
        <if test="et.turnOperation!=null">TURN_OPERATION=#{et.turnOperation},</if>
        <if test="et.dispatchQty!=null">DISPATCH_QTY=#{et.dispatchQty},</if>
        <if test="et.prodHours!=null">PROD_HOURS=#{et.prodHours},</if>
        <if test="et.plannedStartDate!=null">PLANNED_START_DATE=#{et.plannedStartDate},</if>
        <if test="et.plannedCompDate!=null">PLANNED_COMP_DATE=#{et.plannedCompDate},</if>
        <if test="et.earliestStartDate!=null">EARLIEST_START_DATE=#{et.earliestStartDate},</if>
        <if test="et.latestEndDate!=null">LATEST_END_DATE=#{et.latestEndDate},</if>
        <if test="et.soReleasedDate!=null">SO_RELEASED_DATE=#{et.soReleasedDate},</if>
        <if test="et.sfcReleasedDate!=null">SFC_RELEASED_DATE=#{et.sfcReleasedDate},</if>
        <if test="et.releasedCompleteDate!=null">RELEASED_COMPLETE_DATE=#{et.releasedCompleteDate},</if>
        <if test="et.actualStartDate!=null">ACTUAL_START_DATE=#{et.actualStartDate},</if>
        <if test="et.actualCompleteDate!=null">ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate},</if>
        <if test="et.isDispatch!=null">IS_DISPATCH=#{et.isDispatch},</if>
        <if test="et.isImport!=null">IS_IMPORT=#{et.isImport},</if>
        <if test="et.remark!=null">REMARK=#{et.remark},</if>
        <if test="et.prepositionOperation!=null">PREPOSITION_OPERATION=#{et.prepositionOperation},</if>
        <if test="et.isFirstOperation!=null">IS_FIRST_OPERATION=#{et.isFirstOperation},</if>
        <if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.other1!=null">OTHER_1=#{et.other1},</if>
        <if test="et.other2!=null">OTHER_2=#{et.other2},</if>
        <if test="et.other3!=null">OTHER_3=#{et.other3},</if>
        <if test="et.other4!=null">OTHER_4=#{et.other4},</if>
        <if test="et.other5!=null">OTHER_5=#{et.other5},</if>
    </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="updateAllColumnById">
        UPDATE Z_SFC_DISPATCH <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        SHOP_ORDER=#{et.shopOrder},
        SFC=#{et.sfc},
        BLANKING_SIZE=#{et.blankingSize},
        DISPATCH_SEQ=#{et.dispatchSeq},
        DISPATCH_NO=#{et.dispatchNo},
        DISPATCH_STATUS=#{et.dispatchStatus},
        DRAWINGS_NO=#{et.drawingsNo},
        DRAWINGS_REVISION=#{et.drawingsRevision},
        IS_LOCK=#{et.isLock},
        ROUTER_BO=#{et.routerBo},
        STEP_ID=#{et.stepId},
        OPERATION=#{et.operation},
        RESOURCE_TYPE=#{et.resourceType},
        WORK_CENTER=#{et.workCenter},
        RESRCE=#{et.resrce},
        EMPLOYEE=#{et.employee},
        TURN_OPERATION=#{et.turnOperation},
        DISPATCH_QTY=#{et.dispatchQty},
        PROD_HOURS=#{et.prodHours},
        PLANNED_START_DATE=#{et.plannedStartDate},
        PLANNED_COMP_DATE=#{et.plannedCompDate},
        EARLIEST_START_DATE=#{et.earliestStartDate},
        LATEST_END_DATE=#{et.latestEndDate},
        SO_RELEASED_DATE=#{et.soReleasedDate},
        SFC_RELEASED_DATE=#{et.sfcReleasedDate},
        RELEASED_COMPLETE_DATE=#{et.releasedCompleteDate},
        ACTUAL_START_DATE=#{et.actualStartDate},
        ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate},
        IS_DISPATCH=#{et.isDispatch},
        IS_IMPORT=#{et.isImport},
        REMARK=#{et.remark},
        PREPOSITION_OPERATION=#{et.prepositionOperation},
        IS_FIRST_OPERATION=#{et.isFirstOperation},
        CREATE_USER=#{et.createUser},
        CREATED_DATE_TIME=#{et.createdDateTime},
        MODIFY_USER=#{et.modifyUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
        OTHER_1=#{et.other1},
        OTHER_2=#{et.other2},
        OTHER_3=#{et.other3},
        OTHER_4=#{et.other4},
        OTHER_5=#{et.other5},
    </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="update">
        UPDATE Z_SFC_DISPATCH <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.shopOrder!=null">SHOP_ORDER=#{et.shopOrder},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.blankingSize!=null">BLANKING_SIZE=#{et.blankingSize},</if>
        <if test="et.dispatchSeq!=null">DISPATCH_SEQ=#{et.dispatchSeq},</if>
        <if test="et.dispatchNo!=null">DISPATCH_NO=#{et.dispatchNo},</if>
        <if test="et.dispatchStatus!=null">DISPATCH_STATUS=#{et.dispatchStatus},</if>
        <if test="et.drawingsNo!=null">DRAWINGS_NO=#{et.drawingsNo},</if>
        <if test="et.drawingsRevision!=null">DRAWINGS_REVISION=#{et.drawingsRevision},</if>
        <if test="et.isLock!=null">IS_LOCK=#{et.isLock},</if>
        <if test="et.routerBo!=null">ROUTER_BO=#{et.routerBo},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.resourceType!=null">RESOURCE_TYPE=#{et.resourceType},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.employee!=null">EMPLOYEE=#{et.employee},</if>
        <if test="et.turnOperation!=null">TURN_OPERATION=#{et.turnOperation},</if>
        <if test="et.dispatchQty!=null">DISPATCH_QTY=#{et.dispatchQty},</if>
        <if test="et.prodHours!=null">PROD_HOURS=#{et.prodHours},</if>
        <if test="et.plannedStartDate!=null">PLANNED_START_DATE=#{et.plannedStartDate},</if>
        <if test="et.plannedCompDate!=null">PLANNED_COMP_DATE=#{et.plannedCompDate},</if>
        <if test="et.earliestStartDate!=null">EARLIEST_START_DATE=#{et.earliestStartDate},</if>
        <if test="et.latestEndDate!=null">LATEST_END_DATE=#{et.latestEndDate},</if>
        <if test="et.soReleasedDate!=null">SO_RELEASED_DATE=#{et.soReleasedDate},</if>
        <if test="et.sfcReleasedDate!=null">SFC_RELEASED_DATE=#{et.sfcReleasedDate},</if>
        <if test="et.releasedCompleteDate!=null">RELEASED_COMPLETE_DATE=#{et.releasedCompleteDate},</if>
        <if test="et.actualStartDate!=null">ACTUAL_START_DATE=#{et.actualStartDate},</if>
        <if test="et.actualCompleteDate!=null">ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate},</if>
        <if test="et.isDispatch!=null">IS_DISPATCH=#{et.isDispatch},</if>
        <if test="et.isImport!=null">IS_IMPORT=#{et.isImport},</if>
        <if test="et.remark!=null">REMARK=#{et.remark},</if>
        <if test="et.prepositionOperation!=null">PREPOSITION_OPERATION=#{et.prepositionOperation},</if>
        <if test="et.isFirstOperation!=null">IS_FIRST_OPERATION=#{et.isFirstOperation},</if>
        <if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        <if test="et.other1!=null">OTHER_1=#{et.other1},</if>
        <if test="et.other2!=null">OTHER_2=#{et.other2},</if>
        <if test="et.other3!=null">OTHER_3=#{et.other3},</if>
        <if test="et.other4!=null">OTHER_4=#{et.other4},</if>
        <if test="et.other5!=null">OTHER_5=#{et.other5},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.prepositionOperation!=null"> AND PREPOSITION_OPERATION=#{ew.entity.prepositionOperation}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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="deleteById">
        DELETE FROM Z_SFC_DISPATCH WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_SFC_DISPATCH
        <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 Z_SFC_DISPATCH
        <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.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.blankingSize!=null"> AND BLANKING_SIZE=#{ew.entity.blankingSize}</if>
                    <if test="ew.entity.dispatchSeq!=null"> AND DISPATCH_SEQ=#{ew.entity.dispatchSeq}</if>
                    <if test="ew.entity.dispatchNo!=null"> AND DISPATCH_NO=#{ew.entity.dispatchNo}</if>
                    <if test="ew.entity.dispatchStatus!=null"> AND DISPATCH_STATUS=#{ew.entity.dispatchStatus}</if>
                    <if test="ew.entity.drawingsNo!=null"> AND DRAWINGS_NO=#{ew.entity.drawingsNo}</if>
                    <if test="ew.entity.drawingsRevision!=null"> AND DRAWINGS_REVISION=#{ew.entity.drawingsRevision}</if>
                    <if test="ew.entity.isLock!=null"> AND IS_LOCK=#{ew.entity.isLock}</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.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.employee!=null"> AND EMPLOYEE=#{ew.entity.employee}</if>
                    <if test="ew.entity.turnOperation!=null"> AND TURN_OPERATION=#{ew.entity.turnOperation}</if>
                    <if test="ew.entity.dispatchQty!=null"> AND DISPATCH_QTY=#{ew.entity.dispatchQty}</if>
                    <if test="ew.entity.prodHours!=null"> AND PROD_HOURS=#{ew.entity.prodHours}</if>
                    <if test="ew.entity.plannedStartDate!=null"> AND PLANNED_START_DATE=#{ew.entity.plannedStartDate}</if>
                    <if test="ew.entity.plannedCompDate!=null"> AND PLANNED_COMP_DATE=#{ew.entity.plannedCompDate}</if>
                    <if test="ew.entity.earliestStartDate!=null"> AND EARLIEST_START_DATE=#{ew.entity.earliestStartDate}</if>
                    <if test="ew.entity.latestEndDate!=null"> AND LATEST_END_DATE=#{ew.entity.latestEndDate}</if>
                    <if test="ew.entity.soReleasedDate!=null"> AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate}</if>
                    <if test="ew.entity.sfcReleasedDate!=null"> AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate}</if>
                    <if test="ew.entity.releasedCompleteDate!=null"> AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate}</if>
                    <if test="ew.entity.actualStartDate!=null"> AND ACTUAL_START_DATE=#{ew.entity.actualStartDate}</if>
                    <if test="ew.entity.actualCompleteDate!=null"> AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate}</if>
                    <if test="ew.entity.isDispatch!=null"> AND IS_DISPATCH=#{ew.entity.isDispatch}</if>
                    <if test="ew.entity.isImport!=null"> AND IS_IMPORT=#{ew.entity.isImport}</if>
                    <if test="ew.entity.remark!=null"> AND REMARK=#{ew.entity.remark}</if>
                    <if test="ew.entity.isFirstOperation!=null"> AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation}</if>
                    <if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
                    <if test="ew.entity.other1!=null"> AND OTHER_1=#{ew.entity.other1}</if>
                    <if test="ew.entity.other2!=null"> AND OTHER_2=#{ew.entity.other2}</if>
                    <if test="ew.entity.other3!=null"> AND OTHER_3=#{ew.entity.other3}</if>
                    <if test="ew.entity.other4!=null"> AND OTHER_4=#{ew.entity.other4}</if>
                    <if test="ew.entity.other5!=null"> AND OTHER_5=#{ew.entity.other5}</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>

    <delete id="deleteBatchIds">
        DELETE FROM Z_SFC_DISPATCH WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->


    <select id="findSfcDispatch" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM Z_SFC_DISPATCH
        WHERE SITE = #{site} AND SFC = #{sfc}
        <if test="operation != null and operation != ''">
            AND OPERATION = #{operation}
        </if>
        <if test="stepId != null and stepId != ''">
            AND STEP_ID = #{stepId}
        </if>
    </select>


    <select id="findSfcDispatchList" resultMap="FullResultMap">
        SELECT 	WIP.*, CASE WHEN WIP.DISPATCH_SEQ = 1 THEN WIP.PLANNED_START_DATE ELSE V1.PLANNED_COMP_DATE END EARLIEST_START_DATE,
                CASE WHEN V2.HANDLE IS NOT NULL THEN V2.PLANNED_START_DATE ELSE WIP.PLANNED_COMP_DATE END LATEST_END_DATE,
                CASE WHEN WIP.DISPATCH_SEQ = 1 OR V1.OTHER_1 = 'true' THEN N'是' ELSE N'否' END IS_COMPLETED,
                CASE WHEN WIP.DISPATCH_STATUS = 'NEW' THEN N'新建' WHEN WIP.DISPATCH_STATUS = 'CANCEL' THEN N'取消'
                     WHEN WIP.DISPATCH_STATUS = 'PAUSE' THEN N'暂停' WHEN WIP.DISPATCH_STATUS = 'RELEASE' THEN N'发布'
                     END  AS STATUS_NAME
        FROM (
            SELECT 	DISTINCT SD.HANDLE, SD.SITE, SD.SHOP_ORDER, SD.DISPATCH_NO, C1.VALUE WORK_ORDER, IM.ITEM, IT.DESCRIPTION ITEM_DESCRIPTION, SD.SFC, SD.DISPATCH_STATUS,
                    SD.STEP_ID, SD.OPERATION, OT.DESCRIPTION OPERATION_DESCRIPTION, SD.RESOURCE_TYPE, SD.RESRCE, SD.EMPLOYEE, SD.EMPLOYEE USER_NAME, SD.DISPATCH_QTY, SD.PROD_HOURS,
                    CASE WHEN OTHER_1 = 'true' THEN SD.DISPATCH_QTY ELSE 0 END COMPLETED_QTY, SD.PLANNED_START_DATE, SD.PLANNED_COMP_DATE, SD.WORK_CENTER, SD.IS_DISPATCH,
                    SD.ACTUAL_START_DATE, SD.ACTUAL_COMPLETE_DATE, SD.REMARK, SD.DISPATCH_SEQ, SD.DISPATCH_SEQ-1 BEFORE_SEQ, SD.DISPATCH_SEQ+1 AFTER_SEQ,
                    CASE WHEN SD.TURN_OPERATION = 'true' THEN N'是' ELSE N'否' END TURN_OPERATION, SD.BLANKING_SIZE,
                    CASE WHEN IM.LOT_SIZE = 1 THEN N'是' ELSE N'否' END IS_MAJOR
            FROM Z_SFC_DISPATCH SD
            INNER JOIN SHOP_ORDER SO ON SO.SITE = SD.SITE AND SO.SHOP_ORDER = SD.SHOP_ORDER
            LEFT JOIN CUSTOM_FIELDS C1 ON C1.HANDLE = SO.HANDLE AND C1."ATTRIBUTE" = 'WORK_ORDER'
            INNER JOIN ITEM IM ON IM.HANDLE = SO.ITEM_BO
            LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
            INNER JOIN OPERATION O ON O.SITE = SD.SITE AND O.OPERATION = SD.OPERATION AND O.CURRENT_REVISION = 'true'
            LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = O.HANDLE AND OT.LOCALE = 'zh'
            INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SO.BOM_BO
            INNER JOIN ITEM CP ON CP.HANDLE = BC.COMPONENT_GBO
            LEFT JOIN ITEM_T CPT ON CPT.ITEM_BO = CP.HANDLE AND CPT.LOCALE = 'zh'
            WHERE SD.SITE = #{site}
            <if test="workCenter != null and workCenter != ''">
                AND SD.WORK_CENTER = #{workCenter}
            </if>
            <if test="dispatchStatus != null and dispatchStatus != ''">
                AND SD.DISPATCH_STATUS = #{dispatchStatus}
            </if>
            <if test="item != null and item != ''">
                AND IM.ITEM = #{item}
            </if>
            <if test="workOrder != null and workOrder != ''">
                AND C1.VALUE LIKE '%' ||#{workOrder}|| '%'
            </if>
            <if test="shopOrder != null and shopOrder != ''">
                AND SD.SHOP_ORDER = #{shopOrder}
            </if>
            <if test="resourceType != null and resourceType != ''">
                AND SD.RESOURCE_TYPE = #{resourceType}
            </if>
            <if test="resrce != null and resrce != ''">
                AND SD.RESRCE = #{resrce}
            </if>
            <if test="operation != null and operation != ''">
                AND SD.OPERATION = #{operation}
            </if>
            <if test="sfc != null and sfc != ''">
                AND SD.SFC = #{sfc}
            </if>
            <if test="turnOperation != null and turnOperation != ''">
                AND SD.TURN_OPERATION = #{turnOperation}
            </if>
            <if test="componentDescription != null and componentDescription != ''">
                AND CPT.DESCRIPTION LIKE '%' || #{componentDescription} || '%'
            </if>
            <if test="isDispatch != null and isDispatch != ''">
                AND SD.IS_DISPATCH = #{isDispatch}
            </if>
            <if test="startFromDate != null">
                AND SO.PLANNED_START_DATE >= #{startFromDate}
            </if>
            <if test="startToDate != null">
                AND SO.PLANNED_START_DATE &lt;= #{startToDate}
            </if>
            <if test="completeFromDate != null">
                AND SO.PLANNED_COMP_DATE >= #{completeFromDate}
            </if>
            <if test="completeToDate != null">
                AND SO.PLANNED_COMP_DATE &lt;= #{completeToDate}
            </if>
        ) WIP
        LEFT JOIN Z_SFC_DISPATCH V1 ON V1.SITE = WIP.SITE AND V1.SFC = WIP.SFC AND V1.DISPATCH_SEQ = WIP.BEFORE_SEQ
        LEFT JOIN Z_SFC_DISPATCH V2 ON V2.SITE = WIP.SITE AND V2.SFC = WIP.SFC AND V2.DISPATCH_SEQ = WIP.AFTER_SEQ
        ORDER BY WIP.SFC, TO_NUMBER(WIP.DISPATCH_SEQ)
    </select>
</mapper>
