<?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.nantian.cloud.dbcapp.mapper.record.AccessUnionQuotaVoMapper">

    <select id="getAccessQuota" resultType="com.nantian.cloud.dbcapp.vo.AccessUnionQuotaVo">
        SELECT
            info.id AS id,
            info.enterprise_code AS enterprise_code,
            info.cmp_name AS cmp_name,
            quo.record_date AS record_date,
            info.register_date AS register_date,
            info.register_address AS register_address,
            dict.tname
        FROM
            access_enterprise_info AS info
                INNER JOIN access_product_quota AS quo ON info.enterprise_code = quo.enterprise_code
                AND info.state = 2
                AND info.del_flag = 1
                AND quo.del_flag = 1
                <if test="year != null and year != ''">
                    AND LEFT ( quo.record_date ,4) = #{year}
                </if>
                <if test="dictid != null and dictid != ''">
                    AND LEFT ( RIGHT ( info.region_code, 6 ), 4 ) =LEFT ( #{dictid},4 )
                </if>

        LEFT JOIN dict_region AS dict ON LEFT ( RIGHT ( info.region_code, 6 ), 4 ) = LEFT ( dict.id, 4 )

        GROUP BY
            info.enterprise_code,
            quo.record_date
    </select>
</mapper>