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


    <sql id = "BaseSql">
    PSEP.SLAB_ESTA_PLAN_ID,
    PSEP.VIRTUAL_SLAB_NO,
    PSEP.ORDER_NO,
    PSEP.USER_ID,
    PSEP.ST_NO,
    PSEP.STEEL_APP_DATE,
    PSEP.ROLL_APP_DATE,
    PSEP.WHOLE_BACKLOG_CODE,
    PSEP.MAIN_BACKLOG_CODE,
    PSEP.PREC_CAST_LOT_NO,
    PSEP.PREC_PONO,
    PSEP.TMP_SLAB_NO,
    PSEP.LSLAB_DESIGN_FLAG,
    PSEP.LSLAB_T_B_FLAG,
    PSEP.SLAB_SEQ_FLOW,
    PSEP.SLAB_SEQ_HEAT,
    PSEP.CAST_LOT_NO,
    PSEP.CAST_LOT_DIV_NO,
    PSEP.PONO,
    PSEP.PREC_SLAB_NO,
    PSEP.ROLL_PLAN_NO,
    PSEP.MAT_SEQ_NO,
    PSEP.YEAR_ID,
    PSEP.PLAN_ROLL_TIME,
    PSEP.STEEL_START_TIME,
    PSEP.STEEL_END_TIME,
    PSEP.CC_NUM,
    PSEP.CC_TYPE,
    PSEP.MOLD_WID,
    PSEP.MOLD_THICK,
    PSEP.APP_TYPE,
    PSEP.CS_PREC_PLAN_STATUS,
    PSEP.HS_PREC_PLAN_STATUS,
    PSEP.SLAB_THICK,
    PSEP.SLAB_WIDTH,
    PSEP.SLAB_LEN,
    PSEP.SLAB_WT,
    PSEP.APP_WT,
    PSEP.APP_NUM,
    PSEP.ACT_HOT_CHARGE_FLAG,
    PSEP.HEAT_CONFM_FLAG,
    PSEP.BILLET_TYPE,
    PSEP.DESCRIPTION,
    PSEP.REFINE_ROUTE_CODE,
    PSEP.PLAN_TYPE,
    PSEP.TENANT_ID,
    PSEP.ATTRIBUTE1,
    PSEP.ATTRIBUTE2,
    PSEP.ATTRIBUTE3,
    PSEP.ATTRIBUTE4,
    PSEP.ATTRIBUTE5,
    PSEP.creation_date,    PSEP.created_by,    PSEP.last_updated_by,    PSEP.last_update_date,    PSEP.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmSlabEstaPlan">
        select
        <include refid = "BaseSql"/>
        from PM_SLAB_ESTA_PLAN PSEP
        <where>
            <if test="slabEstaPlanId !=null">
                and PSEP.SLAB_ESTA_PLAN_ID = #{slabEstaPlanId,jdbcType = INTEGER}
            </if>
            <if test="virtualSlabNo !=null">
                and PSEP.VIRTUAL_SLAB_NO = #{virtualSlabNo,jdbcType = VARCHAR}
            </if>
            <if test="orderNo !=null">
                and PSEP.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="userId !=null">
                and PSEP.USER_ID = #{userId,jdbcType = VARCHAR}
            </if>
            <if test="stNo !=null">
                and PSEP.ST_NO = #{stNo,jdbcType = VARCHAR}
            </if>
            <if test="steelAppDate !=null">
                and PSEP.STEEL_APP_DATE = #{steelAppDate,jdbcType = OTHER}
            </if>
            <if test="rollAppDate !=null">
                and PSEP.ROLL_APP_DATE = #{rollAppDate,jdbcType = OTHER}
            </if>
            <if test="wholeBacklogCode !=null">
                and PSEP.WHOLE_BACKLOG_CODE = #{wholeBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="mainBacklogCode !=null">
                and PSEP.MAIN_BACKLOG_CODE = #{mainBacklogCode,jdbcType = VARCHAR}
            </if>
            <if test="precCastLotNo !=null">
                and PSEP.PREC_CAST_LOT_NO = #{precCastLotNo,jdbcType = VARCHAR}
            </if>
            <if test="precPono !=null">
                and PSEP.PREC_PONO = #{precPono,jdbcType = VARCHAR}
            </if>
            <if test="tmpSlabNo !=null">
                and PSEP.TMP_SLAB_NO = #{tmpSlabNo,jdbcType = VARCHAR}
            </if>
            <if test="lslabDesignFlag !=null">
                and PSEP.LSLAB_DESIGN_FLAG = #{lslabDesignFlag,jdbcType = VARCHAR}
            </if>
            <if test="lslabTBFlag !=null">
                and PSEP.LSLAB_T_B_FLAG = #{lslabTBFlag,jdbcType = VARCHAR}
            </if>
            <if test="slabSeqFlow !=null">
                and PSEP.SLAB_SEQ_FLOW = #{slabSeqFlow,jdbcType = INTEGER}
            </if>
            <if test="slabSeqHeat !=null">
                and PSEP.SLAB_SEQ_HEAT = #{slabSeqHeat,jdbcType = INTEGER}
            </if>
            <if test="castLotNo !=null">
                and PSEP.CAST_LOT_NO = #{castLotNo,jdbcType = VARCHAR}
            </if>
            <if test="castLotDivNo !=null">
                and PSEP.CAST_LOT_DIV_NO = #{castLotDivNo,jdbcType = INTEGER}
            </if>
            <if test="pono !=null">
                and PSEP.PONO = #{pono,jdbcType = VARCHAR}
            </if>
            <if test="precSlabNo !=null">
                and PSEP.PREC_SLAB_NO = #{precSlabNo,jdbcType = VARCHAR}
            </if>
            <if test="rollPlanNo !=null">
                and PSEP.ROLL_PLAN_NO = #{rollPlanNo,jdbcType = VARCHAR}
            </if>
            <if test="matSeqNo !=null">
                and PSEP.MAT_SEQ_NO = #{matSeqNo,jdbcType = INTEGER}
            </if>
            <if test="yearId !=null">
                and PSEP.YEAR_ID = #{yearId,jdbcType = INTEGER}
            </if>
            <if test="planRollTime !=null">
                and PSEP.PLAN_ROLL_TIME = #{planRollTime,jdbcType = OTHER}
            </if>
            <if test="steelStartTime !=null">
                and PSEP.STEEL_START_TIME = #{steelStartTime,jdbcType = OTHER}
            </if>
            <if test="steelEndTime !=null">
                and PSEP.STEEL_END_TIME = #{steelEndTime,jdbcType = OTHER}
            </if>
            <if test="ccNum !=null">
                and PSEP.CC_NUM = #{ccNum,jdbcType = INTEGER}
            </if>
            <if test="ccType !=null">
                and PSEP.CC_TYPE = #{ccType,jdbcType = VARCHAR}
            </if>
            <if test="moldWid !=null">
                and PSEP.MOLD_WID = #{moldWid,jdbcType = INTEGER}
            </if>
            <if test="moldThick !=null">
                and PSEP.MOLD_THICK = #{moldThick,jdbcType = INTEGER}
            </if>
            <if test="appType !=null">
                and PSEP.APP_TYPE = #{appType,jdbcType = VARCHAR}
            </if>
            <if test="csPrecPlanStatus !=null">
                and PSEP.CS_PREC_PLAN_STATUS = #{csPrecPlanStatus,jdbcType = VARCHAR}
            </if>
            <if test="hsPrecPlanStatus !=null">
                and PSEP.HS_PREC_PLAN_STATUS = #{hsPrecPlanStatus,jdbcType = VARCHAR}
            </if>
            <if test="slabThick !=null">
                and PSEP.SLAB_THICK = #{slabThick,jdbcType = INTEGER}
            </if>
            <if test="slabWidth !=null">
                and PSEP.SLAB_WIDTH = #{slabWidth,jdbcType = INTEGER}
            </if>
            <if test="slabLen !=null">
                and PSEP.SLAB_LEN = #{slabLen,jdbcType = INTEGER}
            </if>
            <if test="slabWt !=null">
                and PSEP.SLAB_WT = #{slabWt,jdbcType = INTEGER}
            </if>
            <if test="appWt !=null">
                and PSEP.APP_WT = #{appWt,jdbcType = INTEGER}
            </if>
            <if test="appNum !=null">
                and PSEP.APP_NUM = #{appNum,jdbcType = INTEGER}
            </if>
            <if test="actHotChargeFlag !=null">
                and PSEP.ACT_HOT_CHARGE_FLAG = #{actHotChargeFlag,jdbcType = VARCHAR}
            </if>
            <if test="heatConfmFlag !=null">
                and PSEP.HEAT_CONFM_FLAG = #{heatConfmFlag,jdbcType = VARCHAR}
            </if>
            <if test="billetType !=null">
                and PSEP.BILLET_TYPE = #{billetType,jdbcType = VARCHAR}
            </if>
            <if test="description !=null">
                and PSEP.DESCRIPTION = #{description,jdbcType = VARCHAR}
            </if>
            <if test="refineRouteCode !=null">
                and PSEP.REFINE_ROUTE_CODE = #{refineRouteCode,jdbcType = VARCHAR}
            </if>
            <if test="tenantId !=null">
                and PSEP.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PSEP.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PSEP.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PSEP.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PSEP.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PSEP.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>

    <select id="selectResvCode" resultType="com.xisc.pm.domain.vo.QeTqSampleGenVO">
        SELECT DISTINCT
            DELE_RESV_CODE,
            TMP_SLAB_NO
        FROM
            QE_TQ_SAMPLE_GEN qtsg
        <where>
            <if test="tenantId !=null">
                and qtsg.TENANT_ID = #{tenantId}
            </if>
            <if test="tmpSlabNoList != null and tmpSlabNoList.size() > 0">
            and qtsg.TMP_SLAB_NO in
            <foreach collection="tmpSlabNoList" item="tmpSlabNo" open="(" close=")" separator="," >
                #{tmpSlabNo}
            </foreach>
            </if>
        </where>
    </select>
</mapper>

