<?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.production.mapper.WorkShopTransferMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.production.model.WorkShopTransfer">
        <id column="HANDLE" property="handle" />
        <result column="SFC_DISPATCH_BO" property="sfcDispatchBo" />
        <result column="SITE" property="site" />
        <result column="TRANSFER_NO" property="transferNo" />
        <result column="WORK_CENTER" property="workCenter" />
        <result column="TRANSFER_WORK_CENTER" property="transferWorkCenter" />
        <result column="SFC" property="sfc" />
        <result column="SHOP_ORDER" property="shopOrder" />
        <result column="STEP_ID" property="stepId" />
        <result column="OPERATION" property="operation" />
        <result column="LAST_OPERATION" property="lastOperation" />
        <result column="NEXT_OPERATION" property="nextOperation" />
        <result column="QTY" property="qty" />
        <result column="IS_OUT" property="isOut" />
        <result column="IS_IN" property="isIn" />
        <result column="IS_OUT_SOURCE" property="isOutSource" />
        <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="TRANSFER_IN_USER" property="transferInUser" />
        <result column="TRANSFER_IN_TIME" property="transferInTime" />
        <result column="TRANSFER_OUT_USER" property="transferOutUser" />
        <result column="TRANSFER_OUT_TIME" property="transferOutTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SFC_DISPATCH_BO, SITE, TRANSFER_NO, WORK_CENTER, TRANSFER_WORK_CENTER, SFC, SHOP_ORDER, STEP_ID, OPERATION, LAST_OPERATION, NEXT_OPERATION, QTY, IS_OUT, IS_IN, IS_OUT_SOURCE, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME, TRANSFER_IN_USER, TRANSFER_IN_TIME, TRANSFER_OUT_USER, TRANSFER_OUT_TIME
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_WORK_SHOP_TRANSFER
        <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_WORK_SHOP_TRANSFER 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_WORK_SHOP_TRANSFER
        <where>
            <if test="ew.entity.handle!=null">
                HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
            <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
            <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
            <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
            <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
            <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
            <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
            <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
            <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
            <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
            <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
            <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
            <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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="getTransferNo" resultMap="BaseResultMap">
        SELECT DISTINCT TRANSFER_NO,WCT.DESCRIPTION WORK_CENTER FROM Z_WORK_SHOP_TRANSFER ZWST
        JOIN WORK_CENTER WC ON WC.WORK_CENTER = ZWST.WORK_CENTER  AND WC.SITE = ZWST.SITE
        LEFT JOIN WORK_CENTER_T WCT ON WCT.WORK_CENTER_BO = WC.HANDLE AND WCT.LOCALE = 'zh'
        WHERE  ZWST.site=#{ew.entity.site}
        <if test="ew.entity.transferNo!=null"> AND ZWST.TRANSFER_NO=#{ew.entity.transferNo}</if>
        <if test="ew.entity.workCenter!=null"> AND ZWST.WORK_CENTER=#{ew.entity.workCenter}</if>
    </select>
    <select id="selectPage" resultMap="BaseResultMap">
        SELECT DISTINCT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    AND ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${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_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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.production.model.WorkShopTransfer">
        INSERT INTO Z_WORK_SHOP_TRANSFER
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="sfcDispatchBo!=null">SFC_DISPATCH_BO,</if>
            <if test="site!=null">SITE,</if>
            <if test="transferNo!=null">TRANSFER_NO,</if>
            <if test="workCenter!=null">WORK_CENTER,</if>
            <if test="transferWorkCenter!=null">TRANSFER_WORK_CENTER,</if>
            <if test="sfc!=null">SFC,</if>
            <if test="shopOrder!=null">SHOP_ORDER,</if>
            <if test="stepId!=null">STEP_ID,</if>
            <if test="operation!=null">OPERATION,</if>
            <if test="lastOperation!=null">LAST_OPERATION,</if>
            <if test="nextOperation!=null">NEXT_OPERATION,</if>
            <if test="qty!=null">QTY,</if>
            <if test="isOut!=null">IS_OUT,</if>
            <if test="isIn!=null">IS_IN,</if>
            <if test="isOutSource!=null">IS_OUT_SOURCE,</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="transferInUser!=null">TRANSFER_IN_USER,</if>
            <if test="transferInTime!=null">TRANSFER_IN_TIME,</if>
            <if test="transferOutUser!=null">TRANSFER_OUT_USER,</if>
            <if test="transferOutTime!=null">TRANSFER_OUT_TIME,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="sfcDispatchBo!=null">#{sfcDispatchBo},</if>
            <if test="site!=null">#{site},</if>
            <if test="transferNo!=null">#{transferNo},</if>
            <if test="workCenter!=null">#{workCenter},</if>
            <if test="transferWorkCenter!=null">#{transferWorkCenter},</if>
            <if test="sfc!=null">#{sfc},</if>
            <if test="shopOrder!=null">#{shopOrder},</if>
            <if test="stepId!=null">#{stepId},</if>
            <if test="operation!=null">#{operation},</if>
            <if test="lastOperation!=null">#{lastOperation},</if>
            <if test="nextOperation!=null">#{nextOperation},</if>
            <if test="qty!=null">#{qty},</if>
            <if test="isOut!=null">#{isOut},</if>
            <if test="isIn!=null">#{isIn},</if>
            <if test="isOutSource!=null">#{isOutSource},</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="transferInUser!=null">#{transferInUser},</if>
            <if test="transferInTime!=null">#{transferInTime},</if>
            <if test="transferOutUser!=null">#{transferOutUser},</if>
            <if test="transferOutTime!=null">#{transferOutTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.production.model.WorkShopTransfer">
        INSERT INTO Z_WORK_SHOP_TRANSFER
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{sfcDispatchBo},
            #{site},
            #{transferNo},
            #{workCenter},
            #{transferWorkCenter},
            #{sfc},
            #{shopOrder},
            #{stepId},
            #{operation},
            #{lastOperation},
            #{nextOperation},
            #{qty},
            #{isOut},
            #{isIn},
            #{isOutSource},
            #{createUser},
            #{createdDateTime},
            #{modifyUser},
            #{modifiedDateTime},
            #{transferInUser},
            #{transferInTime},
            #{transferOutUser},
            #{transferOutTime},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_WORK_SHOP_TRANSFER <trim prefix="SET" suffixOverrides=",">
        <if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.transferNo!=null">TRANSFER_NO=#{et.transferNo},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.transferWorkCenter!=null">TRANSFER_WORK_CENTER=#{et.transferWorkCenter},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.shopOrder!=null">SHOP_ORDER=#{et.shopOrder},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.lastOperation!=null">LAST_OPERATION=#{et.lastOperation},</if>
        <if test="et.nextOperation!=null">NEXT_OPERATION=#{et.nextOperation},</if>
        <if test="et.qty!=null">QTY=#{et.qty},</if>
        <if test="et.isOut!=null">IS_OUT=#{et.isOut},</if>
        <if test="et.isIn!=null">IS_IN=#{et.isIn},</if>
        <if test="et.isOutSource!=null">IS_OUT_SOURCE=#{et.isOutSource},</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.transferInUser!=null">TRANSFER_IN_USER=#{et.transferInUser},</if>
        <if test="et.transferInTime!=null">TRANSFER_IN_TIME=#{et.transferInTime},</if>
        <if test="et.transferOutUser!=null">TRANSFER_OUT_USER=#{et.transferOutUser},</if>
        <if test="et.transferOutTime!=null">TRANSFER_OUT_TIME=#{et.transferOutTime},</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_WORK_SHOP_TRANSFER <trim prefix="SET" suffixOverrides=",">
        SFC_DISPATCH_BO=#{et.sfcDispatchBo},
        SITE=#{et.site},
        TRANSFER_NO=#{et.transferNo},
        WORK_CENTER=#{et.workCenter},
        TRANSFER_WORK_CENTER=#{et.transferWorkCenter},
        SFC=#{et.sfc},
        SHOP_ORDER=#{et.shopOrder},
        STEP_ID=#{et.stepId},
        OPERATION=#{et.operation},
        LAST_OPERATION=#{et.lastOperation},
        NEXT_OPERATION=#{et.nextOperation},
        QTY=#{et.qty},
        IS_OUT=#{et.isOut},
        IS_IN=#{et.isIn},
        IS_OUT_SOURCE=#{et.isOutSource},
        CREATE_USER=#{et.createUser},
        CREATED_DATE_TIME=#{et.createdDateTime},
        MODIFY_USER=#{et.modifyUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
        TRANSFER_IN_USER=#{et.transferInUser},
        TRANSFER_IN_TIME=#{et.transferInTime},
        TRANSFER_OUT_USER=#{et.transferOutUser},
        TRANSFER_OUT_TIME=#{et.transferOutTime},
    </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_WORK_SHOP_TRANSFER <trim prefix="SET" suffixOverrides=",">
        <if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.transferNo!=null">TRANSFER_NO=#{et.transferNo},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.transferWorkCenter!=null">TRANSFER_WORK_CENTER=#{et.transferWorkCenter},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.shopOrder!=null">SHOP_ORDER=#{et.shopOrder},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.lastOperation!=null">LAST_OPERATION=#{et.lastOperation},</if>
        <if test="et.nextOperation!=null">NEXT_OPERATION=#{et.nextOperation},</if>
        <if test="et.qty!=null">QTY=#{et.qty},</if>
        <if test="et.isOut!=null">IS_OUT=#{et.isOut},</if>
        <if test="et.isIn!=null">IS_IN=#{et.isIn},</if>
        <if test="et.isOutSource!=null">IS_OUT_SOURCE=#{et.isOutSource},</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.transferInUser!=null">TRANSFER_IN_USER=#{et.transferInUser},</if>
        <if test="et.transferInTime!=null">TRANSFER_IN_TIME=#{et.transferInTime},</if>
        <if test="et.transferOutUser!=null">TRANSFER_OUT_USER=#{et.transferOutUser},</if>
        <if test="et.transferOutTime!=null">TRANSFER_OUT_TIME=#{et.transferOutTime},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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_WORK_SHOP_TRANSFER WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_WORK_SHOP_TRANSFER
        <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_WORK_SHOP_TRANSFER
        <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.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.transferNo!=null"> AND TRANSFER_NO=#{ew.entity.transferNo}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.transferWorkCenter!=null"> AND TRANSFER_WORK_CENTER=#{ew.entity.transferWorkCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</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.lastOperation!=null"> AND LAST_OPERATION=#{ew.entity.lastOperation}</if>
                    <if test="ew.entity.nextOperation!=null"> AND NEXT_OPERATION=#{ew.entity.nextOperation}</if>
                    <if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
                    <if test="ew.entity.isOut!=null"> AND IS_OUT=#{ew.entity.isOut}</if>
                    <if test="ew.entity.isIn!=null"> AND IS_IN=#{ew.entity.isIn}</if>
                    <if test="ew.entity.isOutSource!=null"> AND IS_OUT_SOURCE=#{ew.entity.isOutSource}</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.transferInUser!=null"> AND TRANSFER_IN_USER=#{ew.entity.transferInUser}</if>
                    <if test="ew.entity.transferInTime!=null"> AND TRANSFER_IN_TIME=#{ew.entity.transferInTime}</if>
                    <if test="ew.entity.transferOutUser!=null"> AND TRANSFER_OUT_USER=#{ew.entity.transferOutUser}</if>
                    <if test="ew.entity.transferOutTime!=null"> AND TRANSFER_OUT_TIME=#{ew.entity.transferOutTime}</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_WORK_SHOP_TRANSFER WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="getOutList" resultType="com.foreverwin.mesnac.production.dto.WorkShopTransferDto">
    SELECT zsd.handle SFC_DISPATCH_BO,zsd.sfc, PREZSD.OPERATION LAST_OPERATION,PREZSD.WORK_CENTER TRANSFER_WORK_CENTER,zsd.WORK_CENTER,WCT.DESCRIPTION WORK_CENTER_DESC,zsd.SHOP_ORDER,c1.VALUE WORK_ORDER,IT.DESCRIPTION ITEM_DESC,ZSD.BLANKING_SIZE,SFC.QTY,PREOT.DESCRIPTION LAST_OPERATION_DESC,PREZSD.EMPLOYEE_DESCRIPTION,OT.DESCRIPTION OPERATION_DESC,
     CASE WHEN ZWST.IS_IN='Y'  THEN '已接收'  WHEN ZWST.IS_OUT='Y'  THEN '转序中'  ELSE '待转出' END STATUS
     FROM Z_SFC_DISPATCH zsd
     JOIN sfc sfc ON sfc.sfc=zsd.sfc AND zsd.site=sfc.site
     INNER JOIN SFC_ROUTING SG ON SG.SFC_BO = sfc.HANDLE
     INNER JOIN SFC_ROUTER SR ON SR.SFC_ROUTING_BO = SG.HANDLE AND SR.IN_USE = 'true'
     left JOIN SFC_STEP SP ON SP.SFC_ROUTER_BO = SR.HANDLE  and sp.step_Id=zsd.STEP_ID
     JOIN WORK_CENTER WC ON WC.WORK_CENTER = ZSD.WORK_CENTER  AND WC.SITE = zsd.SITE
     LEFT JOIN WORK_CENTER_T WCT ON WCT.WORK_CENTER_BO = WC.HANDLE AND WCT.LOCALE = 'zh'
     LEFT JOIN Z_SFC_DISPATCH PREZSD ON zsd.SFC=PREZSD.SFC AND PREZSD.DISPATCH_SEQ=TO_NUMBER(zsd.DISPATCH_SEQ)-1
     LEFT JOIN Z_WORK_SHOP_TRANSFER ZWST ON zsd.HANDLE=zwst.SFC_DISPATCH_BO
     INNER JOIN SHOP_ORDER SO ON SO.SITE = zsd.SITE AND SO.SHOP_ORDER = zsd.SHOP_ORDER
     JOIN OPERATION OP ON OP.OPERATION = zsd.OPERATION AND OP.SITE = ZSD.SITE AND OP.CURRENT_REVISION = 'true'
     JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE ='zh'
     LEFT JOIN CUSTOM_FIELDS C1 ON C1.HANDLE = SO.HANDLE AND C1."ATTRIBUTE" = 'WORK_ORDER'
     INNER JOIN SFC SFC ON SFC.SITE = zsd.SITE AND SFC.SFC = zsd.SFC
     INNER JOIN ITEM IM ON IM.HANDLE = SFC.ITEM_BO
     LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
     LEFT JOIN OPERATION PREOP ON PREOP.OPERATION = zsd.PREPOSITION_OPERATION AND PREOP.SITE = ZSD.SITE AND PREOP.CURRENT_REVISION = 'true'
     LEFT JOIN OPERATION_T PREOT ON PREOT.OPERATION_BO = PREOP.HANDLE AND PREOT.LOCALE ='zh'
     WHERE ZSD.SITE=#{site} AND (zsd.DISPATCH_STATUS='RELEASE' OR zsd.DISPATCH_STATUS='NEW') AND PREZSD.DISPATCH_STATUS='COMPLETE'
    <if test="stepId!=null and stepId!=''">
        AND zsd.STEP_ID=#{stepId}
    </if>
    <if test="workCenter!=null and workCenter!=''">
        AND PREZSD.WORK_CENTER=#{workCenter}
    </if>
    <if test="transferWorkCenter!=null and transferWorkCenter!=''">
        AND ZSD.WORK_CENTER=#{transferWorkCenter}
    </if>
     <if test="operation!=null and operation!=''">
         AND ZSD.OPERATION=#{operation}
     </if>
    <if test="sfc!=null and sfc!=''">
        AND ZSD.sfc=#{sfc}
    </if>
    <if test=" 2 eq  status ">
        AND ZWST.IS_IN='Y' AND ZWST.IS_OUT='Y'
    </if>
    <if test=" 1 eq status ">
        AND ZWST.IS_OUT='Y' AND ZWST.IS_IN IS NULL AND (SP.QTY_IN_QUEUE > 0 OR SP.QTY_IN_WORK > 0)
    </if>
    <if test="0 eq status">
        AND ZWST.IS_OUT IS NULL AND ZWST.IS_IN IS NULL AND (SP.QTY_IN_QUEUE > 0 OR SP.QTY_IN_WORK > 0)
    </if>
    </select>
    <select id="getSfcData" resultType="com.foreverwin.mesnac.production.dto.WorkShopTransferDto">
        SELECT ZSD.handle SFC_DISPATCH_BO,ZSD.STEP_ID,ZSD.RESRCE,ZSD.DISPATCH_NO,ZSD.WORK_CENTER,SC.SFC, SO.SHOP_ORDER, SO_CF2.VALUE WORK_ORDER,SO_CF.VALUE ITEM_NUMBER,SC.QTY,  IM.ITEM, IT.DESCRIPTION ITEM_DESC, OP.OPERATION, OT.DESCRIPTION OPERATION_DESC,
        ST.STATUS ,RO_CF.VALUE IS_OUT_SOURCE
        FROM SFC SC
        INNER JOIN SHOP_ORDER SO ON SO.HANDLE = SC.SHOP_ORDER_BO
        LEFT JOIN CUSTOM_FIELDS SO_CF2 ON SO_CF2.HANDLE = SO.HANDLE AND SO_CF2."ATTRIBUTE" = 'WORK_ORDER'
        LEFT JOIN CUSTOM_FIELDS SO_CF ON SO_CF.HANDLE = SO.HANDLE AND SO_CF."ATTRIBUTE" = 'ITEM_NUMBER'
        INNER JOIN STATUS ST ON ST.HANDLE = SC.STATUS_BO AND ST.STATUS_GROUP = 'SFC'
        INNER JOIN ITEM IM ON IM.HANDLE = SC.ITEM_BO
        LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
        INNER JOIN SFC_ROUTING SG ON SG.SFC_BO = SC.HANDLE
        INNER JOIN SFC_ROUTER SR ON SR.SFC_ROUTING_BO = SG.HANDLE AND SR.IN_USE = 'true'
        INNER JOIN SFC_STEP SP ON SP.SFC_ROUTER_BO = SR.HANDLE  AND (SP.QTY_IN_QUEUE > 0 OR SP.QTY_IN_WORK > 0)
        INNER JOIN ROUTER_STEP RS ON RS.ROUTER_BO = SR.ROUTER_BO AND RS.STEP_ID = SP.STEP_ID
        INNER JOIN ROUTER_OPERATION RO ON RO.ROUTER_STEP_BO = RS.HANDLE
        LEFT JOIN CUSTOM_FIELDS RO_CF ON RO_CF.HANDLE = RO.HANDLE AND RO_CF."ATTRIBUTE" = 'OUT_SOURCE'
        INNER JOIN OPERATION OP ON SP.OPERATION_BO = 'OperationBO:'||OP.SITE||','||OP.OPERATION||',#' AND OP.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE = 'zh'
        JOIN Z_SFC_DISPATCH ZSD ON ZSD.SITE = SC.SITE AND ZSD.SFC = SC.SFC AND ZSD.OPERATION = OP.OPERATION AND ZSD.STEP_ID = SP.STEP_ID
        WHERE SC.SITE = #{site} AND SC.SFC = #{sfc}
    </select>

    <select id="getInList" resultType="com.foreverwin.mesnac.production.dto.WorkShopTransferDto">
        SELECT zsd.sfc,zsd.handle SFC_DISPATCH_BO,zsd.WORK_CENTER,WCT.DESCRIPTION WORK_CENTER_DESC,zsd.SHOP_ORDER,c1.VALUE WORK_ORDER,IT.DESCRIPTION ITEM_DESC,ZSD.BLANKING_SIZE,SFC.QTY,PREOT.DESCRIPTION LAST_OPERATION_DESC,OT.DESCRIPTION OPERATION_DESC,
        CASE WHEN ZWST.IS_IN='Y'  THEN '已接收'  WHEN ZWST.IS_OUT='Y'  THEN '转序中'  ELSE NULL END STATUS
        FROM Z_SFC_DISPATCH zsd
        JOIN sfc sfc ON sfc.sfc=zsd.sfc AND zsd.site=sfc.site
        INNER JOIN SFC_ROUTING SG ON SG.SFC_BO = sfc.HANDLE
        INNER JOIN SFC_ROUTER SR ON SR.SFC_ROUTING_BO = SG.HANDLE AND SR.IN_USE = 'true'
        left JOIN SFC_STEP SP ON SP.SFC_ROUTER_BO = SR.HANDLE  and sp.step_Id=zsd.STEP_ID
        JOIN WORK_CENTER WC ON WC.WORK_CENTER = ZSD.WORK_CENTER  AND WC.SITE = zsd.SITE
        LEFT JOIN WORK_CENTER_T WCT ON WCT.WORK_CENTER_BO = WC.HANDLE AND WCT.LOCALE = 'zh'
        LEFT JOIN Z_WORK_SHOP_TRANSFER ZWST ON zsd.HANDLE=zwst.SFC_DISPATCH_BO
        INNER JOIN SHOP_ORDER SO ON SO.SITE = zsd.SITE AND SO.SHOP_ORDER = zsd.SHOP_ORDER
        JOIN OPERATION OP ON OP.OPERATION = zsd.OPERATION AND OP.SITE = ZSD.SITE AND OP.CURRENT_REVISION = 'true'
        JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE ='zh'
        LEFT JOIN CUSTOM_FIELDS C1 ON C1.HANDLE = SO.HANDLE AND C1."ATTRIBUTE" = 'WORK_ORDER'
        INNER JOIN SFC SFC ON SFC.SITE = zsd.SITE AND SFC.SFC = zsd.SFC
        INNER JOIN ITEM IM ON IM.HANDLE = SFC.ITEM_BO
        LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
        LEFT JOIN OPERATION PREOP ON PREOP.OPERATION = zsd.PREPOSITION_OPERATION AND PREOP.SITE = ZSD.SITE AND PREOP.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION_T PREOT ON PREOT.OPERATION_BO = PREOP.HANDLE AND PREOT.LOCALE ='zh'
        WHERE ZSD.SITE=#{site} AND (zsd.DISPATCH_STATUS='RELEASE' OR zsd.DISPATCH_STATUS='NEW')
        <if test="workCenter!=null and workCenter!=''">
            AND ZSD.WORK_CENTER=#{workCenter}
        </if>
        <if test="transferNo!=null and transferNo!=''">
            AND ZWST.TRANSFER_NO=#{transferNo}
        </if>
        <if test="sfc!=null and sfc!=''">
            AND ZSD.sfc=#{sfc}
        </if>
        <if test="status eq 1">
            AND ZWST.IS_IN='Y' AND ZWST.IS_OUT='Y'
        </if>
        <if test="status eq 0">
            AND ZWST.IS_OUT='Y'  AND ZWST.IS_IN IS NULL AND (SP.QTY_IN_QUEUE > 0 OR SP.QTY_IN_WORK > 0)
        </if>
    </select>

</mapper>
