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


    <sql id = "BaseSql">
    PASS.ID,
    PASS.SUBSTITUTION_RATE,
    PASS.RESIDUE_LEN,
    PASS.MAT_LEN_MIN,
    PASS.MAT_LEN_MAX,
    PASS.MAT_WIDTH_MIN,
    PASS.MAT_WIDTH_MAX,
    PASS.MAT_THICK_MIN,
    PASS.MAT_THICK_MAX,
    PASS.ORDER_WIDTH_MIN,
    PASS.ORDER_WIDTH_MAX,
    PASS.ORDER_THICK_MIN,
    PASS.ORDER_THICK_MAX,
    PASS.DELIVY_DATE_FROM,
    PASS.DELIVY_DATE_TO,
    PASS.IS_USE_ST,
    PASS.USEABLE_DSTOCK,
    PASS.IS_START_FLAG,
    PASS.START_TIME,
    PASS.END_TIME,
    PASS.PRI_MODE,
    PASS.STOCK_RATE,
    PASS.STOCK_DAY,
    PASS.DELIVERY_RATE,
    PASS.XH_COST,
    PASS.FG_COST,
    PASS.DELIVERY_OFFSET_DAY,
    PASS.TENANT_ID,
    PASS.ATTRIBUTE1,
    PASS.ATTRIBUTE2,
    PASS.ATTRIBUTE3,
    PASS.ATTRIBUTE4,
    PASS.ATTRIBUTE5,
    PASS.TRIGGER_CYCLE,
    PASS.OVERSHOOT_CONDITION,
    PASS.creation_date,    PASS.created_by,    PASS.last_updated_by,    PASS.last_update_date,    PASS.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmAutoSubSetting">
        select
        <include refid = "BaseSql"/>
        from PM_AUTO_SUB_SETTING PASS
        <where>
            <if test="id !=null">
                and PASS.ID = #{id,jdbcType = INTEGER}
            </if>
            <if test="substitutionRate !=null">
                and PASS.SUBSTITUTION_RATE = #{substitutionRate,jdbcType = INTEGER}
            </if>
            <if test="residueLen !=null">
                and PASS.RESIDUE_LEN = #{residueLen,jdbcType = INTEGER}
            </if>
            <if test="matLenMin !=null">
                and PASS.MAT_LEN_MIN = #{matLenMin,jdbcType = INTEGER}
            </if>
            <if test="matLenMax !=null">
                and PASS.MAT_LEN_MAX = #{matLenMax,jdbcType = INTEGER}
            </if>
            <if test="matWidthMin !=null">
                and PASS.MAT_WIDTH_MIN = #{matWidthMin,jdbcType = INTEGER}
            </if>
            <if test="matWidthMax !=null">
                and PASS.MAT_WIDTH_MAX = #{matWidthMax,jdbcType = INTEGER}
            </if>
            <if test="matThickMin !=null">
                and PASS.MAT_THICK_MIN = #{matThickMin,jdbcType = INTEGER}
            </if>
            <if test="matThickMax !=null">
                and PASS.MAT_THICK_MAX = #{matThickMax,jdbcType = INTEGER}
            </if>
            <if test="orderWidthMin !=null">
                and PASS.ORDER_WIDTH_MIN = #{orderWidthMin,jdbcType = INTEGER}
            </if>
            <if test="orderWidthMax !=null">
                and PASS.ORDER_WIDTH_MAX = #{orderWidthMax,jdbcType = INTEGER}
            </if>
            <if test="orderThickMin !=null">
                and PASS.ORDER_THICK_MIN = #{orderThickMin,jdbcType = INTEGER}
            </if>
            <if test="orderThickMax !=null">
                and PASS.ORDER_THICK_MAX = #{orderThickMax,jdbcType = INTEGER}
            </if>
            <if test="delivyDateFrom !=null">
                and PASS.DELIVY_DATE_FROM = #{delivyDateFrom,jdbcType = OTHER}
            </if>
            <if test="delivyDateTo !=null">
                and PASS.DELIVY_DATE_TO = #{delivyDateTo,jdbcType = OTHER}
            </if>
            <if test="isUseSt !=null">
                and PASS.IS_USE_ST = #{isUseSt,jdbcType = VARCHAR}
            </if>
            <if test="useableDstock !=null">
                and PASS.USEABLE_DSTOCK = #{useableDstock,jdbcType = VARCHAR}
            </if>
            <if test="isStartFlag !=null">
                and PASS.IS_START_FLAG = #{isStartFlag,jdbcType = VARCHAR}
            </if>
            <if test="startTime !=null">
                and PASS.START_TIME = #{startTime,jdbcType = OTHER}
            </if>
            <if test="endTime !=null">
                and PASS.END_TIME = #{endTime,jdbcType = OTHER}
            </if>
            <if test="priMode !=null">
                and PASS.PRI_MODE = #{priMode,jdbcType = VARCHAR}
            </if>
            <if test="stockRate !=null">
                and PASS.STOCK_RATE = #{stockRate,jdbcType = INTEGER}
            </if>
            <if test="stockDay !=null">
                and PASS.STOCK_DAY = #{stockDay,jdbcType = INTEGER}
            </if>
            <if test="deliveryRate !=null">
                and PASS.DELIVERY_RATE = #{deliveryRate,jdbcType = INTEGER}
            </if>
            <if test="xhCost !=null">
                and PASS.XH_COST = #{xhCost,jdbcType = INTEGER}
            </if>
            <if test="fgCost !=null">
                and PASS.FG_COST = #{fgCost,jdbcType = INTEGER}
            </if>
            <if test="deliveryOffsetDay !=null">
                and PASS.DELIVERY_OFFSET_DAY = #{deliveryOffsetDay,jdbcType = INTEGER}
            </if>
            <if test="tenantId !=null">
                and PASS.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PASS.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PASS.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PASS.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PASS.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PASS.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
            <if test="triggerCycle !=null">
                and PASS.TRIGGER_CYCLE = #{triggerCycle,jdbcType = INTEGER}
            </if>
            <if test="overshootCondition !=null">
                and PASS.OVERSHOOT_CONDITION = #{overshootCondition,jdbcType = VARCHAR}
            </if>
        </where>
    </select>

    <select id = "selectPmAutoSubSetting" resultType = "com.xisc.pm.domain.entity.PmAutoSubSetting">
        select
        <include refid="BaseSql"/>
        from PM_AUTO_SUB_SETTING PASS
        WHERE ROWNUM = 1
    </select>
</mapper>

