<?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.common.mapper.ProdReadyTaskMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.common.model.ProdReadyTask">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="TASK_NO" property="taskNo" />
        <result column="SFC_DISPATCH_BO" property="sfcDispatchBo" />
        <result column="SHOP_ORDER" property="shopOrder" />
        <result column="WORK_CENTER" property="workCenter" />
        <result column="SFC" property="sfc" />
        <result column="OPERATION" property="operation" />
        <result column="STEP_ID" property="stepId" />
        <result column="ITEM" property="item" />
        <result column="RESRCE" property="resrce" />
        <result column="RESULT" property="result" />
        <result column="STATUS" property="status" />
        <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="READY_USER" property="readyUser" />
        <result column="READY_DATE_TIME" property="readyDateTime" />
        <result column="COMPLETE_DATE_TIME" property="completeDateTime" />
        <result column="COMPLETE_USER" property="completeUser" />
        <result column="CANCEL_DATE_TIME" property="cancelDateTime" />
        <result column="CANCEL_USER" property="cancelUser" />
        <result column="REMARKS" property="remarks" />
        <result column="DISPATCH_NO" property="dispatchNo" />
        <result column="ITEM_DESC" property="itemDesc" />
        <result column="RESOURCE_TYPE" property="resourceType" />
        <result column="RESRCE_DESC" property="resrceDesc" />
        <result column="OPERATION_DESC" property="operationDesc" />
        <result column="LAST_OPERATION" property="lastOperation" />
        <result column="EMPLOYEE_DESCRIPTION" property="employeeDescription" />
        <result column="LAST_OPERATION_STATUS" property="lastOperationStatus" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, TASK_NO, SFC_DISPATCH_BO, SHOP_ORDER, WORK_CENTER, SFC, OPERATION, STEP_ID, ITEM, RESRCE, RESULT, STATUS, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME, READY_USER, READY_DATE_TIME, COMPLETE_DATE_TIME, COMPLETE_USER, CANCEL_DATE_TIME, CANCEL_USER, REMARKS
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_PROD_READY_TASK
        <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_PROD_READY_TASK 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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
            <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
            <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
            <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
            <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
            <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
            <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
            <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
            <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
            <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
            <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
            <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
            <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
            <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
            <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
            <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
            <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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.common.model.ProdReadyTask">
        INSERT INTO Z_PROD_READY_TASK
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="taskNo!=null">TASK_NO,</if>
            <if test="sfcDispatchBo!=null">SFC_DISPATCH_BO,</if>
            <if test="shopOrder!=null">SHOP_ORDER,</if>
            <if test="workCenter!=null">WORK_CENTER,</if>
            <if test="sfc!=null">SFC,</if>
            <if test="operation!=null">OPERATION,</if>
            <if test="stepId!=null">STEP_ID,</if>
            <if test="item!=null">ITEM,</if>
            <if test="resrce!=null">RESRCE,</if>
            <if test="result!=null">RESULT,</if>
            <if test="status!=null">STATUS,</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="readyUser!=null">READY_USER,</if>
            <if test="readyDateTime!=null">READY_DATE_TIME,</if>
            <if test="completeDateTime!=null">COMPLETE_DATE_TIME,</if>
            <if test="completeUser!=null">COMPLETE_USER,</if>
            <if test="cancelDateTime!=null">CANCEL_DATE_TIME,</if>
            <if test="cancelUser!=null">CANCEL_USER,</if>
            <if test="remarks!=null">REMARKS,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="taskNo!=null">#{taskNo},</if>
            <if test="sfcDispatchBo!=null">#{sfcDispatchBo},</if>
            <if test="shopOrder!=null">#{shopOrder},</if>
            <if test="workCenter!=null">#{workCenter},</if>
            <if test="sfc!=null">#{sfc},</if>
            <if test="operation!=null">#{operation},</if>
            <if test="stepId!=null">#{stepId},</if>
            <if test="item!=null">#{item},</if>
            <if test="resrce!=null">#{resrce},</if>
            <if test="result!=null">#{result},</if>
            <if test="status!=null">#{status},</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="readyUser!=null">#{readyUser},</if>
            <if test="readyDateTime!=null">#{readyDateTime},</if>
            <if test="completeDateTime!=null">#{completeDateTime},</if>
            <if test="completeUser!=null">#{completeUser},</if>
            <if test="cancelDateTime!=null">#{cancelDateTime},</if>
            <if test="cancelUser!=null">#{cancelUser},</if>
            <if test="remarks!=null">#{remarks},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.common.model.ProdReadyTask">
        INSERT INTO Z_PROD_READY_TASK
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{taskNo},
            #{sfcDispatchBo},
            #{shopOrder},
            #{workCenter},
            #{sfc},
            #{operation},
            #{stepId},
            #{item},
            #{resrce},
            #{result},
            #{status},
            #{createUser},
            #{createdDateTime},
            #{modifyUser},
            #{modifiedDateTime},
            #{readyUser},
            #{readyDateTime},
            #{completeDateTime},
            #{completeUser},
            #{cancelDateTime},
            #{cancelUser},
            #{remarks},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_PROD_READY_TASK <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.taskNo!=null">TASK_NO=#{et.taskNo},</if>
        <if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
        <if test="et.shopOrder!=null">SHOP_ORDER=#{et.shopOrder},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.item!=null">ITEM=#{et.item},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.result!=null">RESULT=#{et.result},</if>
        <if test="et.status!=null">STATUS=#{et.status},</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.readyUser!=null">READY_USER=#{et.readyUser},</if>
        <if test="et.readyDateTime!=null">READY_DATE_TIME=#{et.readyDateTime},</if>
        <if test="et.completeDateTime!=null">COMPLETE_DATE_TIME=#{et.completeDateTime},</if>
        <if test="et.completeUser!=null">COMPLETE_USER=#{et.completeUser},</if>
        <if test="et.cancelDateTime!=null">CANCEL_DATE_TIME=#{et.cancelDateTime},</if>
        <if test="et.cancelUser!=null">CANCEL_USER=#{et.cancelUser},</if>
        <if test="et.remarks!=null">REMARKS=#{et.remarks},</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_PROD_READY_TASK <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        TASK_NO=#{et.taskNo},
        SFC_DISPATCH_BO=#{et.sfcDispatchBo},
        SHOP_ORDER=#{et.shopOrder},
        WORK_CENTER=#{et.workCenter},
        SFC=#{et.sfc},
        OPERATION=#{et.operation},
        STEP_ID=#{et.stepId},
        ITEM=#{et.item},
        RESRCE=#{et.resrce},
        RESULT=#{et.result},
        STATUS=#{et.status},
        CREATE_USER=#{et.createUser},
        CREATED_DATE_TIME=#{et.createdDateTime},
        MODIFY_USER=#{et.modifyUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
        READY_USER=#{et.readyUser},
        READY_DATE_TIME=#{et.readyDateTime},
        COMPLETE_DATE_TIME=#{et.completeDateTime},
        COMPLETE_USER=#{et.completeUser},
        CANCEL_DATE_TIME=#{et.cancelDateTime},
        CANCEL_USER=#{et.cancelUser},
        REMARKS=#{et.remarks},
     </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_PROD_READY_TASK <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.taskNo!=null">TASK_NO=#{et.taskNo},</if>
        <if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
        <if test="et.shopOrder!=null">SHOP_ORDER=#{et.shopOrder},</if>
        <if test="et.workCenter!=null">WORK_CENTER=#{et.workCenter},</if>
        <if test="et.sfc!=null">SFC=#{et.sfc},</if>
        <if test="et.operation!=null">OPERATION=#{et.operation},</if>
        <if test="et.stepId!=null">STEP_ID=#{et.stepId},</if>
        <if test="et.item!=null">ITEM=#{et.item},</if>
        <if test="et.resrce!=null">RESRCE=#{et.resrce},</if>
        <if test="et.result!=null">RESULT=#{et.result},</if>
        <if test="et.status!=null">STATUS=#{et.status},</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.readyUser!=null">READY_USER=#{et.readyUser},</if>
        <if test="et.readyDateTime!=null">READY_DATE_TIME=#{et.readyDateTime},</if>
        <if test="et.completeDateTime!=null">COMPLETE_DATE_TIME=#{et.completeDateTime},</if>
        <if test="et.completeUser!=null">COMPLETE_USER=#{et.completeUser},</if>
        <if test="et.cancelDateTime!=null">CANCEL_DATE_TIME=#{et.cancelDateTime},</if>
        <if test="et.cancelUser!=null">CANCEL_USER=#{et.cancelUser},</if>
        <if test="et.remarks!=null">REMARKS=#{et.remarks},</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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_PROD_READY_TASK
        <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_PROD_READY_TASK
        <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.taskNo!=null"> AND TASK_NO=#{ew.entity.taskNo}</if>
                    <if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
                    <if test="ew.entity.shopOrder!=null"> AND SHOP_ORDER=#{ew.entity.shopOrder}</if>
                    <if test="ew.entity.workCenter!=null"> AND WORK_CENTER=#{ew.entity.workCenter}</if>
                    <if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
                    <if test="ew.entity.operation!=null"> AND OPERATION=#{ew.entity.operation}</if>
                    <if test="ew.entity.stepId!=null"> AND STEP_ID=#{ew.entity.stepId}</if>
                    <if test="ew.entity.item!=null"> AND ITEM=#{ew.entity.item}</if>
                    <if test="ew.entity.resrce!=null"> AND RESRCE=#{ew.entity.resrce}</if>
                    <if test="ew.entity.result!=null"> AND RESULT=#{ew.entity.result}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</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.readyUser!=null"> AND READY_USER=#{ew.entity.readyUser}</if>
                    <if test="ew.entity.readyDateTime!=null"> AND READY_DATE_TIME=#{ew.entity.readyDateTime}</if>
                    <if test="ew.entity.completeDateTime!=null"> AND COMPLETE_DATE_TIME=#{ew.entity.completeDateTime}</if>
                    <if test="ew.entity.completeUser!=null"> AND COMPLETE_USER=#{ew.entity.completeUser}</if>
                    <if test="ew.entity.cancelDateTime!=null"> AND CANCEL_DATE_TIME=#{ew.entity.cancelDateTime}</if>
                    <if test="ew.entity.cancelUser!=null"> AND CANCEL_USER=#{ew.entity.cancelUser}</if>
                    <if test="ew.entity.remarks!=null"> AND REMARKS=#{ew.entity.remarks}</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_PROD_READY_TASK WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="getTaskList" resultMap="BaseResultMap">
        SELECT zsd.BLANKING_SIZE,PREZSD.EMPLOYEE_DESCRIPTION,CASE WHEN TO_NUMBER(zsd.DISPATCH_SEQ)=1 THEN NULL
        WHEN SS.STEP_SEQUENCE>TO_NUMBER(zsd.DISPATCH_SEQ)-1 THEN '完成'
        ELSE '未完成' END LAST_OPERATION_STATUS
        ,PREOT.DESCRIPTION LAST_OPERATION,zprt.*,zsd.DISPATCH_NO,zsd.RESOURCE_TYPE,RES.DESCRIPTION RESRCE_DESC,ITT.DESCRIPTION ITEM_DESC,OT.DESCRIPTION OPERATION_DESC
        FROM Z_PROD_READY_TASK zprt
        JOIN Z_SFC_DISPATCH zsd ON ZPRT.SFC_DISPATCH_BO=ZSD.HANDLE
        LEFT JOIN Z_SFC_DISPATCH PREZSD ON zsd.SFC=PREZSD.SFC AND PREZSD.DISPATCH_SEQ=TO_NUMBER(zsd.DISPATCH_SEQ)-1
        JOIN OPERATION OP ON OP.OPERATION = zprt.OPERATION AND OP.SITE = zprt.SITE AND OP.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE =#{locale}
        JOIN ITEM I ON zprt.ITEM = I.ITEM AND I.SITE = zprt.SITE AND I.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION PREOP ON PREOP.OPERATION = zsd.PREPOSITION_OPERATION AND OP.SITE = zprt.SITE AND OP.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION_T PREOT ON PREOT.OPERATION_BO = PREOP.HANDLE AND OT.LOCALE =#{locale}
        LEFT JOIN ITEM_T ITT ON ITT.ITEM_BO = I.HANDLE AND ITT.LOCALE =#{locale}
        JOIN RESRCE RES ON RES.RESRCE = zprt.RESRCE AND RES.SITE = zprt.SITE
        JOIN SFC S ON S.SFC=ZSD.SFC AND S.SITE=ZSD.SITE
        JOIN SFC_ROUTING SR ON SR.SFC_BO=S.HANDLE
        JOIN SFC_ROUTER SR2 ON SR.HANDLE =SR2.SFC_ROUTING_BO  AND SR2.IN_USE = 'true'
        LEFT JOIN  SFC_STEP SS ON SR2.HANDLE =SS.SFC_ROUTER_BO AND (SS.QTY_IN_QUEUE>0 or SS.QTY_IN_WORK>0)
        WHERE ZPRT.SITE=#{entity.site}
        <if test="admin == 0"> AND ZSD.EMPLOYEE LIKE '%${user}%'   </if>
        <if test="entity.workCenter!=null and entity.workCenter!='' "> AND ZPRT.WORK_CENTER=#{entity.workCenter}</if>
        <if test="entity.resrce!=null and entity.resrce!='' "> AND ZPRT.RESRCE=#{entity.resrce}</if>
        <if test="entity.dispatchNo!=null and entity.dispatchNo!='' "> AND ZSD.DISPATCH_NO=#{entity.dispatchNo}</if>
        <if test="entity.status!=null and entity.status!='' "> AND ZPRT.STATUS=#{entity.status}</if>
        <if test="entity.result!=null and entity.result!='' "> AND ZPRT.RESULT=#{entity.result}</if>
        <if test="entity.sfcStepStatus!=null and entity.sfcStepStatus!='' and entity.sfcStepStatus=='COMPLETE' "> AND ZSD.DISPATCH_STATUS=#{entity.sfcStepStatus}</if>
        <if test="entity.sfcStepStatus!=null and entity.sfcStepStatus!='' and entity.sfcStepStatus!='COMPLETE' "> AND ZSD.DISPATCH_STATUS!='COMPLETE'</if>
        <if test="entity.sfc!=null and entity.sfc!='' "> AND ZPRT.SFC=#{entity.sfc}</if>
        <if test="entity.resourceType!=null and entity.resourceType!='' "> AND ZSD.RESOURCE_TYPE=#{entity.resourceType}</if>
        <if test="entity.shopOrder!=null and entity.shopOrder!='' "> AND ZPRT.SHOP_ORDER=#{entity.shopOrder}</if>
        <if test="entity.item!=null and entity.item!='' "> AND ZPRT.ITEM=#{entity.item}</if>
        <if test="entity.blankingSize!=null and entity.blankingSize!='' "> AND zsd.BLANKING_SIZE LIKE '%${entity.blankingSize}%'</if>
        <if test="entity.planStartDate!=null and entity.planStartDate!='' "> AND TO_CHAR(ZSD.PLANNED_START_DATE,'YYYY-MM-DD')=#{entity.planStartDate}</if>
         ORDER BY zprt.CREATED_DATE_TIME DESC
    </select>

    <select id="loadProExecute" resultMap="BaseResultMap">
        SELECT zprt.*,zsd.DISPATCH_NO,zsd.RESOURCE_TYPE,RES.DESCRIPTION RESRCE_DESC,ITT.DESCRIPTION ITEM_DESC
        FROM Z_PROD_READY_TASK zprt
        JOIN Z_SFC_DISPATCH zsd ON ZPRT.SFC_DISPATCH_BO=ZSD.HANDLE
        JOIN OPERATION OP ON OP.OPERATION = zprt.OPERATION AND OP.SITE = zprt.SITE AND OP.CURRENT_REVISION = 'true'
        LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE =#{locale}
        JOIN ITEM I ON zprt.ITEM = I.ITEM AND I.SITE = zprt.SITE AND I.CURRENT_REVISION = 'true'
        LEFT JOIN ITEM_T ITT ON ITT.ITEM_BO = I.HANDLE AND ITT.LOCALE =#{locale}
        JOIN RESRCE RES ON RES.RESRCE = zprt.RESRCE AND RES.SITE = zprt.SITE
        WHERE ZPRT.SITE=#{entity.site}
        <if test="entity.workCenter!=null and entity.workCenter!='' "> AND ZPRT.WORK_CENTER=#{entity.workCenter}</if>
        <if test="entity.resrce!=null and entity.resrce!='' "> AND ZPRT.RESRCE=#{entity.resrce}</if>
    </select>

    <select id="getItemDetail" resultType="map">
        SELECT zsd.OPERATION||'/'||zsd.STEP_ID OPERATION_STEP_ID, I.ITEM,SUM(INV.QTY_ON_HAND) RECEIVE_QTY,
        ITT.DESCRIPTION ITEM_DESC,S.QTY * BC.QTY NEED_QTY
        FROM Z_SFC_DISPATCH zsd
        INNER JOIN SFC S ON S.SFC = zsd.SFC AND S.SITE = zsd.SITE
        INNER JOIN SFC_BOM SB ON SB.SFC_BO = S.HANDLE
        INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SB.BOM_BO
        INNER JOIN ITEM I ON I.HANDLE = BC.COMPONENT_GBO
        LEFT JOIN INVENTORY INV ON I.HANDLE=Inv.ITEM_BO
        LEFT JOIN CUSTOM_FIELDS CF2 ON CF2.HANDLE = I.HANDLE AND CF2."ATTRIBUTE" = 'ACCESSORY_TYPE'
        LEFT JOIN ITEM_T ITT ON ITT.ITEM_BO = I.HANDLE AND ITT.LOCALE =#{locale}
        INNER JOIN BOM_OPERATION BO ON BO.BOM_COMPONENT_BO = BC.HANDLE
        INNER JOIN OPERATION O ON o.OPERATION=zsd.OPERATION AND o.SITE=ZSD.SITE
        INNER JOIN CUSTOM_FIELDS CF ON CF.HANDLE = BC.HANDLE AND CF."ATTRIBUTE" = 'STEP_ID' AND CF.VALUE = zsd.STEP_ID
        AND BO.OPERATION_BO = 'OperationBO:'||S.SITE||','||zsd.OPERATION||',#'
        WHERE ZSD.SITE=#{site} AND ZSD.DISPATCH_NO=#{dispatchNo}
        AND (CF2.VALUE IS NULL OR cf2.VALUE='0')
        GROUP BY zsd.OPERATION,zsd.STEP_ID,I.ITEM, ITT.DESCRIPTION,S.QTY,BC.QTY
    </select>
    <select id="getToolDetail" resultType="map">
        SELECT zsd.OPERATION||'/'||zsd.STEP_ID OPERATION_STEP_ID, I.ITEM,
        ITT.DESCRIPTION ITEM_DESC
        FROM Z_SFC_DISPATCH zsd
        INNER JOIN SFC S ON S.SFC = zsd.SFC AND S.SITE = zsd.SITE
        INNER JOIN SFC_BOM SB ON SB.SFC_BO = S.HANDLE
        INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SB.BOM_BO
        INNER JOIN ITEM I ON I.HANDLE = BC.COMPONENT_GBO
        INNER JOIN CUSTOM_FIELDS CF2 ON CF2.HANDLE = I.HANDLE AND CF2."ATTRIBUTE" = 'ACCESSORY_TYPE' AND CF2.VALUE = '1'
        INNER JOIN ITEM_T ITT ON ITT.ITEM_BO = I.HANDLE AND ITT.LOCALE =#{locale}
        INNER JOIN BOM_OPERATION BO ON BO.BOM_COMPONENT_BO = BC.HANDLE
        INNER JOIN OPERATION O ON o.OPERATION=zsd.OPERATION AND o.SITE=ZSD.SITE
        INNER JOIN CUSTOM_FIELDS CF ON CF.HANDLE = BC.HANDLE AND CF."ATTRIBUTE" = 'STEP_ID' AND CF.VALUE = zsd.STEP_ID
        AND BO.OPERATION_BO = 'OperationBO:'||S.SITE||','||zsd.OPERATION||',#'
        WHERE ZSD.SITE=#{site} AND ZSD.DISPATCH_NO=#{dispatchNo}
    </select>

    <select id="getUnreadyTasks" resultMap="BaseResultMap">
        SELECT * FROM Z_PROD_READY_TASK zprt
        JOIN Z_SFC_DISPATCH ZSD ON zsd.HANDLE=ZPRT.SFC_DISPATCH_BO
        WHERE (zprt."RESULT" IS NULL OR zprt."RESULT" !='OK') AND ZPRT.SITE=#{site} AND zsd.DISPATCH_STATUS='RELEASE'
        AND  ZSD.PLANNED_START_DATE>#{startTime}  AND  ZSD.PLANNED_START_DATE &lt;= #{endTime}
    </select>
</mapper>
