<?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.xisc.pm.infra.mapper.QdToPoOrderMapper">


    <sql id = "BaseSql">
        QTPO.POM_ID,
    QTPO.PACT_NO,
    QTPO.ORDER_NO,
    QTPO.SEND_NUM,
    QTPO.ORDER_TYPE_CODE,
    QTPO.ORDER_NO_ERP,
    QTPO.ORDER_NO_CUSTOM,
    QTPO.MERG_ORDER_NO,
    QTPO.ORDER_CREATE_TIME,
    QTPO.ORDER_RECV_TIME,
    QTPO.DELIVY_DATE,
    QTPO.DELIVY_DATE_PERD,
    QTPO.DELIVY_DATE_ACCU,
    QTPO.DELIVY_DATE_USER,
    QTPO.PROD_READY_DATE,
    QTPO.URG_ORDER_FLAG,
    QTPO.DELIVY_QTY_FLAG,
    QTPO.FIN_CUST_CODE,
    QTPO.FIN_CUST_ENAME,
    QTPO.FIN_CUST_CNAME,
    QTPO.ORDER_CUST_CODE,
    QTPO.ORDER_CUST_ENAME,
    QTPO.ORDER_CUST_CNAME,
    QTPO.CONSIGN_USER_CODE,
    QTPO.CONSIGN_CUST_ENAME,
    QTPO.CONSIGN_CUST_CNAME,
    QTPO.BALANCE_USER_CODE,
    QTPO.BALANCE_USER_CNAME,
    QTPO.BALANCE_USER_ENAME,
    QTPO.PSC,
    QTPO.APN,
    QTPO.MSC,
    QTPO.SG_SIGN,
    QTPO.SG_STD,
    QTPO.SURFACE_ACCU,
    QTPO.SURFACE_ACCU_CLASS_CODE,
    QTPO.SURFACE_ACCU_CODE,
    QTPO.CUST_STD_CODE,
    QTPO.CUST_STD,
    QTPO.CUST_SG_CODE,
    QTPO.CUST_SG,
    QTPO.PROD_CODE,
    QTPO.PROD_ENAME,
    QTPO.PROD_ENAME_OTHER,
    QTPO.PROD_CNAME,
    QTPO.PROD_CNAME_OTHER,
    QTPO.CERTI_NUM,
    QTPO.METRIC_OR_ENG_FLAG,
    QTPO.CHN_OR_ENG_FLAG,
    QTPO.ORDER_THICK,
    QTPO.ORDER_ENG_THICK,
    QTPO.ORDER_WIDTH,
    QTPO.ORDER_ENG_WIDTH,
    QTPO.ORDER_LEN,
    QTPO.ORDER_ENG_LEN,
    QTPO.ORDER_MIN_LEN,
    QTPO.ORDER_MAX_LEN,
    QTPO.ORDER_ENG_MIN_LEN,
    QTPO.ORDER_ENG_MAX_LEN,
    QTPO.ORDER_WT,
    QTPO.DELIVY_WT_TOL_PLUS,
    QTPO.DELIVY_WT_TOL_MINUS,
    QTPO.ORDER_UNIT_AIM_WT,
    QTPO.ORDER_UNIT_MIN_WT,
    QTPO.ORDER_UNIT_MAX_WT,
    QTPO.ORDER_SHORT_RATE,
    QTPO.ORDER_SHORT_MAX,
    QTPO.ORDER_SHORT_MIN,
    QTPO.ORDER_UNIT_CODE,
    QTPO.ORDER_QTY,
    QTPO.ORDER_NUM,
    QTPO.DELIVY_NUM_TOL_PLUS,
    QTPO.DELIVY_NUM_TOL_MINUS,
    QTPO.WT_METHOD_CODE,
    QTPO.WT_METHOD_NAME,
    QTPO.PACK_TYPE_CODE,
    QTPO.MARK_TYPE_CODE,
    QTPO.MARK_TYPE_DESC,
    QTPO.MARK_POS_CODE,
    QTPO.MARK_POS_DESC,
    QTPO.ORDER_SPECIAL,
    QTPO.NEW_TEST_NO,
    QTPO.EXPORT_FLAG,
    QTPO.TRNP_MODE_CODE,
    QTPO.DELIVY_PLACE_CODE,
    QTPO.DELIVY_PLACE_NAME,
    QTPO.PROD_DIF,
    QTPO.PROD_CODE_HP,
    QTPO.PROD_DENSITY,
    QTPO.PROD_AUTH,
    QTPO.BETTER_SURF_WARD_CODE,
    QTPO.WT_AIM,
    QTPO.CHECK_METHOD_CODE,
    QTPO.ACCPT_MODE_CODE,
    QTPO.ACCP_AUTH_CODE,
    QTPO.ACCPT_STD,
    QTPO.CHECK_AUTH_CODE,
    QTPO.DELIVY_DATE_TRNP,
    QTPO.USER_APPO_THICK,
    QTPO.TWO_ROLL_ORDER_MARK,
    QTPO.TWO_ROLL_MARK,
    QTPO.ORDER_MODI_QMARK,
    QTPO.PROJECT_CODE,
    QTPO.PROJECT_NAME,
    QTPO.SHP_CODE,
    QTPO.WIDTH_DIV,
    QTPO.WIDTH_MIN,
    QTPO.WIDTH_MAX,
    QTPO.LEN_DIV,
    QTPO.LEN_AIM,
    QTPO.WT_THICK_ADD,
    QTPO.GAUGE_COMP,
    QTPO.USER_MANAGE_NM,
    QTPO.SHOT_FLAG,
    QTPO.SHOT_PAINT_CODE,
    QTPO.TOP_PAINT_CODE,
    QTPO.BOT_PAINT_CODE,
    QTPO.STACK_MARK,
    QTPO.STACK_MARK_SIZE,
    QTPO.TRIM_FLAG,
    QTPO.PRIVATE_ROUTE_CODE,
    QTPO.PRIVATE_ROUTE_NAME,
    QTPO.GIVE_SAMPLE_FLAG,
    QTPO.GIVE_SAMPLE_SHARP,
    QTPO.GIVE_SAMPLE_LEN,
    QTPO.SETTLE_CODE,
    QTPO.MSC_LINE_NO,
    QTPO.CERTI_STD,
    QTPO.SPECIAL_PRINT,
    QTPO.SECTION_MANAGE,
    QTPO.HULL_SECTION_NO,
    QTPO.MIN_THICK,
    QTPO.MAX_THICK,
    QTPO.NUCEAR_PART_NO,
    QTPO.DELIVERY_DATE,
    QTPO.PUR_ORDER,
    QTPO.INGOT_ROLL,
    QTPO.SCALE_THICK,
    QTPO.NEED_LECQUERING,
    QTPO.WITNESS_TYPE,
    QTPO.START_WORK_FILE_FLAG,
    QTPO.THICK_TOL_MAX,
    QTPO.THICK_TOL_MIN,
    QTPO.PRODUCT_TARG_THICK,
    QTPO.WIDTH_TOL_MAX,
    QTPO.WIDTH_TOL_MIN,
    QTPO.LEN_TOL_MAX,
    QTPO.LEN_TOL_MIN,
    QTPO.THICK_ADDV,
    QTPO.WIDTH_ADDV,
    QTPO.LEN_ADDV,
    QTPO.MAT_DESIGN_FLAG,
    QTPO.UOE_FLAG,
    QTPO.SAMPLE_LEN_HEAD,
    QTPO.SAMPLE_LEN_TAIL,
    QTPO.RAIN_DELV_FLAG,
    QTPO.ULT_DETECT_STD1,
    QTPO.ULT_DETECT_STD2,
    QTPO.ULT_DETECT_STD3,
    QTPO.ULT_DETECT_STD4,
    QTPO.ULT_DETECT_STD5,
    QTPO.BACKLOG_UT_MARK,
    QTPO.BACKLOG_N_MARK,
    QTPO.BACKLOG_Q_MARK,
    QTPO.BACKLOG_T_MARK,
    QTPO.BACKLOG_A_MARK,
    QTPO.BACKLOG_DEMAG_MARK,
    QTPO.BACKLOG_PT_MARK,
    QTPO.BACKLOG_MT_MARK,
    QTPO.BACKLOG_TMCP_MARK,
    QTPO.PROD_SR_MARK,
    QTPO.PROD_SIDE_MARK,
    QTPO.PROD_SHOT_MARK,
    QTPO.PROD_N_MARK,
    QTPO.PROD_Q_MARK,
    QTPO.PROD_T_MARK,
    QTPO.PROD_A_MARK,
    QTPO.C_DIV,
    QTPO.ALLOY_DIV,
    QTPO.SLAB_MIN_LEN_RATE,
    QTPO.SLAB_MAX_LEN_RATE,
    QTPO.SLAB_MIN_WT_RATE,
    QTPO.PICK_PATTERN_CODE,
    QTPO.SAMPLE_MODE_CODE,
    QTPO.PLATE_CROWN,
    QTPO.PLUS_FLAG,
    QTPO.DELIVERY_STATE,
    QTPO.PLANER_FLAG,
    QTPO.TENANT_ID,
    QTPO.ATTRIBUTE1,
    QTPO.ATTRIBUTE2,
    QTPO.ATTRIBUTE3,
    QTPO.ATTRIBUTE4,
    QTPO.ATTRIBUTE5,
    QTPO.STAINLESS_THK,
    QTPO.COMP_BOARD_DENSITY,
    QTPO.THK_TOL_TYPE,
    QTPO.AXIAL_ROLL_MARK,
    QTPO.SAMPLE_GEN_FLAG,
    QTPO.creation_date,    QTPO.created_by,    QTPO.last_updated_by,    QTPO.last_update_date,    QTPO.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select
        <include refid = "BaseSql"/>
        from QD_TO_PO_ORDER QTPO
        <where>
            <if test="pomId !=null">
                and QTPO.POM_ID = #{pomId,jdbcType = INTEGER}
            </if>
            <if test="pactNo !=null">
                and QTPO.PACT_NO = #{pactNo,jdbcType = VARCHAR}
            </if>
            <if test="orderNo !=null">
                and QTPO.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="sendNum !=null">
                and QTPO.SEND_NUM = #{sendNum,jdbcType = INTEGER}
            </if>
            <if test="orderTypeCode !=null">
                and QTPO.ORDER_TYPE_CODE = #{orderTypeCode,jdbcType = VARCHAR}
            </if>
            <if test="orderNoErp !=null">
                and QTPO.ORDER_NO_ERP = #{orderNoErp,jdbcType = VARCHAR}
            </if>
            <if test="orderNoCustom !=null">
                and QTPO.ORDER_NO_CUSTOM = #{orderNoCustom,jdbcType = VARCHAR}
            </if>
            <if test="mergOrderNo !=null">
                and QTPO.MERG_ORDER_NO = #{mergOrderNo,jdbcType = VARCHAR}
            </if>
            <if test="orderCreateTime !=null">
                and QTPO.ORDER_CREATE_TIME = #{orderCreateTime,jdbcType = OTHER}
            </if>
            <if test="orderRecvTime !=null">
                and QTPO.ORDER_RECV_TIME = #{orderRecvTime,jdbcType = OTHER}
            </if>
            <if test="delivyDate !=null">
                and QTPO.DELIVY_DATE = #{delivyDate,jdbcType = VARCHAR}
            </if>
            <if test="delivyDatePerd !=null">
                and QTPO.DELIVY_DATE_PERD = #{delivyDatePerd,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateAccu !=null">
                and QTPO.DELIVY_DATE_ACCU = #{delivyDateAccu,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateUser !=null">
                and QTPO.DELIVY_DATE_USER = #{delivyDateUser,jdbcType = OTHER}
            </if>
            <if test="prodReadyDate !=null">
                and QTPO.PROD_READY_DATE = #{prodReadyDate,jdbcType = OTHER}
            </if>
            <if test="urgOrderFlag !=null">
                and QTPO.URG_ORDER_FLAG = #{urgOrderFlag,jdbcType = VARCHAR}
            </if>
            <if test="delivyQtyFlag !=null">
                and QTPO.DELIVY_QTY_FLAG = #{delivyQtyFlag,jdbcType = VARCHAR}
            </if>
            <if test="finCustCode !=null">
                and QTPO.FIN_CUST_CODE = #{finCustCode,jdbcType = VARCHAR}
            </if>
            <if test="finCustEname !=null">
                and QTPO.FIN_CUST_ENAME = #{finCustEname,jdbcType = VARCHAR}
            </if>
            <if test="finCustCname !=null">
                and QTPO.FIN_CUST_CNAME = #{finCustCname,jdbcType = VARCHAR}
            </if>
            <if test="orderCustCode !=null">
                and QTPO.ORDER_CUST_CODE = #{orderCustCode,jdbcType = VARCHAR}
            </if>
            <if test="orderCustEname !=null">
                and QTPO.ORDER_CUST_ENAME = #{orderCustEname,jdbcType = VARCHAR}
            </if>
            <if test="orderCustCname !=null">
                and QTPO.ORDER_CUST_CNAME = #{orderCustCname,jdbcType = VARCHAR}
            </if>
            <if test="consignUserCode !=null">
                and QTPO.CONSIGN_USER_CODE = #{consignUserCode,jdbcType = VARCHAR}
            </if>
            <if test="consignCustEname !=null">
                and QTPO.CONSIGN_CUST_ENAME = #{consignCustEname,jdbcType = VARCHAR}
            </if>
            <if test="consignCustCname !=null">
                and QTPO.CONSIGN_CUST_CNAME = #{consignCustCname,jdbcType = VARCHAR}
            </if>
            <if test="balanceUserCode !=null">
                and QTPO.BALANCE_USER_CODE = #{balanceUserCode,jdbcType = VARCHAR}
            </if>
            <if test="balanceUserCname !=null">
                and QTPO.BALANCE_USER_CNAME = #{balanceUserCname,jdbcType = VARCHAR}
            </if>
            <if test="balanceUserEname !=null">
                and QTPO.BALANCE_USER_ENAME = #{balanceUserEname,jdbcType = VARCHAR}
            </if>
            <if test="psc !=null">
                and QTPO.PSC = #{psc,jdbcType = VARCHAR}
            </if>
            <if test="apn !=null">
                and QTPO.APN = #{apn,jdbcType = VARCHAR}
            </if>
            <if test="msc !=null">
                and QTPO.MSC = #{msc,jdbcType = VARCHAR}
            </if>
            <if test="sgSign !=null">
                and QTPO.SG_SIGN = #{sgSign,jdbcType = VARCHAR}
            </if>
            <if test="sgStd !=null">
                and QTPO.SG_STD = #{sgStd,jdbcType = VARCHAR}
            </if>
            <if test="surfaceAccu !=null">
                and QTPO.SURFACE_ACCU = #{surfaceAccu,jdbcType = VARCHAR}
            </if>
            <if test="surfaceAccuClassCode !=null">
                and QTPO.SURFACE_ACCU_CLASS_CODE = #{surfaceAccuClassCode,jdbcType = VARCHAR}
            </if>
            <if test="surfaceAccuCode !=null">
                and QTPO.SURFACE_ACCU_CODE = #{surfaceAccuCode,jdbcType = VARCHAR}
            </if>
            <if test="custStdCode !=null">
                and QTPO.CUST_STD_CODE = #{custStdCode,jdbcType = VARCHAR}
            </if>
            <if test="custStd !=null">
                and QTPO.CUST_STD = #{custStd,jdbcType = VARCHAR}
            </if>
            <if test="custSgCode !=null">
                and QTPO.CUST_SG_CODE = #{custSgCode,jdbcType = VARCHAR}
            </if>
            <if test="custSg !=null">
                and QTPO.CUST_SG = #{custSg,jdbcType = VARCHAR}
            </if>
            <if test="prodCode !=null">
                and QTPO.PROD_CODE = #{prodCode,jdbcType = VARCHAR}
            </if>
            <if test="prodEname !=null">
                and QTPO.PROD_ENAME = #{prodEname,jdbcType = VARCHAR}
            </if>
            <if test="prodEnameOther !=null">
                and QTPO.PROD_ENAME_OTHER = #{prodEnameOther,jdbcType = VARCHAR}
            </if>
            <if test="prodCname !=null">
                and QTPO.PROD_CNAME = #{prodCname,jdbcType = VARCHAR}
            </if>
            <if test="prodCnameOther !=null">
                and QTPO.PROD_CNAME_OTHER = #{prodCnameOther,jdbcType = VARCHAR}
            </if>
            <if test="certiNum !=null">
                and QTPO.CERTI_NUM = #{certiNum,jdbcType = INTEGER}
            </if>
            <if test="metricOrEngFlag !=null">
                and QTPO.METRIC_OR_ENG_FLAG = #{metricOrEngFlag,jdbcType = VARCHAR}
            </if>
            <if test="chnOrEngFlag !=null">
                and QTPO.CHN_OR_ENG_FLAG = #{chnOrEngFlag,jdbcType = VARCHAR}
            </if>
            <if test="orderThick !=null">
                and QTPO.ORDER_THICK = #{orderThick,jdbcType = INTEGER}
            </if>
            <if test="orderEngThick !=null">
                and QTPO.ORDER_ENG_THICK = #{orderEngThick,jdbcType = VARCHAR}
            </if>
            <if test="orderWidth !=null">
                and QTPO.ORDER_WIDTH = #{orderWidth,jdbcType = INTEGER}
            </if>
            <if test="orderEngWidth !=null">
                and QTPO.ORDER_ENG_WIDTH = #{orderEngWidth,jdbcType = VARCHAR}
            </if>
            <if test="orderLen !=null">
                and QTPO.ORDER_LEN = #{orderLen,jdbcType = INTEGER}
            </if>
            <if test="orderEngLen !=null">
                and QTPO.ORDER_ENG_LEN = #{orderEngLen,jdbcType = VARCHAR}
            </if>
            <if test="orderMinLen !=null">
                and QTPO.ORDER_MIN_LEN = #{orderMinLen,jdbcType = INTEGER}
            </if>
            <if test="orderMaxLen !=null">
                and QTPO.ORDER_MAX_LEN = #{orderMaxLen,jdbcType = INTEGER}
            </if>
            <if test="orderEngMinLen !=null">
                and QTPO.ORDER_ENG_MIN_LEN = #{orderEngMinLen,jdbcType = VARCHAR}
            </if>
            <if test="orderEngMaxLen !=null">
                and QTPO.ORDER_ENG_MAX_LEN = #{orderEngMaxLen,jdbcType = VARCHAR}
            </if>
            <if test="orderWt !=null">
                and QTPO.ORDER_WT = #{orderWt,jdbcType = INTEGER}
            </if>
            <if test="delivyWtTolPlus !=null">
                and QTPO.DELIVY_WT_TOL_PLUS = #{delivyWtTolPlus,jdbcType = INTEGER}
            </if>
            <if test="delivyWtTolMinus !=null">
                and QTPO.DELIVY_WT_TOL_MINUS = #{delivyWtTolMinus,jdbcType = INTEGER}
            </if>
            <if test="orderUnitAimWt !=null">
                and QTPO.ORDER_UNIT_AIM_WT = #{orderUnitAimWt,jdbcType = INTEGER}
            </if>
            <if test="orderUnitMinWt !=null">
                and QTPO.ORDER_UNIT_MIN_WT = #{orderUnitMinWt,jdbcType = INTEGER}
            </if>
            <if test="orderUnitMaxWt !=null">
                and QTPO.ORDER_UNIT_MAX_WT = #{orderUnitMaxWt,jdbcType = INTEGER}
            </if>
            <if test="orderShortRate !=null">
                and QTPO.ORDER_SHORT_RATE = #{orderShortRate,jdbcType = INTEGER}
            </if>
            <if test="orderShortMax !=null">
                and QTPO.ORDER_SHORT_MAX = #{orderShortMax,jdbcType = INTEGER}
            </if>
            <if test="orderShortMin !=null">
                and QTPO.ORDER_SHORT_MIN = #{orderShortMin,jdbcType = INTEGER}
            </if>
            <if test="orderUnitCode !=null">
                and QTPO.ORDER_UNIT_CODE = #{orderUnitCode,jdbcType = VARCHAR}
            </if>
            <if test="orderQty !=null">
                and QTPO.ORDER_QTY = #{orderQty,jdbcType = INTEGER}
            </if>
            <if test="orderNum !=null">
                and QTPO.ORDER_NUM = #{orderNum,jdbcType = INTEGER}
            </if>
            <if test="delivyNumTolPlus !=null">
                and QTPO.DELIVY_NUM_TOL_PLUS = #{delivyNumTolPlus,jdbcType = INTEGER}
            </if>
            <if test="delivyNumTolMinus !=null">
                and QTPO.DELIVY_NUM_TOL_MINUS = #{delivyNumTolMinus,jdbcType = INTEGER}
            </if>
            <if test="wtMethodCode !=null">
                and QTPO.WT_METHOD_CODE = #{wtMethodCode,jdbcType = VARCHAR}
            </if>
            <if test="wtMethodName !=null">
                and QTPO.WT_METHOD_NAME = #{wtMethodName,jdbcType = VARCHAR}
            </if>
            <if test="packTypeCode !=null">
                and QTPO.PACK_TYPE_CODE = #{packTypeCode,jdbcType = VARCHAR}
            </if>
            <if test="markTypeCode !=null">
                and QTPO.MARK_TYPE_CODE = #{markTypeCode,jdbcType = VARCHAR}
            </if>
            <if test="markTypeDesc !=null">
                and QTPO.MARK_TYPE_DESC = #{markTypeDesc,jdbcType = VARCHAR}
            </if>
            <if test="markPosCode !=null">
                and QTPO.MARK_POS_CODE = #{markPosCode,jdbcType = VARCHAR}
            </if>
            <if test="markPosDesc !=null">
                and QTPO.MARK_POS_DESC = #{markPosDesc,jdbcType = VARCHAR}
            </if>
            <if test="orderSpecial !=null">
                and QTPO.ORDER_SPECIAL = #{orderSpecial,jdbcType = VARCHAR}
            </if>
            <if test="newTestNo !=null">
                and QTPO.NEW_TEST_NO = #{newTestNo,jdbcType = VARCHAR}
            </if>
            <if test="exportFlag !=null">
                and QTPO.EXPORT_FLAG = #{exportFlag,jdbcType = VARCHAR}
            </if>
            <if test="trnpModeCode !=null">
                and QTPO.TRNP_MODE_CODE = #{trnpModeCode,jdbcType = VARCHAR}
            </if>
            <if test="delivyPlaceCode !=null">
                and QTPO.DELIVY_PLACE_CODE = #{delivyPlaceCode,jdbcType = VARCHAR}
            </if>
            <if test="delivyPlaceName !=null">
                and QTPO.DELIVY_PLACE_NAME = #{delivyPlaceName,jdbcType = VARCHAR}
            </if>
            <if test="prodDif !=null">
                and QTPO.PROD_DIF = #{prodDif,jdbcType = VARCHAR}
            </if>
            <if test="prodCodeHp !=null">
                and QTPO.PROD_CODE_HP = #{prodCodeHp,jdbcType = VARCHAR}
            </if>
            <if test="prodDensity !=null">
                and QTPO.PROD_DENSITY = #{prodDensity,jdbcType = INTEGER}
            </if>
            <if test="prodAuth !=null">
                and QTPO.PROD_AUTH = #{prodAuth,jdbcType = VARCHAR}
            </if>
            <if test="betterSurfWardCode !=null">
                and QTPO.BETTER_SURF_WARD_CODE = #{betterSurfWardCode,jdbcType = VARCHAR}
            </if>
            <if test="wtAim !=null">
                and QTPO.WT_AIM = #{wtAim,jdbcType = INTEGER}
            </if>
            <if test="checkMethodCode !=null">
                and QTPO.CHECK_METHOD_CODE = #{checkMethodCode,jdbcType = VARCHAR}
            </if>
            <if test="accptModeCode !=null">
                and QTPO.ACCPT_MODE_CODE = #{accptModeCode,jdbcType = VARCHAR}
            </if>
            <if test="accpAuthCode !=null">
                and QTPO.ACCP_AUTH_CODE = #{accpAuthCode,jdbcType = VARCHAR}
            </if>
            <if test="accptStd !=null">
                and QTPO.ACCPT_STD = #{accptStd,jdbcType = VARCHAR}
            </if>
            <if test="checkAuthCode !=null">
                and QTPO.CHECK_AUTH_CODE = #{checkAuthCode,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateTrnp !=null">
                and QTPO.DELIVY_DATE_TRNP = #{delivyDateTrnp,jdbcType = VARCHAR}
            </if>
            <if test="userAppoThick !=null">
                and QTPO.USER_APPO_THICK = #{userAppoThick,jdbcType = INTEGER}
            </if>
            <if test="twoRollOrderMark !=null">
                and QTPO.TWO_ROLL_ORDER_MARK = #{twoRollOrderMark,jdbcType = VARCHAR}
            </if>
            <if test="twoRollMark !=null">
                and QTPO.TWO_ROLL_MARK = #{twoRollMark,jdbcType = VARCHAR}
            </if>
            <if test="orderModiQmark !=null">
                and QTPO.ORDER_MODI_QMARK = #{orderModiQmark,jdbcType = VARCHAR}
            </if>
            <if test="projectCode !=null">
                and QTPO.PROJECT_CODE = #{projectCode,jdbcType = VARCHAR}
            </if>
            <if test="projectName !=null">
                and QTPO.PROJECT_NAME = #{projectName,jdbcType = VARCHAR}
            </if>
            <if test="shpCode !=null">
                and QTPO.SHP_CODE = #{shpCode,jdbcType = VARCHAR}
            </if>
            <if test="widthDiv !=null">
                and QTPO.WIDTH_DIV = #{widthDiv,jdbcType = VARCHAR}
            </if>
            <if test="widthMin !=null">
                and QTPO.WIDTH_MIN = #{widthMin,jdbcType = INTEGER}
            </if>
            <if test="widthMax !=null">
                and QTPO.WIDTH_MAX = #{widthMax,jdbcType = INTEGER}
            </if>
            <if test="lenDiv !=null">
                and QTPO.LEN_DIV = #{lenDiv,jdbcType = VARCHAR}
            </if>
            <if test="lenAim !=null">
                and QTPO.LEN_AIM = #{lenAim,jdbcType = INTEGER}
            </if>
            <if test="wtThickAdd !=null">
                and QTPO.WT_THICK_ADD = #{wtThickAdd,jdbcType = INTEGER}
            </if>
            <if test="gaugeComp !=null">
                and QTPO.GAUGE_COMP = #{gaugeComp,jdbcType = INTEGER}
            </if>
            <if test="userManageNm !=null">
                and QTPO.USER_MANAGE_NM = #{userManageNm,jdbcType = VARCHAR}
            </if>
            <if test="shotFlag !=null">
                and QTPO.SHOT_FLAG = #{shotFlag,jdbcType = VARCHAR}
            </if>
            <if test="shotPaintCode !=null">
                and QTPO.SHOT_PAINT_CODE = #{shotPaintCode,jdbcType = VARCHAR}
            </if>
            <if test="topPaintCode !=null">
                and QTPO.TOP_PAINT_CODE = #{topPaintCode,jdbcType = VARCHAR}
            </if>
            <if test="botPaintCode !=null">
                and QTPO.BOT_PAINT_CODE = #{botPaintCode,jdbcType = VARCHAR}
            </if>
            <if test="stackMark !=null">
                and QTPO.STACK_MARK = #{stackMark,jdbcType = VARCHAR}
            </if>
            <if test="stackMarkSize !=null">
                and QTPO.STACK_MARK_SIZE = #{stackMarkSize,jdbcType = VARCHAR}
            </if>
            <if test="trimFlag !=null">
                and QTPO.TRIM_FLAG = #{trimFlag,jdbcType = VARCHAR}
            </if>
            <if test="privateRouteCode !=null">
                and QTPO.PRIVATE_ROUTE_CODE = #{privateRouteCode,jdbcType = VARCHAR}
            </if>
            <if test="privateRouteName !=null">
                and QTPO.PRIVATE_ROUTE_NAME = #{privateRouteName,jdbcType = VARCHAR}
            </if>
            <if test="giveSampleFlag !=null">
                and QTPO.GIVE_SAMPLE_FLAG = #{giveSampleFlag,jdbcType = VARCHAR}
            </if>
            <if test="giveSampleSharp !=null">
                and QTPO.GIVE_SAMPLE_SHARP = #{giveSampleSharp,jdbcType = VARCHAR}
            </if>
            <if test="giveSampleLen !=null">
                and QTPO.GIVE_SAMPLE_LEN = #{giveSampleLen,jdbcType = INTEGER}
            </if>
            <if test="settleCode !=null">
                and QTPO.SETTLE_CODE = #{settleCode,jdbcType = VARCHAR}
            </if>
            <if test="mscLineNo !=null">
                and QTPO.MSC_LINE_NO = #{mscLineNo,jdbcType = VARCHAR}
            </if>
            <if test="certiStd !=null">
                and QTPO.CERTI_STD = #{certiStd,jdbcType = VARCHAR}
            </if>
            <if test="specialPrint !=null">
                and QTPO.SPECIAL_PRINT = #{specialPrint,jdbcType = VARCHAR}
            </if>
            <if test="sectionManage !=null">
                and QTPO.SECTION_MANAGE = #{sectionManage,jdbcType = VARCHAR}
            </if>
            <if test="hullSectionNo !=null">
                and QTPO.HULL_SECTION_NO = #{hullSectionNo,jdbcType = VARCHAR}
            </if>
            <if test="minThick !=null">
                and QTPO.MIN_THICK = #{minThick,jdbcType = INTEGER}
            </if>
            <if test="maxThick !=null">
                and QTPO.MAX_THICK = #{maxThick,jdbcType = INTEGER}
            </if>
            <if test="nucearPartNo !=null">
                and QTPO.NUCEAR_PART_NO = #{nucearPartNo,jdbcType = VARCHAR}
            </if>
            <if test="deliveryDate !=null">
                and QTPO.DELIVERY_DATE = #{deliveryDate,jdbcType = VARCHAR}
            </if>
            <if test="purOrder !=null">
                and QTPO.PUR_ORDER = #{purOrder,jdbcType = VARCHAR}
            </if>
            <if test="ingotRoll !=null">
                and QTPO.INGOT_ROLL = #{ingotRoll,jdbcType = VARCHAR}
            </if>
            <if test="scaleThick !=null">
                and QTPO.SCALE_THICK = #{scaleThick,jdbcType = VARCHAR}
            </if>
            <if test="needLecquering !=null">
                and QTPO.NEED_LECQUERING = #{needLecquering,jdbcType = VARCHAR}
            </if>
            <if test="witnessType !=null">
                and QTPO.WITNESS_TYPE = #{witnessType,jdbcType = VARCHAR}
            </if>
            <if test="startWorkFileFlag !=null">
                and QTPO.START_WORK_FILE_FLAG = #{startWorkFileFlag,jdbcType = VARCHAR}
            </if>
            <if test="thickTolMax !=null">
                and QTPO.THICK_TOL_MAX = #{thickTolMax,jdbcType = INTEGER}
            </if>
            <if test="thickTolMin !=null">
                and QTPO.THICK_TOL_MIN = #{thickTolMin,jdbcType = INTEGER}
            </if>
            <if test="productTargThick !=null">
                and QTPO.PRODUCT_TARG_THICK = #{productTargThick,jdbcType = INTEGER}
            </if>
            <if test="widthTolMax !=null">
                and QTPO.WIDTH_TOL_MAX = #{widthTolMax,jdbcType = INTEGER}
            </if>
            <if test="widthTolMin !=null">
                and QTPO.WIDTH_TOL_MIN = #{widthTolMin,jdbcType = INTEGER}
            </if>
            <if test="lenTolMax !=null">
                and QTPO.LEN_TOL_MAX = #{lenTolMax,jdbcType = INTEGER}
            </if>
            <if test="lenTolMin !=null">
                and QTPO.LEN_TOL_MIN = #{lenTolMin,jdbcType = INTEGER}
            </if>
            <if test="thickAddv !=null">
                and QTPO.THICK_ADDV = #{thickAddv,jdbcType = INTEGER}
            </if>
            <if test="widthAddv !=null">
                and QTPO.WIDTH_ADDV = #{widthAddv,jdbcType = INTEGER}
            </if>
            <if test="lenAddv !=null">
                and QTPO.LEN_ADDV = #{lenAddv,jdbcType = INTEGER}
            </if>
            <if test="matDesignFlag !=null">
                and QTPO.MAT_DESIGN_FLAG = #{matDesignFlag,jdbcType = VARCHAR}
            </if>
            <if test="uoeFlag !=null">
                and QTPO.UOE_FLAG = #{uoeFlag,jdbcType = VARCHAR}
            </if>
            <if test="sampleLenHead !=null">
                and QTPO.SAMPLE_LEN_HEAD = #{sampleLenHead,jdbcType = INTEGER}
            </if>
            <if test="sampleLenTail !=null">
                and QTPO.SAMPLE_LEN_TAIL = #{sampleLenTail,jdbcType = INTEGER}
            </if>
            <if test="rainDelvFlag !=null">
                and QTPO.RAIN_DELV_FLAG = #{rainDelvFlag,jdbcType = VARCHAR}
            </if>
            <if test="ultDetectStd1 !=null">
                and QTPO.ULT_DETECT_STD1 = #{ultDetectStd1,jdbcType = VARCHAR}
            </if>
            <if test="ultDetectStd2 !=null">
                and QTPO.ULT_DETECT_STD2 = #{ultDetectStd2,jdbcType = VARCHAR}
            </if>
            <if test="ultDetectStd3 !=null">
                and QTPO.ULT_DETECT_STD3 = #{ultDetectStd3,jdbcType = VARCHAR}
            </if>
            <if test="ultDetectStd4 !=null">
                and QTPO.ULT_DETECT_STD4 = #{ultDetectStd4,jdbcType = VARCHAR}
            </if>
            <if test="ultDetectStd5 !=null">
                and QTPO.ULT_DETECT_STD5 = #{ultDetectStd5,jdbcType = VARCHAR}
            </if>
            <if test="backlogUtMark !=null">
                and QTPO.BACKLOG_UT_MARK = #{backlogUtMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogNMark !=null">
                and QTPO.BACKLOG_N_MARK = #{backlogNMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogQMark !=null">
                and QTPO.BACKLOG_Q_MARK = #{backlogQMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogTMark !=null">
                and QTPO.BACKLOG_T_MARK = #{backlogTMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogAMark !=null">
                and QTPO.BACKLOG_A_MARK = #{backlogAMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogDemagMark !=null">
                and QTPO.BACKLOG_DEMAG_MARK = #{backlogDemagMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogPtMark !=null">
                and QTPO.BACKLOG_PT_MARK = #{backlogPtMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogMtMark !=null">
                and QTPO.BACKLOG_MT_MARK = #{backlogMtMark,jdbcType = VARCHAR}
            </if>
            <if test="backlogTmcpMark !=null">
                and QTPO.BACKLOG_TMCP_MARK = #{backlogTmcpMark,jdbcType = VARCHAR}
            </if>
            <if test="prodSrMark !=null">
                and QTPO.PROD_SR_MARK = #{prodSrMark,jdbcType = VARCHAR}
            </if>
            <if test="prodSideMark !=null">
                and QTPO.PROD_SIDE_MARK = #{prodSideMark,jdbcType = VARCHAR}
            </if>
            <if test="prodShotMark !=null">
                and QTPO.PROD_SHOT_MARK = #{prodShotMark,jdbcType = VARCHAR}
            </if>
            <if test="prodNMark !=null">
                and QTPO.PROD_N_MARK = #{prodNMark,jdbcType = VARCHAR}
            </if>
            <if test="prodQMark !=null">
                and QTPO.PROD_Q_MARK = #{prodQMark,jdbcType = VARCHAR}
            </if>
            <if test="prodTMark !=null">
                and QTPO.PROD_T_MARK = #{prodTMark,jdbcType = VARCHAR}
            </if>
            <if test="prodAMark !=null">
                and QTPO.PROD_A_MARK = #{prodAMark,jdbcType = VARCHAR}
            </if>
            <if test="cDiv !=null">
                and QTPO.C_DIV = #{cDiv,jdbcType = VARCHAR}
            </if>
            <if test="alloyDiv !=null">
                and QTPO.ALLOY_DIV = #{alloyDiv,jdbcType = VARCHAR}
            </if>
            <if test="slabMinLenRate !=null">
                and QTPO.SLAB_MIN_LEN_RATE = #{slabMinLenRate,jdbcType = INTEGER}
            </if>
            <if test="slabMaxLenRate !=null">
                and QTPO.SLAB_MAX_LEN_RATE = #{slabMaxLenRate,jdbcType = INTEGER}
            </if>
            <if test="slabMinWtRate !=null">
                and QTPO.SLAB_MIN_WT_RATE = #{slabMinWtRate,jdbcType = INTEGER}
            </if>
            <if test="pickPatternCode !=null">
                and QTPO.PICK_PATTERN_CODE = #{pickPatternCode,jdbcType = VARCHAR}
            </if>
            <if test="sampleModeCode !=null">
                and QTPO.SAMPLE_MODE_CODE = #{sampleModeCode,jdbcType = VARCHAR}
            </if>
            <if test="plateCrown !=null">
                and QTPO.PLATE_CROWN = #{plateCrown,jdbcType = INTEGER}
            </if>
            <if test="plusFlag !=null">
                and QTPO.PLUS_FLAG = #{plusFlag,jdbcType = VARCHAR}
            </if>
            <if test="deliveryState !=null">
                and QTPO.DELIVERY_STATE = #{deliveryState,jdbcType = VARCHAR}
            </if>
            <if test="planerFlag !=null">
                and QTPO.PLANER_FLAG = #{planerFlag,jdbcType = VARCHAR}
            </if>
            <if test="tenantId !=null">
                and QTPO.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and QTPO.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and QTPO.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and QTPO.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and QTPO.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and QTPO.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
            <if test="stainlessThk !=null">
                and QTPO.STAINLESS_THK = #{stainlessThk,jdbcType = INTEGER}
            </if>
            <if test="compBoardDensity !=null">
                and QTPO.COMP_BOARD_DENSITY = #{compBoardDensity,jdbcType = INTEGER}
            </if>
            <if test="orderNoList != null and orderNoList.size() > 0">
                and  (QTPO.ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator="," index="index">
                    <if test="(index % 999) == 998"> NULL ) OR QTPO.ORDER_NO in (</if> #{orderNo}
                </foreach>)
            </if>
        </where>
    </select>

    <select id="orderList" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select
        distinct
        QTPO.POM_ID,
        QTPO.ORDER_NO,
        QTPO.CONSIGN_CUST_CNAME,
        CM.ORDER_STATUS,
        QTPO.PSC,
        QTPO.MSC,
        QTPO.APN,
        QTPO.SG_SIGN,
        QTPO.ORDER_THICK,
        QTPO.THICK_TOL_MIN,
        QTPO.THICK_TOL_MAX,
        QTPO.ORDER_WIDTH,
        QTPO.WIDTH_MIN,
        QTPO.WIDTH_MAX,
        QTPO.WIDTH_TOL_MIN,
        QTPO.WIDTH_TOL_MAX,
        QTPO.ORDER_MIN_LEN,
        QTPO.ORDER_MAX_LEN,
        QTPO.LEN_TOL_MIN,
        QTPO.LEN_TOL_MAX,
        QTPO.ORDER_WT,
        QTPO.ORDER_NUM,
        CM.ORD_REM_WGT AS LACK_WGT,
        CM.ORD_REM_NUM AS LACK_NUM,
        <!--  QTPLC.WHOLE_BACKLOG, -->
        QTPO.WIDTH_MAX,
        QTPO.WIDTH_MIN,
        QTPO.DELIVY_DATE,
        <!-- CD.LACK_NUM,
         QTPLC.MSC_LINE_NO, -->
        QTPO.TRIM_FLAG,
        <!-- QTLRU.UT_GRADE AS RSLT_LEVEL,
         QTLRU.UT_STDNAME AS UST_STAND, -->
        QTPO.DELIVERY_STATE,
        QTPO.SG_STD,
        QTPO.HULL_SECTION_NO,
        QTPO.SECTION_MANAGE
        from QD_TO_PO_ORDER QTPO
        left join CT_MAIN CM on (QTPO.ORDER_NO = CM.ORDER_NO and QTPO.TENANT_ID = CM.TENANT_ID)
        <!-- left join CT_DET CD on QTPO.ORDER_NO = CD.ORDER_NO
          left join QD_TO_PO_LINE_COMB QTPLC on QTPO.ORDER_NO = QTPLC.ORDER_NO
         left join QD_TO_LINEUP_RESULT_UT QTLRU on QTPO.ORDER_NO = QTLRU.ORDER_NO -->
        <where>
            CM.ORDER_STATUS >= '40' and ORDER_STATUS &lt; '57'
            <if test="tenantId !=null">
                and QTPO.TENANT_ID = #{tenantId}
            </if>
            <!--and CM.ORD_REM_NUM > 0 -->
            <if test="actThk !=null">
                and (COALESCE(QTPO.ORDER_THICK, 0) + COALESCE(QTPO.THICK_TOL_MIN, 0)) <![CDATA[ <= ]]> #{actThk}
                and (COALESCE(QTPO.ORDER_THICK, 0) + COALESCE(QTPO.THICK_TOL_MAX, 0)) <![CDATA[ >= ]]>  #{actThk}
            </if>
            <if test="actWid !=null">
                and (COALESCE(QTPO.WIDTH_MIN, 0) + COALESCE(QTPO.WIDTH_TOL_MIN, 0)) <![CDATA[ <= ]]> #{actWid}
                and (COALESCE(QTPO.WIDTH_MAX, 0) + COALESCE(QTPO.WIDTH_TOL_MAX, 0)) <![CDATA[ >= ]]>  #{actWid}
            </if>
            <if test="actLen !=null">
                and (COALESCE(QTPO.ORDER_MIN_LEN, 0) + COALESCE(QTPO.LEN_TOL_MIN, 0)) <![CDATA[ <= ]]> #{actLen}
                and (COALESCE(QTPO.ORDER_MAX_LEN,0) + COALESCE(QTPO.LEN_TOL_MAX, 0)) <![CDATA[ >= ]]>  #{actLen}
            </if>
            <if test="orderNo !=null">
                <bind name="orderNo" value="orderNo + '%'"/>
                and QTPO.ORDER_NO LIKE #{orderNo,jdbcType=VARCHAR}
            </if>
            <if test="orderNoFirst !=null">
                and SUBSTRING(QTPO.ORDER_NO, 1, 1) = #{orderNoFirst,jdbcType = VARCHAR}
            </if>
            <if test="sgSign !=null">
                <bind name="sgSign" value="sgSign + '%'"/>
                and QTPO.SG_SIGN LIKE #{sgSign,jdbcType=VARCHAR}
            </if>
            <if test="psc !=null">
                <bind name="psc" value="psc + '%'"/>
                and QTPO.PSC LIKE #{psc,jdbcType=VARCHAR}
            </if>
            <!--  <if test="mscLineNo !=null">
                  and QTPLC.MSC_LINE_NO = #{mscLineNo,jdbcType = VARCHAR}
              </if> -->
            <if test="orderTypeCode !=null">
                and QTPO.ORDER_TYPE_CODE = #{orderTypeCode,jdbcType = VARCHAR}
            </if>
            <if test="orderThick !=null">
                and QTPO.ORDER_THICK = #{orderThick,jdbcType = INTEGER}
            </if>
            <if test="orderThickFrom !=null">
                and QTPO.ORDER_THICK >= #{orderThickFrom,jdbcType = INTEGER}
            </if>
            <if test="orderThickTo !=null">
                and QTPO.ORDER_THICK &lt;= #{orderThickTo,jdbcType = INTEGER}
            </if>
            <if test="orderWidthFrom !=null">
                and QTPO.ORDER_WIDTH >= #{orderWidthFrom,jdbcType = INTEGER}
            </if>
            <if test="orderWidthTo !=null">
                and QTPO.ORDER_WIDTH &lt;= #{orderWidthTo,jdbcType = INTEGER}
            </if>
            <if test="orderMinLen !=null">
                and QTPO.ORDER_MIN_LEN >= #{orderMinLen,jdbcType = INTEGER}
            </if>
            <if test="orderMaxLen !=null">
                and QTPO.ORDER_MAX_LEN &lt;= #{orderMaxLen,jdbcType = INTEGER}
            </if>
            <if test="orderStatusFrom !=null">
                and CM.ORDER_STATUS >= #{orderStatusFrom,jdbcType = INTEGER}
            </if>
            <if test="orderStatusTo !=null">
                and CM.ORDER_STATUS &lt;= #{orderStatusTo,jdbcType = INTEGER}
            </if>
            <if test="specialPrint !=null">
                and QTPO.SPECIAL_PRINT = #{specialPrint,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateFrom !=null">
                and QTPO.DELIVY_DATE >= #{delivyDateFrom,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateTo !=null">
                and QTPO.DELIVY_DATE &lt;= #{delivyDateTo,jdbcType = VARCHAR}
            </if>
        </where>
    </select>

    <select id="surplusSlabOrderList" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select
        distinct
        QTPO.POM_ID,
        QTPO.ORDER_NO,
        QTPO.CONSIGN_CUST_CNAME,
        CM.ORDER_STATUS,
        QTPO.PSC,
        QTPO.MSC,
        QTPO.APN,
        QTPO.SG_SIGN,
        QTPO.ORDER_THICK,
        QTPO.THICK_TOL_MIN,
        QTPO.THICK_TOL_MAX,
        QTPO.WIDTH_TOL_MIN,
        QTPO.WIDTH_TOL_MAX,
        QTPO.ORDER_WIDTH,
        QTPO.WIDTH_MIN,
        QTPO.WIDTH_MAX,
        QTPO.ORDER_MIN_LEN,
        QTPO.ORDER_MAX_LEN,
        QTPO.LEN_TOL_MIN,
        QTPO.LEN_TOL_MAX,
        QTPO.ORDER_WT,
        QTPO.ORDER_NUM,
        CM.ORD_REM_WGT AS LACK_WGT,
        CM.ORD_REM_NUM AS LACK_NUM,
        <!--  QTPLC.WHOLE_BACKLOG, -->
        QTPO.WIDTH_MAX,
        QTPO.WIDTH_MIN,
        QTPO.DELIVY_DATE,
        <!-- CD.LACK_NUM,
         QTPLC.MSC_LINE_NO,
         MP.FINAL_CUT_SURFACE_CODE, -->
        QTPO.TRIM_FLAG,
        <!--  QTLRU.UT_GRADE AS RSLT_LEVEL,
          QTLRU.UT_STDNAME AS UST_STAND, -->
        QTPO.DELIVERY_STATE,
        QTPO.SG_STD,
        QTPO.HULL_SECTION_NO,
        QTPO.SECTION_MANAGE
        from QD_TO_PO_ORDER QTPO
        left join CT_MAIN CM on QTPO.ORDER_NO = CM.ORDER_NO
        <!--  left join CT_DET CD on QTPO.ORDER_NO = CD.ORDER_NO
          left join QD_TO_PO_LINE_COMB QTPLC on QTPO.ORDER_NO = QTPLC.ORDER_NO
          left join MM_PLATE MP on QTPO.ORDER_NO = MP.ORDER_NO
          left join MM_SLAB MS on QTPO.ORDER_NO = MS.ORDER_NO
          left join QD_TO_LINEUP_RESULT_UT QTLRU on QTPO.ORDER_NO = QTLRU.ORDER_NO -->
        <where>
            CM.ORDER_STATUS >= '40' and ORDER_STATUS &lt; '57'
            <!-- and CM.ORD_REM_NUM > 0 -->
            <if test="actThk !=null">
                and (COALESCE(QTPO.ORDER_THICK, 0) + COALESCE(QTPO.THICK_TOL_MIN, 0)) <![CDATA[ <= ]]> #{actThk}
                and (COALESCE(QTPO.ORDER_THICK, 0) + COALESCE(QTPO.THICK_TOL_MAX, 0)) <![CDATA[ >= ]]>  #{actThk}
            </if>
            <if test="actWid !=null">
                and (COALESCE(QTPO.WIDTH_MIN, 0) + COALESCE(QTPO.WIDTH_TOL_MIN, 0)) <![CDATA[ <= ]]> #{actWid}
                and (COALESCE(QTPO.WIDTH_MAX, 0) + COALESCE(QTPO.WIDTH_TOL_MAX, 0)) <![CDATA[ >= ]]>  #{actWid}
            </if>
            <if test="actLen !=null">
                and (COALESCE(QTPO.ORDER_MIN_LEN, 0) + COALESCE(QTPO.LEN_TOL_MIN, 0)) <![CDATA[ <= ]]> #{actLen}
                and (COALESCE(QTPO.ORDER_MAX_LEN,0) + COALESCE(QTPO.LEN_TOL_MAX, 0)) <![CDATA[ >= ]]>  #{actLen}
            </if>
            <if test="psc !=null">
                and QTPO.PSC = #{psc}
            </if>
            <if test="apn !=null">
                and QTPO.APN = #{apn}
            </if>
            <if test="msc !=null">
                and QTPO.MSC = #{msc}
            </if>
            <if test="orderNo !=null">
                <bind name="orderNo" value="orderNo + '%'"/>
                and QTPO.ORDER_NO LIKE #{orderNo,jdbcType=VARCHAR}
            </if>
            <if test="orderNoFirst !=null">
                and SUBSTR(QTPO.ORDER_NO, 1, 1) = #{orderNoFirst,jdbcType = VARCHAR}
            </if>
            <!--   <if test="sgSign !=null">
                   and QTPO.SG_SIGN LIKE CONCAT(#{sgSign,jdbcType=VARCHAR}, '%')
               </if> -->
            <if test="sgSign !=null">
                and QTPO.SG_SIGN = #{sgSign,jdbcType=VARCHAR}
            </if>
            <!--  <if test="holdCauseCode !=null">
                  and MS.HOLD_CAUSE_CODE = #{holdCauseCode,jdbcType=VARCHAR}
              </if> -->
            <if test="psc !=null">
                and QTPO.PSC LIKE CONCAT(#{psc,jdbcType=VARCHAR}, '%')
            </if>
            <if test="mscLineNo !=null">
                and QTPLC.MSC_LINE_NO = #{mscLineNo,jdbcType = VARCHAR}
            </if>
            <if test="orderTypeCode !=null">
                and QTPO.ORDER_TYPE_CODE = #{orderTypeCode,jdbcType = VARCHAR}
            </if>
            <if test="orderThick !=null">
                and QTPO.ORDER_THICK = #{orderThick,jdbcType = INTEGER}
            </if>
            <if test="orderThickFrom !=null">
                and QTPO.ORDER_THICK >= #{orderThickFrom,jdbcType = INTEGER}
            </if>
            <if test="orderThickTo !=null">
                and QTPO.ORDER_THICK &lt; #{orderThickTo,jdbcType = INTEGER}
            </if>
            <if test="orderWidthFrom !=null">
                and QTPO.ORDER_WIDTH >= #{orderWidthFrom,jdbcType = INTEGER}
            </if>
            <if test="orderWidthTo !=null">
                and QTPO.ORDER_WIDTH &lt; #{orderWidthFrom,jdbcType = INTEGER}
            </if>
            <if test="orderMinLen !=null">
                and QTPO.ORDER_MIN_LEN >= #{orderMinLen,jdbcType = INTEGER}
            </if>
            <if test="orderMaxLen !=null">
                and QTPO.ORDER_MAX_LEN &lt; #{orderMaxLen,jdbcType = INTEGER}
            </if>
            <if test="orderStatusFrom !=null">
                and CM.ORDER_STATUS >= #{orderStatusFrom,jdbcType = INTEGER}
            </if>
            <if test="orderStatusTo !=null">
                and CM.ORDER_STATUS <![CDATA[ <= ]]> #{orderStatusTo,jdbcType = INTEGER}
            </if>
            <if test="specialPrint !=null">
                and QTPO.SPECIAL_PRINT = #{specialPrint,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateFrom !=null">
                and QTPO.DELIVY_DATE >= #{delivyDateFrom,jdbcType = VARCHAR}
            </if>
            <if test="delivyDateTo !=null">
                and QTPO.DELIVY_DATE &lt; #{delivyDateTo,jdbcType = VARCHAR}
            </if>
        </where>
    </select>

    <select id="selectQdToPoOrder" resultType="com.xisc.pm.api.dto.PmProContPoolResposeDTO">
        SELECT
        <if test="pageFlag != null and pageFlag == 1">
            DISTINCT qtpo.ORDER_NO
        </if>
        <if test="pageFlag != null and pageFlag == 0">
            qtpo.ORDER_NO,
            '38' ORDER_STATUS,
            qtplc.MSC_LINE_NO,
            qtpo.ORDER_TYPE_CODE,
            qtpo.DELIVY_DATE,
            qtlrs.ST_NO,
            qtpo.SG_SIGN,
            qtpo.NEED_LECQUERING,
            qtpo.ORDER_THICK,
            qtpo.ORDER_WIDTH,
            qtpo.ORDER_MIN_LEN,
            qtpo.ORDER_MAX_LEN,
            qtpo.ORDER_QTY,
            qtpo.DELIVY_NUM_TOL_PLUS AS DELIVY_QTY_TOL_PLUS,
            qtpo.DELIVY_NUM_TOL_MINUS AS DELIVY_QTY_TOL_MINUS,
            qtpo.ORDER_WT,
            qtpo.CONSIGN_CUST_CNAME,
            qtpo.DELIVY_PLACE_NAME,
            qtpo.ORDER_CUST_CNAME,
            qtpo.HULL_SECTION_NO,
            qtpo.ORDER_NO_ERP,
            qtpo.SECTION_MANAGE AS SECTION_MANAGE_FLAG
        </if>
        FROM
        QD_TO_PO_ORDER qtpo
        LEFT JOIN CT_MAIN cm on cm.ORDER_NO = qtpo.ORDER_NO
        LEFT JOIN QD_TO_PO_LINE_COMB qtplc on qtplc.ORDER_NO = qtpo.ORDER_NO
        LEFT JOIN QD_TO_LINEUP_RESULT_STEEL qtlrs ON qtlrs.ORDER_NO = qtpo.ORDER_NO AND qtplc.MSC_LINE_NO = qtlrs.MSC_LINE_NO
        WHERE
        qtpo.TENANT_ID = #{tenantId}
        and cm.ORDER_STATUS = '38'
        and qtpo.ORDER_TYPE_CODE not in ('QBP', 'QLP', 'NBP')
        <if test="orderNoList != null and orderNoList.size() > 0">
            and qtpo.ORDER_NO in
            <foreach collection="orderNoList" open="(" close=")" separator="," item="orderNoCt">
                #{orderNoCt}
            </foreach>
        </if>
        <if test="orderThickFrom != null">
            and qtpo.ORDER_THICK <![CDATA[ >= ]]> #{orderThickFrom}
        </if>
        <if test="orderThickTo != null">
            and qtpo.ORDER_THICK <![CDATA[ <= ]]> #{orderThickTo}
        </if>
        <if test="hullSectionFrom != null">
            and qtpo.HULL_SECTION_NO <![CDATA[ >= ]]> #{hullSectionFrom}
        </if>
        <if test="hullSectionTo != null">
            and qtpo.HULL_SECTION_NO <![CDATA[ <= ]]> #{hullSectionTo}
        </if>
        <!-- <if test="mscLineNo != null and mscLineNo != ''">
            and qtpo.MSC_LINE_NO = #{mscLineNo}
        </if> -->
        <if test="delivyDateFrom != null">
            and qtpo.DELIVY_DATE <![CDATA[ >= ]]> #{delivyDateFrom}
        </if>
        <if test="delivyDateTo != null">
            and qtpo.DELIVY_DATE <![CDATA[ <= ]]> #{delivyDateTo}
        </if>
        <if test="delivyDateFromStr != null">
            and qtpo.DELIVY_DATE <![CDATA[ >= ]]> #{delivyDateFromStr}
        </if>
        <if test="delivyDateToStr != null">
            and qtpo.DELIVY_DATE <![CDATA[ <= ]]> #{delivyDateToStr}
        </if>
        <if test="stNo != null and stNo != ''" >
            <bind name="stNoLike" value="'%' + stNo + '%'"/>
            and qtlrs.ST_NO like #{stNoLike}
        </if>
        <if test="needLecquering != null and needLecquering != ''" >
            and qtpo.NEED_LECQUERING = #{needLecquering}
        </if>
        <if test="mscLineNo != null and mscLineNo != ''" >
            <!-- and qtplc.MSC_LINE_NO = #{mscLineNo} -->
            and EXISTS (select 1 from QD_TO_PO_LINE_COMB comb where comb.ORDER_NO = qtpo.ORDER_NO and comb.MSC_LINE_NO = #{mscLineNo})
        </if>
        <if test="sgSign != null and sgSign != ''" >
            <bind name="sgSignLike" value="'%' + sgSign + '%'"/>
            and qtpo.SG_SIGN like #{sgSignLike}
        </if>
        <if test="orderNoErp != null and orderNoErp != ''" >
            <bind name="orderNoErpLike" value="'%' + orderNoErp + '%'"/>
            and qtpo.ORDER_NO_ERP like #{orderNoErpLike}
        </if>
        <if test="orderNo != null and orderNo != ''" >
            <bind name="orderNoLike" value="'%' + orderNo + '%'"/>
            and qtpo.ORDER_NO like #{orderNoLike}
        </if>


    </select>

    <select id="qdToLineupResultSampleOrderList" resultType="java.lang.String">
        select ORDER_NO from QD_TO_LINEUP_RESULT_SAMPLE qtlrs
        where
        qtlrs.TENANT_ID = #{tenantId}
        and qtlrs.ORDER_NO in
        <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator=",">
            #{orderNo}
        </foreach>
        and (qtlrs.TEST_ITEM_CODE in ('02','06','20','21','71') or (qtlrs.TEST_ITEM_CODE <![CDATA[ >= ]]> '31' or qtlrs.TEST_ITEM_CODE <![CDATA[ <= ]]> '67'))
    </select>

    <select id="qdToLineupResultSampleAllOrderList" resultType="java.lang.String">
        select ORDER_NO from QD_TO_LINEUP_RESULT_SAMPLE qtlrs
        where
        qtlrs.TENANT_ID = #{tenantId}
        and qtlrs.ORDER_NO in
        <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator=",">
            #{orderNo}
        </foreach>
    </select>

    <select id="selectFhbOrderNoByBaseOrderNo" resultType="java.lang.String">
        select
        pcor.PRODUCT_ORDER_NO
        from
        PM_COMPOSITE_ORDER_REL pcor
        left join PM_PRO_CONT_PROD_ATTR ppcpa on pcor.PRODUCT_ORDER_NO = ppcpa.ORDER_NO
        <where>
            pcor.TENANT_ID = #{tenantId}
            and pcor.BASE_ORDER_NO = #{baseOrderNo}
            <if test="slabType != null and slabType != ''" >
                <choose>
                    <when test="slabType == 'F'.toString() or slabType == 'K'.toString()">
                        <if test="qfhQueryFlag != null and qfhQueryFlag != ''">
                            <choose>
                                <when test="qfhQueryFlag == '1'.toString()">
                                    <if test="lovHavingComList != null and lovHavingComList.size() > 0">
                                        and ppcpa.ORDER_TYPE_CODE IN
                                        <foreach collection="lovHavingComList" index="index" item="item" open="(" separator="," close=")">
                                            #{item}
                                        </foreach>
                                    </if>
                                </when>
                                <when test="qfhQueryFlag == '0'.toString()">
                                    <if test="lovNotHavingComList != null and lovNotHavingComList.size() > 0">
                                        and ppcpa.ORDER_TYPE_CODE NOT IN
                                        <foreach collection="lovNotHavingComList" index="index" item="item" open="(" separator="," close=")">
                                            #{item}
                                        </foreach>
                                    </if>
                                </when>
                            </choose>
                        </if>
                        and ppcpa.ORDER_TYPE_CODE != 'QDH'
                    </when>
                    <when test="slabType == 'E'.toString()">
                        <if test="lovNotHavingComEList != null and lovNotHavingComEList.size() > 0">
                            and ppcpa.ORDER_TYPE_CODE NOT IN
                            <foreach collection="lovNotHavingComEList" index="index" item="item" open="(" separator="," close=")">
                                #{item}
                            </foreach>
                        </if>
                    </when>
                </choose>
            </if>
        </where>
    </select>

    <select id="queryBeginRollTempByMscLine" resultType="java.math.BigDecimal">
        select nvl(SCD_BG_TEMP,-1)
        from QD_TO_LINEUP_RESULT_ROLLING
        where ORDER_NO = #{orderNo}
          and TENANT_ID = #{tenantId}
          and MSC_LINE_NO = #{mscLineNo}
          AND to_number(SLAB_THK_MIN)  <![CDATA[ <=  ]]> #{slabThk}
          AND to_number(SLAB_THK_MAX)  <![CDATA[ >= ]]>  #{slabThk}
    </select>

    <select id="queryMidSLabThkAim" resultType="java.math.BigDecimal">
        select
            MID_SLAB_THK_AIM
        from
            QD_TO_LINEUP_RESULT_ROLLING
        where
            MSC_LINE_NO = #{mscLineNo}
          and ORDER_NO = #{orderNo}
          and TENANT_ID = #{tenantId}
    </select>

    <select id="selectQdOrderList" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select
        <include refid = "BaseSql"/>
        from QD_TO_PO_ORDER QTPO
        <where>
            <if test="tenantId !=null">
                and QTPO.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoList != null and orderNoList.size()>0">
                and  (QTPO.ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator="," index="index">
                    <if test="(index % 999) == 998"> NULL ) OR QTPO.ORDER_NO in (</if> #{orderNo}
                </foreach>)
            </if>
        </where>
    </select>

    <select id="selectCtDetByOrderList" resultType="com.xisc.pm.domain.vo.CtDetVO">
        SELECT
        cd.ORDER_NO,
        (COALESCE(cd.STOCK_NUM, 0) - (COALESCE(cd.PLAN_NUM, 0) )) AS USERD_BOARD_NUM
        FROM
        CT_DET cd
        <where>
            cd.SUB_BACKLOG_CODE IS NULL
            AND cd.WHOLE_BACKLOG_CODE = '13'
            AND (COALESCE(cd.STOCK_NUM, 0) - (COALESCE(cd.PLAN_NUM, 0) )) > 0
            <if test="tenantId !=null">
                AND cd.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoList != null and orderNoList.size()>0">
                and  (cd.ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator="," index="index">
                    <if test="(index % 999) == 998"> NULL ) OR cd.ORDER_NO in (</if> #{orderNo}
                </foreach>)
            </if>
        </where>
    </select>

    <select id="selectWitnessOrderPass" resultType="com.xisc.pm.api.dto.ObtainWitnessPointDTO">
        select
        QTWOP.ORDER_NO,
        QTWOP.WITNESS_POINT,
        QTWOP.WITNESS_POINT_STATUS
        from QE_TJ_WITNESS_ORDER_PASS QTWOP
        <where>
            and QTWOP.TENANT_ID = #{tenantId}
            <if test="orderNoList != null and orderNoList.size()>0">
                and  ( QTWOP.ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator="," index="index">
                    <if test="(index % 999) == 998"> NULL ) OR QTWOP.ORDER_NO in (</if> #{orderNo}
                </foreach>)
            </if>
            <if test="witnessPointList != null and witnessPointList.size()>0">
                and QTWOP.WITNESS_POINT in
                <foreach collection="witnessPointList" item="witnessPoint" open="(" close=")" separator=",">
                    #{witnessPoint}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectQdToPoLineCombList" resultType="com.xisc.pm.domain.vo.QdToPoLineCombVO">
        SELECT
        qtplc.MSC_LINE_NO,
        qtplc.WHOLE_BACKLOG,
        qtplc.ORDER_NO,
        qtplc.ST_GRADE
        FROM
        QD_TO_PO_LINE_COMB qtplc
        <where>
            <if test="tenantId !=null">
                and qtplc.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoList != null and orderNoList.size() > 0">
                and qtplc.ORDER_NO in
                <foreach collection="orderNoList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="mscLineNoList != null and mscLineNoList.size() > 0">
                and qtplc.MSC_LINE_NO in
                <foreach collection="mscLineNoList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectByOrderAndMscLineList" resultType="com.xisc.pm.domain.vo.QdToPoLineCombVO">
        SELECT
        qtplc.ORDER_NO,
        qtplc.MSC_LINE_NO,
        qtplc.ST_NO,
        qtplc.WHOLE_BACKLOG,
        qtplc.ST_GRADE,
        qtlrr.PLATE_DT_CODE
        FROM
        QD_TO_PO_LINE_COMB  qtplc
        left join QD_TO_LINEUP_RESULT_ROLLING qtlrr on qtplc.ORDER_NO = qtlrr.ORDER_NO and qtplc.MSC_LINE_NO = qtlrr.MSC_LINE_NO and qtplc.TENANT_ID = qtlrr.TENANT_ID
        <where>
            <if test="tenantId !=null">
                and qtplc.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoList != null and orderNoList.size() > 0">
                and qtplc.ORDER_NO in
                <foreach collection="orderNoList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="mscLineNoList != null and mscLineNoList.size() > 0">
                and qtplc.MSC_LINE_NO in
                <foreach collection="mscLineNoList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

</mapper>

