<?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.PmMmPlateMapper">
    <sql id = "BaseSql2">
        MS.SLAB_ID,
    MS.SLAB_NO,
    MS.ORDER_NO,
    MS.FIRST_ORDER_NO,
    MS.PONO,
    MS.SLAB_TYPE,
    MS.OLD_ORDER_NO,
    MS.MSC_LINE_NO,
    MS.REC_STS,
    MS.PROC_CD,
    MS.BEF_PROC_CD,
    MS.PROD_YEAR,
    MS.LOADING_TIME,
    MS.ORIGIN_SLAB_NO,
    MS.PLAN_NO,
    MS.ROLL_PLAN_NO,
    MS.PSC,
    MS.APN,
    MS.MSC,
    MS.PLATE_DT_CODE,
    MS.PROD_CODE_HP,
    MS.SLAB_ORIGIN_CODE,
    MS.SLAB_STATUS,
    MS.STD_SG_CODE,
    MS.SG_SIGN,
    MS.SG_STD,
    MS.OLD_STD_SG_CODE,
    MS.OLD_SG_STD,
    MS.OLD_SG_SIGN,
    MS.ST_NO,
    MS.OLD_PLATE_NO,
    MS.OLD_SLAB_NO,
    MS.AC_UNIT_CODE,
    MS.UNIT_CODE,
    MS.PRE_UNIT_CODE,
    MS.HOT_DEST1,
    MS.HOT_DEST2,
    MS.HOT_DEST3,
    MS.HOT_DEST4,
    MS.HOT_DEST5,
    MS.HOT_DEST,
    MS.SLAB_TARG_THK,
    MS.SLAB_TARG_WID,
    MS.SLAB_TARG_LEN,
    MS.SLAB_ACT_THK,
    MS.SLAB_ACT_WID,
    MS.SLAB_ACT_LEN,
    MS.SLAB_ACT_WGT,
    MS.SLAB_GROSS_WGT,
    MS.WGT_MODE,
    MS.PROD_TIME,
    MS.WHOLE_BACKLOG,
    MS.WHOLE_BACKLOG_SEQ,
    MS.WHOLE_BACKLOG_CODE,
    MS.NEXT_WHOLE_BACKLOG_SEQ,
    MS.NEXT_WHOLE_BACKLOG_CODE,
    MS.OUTTRUST_FLAG,
    MS.HOLD_FLAG,
    MS.HOLD_CAUSE_CODE,
    MS.HOLD_TIME,
    MS.HOLD_SHIFT_NO,
    MS.HOLD_MAKER,
    MS.REL_TIME,
    MS.REL_MAKER,
    MS.REMAIN_CAUSE_CODE,
    MS.REMAIN_DECIDE_TIME,
    MS.REMAIN_DECIDE_MAKER,
    MS.REMAIN_DECIDE_CODE,
    MS.SCRAP_CAUSE_CODE,
    MS.SCRAP_MAKER,
    MS.SCRAP_TIME,
    MS.SURFACE_DECIDE_CODE,
    MS.CONFM_FLAG,
    MS.SURFACE_DECIDE_TIME,
    MS.SURFACE_DECIDE_MAKER,
    MS.PCH_JUDGE_CODE,
    MS.PCH_JUDGE_RESULT,
    MS.PCH_JUDGE_ABN,
    MS.PCH_JUDGE_TIME,
    MS.PCH_JUDGE_MAKER,
    MS.COMPLEX_DECIDE_CODE,
    MS.COMPLEX_DECIDE_TIME,
    MS.COMPLEX_DECIDE_MAKER,
    MS.OLD_COMPLEX_DECIDE_CODE,
    MS.OLD_COMPLEX_DECIDE_TIME,
    MS.OLD_COMPLEX_DECIDE_MAKER,
    MS.PRE_ST_NO,
    MS.HEAT_NO,
    MS.SLAB_DEST,
    MS.HOT_CHARGE_FLAG,
    MS.SAMPLE_MART_NO,
    MS.PONO_SLAB,
    MS.FIX_SLAB_NUM,
    MS.ABNR_CODE1,
    MS.ABNR_CODE2,
    MS.ABNR_CODE3,
    MS.ABNR_CODE4,
    MS.ABNR_CODE5,
    MS.ABNR_CODE6,
    MS.ABNR_CODE7,
    MS.ABNR_CODE8,
    MS.ABNR_CODE9,
    MS.ABNR_CODE10,
    MS.SLABTOP_FLAG,
    MS.SLABTOP_TIME,
    MS.SLAB_FLAG,
    MS.SECUT_PLAN_NO,
    MS.BIG_BACKLOG_CODE,
    MS.SUB_BACKLOG_CODE,
    MS.SUB_BACKLOG_SEQ,
    MS.NEXT_SUB_BACKLOG_CODE,
    MS.NEXT_SUB_BACKLOG_SEQ,
    MS.BD_FLAG,
    MS.SLAB_RETURN_TIME,
    MS.SLAB_RETURN_CODE,
    MS.SLAB_RETURN_CAUSE_CODE,
    MS.SMP_GROUP,
    MS.REMARK,
    MS.SPARE_FIELD1,
    MS.SPARE_FIELD2,
    MS.SPARE_FIELD3,
    MS.SPARE_FIELD4,
    MS.SPARE_FIELD5,
    MS.SPARE_FIELD6,
    MS.SPARE_FIELD7,
    MS.SPARE_FIELD8,
    MS.SPARE_FIELD9,
    MS.SPARE_FIELD10,
    MS.TENANT_ID,
    MS.TRANFER_FLAG,
    MS.creation_date,    MS.created_by,    MS.last_updated_by,    MS.last_update_date,    MS.object_version_number
    </sql>

    <sql id = "BaseSql3">
        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_PRO_NO,
        QTPO.WITNESS_TYPE,
        QTPO.START_WORK_FILE_FLAG,
        QTPO.THICK_TOL_MAX,
        QTPO.THICK_TOL_MIN,
        QTPO.PRODUCT_TARG_THICK,
        QTPO.THK_TOL_TYPE,
        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.STAINLESS_THK,
        QTPO.COMP_BOARD_DENSITY,
        QTPO.PROD_CLASS_CODE,
        QTPO.PAY_CODE,
        QTPO.PROV_CODE,
        QTPO.PRINT_TYPE,
        QTPO.FACE_PRINT_DETAIL_A,
        QTPO.FACE_PRINT_DETAIL_B,
        QTPO.FACE_PRINT_DETAIL_C,
        QTPO.FACE_PRINT_DETAIL_D,
        QTPO.FACE_PRINT_DETAIL_E,
        QTPO.FACE_PRINT_DETAIL_F,
        QTPO.FACE_PRINT_DETAIL_G,
        QTPO.FACE_PRINT_DETAIL_H,
        QTPO.SIDE_PRINT_DETAIL_A,
        QTPO.SIDE_PRINT_DETAIL_B,
        QTPO.STAMP_PRINT_DETAIL_A,
        QTPO.STAMP_PRINT_DETAIL_B,
        QTPO.STAMP_PRINT_DETAIL_C,
        QTPO.STAMP_PRINT_DETAIL_D,
        QTPO.YS_STAND,
        QTPO.YS_REMARK,
        QTPO.TS_STAND,
        QTPO.TS_REMARK,
        QTPO.TS_MAX,
        QTPO.TS_MIN,
        QTPO.HARDNESS_AIM,
        QTPO.TENANT_ID,
        QTPO.ATTRIBUTE1,
        QTPO.ATTRIBUTE2,
        QTPO.ATTRIBUTE3,
        QTPO.ATTRIBUTE4,
        QTPO.ATTRIBUTE5,
        QTPO.RALLY_FLAG,
        QTPO.creation_date,        QTPO.created_by,        QTPO.last_updated_by,        QTPO.last_update_date,        QTPO.object_version_number
    </sql>

    <sql id = "BaseSql">
    MP.PLATE_ID,
    MP.MAT_NO,
    MP.OCCR_CD,
    MP.MSC_LINE_NO,
    MP.REC_STS,
    MP.PROC_CD,
    MP.BEF_PROC_CD,
    MP.PROD_CD,
    MP.MOTHER_NO,
    MP.SLAB_NO,
    MP.PLAN_NO,
    MP.ORDER_NO,
    MP.FIRST_ORDER_NO,
    MP.ORG_ORDER_NO,
    MP.PONO,
    MP.PONO_SLAB,
    MP.PROD_YEAR,
    MP.MAT_STATUS,
    MP.PROD_TIME,
    MP.DEL_TO_TIME,
    MP.PSC,
    MP.APN,
    MP.MSC,
    MP.OUTTRUST_FLAG,
    MP.BETTER_SURF_WARD_CODE,
    MP.ORD_FL,
    MP.SURFACE_DECIDE_CODE,
    MP.SURFACE_DECIDE_TIME,
    MP.REMAIN_CAUSE_CODE,
    MP.REMAIN_DECIDE_TIME,
    MP.REMAIN_DECIDE_MAKER,
    MP.REMAIN_DECIDE_CODE,
    MP.COMPLEX_DECIDE_CODE,
    MP.COMPLEX_DECIDE_TIME,
    MP.COMPLEX_DECIDE_MAKER,
    MP.COMPLEX_JUDGE_ABN,
    MP.PCH_JUDGE_CODE,
    MP.PCH_JUDGE_RESULT,
    MP.PCH_JUDGE_ABN,
    MP.PCH_JUDGE_TIME,
    MP.PCH_JUDGE_MAKER,
    MP.OLD_COMPLEX_DECIDE_CODE,
    MP.OLD_COMPLEX_DECIDE_TIME,
    MP.OLD_COMPLEX_DECIDE_MAKER,
    MP.HOLD_FLAG,
    MP.HOLD_CAUSE_CODE,
    MP.HOLD_TIME,
    MP.HOLD_SHIFT_NO,
    MP.HOLD_MAKER,
    MP.REL_TIME,
    MP.REL_MAKER,
    MP.SHIFT,
    MP.GROUP_CD,
    MP.MAT_ACT_THK,
    MP.MAT_ACT_WID,
    MP.MAT_ACT_LEN,
    MP.MAT_ACT_WGT,
    MP.WGT_MODE,
    MP.MAT_GROSS_WGT,
    MP.CONFM_FLAG,
    MP.ACT_SMP_FL,
    MP.ACT_SMP_LEN,
    MP.SMP_SET_FL,
    MP.HOT_DEST1,
    MP.HOT_DEST2,
    MP.HOT_DEST3,
    MP.HOT_DEST4,
    MP.HOT_DEST5,
    MP.TRANFER_FLAG,
    MP.HOT_DEST,
    MP.CAN_ASSIGN_FLAG,
    MP.ST_NO,
    MP.SG_STD,
    MP.SG_SIGN,
    MP.OLD_SG_STD,
    MP.OLD_SG_SIGN,
    MP.PROD_CODE_HP,
    MP.BIG_BACKLOG_CODE,
    MP.SUB_BACKLOG_CODE,
    MP.SUB_BACKLOG_SEQ,
    MP.NEXT_SUB_BACKLOG_CODE,
    MP.NEXT_SUB_BACKLOG_SEQ,
    MP.WHOLE_BACKLOG,
    MP.WHOLE_BACKLOG_SEQ,
    MP.WHOLE_BACKLOG_CODE,
    MP.NEXT_WHOLE_BACKLOG_SEQ,
    MP.NEXT_WHOLE_BACKLOG_CODE,
    MP.PLATE_DT_CODE,
    MP.BD_FLAG,
    MP.SHP_CODE,
    MP.PLAN_GAS_CNT,
    MP.HTM_CRASH_FLAG,
    MP.AC_UNIT_CODE,
    MP.FINAL_CUT_TIME,
    MP.FINAL_CUT_SURFACE_CODE,
    MP.UNIT_CODE,
    MP.PRE_UNIT_CODE,
    MP.SMP_GROUP,
    MP.REMARK,
    MP.SPARE_FIELD1,
    MP.SPARE_FIELD2,
    MP.SPARE_FIELD3,
    MP.SPARE_FIELD4,
    MP.SPARE_FIELD5,
    MP.SPARE_FIELD6,
    MP.SPARE_FIELD7,
    MP.SPARE_FIELD8,
    MP.SPARE_FIELD9,
    MP.SPARE_FIELD10,
    MP.SPARE_FIELD11,
    MP.SPARE_FIELD12,
    MP.SPARE_FIELD13,
    MP.SPARE_FIELD14,
    MP.SPARE_FIELD15,
    MP.SPARE_FIELD16,
    MP.SPARE_FIELD17,
    MP.SPARE_FIELD18,
    MP.SPARE_FIELD19,
    MP.SPARE_FIELD20,
    MP.TENANT_ID,
    MP.creation_date,    MP.created_by,    MP.last_updated_by,    MP.last_update_date,    MP.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.vo.MmPlateVO">
        select
        <include refid = "BaseSql"/>
        from MM_PLATE MP
        <where>
            MP.REC_STS = '2'
            <if test="plateId !=null">
                and MP.PLATE_ID = #{plateId,jdbcType = INTEGER}
            </if>
            <if test="matNo !=null">
                and MP.MAT_NO = #{matNo,jdbcType = VARCHAR}
            </if>
            <if test="occrCd !=null">
                and MP.OCCR_CD = #{occrCd,jdbcType = VARCHAR}
            </if>
            <if test="mscLineNo !=null">
                and MP.MSC_LINE_NO = #{mscLineNo,jdbcType = VARCHAR}
            </if>
            <if test="recSts !=null">
                and MP.REC_STS = #{recSts,jdbcType = VARCHAR}
            </if>
            <if test="procCd !=null">
                and MP.PROC_CD = #{procCd,jdbcType = VARCHAR}
            </if>
            <if test="befProcCd !=null">
                and MP.BEF_PROC_CD = #{befProcCd,jdbcType = VARCHAR}
            </if>
            <if test="prodCd !=null">
                and MP.PROD_CD = #{prodCd,jdbcType = VARCHAR}
            </if>
            <if test="motherNo !=null">
                and MP.MOTHER_NO = #{motherNo,jdbcType = VARCHAR}
            </if>
            <if test="slabNo !=null">
                and MP.SLAB_NO = #{slabNo,jdbcType = VARCHAR}
            </if>
            <if test="planNo !=null">
                and MP.PLAN_NO = #{planNo,jdbcType = VARCHAR}
            </if>
            <if test="orderNo !=null">
                and MP.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="firstOrderNo !=null">
                and MP.FIRST_ORDER_NO = #{firstOrderNo,jdbcType = VARCHAR}
            </if>
            <if test="orgOrderNo !=null">
                and MP.ORG_ORDER_NO = #{orgOrderNo,jdbcType = VARCHAR}
            </if>
            <if test="pono !=null">
                and MP.PONO = #{pono,jdbcType = VARCHAR}
            </if>
            <if test="ponoSlab !=null">
                and MP.PONO_SLAB = #{ponoSlab,jdbcType = VARCHAR}
            </if>
            <if test="prodYear !=null">
                and MP.PROD_YEAR = #{prodYear,jdbcType = VARCHAR}
            </if>
            <if test="matStatus !=null">
                and MP.MAT_STATUS = #{matStatus,jdbcType = VARCHAR}
            </if>
            <if test="prodTime !=null">
                and MP.PROD_TIME = #{prodTime,jdbcType = OTHER}
            </if>
            <if test="delToTime !=null">
                and MP.DEL_TO_TIME = #{delToTime,jdbcType = OTHER}
            </if>
            <if test="psc !=null">
                and MP.PSC = #{psc,jdbcType = VARCHAR}
            </if>
            <if test="apn !=null">
                and MP.APN = #{apn,jdbcType = VARCHAR}
            </if>
            <if test="msc !=null">
                and MP.MSC = #{msc,jdbcType = VARCHAR}
            </if>
            <if test="outtrustFlag !=null">
                and MP.OUTTRUST_FLAG = #{outtrustFlag,jdbcType = VARCHAR}
            </if>
            <if test="betterSurfWardCode !=null">
                and MP.BETTER_SURF_WARD_CODE = #{betterSurfWardCode,jdbcType = VARCHAR}
            </if>
            <if test="ordFl !=null">
                and MP.ORD_FL = #{ordFl,jdbcType = VARCHAR}
            </if>
            <if test="surfaceDecideCode !=null">
                and MP.SURFACE_DECIDE_CODE = #{surfaceDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="surfaceDecideTime !=null">
                and MP.SURFACE_DECIDE_TIME = #{surfaceDecideTime,jdbcType = OTHER}
            </if>
            <if test="remainCauseCode !=null">
                and MP.REMAIN_CAUSE_CODE = #{remainCauseCode,jdbcType = VARCHAR}
            </if>
            <if test="remainDecideTime !=null">
                and MP.REMAIN_DECIDE_TIME = #{remainDecideTime,jdbcType = OTHER}
            </if>
            <if test="remainDecideMaker !=null">
                and MP.REMAIN_DECIDE_MAKER = #{remainDecideMaker,jdbcType = VARCHAR}
            </if>
            <if test="remainDecideCode !=null">
                and MP.REMAIN_DECIDE_CODE = #{remainDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="complexDecideCode !=null">
                and MP.COMPLEX_DECIDE_CODE = #{complexDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="complexDecideTime !=null">
                and MP.COMPLEX_DECIDE_TIME = #{complexDecideTime,jdbcType = OTHER}
            </if>
            <if test="complexDecideMaker !=null">
                and MP.COMPLEX_DECIDE_MAKER = #{complexDecideMaker,jdbcType = VARCHAR}
            </if>
            <if test="complexJudgeAbn !=null">
                and MP.COMPLEX_JUDGE_ABN = #{complexJudgeAbn,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeCode !=null">
                and MP.PCH_JUDGE_CODE = #{pchJudgeCode,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeResult !=null">
                and MP.PCH_JUDGE_RESULT = #{pchJudgeResult,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeAbn !=null">
                and MP.PCH_JUDGE_ABN = #{pchJudgeAbn,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeTime !=null">
                and MP.PCH_JUDGE_TIME = #{pchJudgeTime,jdbcType = OTHER}
            </if>
            <if test="pchJudgeMaker !=null">
                and MP.PCH_JUDGE_MAKER = #{pchJudgeMaker,jdbcType = VARCHAR}
            </if>
            <if test="oldComplexDecideCode !=null">
                and MP.OLD_COMPLEX_DECIDE_CODE = #{oldComplexDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="oldComplexDecideTime !=null">
                and MP.OLD_COMPLEX_DECIDE_TIME = #{oldComplexDecideTime,jdbcType = OTHER}
            </if>
            <if test="oldComplexDecideMaker !=null">
                and MP.OLD_COMPLEX_DECIDE_MAKER = #{oldComplexDecideMaker,jdbcType = VARCHAR}
            </if>
            <if test="holdFlag !=null">
                and MP.HOLD_FLAG = #{holdFlag,jdbcType = VARCHAR}
            </if>
            <if test="holdCauseCode !=null">
                and MP.HOLD_CAUSE_CODE = #{holdCauseCode,jdbcType = VARCHAR}
            </if>
            <if test="holdTime !=null">
                and MP.HOLD_TIME = #{holdTime,jdbcType = OTHER}
            </if>
            <if test="holdShiftNo !=null">
                and MP.HOLD_SHIFT_NO = #{holdShiftNo,jdbcType = VARCHAR}
            </if>
            <if test="holdMaker !=null">
                and MP.HOLD_MAKER = #{holdMaker,jdbcType = VARCHAR}
            </if>
            <if test="relTime !=null">
                and MP.REL_TIME = #{relTime,jdbcType = OTHER}
            </if>
            <if test="relMaker !=null">
                and MP.REL_MAKER = #{relMaker,jdbcType = VARCHAR}
            </if>
            <if test="shift !=null">
                and MP.SHIFT = #{shift,jdbcType = VARCHAR}
            </if>
            <if test="groupCd !=null">
                and MP.GROUP_CD = #{groupCd,jdbcType = VARCHAR}
            </if>
            <if test="matActThk !=null">
                and MP.MAT_ACT_THK = #{matActThk,jdbcType = INTEGER}
            </if>
            <if test="matActWid !=null">
                and MP.MAT_ACT_WID = #{matActWid,jdbcType = INTEGER}
            </if>
            <if test="matActLen !=null">
                and MP.MAT_ACT_LEN = #{matActLen,jdbcType = INTEGER}
            </if>
            <if test="matActWgt !=null">
                and MP.MAT_ACT_WGT = #{matActWgt,jdbcType = INTEGER}
            </if>
            <if test="wgtMode !=null">
                and MP.WGT_MODE = #{wgtMode,jdbcType = VARCHAR}
            </if>
            <if test="matGrossWgt !=null">
                and MP.MAT_GROSS_WGT = #{matGrossWgt,jdbcType = INTEGER}
            </if>
            <if test="confmFlag !=null">
                and MP.CONFM_FLAG = #{confmFlag,jdbcType = VARCHAR}
            </if>
            <if test="actSmpFl !=null">
                and MP.ACT_SMP_FL = #{actSmpFl,jdbcType = VARCHAR}
            </if>
            <if test="actSmpLen !=null">
                and MP.ACT_SMP_LEN = #{actSmpLen,jdbcType = INTEGER}
            </if>
            <if test="smpSetFl !=null">
                and MP.SMP_SET_FL = #{smpSetFl,jdbcType = VARCHAR}
            </if>
            <if test="hotDest1 !=null">
                and MP.HOT_DEST1 = #{hotDest1,jdbcType = VARCHAR}
            </if>
            <if test="hotDest2 !=null">
                and MP.HOT_DEST2 = #{hotDest2,jdbcType = VARCHAR}
            </if>
            <if test="hotDest3 !=null">
                and MP.HOT_DEST3 = #{hotDest3,jdbcType = VARCHAR}
            </if>
            <if test="hotDest4 !=null">
                and MP.HOT_DEST4 = #{hotDest4,jdbcType = VARCHAR}
            </if>
            <if test="hotDest5 !=null">
                and MP.HOT_DEST5 = #{hotDest5,jdbcType = VARCHAR}
            </if>
            <if test="tranferFlag !=null">
                and MP.TRANFER_FLAG = #{tranferFlag,jdbcType = VARCHAR}
            </if>
            <if test="hotDest !=null">
                and MP.HOT_DEST = #{hotDest,jdbcType = VARCHAR}
            </if>
            <if test="canAssignFlag !=null">
                and MP.CAN_ASSIGN_FLAG = #{canAssignFlag,jdbcType = VARCHAR}
            </if>
            <if test="stNo !=null">
                and MP.ST_NO = #{stNo,jdbcType = VARCHAR}
            </if>
            <if test="sgStd !=null">
                and MP.SG_STD = #{sgStd,jdbcType = VARCHAR}
            </if>
            <if test="sgSign !=null">
                and MP.SG_SIGN = #{sgSign,jdbcType = VARCHAR}
            </if>
            <if test="oldSgStd !=null">
                and MP.OLD_SG_STD = #{oldSgStd,jdbcType = VARCHAR}
            </if>
            <if test="oldSgSign !=null">
                and MP.OLD_SG_SIGN = #{oldSgSign,jdbcType = VARCHAR}
            </if>
            <if test="prodCodeHp !=null">
                and MP.PROD_CODE_HP = #{prodCodeHp,jdbcType = VARCHAR}
            </if>
            <if test="bigBacklogCode !=null">
                and MP.BIG_BACKLOG_CODE = #{bigBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="subBacklogCode !=null">
                and MP.SUB_BACKLOG_CODE = #{subBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="subBacklogSeq !=null">
                and MP.SUB_BACKLOG_SEQ = #{subBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="nextSubBacklogCode !=null">
                and MP.NEXT_SUB_BACKLOG_CODE = #{nextSubBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="nextSubBacklogSeq !=null">
                and MP.NEXT_SUB_BACKLOG_SEQ = #{nextSubBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="wholeBacklog !=null">
                and MP.WHOLE_BACKLOG = #{wholeBacklog,jdbcType = VARCHAR}
            </if>
            <if test="wholeBacklogSeq !=null">
                and MP.WHOLE_BACKLOG_SEQ = #{wholeBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="wholeBacklogCode !=null">
                and MP.WHOLE_BACKLOG_CODE = #{wholeBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="nextWholeBacklogSeq !=null">
                and MP.NEXT_WHOLE_BACKLOG_SEQ = #{nextWholeBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="nextWholeBacklogCode !=null">
                and MP.NEXT_WHOLE_BACKLOG_CODE = #{nextWholeBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="plateDtCode !=null">
                and MP.PLATE_DT_CODE = #{plateDtCode,jdbcType = VARCHAR}
            </if>
            <if test="bdFlag !=null">
                and MP.BD_FLAG = #{bdFlag,jdbcType = VARCHAR}
            </if>
            <if test="shpCode !=null">
                and MP.SHP_CODE = #{shpCode,jdbcType = VARCHAR}
            </if>
            <if test="planGasCnt !=null">
                and MP.PLAN_GAS_CNT = #{planGasCnt,jdbcType = INTEGER}
            </if>
            <if test="htmCrashFlag !=null">
                and MP.HTM_CRASH_FLAG = #{htmCrashFlag,jdbcType = VARCHAR}
            </if>
            <if test="acUnitCode !=null">
                and MP.AC_UNIT_CODE = #{acUnitCode,jdbcType = VARCHAR}
            </if>
            <if test="finalCutTime !=null">
                and MP.FINAL_CUT_TIME = #{finalCutTime,jdbcType = OTHER}
            </if>
            <if test="finalCutSurfaceCode !=null">
                and MP.FINAL_CUT_SURFACE_CODE = #{finalCutSurfaceCode,jdbcType = VARCHAR}
            </if>
            <if test="unitCode !=null">
                and MP.UNIT_CODE = #{unitCode,jdbcType = VARCHAR}
            </if>
            <if test="preUnitCode !=null">
                and MP.PRE_UNIT_CODE = #{preUnitCode,jdbcType = VARCHAR}
            </if>
            <if test="smpGroup !=null">
                and MP.SMP_GROUP = #{smpGroup,jdbcType = VARCHAR}
            </if>
            <if test="remark !=null">
                and MP.REMARK = #{remark,jdbcType = VARCHAR}
            </if>
            <if test="spareField1 !=null">
                and MP.SPARE_FIELD1 = #{spareField1,jdbcType = VARCHAR}
            </if>
            <if test="spareField2 !=null">
                and MP.SPARE_FIELD2 = #{spareField2,jdbcType = VARCHAR}
            </if>
            <if test="spareField3 !=null">
                and MP.SPARE_FIELD3 = #{spareField3,jdbcType = VARCHAR}
            </if>
            <if test="spareField4 !=null">
                and MP.SPARE_FIELD4 = #{spareField4,jdbcType = VARCHAR}
            </if>
            <if test="spareField5 !=null">
                and MP.SPARE_FIELD5 = #{spareField5,jdbcType = VARCHAR}
            </if>
            <if test="spareField6 !=null">
                and MP.SPARE_FIELD6 = #{spareField6,jdbcType = VARCHAR}
            </if>
            <if test="spareField7 !=null">
                and MP.SPARE_FIELD7 = #{spareField7,jdbcType = VARCHAR}
            </if>
            <if test="spareField8 !=null">
                and MP.SPARE_FIELD8 = #{spareField8,jdbcType = VARCHAR}
            </if>
            <if test="spareField9 !=null">
                and MP.SPARE_FIELD9 = #{spareField9,jdbcType = VARCHAR}
            </if>
            <if test="spareField10 !=null">
                and MP.SPARE_FIELD10 = #{spareField10,jdbcType = VARCHAR}
            </if>
            <if test="spareField11 !=null">
                and MP.SPARE_FIELD11 = #{spareField11,jdbcType = INTEGER}
            </if>
            <if test="spareField12 !=null">
                and MP.SPARE_FIELD12 = #{spareField12,jdbcType = INTEGER}
            </if>
            <if test="spareField13 !=null">
                and MP.SPARE_FIELD13 = #{spareField13,jdbcType = INTEGER}
            </if>
            <if test="spareField14 !=null">
                and MP.SPARE_FIELD14 = #{spareField14,jdbcType = INTEGER}
            </if>
            <if test="spareField15 !=null">
                and MP.SPARE_FIELD15 = #{spareField15,jdbcType = INTEGER}
            </if>
            <if test="spareField16 !=null">
                and MP.SPARE_FIELD16 = #{spareField16,jdbcType = INTEGER}
            </if>
            <if test="spareField17 !=null">
                and MP.SPARE_FIELD17 = #{spareField17,jdbcType = INTEGER}
            </if>
            <if test="spareField18 !=null">
                and MP.SPARE_FIELD18 = #{spareField18,jdbcType = INTEGER}
            </if>
            <if test="spareField19 !=null">
                and MP.SPARE_FIELD19 = #{spareField19,jdbcType = INTEGER}
            </if>
            <if test="spareField20 !=null">
                and MP.SPARE_FIELD20 = #{spareField20,jdbcType = INTEGER}
            </if>
            <if test="tenantId !=null">
                and MP.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="matStatusList != null and matStatusList.size() > 0">
            	and MP.MAT_STATUS in 
            	<foreach collection="matStatusList" item="status" open="(" close=")" separator=",">
            		#{status}
            	</foreach>
            </if>
        </where>
    </select>

    <select id="selectMmPlatePrimary" resultType="com.xisc.pm.domain.vo.MmPlateVO">
        select
        <include refid = "BaseSql"/>
        from MM_PLATE MP
        where  MP.PLATE_ID = #{plateId,jdbcType = INTEGER}
    </select>
    <select id="surplusSteelPlateList" resultType="com.xisc.pm.domain.vo.MmPlateVO">
        select
            MP.REC_STS,
            MP.PLATE_ID,
            MP.MAT_NO,
            MP.ORDER_NO,
            MP.SG_SIGN,
            MP.MAT_ACT_THK,
            MP.MAT_ACT_WID,
            MP.MAT_ACT_LEN,
            MP.PROD_CODE_HP,
            MP.PSC,
            WMP.STOCK_CODE,
            MP.ST_NO,
            MP.MAT_STATUS,
            MP.REMAIN_CAUSE_CODE,
            WMP.PILE_NO,
            MP.COMPLEX_DECIDE_CODE,
            WMP.LAYER_NO,
            MP.MAT_ACT_WGT,
            MP.MSC,
            MP.APN,
            MP.FINAL_CUT_SURFACE_CODE,
            MP.REMAIN_CAUSE_CODE,
            MP.PROD_CD,
            LISTAGG(MUR.RSLT_LEVEL, ',') WITHIN GROUP (ORDER BY MUR.RSLT_LEVEL) AS RSLT_LEVEL,
            LISTAGG(MUR.DETECT_RESULT_CODE, ',') WITHIN GROUP (ORDER BY MUR.DETECT_RESULT_CODE) AS DETECT_RESULT_CODE,
            QTPO.SG_STD,
            QTPO.DELIVERY_STATE,
            MP.MSC_LINE_NO,
            MP.ORG_ORDER_NO,
            MP.PONO_SLAB,
            MP.SLAB_NO
        from
                MM_PLATE MP
                left join MM_UST_RSLT MUR on (MP.MAT_NO = MUR.PLATE_NO and MUR.DETECT_RESULT_CODE = '1')
                left join QD_TO_PO_ORDER QTPO on MP.ORDER_NO = QTPO.ORDER_NO
                left join WM_MAT_PILE WMP  on MP.MAT_NO = WMP.MAT_NO
        <where>
            MP.MAT_STATUS in ('33', '39')
            and MP.COMPLEX_DECIDE_CODE = '1'
            and MP.REC_STS = '2'
            <if test="orderThickMaxValue !=null">
                and MP.MAT_ACT_THK <![CDATA[ <= ]]> #{orderThickMaxValue}
            </if>
            <if test="orderThickMinValue !=null">
                and MP.MAT_ACT_THK <![CDATA[ >= ]]> #{orderThickMinValue}
            </if>
            <if test="widthMaxValue !=null">
                and MP.MAT_ACT_WID <![CDATA[ <= ]]> #{widthMaxValue}
            </if>
            <if test="widthMinValue !=null">
                and MP.MAT_ACT_WID <![CDATA[ >= ]]> #{widthMinValue}
            </if>
            <if test="orderLenMaxValue !=null">
                and MP.MAT_ACT_LEN <![CDATA[ <= ]]> #{orderLenMaxValue}
            </if>
            <if test="orderLenMinValue !=null">
                and MP.MAT_ACT_LEN <![CDATA[ >= ]]> #{orderLenMinValue}
            </if>
            <if test="plateId !=null">
                and MP.PLATE_ID = #{plateId,jdbcType = INTEGER}
            </if>
            <if test="matNo !=null">
                and MP.MAT_NO = #{matNo,jdbcType = VARCHAR}
            </if>
            <if test="orderNo !=null">
                and MP.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="psc !=null">
                and MP.PSC = #{psc,jdbcType = VARCHAR}
            </if>
            <if test="msc !=null">
                and MP.MSC = #{msc}
            </if>
            <if test="apn !=null">
                and MP.APN = #{apn}
            </if>
            <if test="stockCode !=null">
                and WMP.STOCK_CODE = #{stockCode,jdbcType = VARCHAR}
            </if>
            <if test="pileNo !=null">
                and WMP.PILE_NO = #{pileNo,jdbcType = VARCHAR}
            </if>
            <if test="remainCauseCode !=null">
                and MP.REMAIN_CAUSE_CODE = #{remainCauseCode,jdbcType = VARCHAR}
            </if>
            <if test="remainDecideCode !=null">
                and MP.REMAIN_DECIDE_CODE = #{remainDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="complexDecideCode !=null">
                and MP.COMPLEX_DECIDE_CODE = #{complexDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="complexDecideTime !=null">
                and MP.COMPLEX_DECIDE_TIME = #{complexDecideTime,jdbcType = OTHER}
            </if>
            <if test="complexDecideMaker !=null">
                and MP.COMPLEX_DECIDE_MAKER = #{complexDecideMaker,jdbcType = VARCHAR}
            </if>
            <if test="complexJudgeAbn !=null">
                and MP.COMPLEX_JUDGE_ABN = #{complexJudgeAbn,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeCode !=null">
                and MP.PCH_JUDGE_CODE = #{pchJudgeCode,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeResult !=null">
                and MP.PCH_JUDGE_RESULT = #{pchJudgeResult,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeAbn !=null">
                and MP.PCH_JUDGE_ABN = #{pchJudgeAbn,jdbcType = VARCHAR}
            </if>
            <if test="pchJudgeTime !=null">
                and MP.PCH_JUDGE_TIME = #{pchJudgeTime,jdbcType = OTHER}
            </if>
            <if test="pchJudgeMaker !=null">
                and MP.PCH_JUDGE_MAKER = #{pchJudgeMaker,jdbcType = VARCHAR}
            </if>
            <if test="oldComplexDecideCode !=null">
                and MP.OLD_COMPLEX_DECIDE_CODE = #{oldComplexDecideCode,jdbcType = VARCHAR}
            </if>
            <if test="oldComplexDecideTime !=null">
                and MP.OLD_COMPLEX_DECIDE_TIME = #{oldComplexDecideTime,jdbcType = OTHER}
            </if>
            <if test="oldComplexDecideMaker !=null">
                and MP.OLD_COMPLEX_DECIDE_MAKER = #{oldComplexDecideMaker,jdbcType = VARCHAR}
            </if>
            <if test="holdFlag !=null">
                and MP.HOLD_FLAG = #{holdFlag,jdbcType = VARCHAR}
            </if>
            <if test="holdCauseCode !=null">
                and MP.HOLD_CAUSE_CODE = #{holdCauseCode,jdbcType = VARCHAR}
            </if>
            <if test="holdTime !=null">
                and MP.HOLD_TIME = #{holdTime,jdbcType = OTHER}
            </if>
            <if test="holdShiftNo !=null">
                and MP.HOLD_SHIFT_NO = #{holdShiftNo,jdbcType = VARCHAR}
            </if>
            <if test="holdMaker !=null">
                and MP.HOLD_MAKER = #{holdMaker,jdbcType = VARCHAR}
            </if>
            <if test="matStatus !=null">
                and MP.MAT_STATUS = #{matStatus,jdbcType = VARCHAR}
            </if>
            <if test="relTime !=null">
                and MP.REL_TIME = #{relTime,jdbcType = OTHER}
            </if>
            <if test="relMaker !=null">
                and MP.REL_MAKER = #{relMaker,jdbcType = VARCHAR}
            </if>
            <if test="shift !=null">
                and MP.SHIFT = #{shift,jdbcType = VARCHAR}
            </if>
            <if test="groupCd !=null">
                and MP.GROUP_CD = #{groupCd,jdbcType = VARCHAR}
            </if>
            <if test="matActThk !=null">
                and MP.MAT_ACT_THK = #{matActThk,jdbcType = INTEGER}
            </if>
            <if test="matActThkFrom !=null">
                and MP.MAT_ACT_THK >= #{matActThkFrom,jdbcType = INTEGER}
            </if>
            <if test="matActThkTo !=null">
                and MP.MAT_ACT_THK &lt;= #{matActThkTo,jdbcType = INTEGER}
            </if>
            <if test="matActWidFrom !=null">
                and MP.MAT_ACT_WID >= #{matActWidFrom,jdbcType = INTEGER}
            </if>
            <if test="matActWidTo !=null">
                and MP.MAT_ACT_WID &lt;= #{matActWidTo,jdbcType = INTEGER}
            </if>
            <if test="matActLenFrom !=null">
                and MP.MAT_ACT_LEN >= #{matActLenFrom,jdbcType = INTEGER}
            </if>
            <if test="matActLenTo !=null">
                and MP.MAT_ACT_LEN &lt;= #{matActLenTo,jdbcType = INTEGER}
            </if>
            <if test="matActWgt !=null">
                and MP.MAT_ACT_WGT = #{matActWgt,jdbcType = INTEGER}
            </if>
            <if test="wgtMode !=null">
                and MP.WGT_MODE = #{wgtMode,jdbcType = VARCHAR}
            </if>
            <if test="matGrossWgt !=null">
                and MP.MAT_GROSS_WGT = #{matGrossWgt,jdbcType = INTEGER}
            </if>
            <if test="confmFlag !=null">
                and MP.CONFM_FLAG = #{confmFlag,jdbcType = VARCHAR}
            </if>
            <if test="actSmpFl !=null">
                and MP.ACT_SMP_FL = #{actSmpFl,jdbcType = VARCHAR}
            </if>
            <if test="actSmpLen !=null">
                and MP.ACT_SMP_LEN = #{actSmpLen,jdbcType = INTEGER}
            </if>
            <if test="smpSetFl !=null">
                and MP.SMP_SET_FL = #{smpSetFl,jdbcType = VARCHAR}
            </if>
            <if test="hotDest1 !=null">
                and MP.HOT_DEST1 = #{hotDest1,jdbcType = VARCHAR}
            </if>
            <if test="hotDest2 !=null">
                and MP.HOT_DEST2 = #{hotDest2,jdbcType = VARCHAR}
            </if>
            <if test="hotDest3 !=null">
                and MP.HOT_DEST3 = #{hotDest3,jdbcType = VARCHAR}
            </if>
            <if test="hotDest4 !=null">
                and MP.HOT_DEST4 = #{hotDest4,jdbcType = VARCHAR}
            </if>
            <if test="hotDest5 !=null">
                and MP.HOT_DEST5 = #{hotDest5,jdbcType = VARCHAR}
            </if>
            <if test="tranferFlag !=null">
                and MP.TRANFER_FLAG = #{tranferFlag,jdbcType = VARCHAR}
            </if>
            <if test="hotDest !=null">
                and MP.HOT_DEST = #{hotDest,jdbcType = VARCHAR}
            </if>
            <if test="canAssignFlag !=null">
                and MP.CAN_ASSIGN_FLAG = #{canAssignFlag,jdbcType = VARCHAR}
            </if>
            <if test="stNo !=null">
                and MP.ST_NO = #{stNo,jdbcType = VARCHAR}
            </if>
            <if test="sgStd !=null">
                and MP.SG_STD = #{sgStd,jdbcType = VARCHAR}
            </if>
            <if test="sgSign !=null">
                and MP.SG_SIGN = #{sgSign,jdbcType = VARCHAR}
            </if>
            <if test="oldSgStd !=null">
                and MP.OLD_SG_STD = #{oldSgStd,jdbcType = VARCHAR}
            </if>
            <if test="oldSgSign !=null">
                and MP.OLD_SG_SIGN = #{oldSgSign,jdbcType = VARCHAR}
            </if>
            <if test="prodCodeHp !=null">
                and MP.PROD_CODE_HP = #{prodCodeHp,jdbcType = VARCHAR}
            </if>
            <if test="bigBacklogCode !=null">
                and MP.BIG_BACKLOG_CODE = #{bigBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="subBacklogCode !=null">
                and MP.SUB_BACKLOG_CODE = #{subBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="subBacklogSeq !=null">
                and MP.SUB_BACKLOG_SEQ = #{subBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="nextSubBacklogCode !=null">
                and MP.NEXT_SUB_BACKLOG_CODE = #{nextSubBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="nextSubBacklogSeq !=null">
                and MP.NEXT_SUB_BACKLOG_SEQ = #{nextSubBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="wholeBacklog !=null">
                and MP.WHOLE_BACKLOG = #{wholeBacklog,jdbcType = VARCHAR}
            </if>
            <if test="wholeBacklogSeq !=null">
                and MP.WHOLE_BACKLOG_SEQ = #{wholeBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="wholeBacklogCode !=null">
                and MP.WHOLE_BACKLOG_CODE = #{wholeBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="nextWholeBacklogSeq !=null">
                and MP.NEXT_WHOLE_BACKLOG_SEQ = #{nextWholeBacklogSeq,jdbcType = INTEGER}
            </if>
            <if test="nextWholeBacklogCode !=null">
                and MP.NEXT_WHOLE_BACKLOG_CODE = #{nextWholeBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="plateDtCode !=null">
                and MP.PLATE_DT_CODE = #{plateDtCode,jdbcType = VARCHAR}
            </if>
            <if test="bdFlag !=null">
                and MP.BD_FLAG = #{bdFlag,jdbcType = VARCHAR}
            </if>
            <if test="shpCode !=null">
                and MP.SHP_CODE = #{shpCode,jdbcType = VARCHAR}
            </if>
            <if test="planGasCnt !=null">
                and MP.PLAN_GAS_CNT = #{planGasCnt,jdbcType = INTEGER}
            </if>
            <if test="htmCrashFlag !=null">
                and MP.HTM_CRASH_FLAG = #{htmCrashFlag,jdbcType = VARCHAR}
            </if>
            <if test="unitCode !=null">
                and MP.UNIT_CODE = #{unitCode,jdbcType = VARCHAR}
            </if>
        </where>
        GROUP BY
          MP.REC_STS,
          MP.PLATE_ID,
          MP.MAT_NO,
          MP.ORDER_NO,
          MP.SG_SIGN,
          MP.MAT_ACT_THK,
          MP.MAT_ACT_WID,
          MP.MAT_ACT_LEN,
          MP.PROD_CODE_HP,
          MP.PSC,
          WMP.STOCK_CODE,
          MP.ST_NO,
          MP.MAT_STATUS,
          MP.REMAIN_CAUSE_CODE,
          WMP.PILE_NO,
          MP.COMPLEX_DECIDE_CODE,
          WMP.LAYER_NO,
          MP.MAT_ACT_WGT,
          MP.MSC,
          MP.APN,
          MP.FINAL_CUT_SURFACE_CODE,
          MP.REMAIN_CAUSE_CODE,
          MP.PROD_CD,
          QTPO.SG_STD,
          QTPO.DELIVERY_STATE,
          MP.MSC_LINE_NO,
          MP.ORG_ORDER_NO,
          MP.PONO_SLAB,
          MP.SLAB_NO
    </select>

    <select id="smallProcessCodeNtNum" resultType="java.lang.Integer">
        select count(*) from
        (select distinct(t3.second_str) from
        (select SUBSTR(t1.sub_backlog_code, 2, 1) as second_str
        from MM_PLATE_SMALL_PRO t1 left join MM_HTMRSLT t2 on t1.SUB_BACKLOG_SEQ = t2.SUB_BACKLOG_SEQ and
        t1.MAT_NO = t2.MAT_NO
        where t1.backlog_add_div = '0'
        and t1.sub_backlog_code like '_N%' or t1.sub_backlog_code like '_T%'
        and t1.MAT_NO in
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>) t3) t4
    </select>

    <select id="smallProcessCodeQtNum" resultType="java.lang.Integer">
        select count(*) from
        (select distinct(t3.second_str) from
        (select SUBSTR(t1.sub_backlog_code, 2, 1) as second_str
        from MM_PLATE_SMALL_PRO t1 left join MM_HTMRSLT t2 on t1.SUB_BACKLOG_SEQ = t2.SUB_BACKLOG_SEQ and
        t1.MAT_NO = t2.MAT_NO
        where t1.backlog_add_div = '0'
        and t1.sub_backlog_code like '_Q%' or t1.sub_backlog_code like '_T%'
        and t1.MAT_NO in
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>) t3) t4
    </select>

    <select id="selectMaxProdSeqNo" resultType="java.lang.String">
        select max(t1.PROD_SEQ_NO) as MAX_PROD_SEQ_NO from MM_HTMRSLT t1
        where t1.MAT_NO in
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>)
    </select>

    <select id="selectHeatTreatmentMethodCode" resultType="java.lang.String">
        select t1.HOT_TREAT_METHOD_CODE from MM_HTMRSLT t1 where t1.PROD_SEQ_NO = #{maxProdSeqNo}
    </select>
    <select id="selectMaxProdSeqNoByMatNo" resultType="java.lang.String">
        select max(t1.PROD_SEQ_NO) as MAX_PROD_SEQ_NO from MM_HTMRSLT t1
        where t1.PLATE_NO in
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>)
    </select>
    <select id="selectUstValueLast" resultType="java.lang.String">
        select t1.UST_VALUE_LAST from MM_HTMRSLT t1 where t1.PROD_SEQ_NO = #{maxProdSeqNo}
    </select>
    <select id="selectSgsing" resultType="java.lang.String">
       select distinct SG_SIGN from (select SG_SIGN
        FROM PM_PD_SLAB_INFO
        where PD_STATUS_HP = '27'
          and SG_SIGN is not null
          and PD_PROGRAM is not null
        <if test="timeFrom !=null">
          and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="createdBy !=null">
          and CREATED_BY = #{createdBy}
        </if>
        union all
        select SG_SIGN
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
          and SG_SIGN is not null
          and PD_PROGRAM is not null
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="createdBy !=null">
            and CREATED_BY = #{createdBy}
        </if>
        union all
        select SG_SIGN
        FROM PM_CD_CONT_LOG
        where SG_SIGN is not null
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="createdBy !=null">
            and CREATED_BY = #{createdBy}
        </if>) t order by SG_SIGN ASC
    </select>
    <select id="selectPlateInfoCount" resultType="java.lang.Integer">
        select COUNT(*)
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
          and SG_SIGN is not null
          and PD_PROGRAM is not null
          and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
          and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
    </select>
    <select id="selectPlateInfoSum" resultType="java.lang.Long">
        select SUM(MAT_ACT_WT)
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
          and SG_SIGN is not null
          and PD_PROGRAM is not null
          and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
    </select>
    <select id="selectSlabNoList" resultType="java.lang.String">
        select t1.PLATE_NO
        from PM_PD_CONT_SUM t1
                 join QD_TO_PO_ORDER t2 on t1.ORDER_NO = t2.ORDER_NO
        where t2.ORDER_TYPE_CODE != 'YZA' and t1.PLATE_NO is not null
    </select>

    <select id="selectPlateInfo" resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpouupn, SUM(MAT_ACT_WT) as hpouup
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
        <if test="orderTypeCode == 1">
            and SLAB_NO in
            <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
            #{slabNo}
            </foreach>
        </if>
    </select>

    <select id="selectHpouupAndHpouupnInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpouupn, COALESCE(SUM(MAT_ACT_WT), 0) as hpouup
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="orderTypeCode == 1">
        <if test="slabNoList != null and slabNoList.size() > 0">
            and SLAB_NO in
            <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                #{slabNo}
            </foreach>
        </if>
        </if>
    </select>

    <select id="selectHpouup5mAndpouupn5m"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpouupn5m, COALESCE(SUM(MAT_ACT_WT), 0) as hpouup5m
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and SUBSTR(PLATE_NO, 5, 1) IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
    </select>
    <select id="selectHpouup5mAndpouupn5mInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpouupn5m, COALESCE(SUM(MAT_ACT_WT), 0) as hpouup5m
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and SUBSTR(PLATE_NO, 5, 1) IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="orderTypeCode == 1">
        <if test="slabNoList != null and slabNoList.size() > 0">
            and SLAB_NO in
            <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                #{slabNo}
            </foreach>
        </if>
        </if>
    </select>

    <select id="selectHpouup3mAndpouupn3m"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpouupn3m, SUM(MAT_ACT_WT) as hpouup3m
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and SUBSTR(PLATE_NO, 5, 1) NOT IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
    </select>

    <select id="selectHpouup3mAndpouupn3mInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpouupn3m, COALESCE(SUM(MAT_ACT_WT), 0) as hpouup3m
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and SUBSTR(PLATE_NO, 5, 1) NOT IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and SLAB_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
    </select>


    <select id="selectHpoaupAndSghpoaupnSign"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as sghpoaupnSign, SUM(WT) as hpoaup
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
        and MAT_NO NOT IN
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        <if test="orderTypeCode == 1">
            and ORDER_NO in
            <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                #{orderNo}
            </foreach>
        </if>
    </select>

    <select id="selectHpoaupAndSghpoaupnSignInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as sghpoaupnSign, COALESCE(SUM(WT), 0) as hpoaup
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="matNoList != null and matNoList.size() > 0">
        and MAT_NO NOT IN
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        </if>
        <if test="orderTypeCode == 1">
        <if test="orderNoList != null and orderNoList.size() > 0">
            and ORDER_NO in
            <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                #{orderNo}
            </foreach>
        </if>
        </if>
    </select>

    <select id="selectMatNoList" resultType="java.lang.String">
        select MAT_NO from PM_CD_CONT_LOG where FUNC_ID = 'pmoahp02_putup'
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
    </select>
    <select id="selectOrderNoList" resultType="java.lang.String">
        select order_no from QD_TO_PO_ORDER where ORDER_TYPE_CODE != 'YZA' AND ORDER_TYPE_CODE NOT LIKE 'N%'
    </select>
    <select id="selectHpoaup5mAndHpoaupn5m"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpoaupn5m, SUM(WT) as hpoaup5m
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and SUBSTR(PLATE_NO, 5, 1) IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
        and MAT_NO NOT IN
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        <if test="orderTypeCode == 1">
            and ORDER_NO in
            <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                #{orderNo}
            </foreach>
        </if>
    </select>

    <select id="selectHpoaup5mAndHpoaupn5mInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpoaupn5m, COALESCE(SUM(WT), 0) as hpoaup5m
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and SUBSTR(MAT_NO, 5, 1) IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="matNoList != null and matNoList.size() > 0">
        and MAT_NO NOT IN
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        </if>
        <if test="orderTypeCode == 1">
        <if test="orderNoList != null and orderNoList.size() > 0">
            and ORDER_NO in
            <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                #{orderNo}
            </foreach>
        </if>
        </if>
    </select>


    <select id="selectHpoaup3mAndHpoaupn3m"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpoaupn3m, SUM(WT) as hpoaup3m
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and SUBSTR(PLATE_NO, 5, 1) NOT IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
        and MAT_NO NOT IN
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        <if test="orderTypeCode == 1">
            and ORDER_NO in
            <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                #{orderNo}
            </foreach>
        </if>

    </select>

    <select id="selectHpoaup3mAndHpoaupn3mInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as hpoaupn3m, COALESCE(SUM(WT), 0) as hpoaup3m
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and SUBSTR(MAT_NO, 5, 1) NOT IN ('K','L','M','N','O','P','Q','R','S','T')
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="matNoList != null and matNoList.size() > 0">
        and MAT_NO NOT IN
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        </if>
        <if test="orderTypeCode == 1">
        <if test="orderNoList != null and orderNoList.size() > 0">
            and ORDER_NO in
            <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                #{orderNo}
            </foreach>
        </if>
        </if>
    </select>

    <select id="selectSmouupAndSmouupn"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as smouupn, SUM(WT) as smouup
        FROM PM_PD_SLAB_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
        <if test="orderTypeCode == 1">
            and SLAB_NO in
            <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                #{slabNo}
            </foreach>
        </if>
    </select>

    <select id="selectSmouupAndSmouupnInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as smouupn, COALESCE(SUM(MAT_ACT_WT), 0) as smouup
        FROM PM_PD_SLAB_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="orderTypeCode == 1">
        <if test="slabNoList != null and slabNoList.size() > 0">
            and SLAB_NO in
            <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                #{slabNo}
            </foreach>
        </if>
        </if>
    </select>

    <select id="selectSlabNo" resultType="java.lang.String">
        select PM_PD_CONT_SUM.SLAB_NO from PM_PD_CONT_SUM join QD_TO_PO_ORDER on PM_PD_CONT_SUM.ORDER_NO = QD_TO_PO_ORDER.ORDER_NO
        where QD_TO_PO_ORDER.ORDER_TYPE_CODE != 'YZA'
    </select>
    <select id="selectSmoaupAndSmoaupn"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as smoaupn, SUM(WT) as smoaup
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoasm01_putup'
        and SG_SIGN is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN in
        <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
            #{sgSign}
        </foreach>
        <if test="orderTypeCode == 1">
            and SLAB_NO in
            <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                #{slabNo}
            </foreach>
        </if>
    </select>
    <select id="selectSmoaupAndSmoaupnInfo"
            resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select COUNT(*) as smoaupn, COALESCE(SUM(WT), 0) as smoaup
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoasm01_putup'
        and SG_SIGN is not null
        and LAST_UPDATE_DATE BETWEEN #{timeFrom} AND #{timeTo}
        and SG_SIGN = #{sgSign}
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and MAT_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
    </select>

    <select id="selectOrderStatus" resultType="com.xisc.pm.domain.vo.CtMainVO">
        select
            ORDER_STATUS,
            ORDER_NO
        FROM CT_MAIN
        where ORDER_NO in
        <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
            #{orderNo}
        </foreach>
        <if test="tenantId !=null">
            and TENANT_ID = #{tenantId}
        </if>
    </select>

    <select id="selectGiveSampleFlag" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO">
        select
            GIVE_SAMPLE_FLAG,
            ORDER_NO
        FROM
            QD_TO_PO_ORDER
        where ORDER_NO in
        <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
            #{orderNo}
        </foreach>
        <if test="tenantId !=null">
            and TENANT_ID = #{tenantId}
        </if>
    </select>
    <select id="selectOrderStatusByOrderNo" resultType="java.lang.String">
        select ORDER_STATUS FROM CT_MAIN where ORDER_NO = #{orderNo}
    </select>
    <select id="selectMmSlabList" resultType="com.xisc.pm.domain.entity.MmSlab">
        select
        <include refid = "BaseSql2"/>
        from MM_SLAB MS
        where MS.SLAB_NO in
        <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
            #{slabNo}
        </foreach>
    </select>
    <select id="selectLackWgt" resultType="java.math.BigDecimal">
        select LACK_WGT FROM CT_DET WHERE ORDER_NO = #{orderNo} and WHOLE_BACKLOG_CODE = '9A' and SUB_BACKLOG_CODE is null
    </select>
    <select id="selectWmMatPileList" resultType="com.xisc.pm.domain.vo.WmMatPileVO1">
        select STOCK_CODE FROM WM_MAT_PILE WHERE MAT_NO in
        <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
            #{slabNo}
        </foreach>
    </select>
    <select id="selectMmPateList" resultType="com.xisc.pm.domain.vo.MmPlateVO">
        select
        <include refid = "BaseSql"/>
        from MM_PLATE MP
        where MP.MAT_STATUS = #{matStatus}
        and MP.MAT_NO in
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
        and MP.REC_STS ='2'
    </select>
    <select id="selectOrderInfo" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select
        <include refid = "BaseSql3"/>
            from QD_TO_PO_ORDER QTPO
        where
            QTPO.ORDER_NO in
        <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
            #{orderNo}
        </foreach>
        and QTPO.TENANT_ID = #{tenantId}
    </select>
    <select id="selectQdtoLineupResultRolling" resultType="com.xisc.pm.domain.vo.QdToLineupResultRollingVO">
        select DISTINCT
            MSC_LINE_NO,
            ROLL_DIRECT_CODE,
            CTRL_ROLL_CODE
        FROM
           QD_TO_LINEUP_RESULT_ROLLING
        where
        ORDER_NO = #{orderNo}
        and TENANT_ID = #{tenantId}
        and MSC_LINE_NO in
        <foreach collection="mscLineNoList" item="mscLineNo" open="(" separator="," close=")">
            #{mscLineNo}
        </foreach>
    </select>
    <select id="selectQdToLineupResultSizing" resultType="com.xisc.pm.domain.vo.QdToLineupResultSizingVO1">
        select ULT_CODE FROM QD_TO_LINEUP_RESULT_SIZING where
         ORDER_NO in
        <foreach collection="orgOrderNoList" item="orgOrderNo" open="(" separator="," close=")">
            #{orgOrderNo}
        </foreach>
    </select>
    <select id="selectMscLineNo" resultType="java.lang.String">
        select MSC_LINE_NO
        FROM QD_TO_PO_LINE_COMB where ORDER_NO = #{orderNo}
    </select>
    <select id="selectComplexDecideCode" resultType="java.lang.String">
        select COMPLEX_DECIDE_CODE from MM_PLATE where MAT_NO = #{ponoSlabNo} and REC_STS = '2'
    </select>
    <select id="selectOrdRemNum" resultType="java.lang.Long">
        select ORD_REM_NUM from CT_MAIN where ORDER_NO = #{orderNo}
    </select>
    <select id="selectOrdRemWgt" resultType="java.math.BigDecimal">
        select ORD_REM_WGT from CT_MAIN where ORDER_NO = #{orderNo}
    </select>
    
    <select id="selectMmRolling" resultType="com.xisc.pm.domain.vo.MmRollingVo">
    	select 
    	  <!-- mrm.MSC_LINE_NO, -->
    	  mrm.ROLL_DIRECT_CODE,
    	  mrm.AD_MODE_CODE,
    	  mrm.CTRL_ROLL_CODE
    	from
    	<if test="rollLineNo != null and rollLineNo == '10'.toString()">
    		MM_ROLLING_M1 mrm
    	</if>
    	<if test="rollLineNo != null and rollLineNo == '20'.toString()">
    		MM_ROLLING_M2 mrm
    	</if>
    	<if test="rollLineNo != null and rollLineNo == '30'.toString()">
    		MM_ROLLING_M3 mrm
    	</if>
    	where mrm.TENANT_ID = #{tenantId}
    	and mrm.MAT_NO = #{matNo}
    	and mrm.PROD_YEAR = #{prodYear}
    </select>

    <select id="batchSelectHpouupAndHpouupnInfo" resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
               COUNT(*) as hpouupn,
               COALESCE(SUM(MAT_ACT_WT), 0) as hpouup,
               SG_SIGN
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and PLATE_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
        group by SG_SIGN
    </select>

    <select id="batchSelectHpouup5mAndpouupn5mInfo" resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
            COUNT(*) as hpouupn5m,
            COALESCE(SUM(MAT_ACT_WT), 0) as hpouup5m,
            SG_SIGN
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and MSC_LINE_NO LIKE '10%'
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and PLATE_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
        group by SG_SIGN
    </select>

    <select id="batchSelectHpouup3mAndpouupn3mInfo" resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
            COUNT(*) as hpouupn3m,
            COALESCE(SUM(MAT_ACT_WT), 0) as hpouup3m,
            SG_SIGN
        FROM PM_PD_PLATE_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        and MSC_LINE_NO LIKE '00%'
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and PLATE_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
        group by SG_SIGN
    </select>

    <select id="batchSelectHpoaupAndSghpoaupnSignInfo"  resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
        count (1) AS sghpoaupnSign,
        COALESCE( SUM( t.WT ), 0 ) AS hpoaup,
        t.SG_SIGN
        from
        (SELECT
        MAT_NO,
        SG_SIGN,
        WT,
        ROW_NUMBER ( ) OVER ( PARTITION BY MAT_NO,SG_SIGN ORDER BY CREATION_DATE DESC ) AS row_num
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="orderNoList != null and orderNoList.size() > 0">
                and ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                    #{orderNo}
                </foreach>
            </if>
        </if>
        ) t
        where
        t.row_num = 1
        GROUP BY  t.SG_SIGN
    </select>

    <select id="batchSelectHpoaup5mAndHpoaupn5mInfo"  resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
        COUNT(1) as hpoaupn5m,
        COALESCE(SUM(t.WT), 0) as hpoaup5m,
        t.SG_SIGN
        from
        (SELECT
        MAT_NO,
        SG_SIGN,
        WT,
        ROW_NUMBER ( ) OVER ( PARTITION BY MAT_NO,SG_SIGN ORDER BY CREATION_DATE DESC ) AS row_num
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and MSC_LINE_NO LIKE '10%'
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="orderNoList != null and orderNoList.size() > 0">
                and ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                    #{orderNo}
                </foreach>
            </if>
        </if>
        ) t
        where
        t.row_num = 1
        GROUP BY  t.SG_SIGN
    </select>

    <select id="batchSelectHpoaup3mAndHpoaupn3mInfo"  resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
        COUNT(1) as hpoaupn3m,
        COALESCE(SUM(t.WT), 0) as hpoaup3m,
        t.SG_SIGN
        from
        (SELECT
        MAT_NO,
        SG_SIGN,
        WT,
        ROW_NUMBER ( ) OVER ( PARTITION BY MAT_NO,SG_SIGN ORDER BY CREATION_DATE DESC ) AS row_num
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoahp02_putup'
        and SG_SIGN is not null
        and MSC_LINE_NO LIKE '00%'
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="orderNoList != null and orderNoList.size() > 0">
                and ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
                    #{orderNo}
                </foreach>
            </if>
        </if>
        ) t
        where
        t.row_num = 1
        GROUP BY  t.SG_SIGN
    </select>

    <select id="batchSelectSmouupAndSmouupnInfo"  resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
            COUNT(*) as smouupn,
            COALESCE(SUM(MAT_ACT_WT), 0) as smouup,
            SG_SIGN
        FROM PM_PD_SLAB_INFO
        where PD_STATUS_HP = '27'
        and SG_SIGN is not null
        and PD_PROGRAM is not null
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and SLAB_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
        group by SG_SIGN
    </select>

    <select id="batchSelectSmoaupAndSmoaupnInfo"  resultType="com.xisc.pm.api.dto.PmFinishedProductsServeAsStatisticsDTO">
        select
            COUNT(1) as smoaupn,
            COALESCE(SUM(t.WT), 0) as smoaup,
            t.SG_SIGN
        FROM (
        SELECT
        MAT_NO,
        SG_SIGN,
        WT,
        ROW_NUMBER ( ) OVER ( PARTITION BY MAT_NO,SG_SIGN ORDER BY CREATION_DATE DESC ) AS row_num
        FROM PM_CD_CONT_LOG
        where FUNC_ID = 'pmoasm01_putup'
        and SG_SIGN is not null
        <if test="timeFrom !=null">
            and LAST_UPDATE_DATE &gt;= #{timeFrom}
        </if>
        <if test="timeTo != null">
            AND LAST_UPDATE_DATE &lt;= #{timeTo}
        </if>
        <if test="sgSignList != null and sgSignList.size() > 0">
            and SG_SIGN in
            <foreach collection="sgSignList" item="sgSign" open="(" separator="," close=")">
                #{sgSign}
            </foreach>
        </if>
        <if test="orderTypeCode == 1">
            <if test="slabNoList != null and slabNoList.size() > 0">
                and MAT_NO in
                <foreach collection="slabNoList" item="slabNo" open="(" separator="," close=")">
                    #{slabNo}
                </foreach>
            </if>
        </if>
        ) t
        where
        t.row_num = 1
        group by t.SG_SIGN
    </select>
    <select id="selectGiveSampleFlagByOrderNo" resultType="java.lang.String">
        select GIVE_SAMPLE_FLAG from QD_TO_PO_ORDER where ORDER_NO = #{orderNo}
    </select>
    <select id="selectMscLineNoList" resultType="com.xisc.pm.api.dto.WmConfmPlanMatDTO">
        select MAT_NO, MSC_LINE_NO from WM_CONFM_PLAN_MAT where
        MAT_NO in
        <foreach collection="matNoList" item="matNo" open="(" separator="," close=")">
            #{matNo}
        </foreach>
    </select>
    <select id="selectOrderInfoByOrderNo" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select MSC, PSC , APN FROM QD_TO_PO_ORDER where ORDER_NO = #{orderNo}
    </select>
    <select id="selectRollDirectCode" resultType="java.lang.String">
        select DISTINCT
            ROLL_DIRECT_CODE
        from
            QD_TO_LINEUP_RESULT_ROLLING
        where ORDER_NO = #{orderNo}
         and TENANT_ID = #{tenantId}
    </select>
    <select id="selectRollDirectCodeList" resultType="com.xisc.pm.domain.vo.MmPlateVO">
        select DISTINCT
            ORDER_NO,
            ROLL_DIRECT_CODE,
            ctrl_roll_code,
            MSC_LINE_NO
        from
        QD_TO_LINEUP_RESULT_ROLLING
        where ORDER_NO in
        <foreach collection="orgOrderNoList" item="orderNo" open="(" separator="," close=")">
            #{orderNo}
        </foreach>
        <if test="mscLineNoList != null and mscLineNoList.size()>0">
            and MSC_LINE_NO in
            <foreach collection="mscLineNoList" item="mscLineNo" open="(" separator="," close=")">
                #{mscLineNo}
            </foreach>
        </if>
        and TENANT_ID = #{tenantId}
    </select>
    <select id="selectOrderTypeCodeList" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO1">
        select ORDER_NO, ORDER_TYPE_CODE from QD_TO_PO_ORDER where ORDER_NO in
        <foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
            #{orderNo}
        </foreach>
    </select>
    <select id="selectListOrderStatusByOrderNo" resultType="com.xisc.pm.domain.vo.CtMainVO">
        select
        cm.ORDER_NO,
        cm.ORDER_STATUS
        FROM
        CT_MAIN cm
        <where>
            <if test="tenantId !=null">
                and cm.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoList != null and orderNoList.size()>0">
                and cm.ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator=",">
                    #{orderNo}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectGiveSampleFlagListByOrderNo" resultType="com.xisc.pm.domain.vo.QdToPoOrderVO">
        select
        qtpo.ORDER_NO,
        qtpo.GIVE_SAMPLE_FLAG,
        qtpo.ORDER_TYPE_CODE
        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=",">
                    #{orderNo}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getSubBacklogCode" resultType="com.xisc.pm.domain.vo.MmPlateSmallProVO">
        SELECT
            mpsp.MAT_NO,
            SUBSTR( mpsp.SUB_BACKLOG_CODE, 2, 1 ) as SUB_BACKLOG_CODE,
            mpsp.SUB_BACKLOG_SEQ
        FROM
            MM_PLATE_SMALL_PRO mpsp
        <where>
            mpsp.BACKLOG_ADD_DIV = '0'
            and BACKLOG_PASS_TIME is not null
            and SUBSTR( mpsp.SUB_BACKLOG_CODE, 2, 1 ) IN ( 'A', 'Q', 'N', 'T' )
            <if test="tenantId !=null">
                and mpsp.TENANT_ID = #{tenantId}
            </if>
            <if test="matNoList != null and matNoList.size()>0">
                and  mpsp.MAT_NO in
                <foreach collection="matNoList" item="matNo" open="(" close=")" separator=",">
                    #{matNo}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getHeatTreatType" resultType="com.xisc.pm.domain.vo.QdToLineupResultHeattreatVO">
        SELECT
        t.ORDER_NO,
        t.HEAT_TREATMENT_TYPE,
        t.MSC_LINE_NO
        FROM
        (
        SELECT
        qlrh.ORDER_NO,
        qlrh.HEAT_TREATMENT_TYPE,
        qlrh.MSC_LINE_NO,
        ROW_NUMBER ( ) OVER ( PARTITION BY qlrh.ORDER_NO ORDER BY qlrh.CREATION_DATE ASC ) AS rn
        FROM
        QD_TO_LINEUP_RESULT_HEATTREAT qlrh
        <where>
            <if test="tenantId !=null">
                and qlrh.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoAllList != null and orderNoAllList.size()>0">
                and qlrh.ORDER_NO in
                <foreach collection="orderNoAllList" item="orderNo" open="(" close=")" separator=",">
                    #{orderNo}
                </foreach>
            </if>
            <if test="mscLineNoList != null and mscLineNoList.size()>0">
                and qlrh.MSC_LINE_NO in
                <foreach collection="mscLineNoList" item="mscLineNo" open="(" close=")" separator=",">
                    #{mscLineNo}
                </foreach>
            </if>
        </where>
        ) t
        WHERE
        t.rn = 1
    </select>

    <select id="selectUtCode" resultType="com.xisc.pm.domain.vo.QdToLineupResultUTVO">
        SELECT DISTINCT
            qtru.ORDER_NO,
            qtru.UT_CODE,
            qtru.UT_STDNAME,
            qtru.UT_GRADE
        FROM
            QD_TO_LINEUP_RESULT_UT qtru
        <where>
            <if test="tenantId !=null">
                and qtru.TENANT_ID = #{tenantId}
            </if>
            <if test="orderNoList != null and orderNoList.size()>0">
                and  (qtru.ORDER_NO in
                <foreach collection="orderNoList" item="orderNo" open="(" close=")" separator="," index="index">
                    <if test="(index % 999) == 998"> NULL ) OR qtru.ORDER_NO in (</if> #{orderNo}
                </foreach>)
            </if>
        </where>
    </select>

    <select id="selectResutCode" resultType="com.xisc.pm.domain.vo.MmUstRsltVO">
        SELECT
           mur.PLATE_NO,
           mur.DETECT_RESULT_CODE
        FROM
            MM_UST_RSLT mur
        <where>
            <if test="tenantId !=null">
                and mur.TENANT_ID = #{tenantId}
            </if>
            <if test="matNoList != null and matNoList.size()>0">
                and  mur.PLATE_NO in
                <foreach collection="matNoList" item="matNo" open="(" close=")" separator=",">
                    #{matNo}
                </foreach>
            </if>
            <if test="utCodeList != null and utCodeList.size()>0">
                and  mur.UST_STAND in
                <foreach collection="utCodeList" item="utCode" open="(" close=")" separator=",">
                    #{utCode}
                </foreach>
            </if>
        </where>
    </select>

    <select id="queryStockLineByMatNo" resultType="com.xisc.pm.domain.vo.WmStockInfoVO">
        SELECT DISTINCT
            wmp.MAT_NO,
            wsi.STOCK_LINE,
            wsi.STOCK_CODE
        FROM
            WM_MAT_PILE wmp
                JOIN WM_STOCK_INFO wsi ON wmp.STOCK_CODE = wsi.STOCK_CODE
        <where>
            <if test="tenantId !=null">
                and wmp.TENANT_ID = #{tenantId}
            </if>
            <if test="matNoList != null and matNoList.size()>0">
                and  wmp.MAT_NO in
                <foreach collection="matNoList" item="matNo" open="(" close=")" separator=",">
                    #{matNo}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getMmPlateByMatNo" resultType="com.xisc.pm.domain.vo.MmPlateVO">
        SELECT
            mp.PROD_YEAR,
            mp.MAT_NO,
            mp.PROD_CD,
            mp.PROC_CD,
            mp.MAT_STATUS,
			mp.WHOLE_BACKLOG_CODE,
            mp.rec_sts
        FROM
            MM_PLATE mp
        <where>
            <if test="tenantId !=null">
                and mp.TENANT_ID = #{tenantId}
            </if>
            <if test="matNoList != null and matNoList.size()>0">
                and mp.MAT_NO in
                <foreach collection="matNoList" item="matNo" open="(" close=")" separator=",">
                    #{matNo}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getMmPlateByPrimaryPlateId" resultType="com.xisc.pm.domain.vo.MmPlateVO">
        select
        <include refid = "BaseSql"/>
        from MM_PLATE MP
        where
           MP.TENANT_ID = #{tenantId}
           and MP.PLATE_ID in
           <foreach collection="mmPlateIdList" item="plateId" open="(" close=")" separator=",">
                #{plateId}
           </foreach>
    </select>
</mapper>
