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


    <sql id = "BaseSql">
    PPL.PROD_LINE_ID,
    PPL.PROD_LINE_CODE,
    PPL.PROD_LINE_NAME,
    PPL.TM_ROLL_PL,
    PPL.PRIORITY,
    PPL.PROD_LINE_PRODUCTIVITY,
    PPL.VALID_FLAG,
    PPL.TENANT_ID,
    PPL.ATTRIBUTE1,
    PPL.ATTRIBUTE2,
    PPL.ATTRIBUTE3,
    PPL.ATTRIBUTE4,
    PPL.ATTRIBUTE5,
    PPL.creation_date,
    PPL.created_by,
    PPL.last_updated_by,
    PPL.last_update_date,
    PPL.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.api.dto.PmProductionLineDTO">
        select
        <include refid="BaseSql"/>
        from PM_PRODUCTION_LINE PPL
        <where>
            <if test="tenantId != null">
                and PPL.TENANT_ID = #{tenantId}
            </if>
            <if test="pmProductionLineDTO.tmRollPl !=null">
                and PPL.TM_ROLL_PL = #{pmProductionLineDTO.tmRollPl}
            </if>
            <if test="pmProductionLineDTO.prodLineCode !=null">
                <bind name="prodLineCode" value="'%' + pmProductionLineDTO.prodLineCode + '%'"/>
                and PPL.PROD_LINE_CODE LIKE #{prodLineCode}
            </if>
            <if test="pmProductionLineDTO.prodLineName !=null">
                <bind name="prodLineName" value="'%' + pmProductionLineDTO.prodLineName + '%'"/>
                and PPL.PROD_LINE_NAME LIKE #{prodLineName}
            </if>
        </where>
    </select>
</mapper>

