<?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.QdToPoLineCombMapper">


    <sql id = "BaseSql">
    QTPLC.POLC_ID,
    QTPLC.ORDER_NO,
    QTPLC.WHOLE_BACKLOG_NO,
    QTPLC.WHOLE_BACKLOG,
    QTPLC.MSC_LINE_TYPE,
    QTPLC.MSC_LINE_NO,
    QTPLC.APN,
    QTPLC.ST_NO,
    QTPLC.ST_GRADE,
    QTPLC.MAT_DESIGN_FLAG,
    QTPLC.ROLL_LEN_MAX_TNO,
    QTPLC.PREP_NUM,
    QTPLC.DEFAULT_FLAG,
    QTPLC.HOLD_FLAG,
    QTPLC.TENANT_ID,
    QTPLC.ATTRIBUTE1,
    QTPLC.ATTRIBUTE2,
    QTPLC.ATTRIBUTE3,
    QTPLC.ATTRIBUTE4,
    QTPLC.ATTRIBUTE5,
    QTPLC.creation_date,    QTPLC.created_by,    QTPLC.last_updated_by,    QTPLC.last_update_date,    QTPLC.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.vo.QdToPoLineCombVO1">
        select
        <include refid = "BaseSql"/>
        from QD_TO_PO_LINE_COMB QTPLC
        <where>
            <if test="polcId !=null">
                and QTPLC.POLC_ID = #{polcId,jdbcType = INTEGER}
            </if>
            <if test="orderNo !=null">
                and QTPLC.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="wholeBacklogNo !=null">
                and QTPLC.WHOLE_BACKLOG_NO = #{wholeBacklogNo,jdbcType = INTEGER}
            </if>
            <if test="wholeBacklog !=null">
                and QTPLC.WHOLE_BACKLOG = #{wholeBacklog,jdbcType = VARCHAR}
            </if>
            <if test="mscLineType !=null">
                and QTPLC.MSC_LINE_TYPE = #{mscLineType,jdbcType = VARCHAR}
            </if>
            <if test="mscLineNo !=null">
                and QTPLC.MSC_LINE_NO = #{mscLineNo,jdbcType = VARCHAR}
            </if>
            <if test="apn !=null">
                and QTPLC.APN = #{apn,jdbcType = VARCHAR}
            </if>
            <if test="stNo !=null">
                and QTPLC.ST_NO = #{stNo,jdbcType = VARCHAR}
            </if>
            <if test="stGrade !=null">
                and QTPLC.ST_GRADE = #{stGrade,jdbcType = VARCHAR}
            </if>
            <if test="matDesignFlag !=null">
                and QTPLC.MAT_DESIGN_FLAG = #{matDesignFlag,jdbcType = VARCHAR}
            </if>
            <if test="rollLenMaxTno !=null">
                and QTPLC.ROLL_LEN_MAX_TNO = #{rollLenMaxTno,jdbcType = VARCHAR}
            </if>
            <if test="prepNum !=null">
                and QTPLC.PREP_NUM = #{prepNum,jdbcType = INTEGER}
            </if>
            <if test="defaultFlag !=null">
                and QTPLC.DEFAULT_FLAG = #{defaultFlag,jdbcType = VARCHAR}
            </if>
            <if test="holdFlag !=null">
                and QTPLC.HOLD_FLAG = #{holdFlag,jdbcType = VARCHAR}
            </if>
            <if test="tenantId !=null">
                and QTPLC.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and QTPLC.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and QTPLC.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and QTPLC.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and QTPLC.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and QTPLC.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>
    
    <select id="selectPmContMscTech" resultType="com.xisc.pm.domain.entity.PmContMscTech">
    	select 
    		qtplc.ORDER_NO as ORDER_NO,
    		qtplc.MSC_LINE_NO as MSC_LINE_NO,
    		' ' as WHOLE_BACKLOG,
    		qtlrs.ST_NO as ST_NO,
			' ' as ST_NO1,
			' ' ST_NO2,
			' ' qtlrs.ST_NO3,
			' ' qtlrs.ST_NO4,
			qtlrs.ST_NO5,
			qtlrs.ST_NO6,
			qtlrs.ST_NO7,
			qtlrs.ST_NO8,
			qtlrs.ST_NO9,
			qtlrs.SLAB_PLACE_STD,
			qtlrs.SLAB_FINISH_CODE,
			qtlrs.FLAME_CLEAN_DIV,
			qtlrs.SLAB_DEST,
			qtlrs.EXPAND_QUOT
			
    	from QD_TO_PO_LINE_COMB qtplc 
    	left join QD_TO_LINEUP_RESULT_STEEL qtlrs on qtlrs.ORDER_NO = qtplc.ORDER_NO and qtlrs.MSC_LINE_NO = qtplc.MSC_LINE_NO
    	
    </select>
    
</mapper>
