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


    <sql id = "BaseSql">
    PPSG.POLICY_ST_GROUP_ID,
    PPSG.POLICY_ID,
    PPSG.STEEL_GROUP_CODE,
    PPSG.TENANT_ID,
    PPSG.ATTRIBUTE1,
    PPSG.ATTRIBUTE2,
    PPSG.ATTRIBUTE3,
    PPSG.ATTRIBUTE4,
    PPSG.ATTRIBUTE5,
    PPSG.creation_date,    PPSG.created_by,    PPSG.last_updated_by,    PPSG.last_update_date,    PPSG.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmPolicySteelGroup">
        select
        <include refid = "BaseSql"/>
        from PM_POLICY_STEEL_GROUP PPSG
        <where>
            <if test="policyStGroupId !=null">
                and PPSG.POLICY_ST_GROUP_ID = #{policyStGroupId,jdbcType = INTEGER}
            </if>
            <if test="policyId !=null">
                and PPSG.POLICY_ID = #{policyId,jdbcType = INTEGER}
            </if>
            <if test="steelGroupCode !=null">
                and PPSG.STEEL_GROUP_CODE = #{steelGroupCode,jdbcType = VARCHAR}
            </if>
            <if test="tenantId !=null">
                and PPSG.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PPSG.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PPSG.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PPSG.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PPSG.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PPSG.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>
    
    <select id="selectStNoList" resultType="com.xisc.pm.app.service.autoboard.dto.PmPolicyStDTO">
    	select ppsg.POLICY_ID ,ppsg.STEEL_GROUP_CODE , pstg.ST_NO from PM_POLICY_STEEL_GROUP ppsg
		LEFT JOIN PM_STEEL_TYPE_GROUP pstg on ppsg.STEEL_GROUP_CODE = pstg.STEEL_GROUP_CODE and pstg.VALID_FLAG = 1
		where ppsg.TENANt_ID = #{tenantId}
		and ppsg.POLICY_ID in 
		<foreach collection="policyIdList" item="policyId" open="(" close=")" separator=",">
			#{policyId}
		</foreach>
    </select>
</mapper>

