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


    <sql id = "BaseSql">
    PCLS.ORDER_SPECTION_ID,
    PCLS.ORDER_NO,
    PCLS.ASSIGNED_PROD_LINE_ID,
    PCLS.MOLD_THICK,
    PCLS.MOLD_WID,
    PCLS.TENANT_ID,
    PCLS.ATTRIBUTE1,
    PCLS.ATTRIBUTE2,
    PCLS.ATTRIBUTE3,
    PCLS.ATTRIBUTE4,
    PCLS.ATTRIBUTE5,
    PCLS.creation_date,    PCLS.created_by,    PCLS.last_updated_by,    PCLS.last_update_date,    PCLS.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmContractLineSpec">
        select
        <include refid = "BaseSql"/>
        from PM_CONTRACT_LINE_SPEC PCLS
        <where>
            <if test="orderSpectionId !=null">
                and PCLS.ORDER_SPECTION_ID = #{orderSpectionId,jdbcType = INTEGER}
            </if>
            <if test="orderNo !=null">
                and PCLS.ORDER_NO = #{orderNo,jdbcType = VARCHAR}
            </if>
            <if test="assignedProdLineId !=null">
                and PCLS.ASSIGNED_PROD_LINE_ID = #{assignedProdLineId,jdbcType = INTEGER}
            </if>
            <if test="moldThick !=null">
                and PCLS.MOLD_THICK = #{moldThick,jdbcType = INTEGER}
            </if>
            <if test="moldWid !=null">
                and PCLS.MOLD_WID = #{moldWid,jdbcType = INTEGER}
            </if>
            <if test="tenantId !=null">
                and PCLS.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PCLS.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PCLS.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PCLS.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PCLS.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PCLS.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>

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

