<?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="cn.cecep.talroad.mapper.PCodAreaInfoMapper">

    <!-- 通用查询映射结果 -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.cecep.talroad.domain.PCodeAreaInfo">
        <id column="area_code" property="areaCode" />
        <result column="area_name" property="areaName" />
        <result column="longitude" property="longitude" />
        <result column="latitude" property="latitude" />
        <result column="is_used" property="isUsed" />
        <result column="area_type" property="areaType" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        area_code, area_name, longitude, latitude, is_used,area_type
    </sql>

    <select id="findDataPollution" resultType="cn.cecep.talroad.domain.vo.ControlVo">
        SELECT
            distinct
            p.control_level_id as controlLevelId,
            p.region_code,
            s.level_code ,
            s.level_name,
            s.level_name as label,
            p.control_level_id as value,
            s.control_type
        FROM
            p_code_region_control p
            LEFT JOIN s_envgas_station_control s ON s.pk_id = p.control_level_id  WHERE  p.type=#{type}
        <foreach collection="controlList" item="name" open="and  p.region_code in (" separator="," close=")">
            #{name}
        </foreach>

        <if test="controlType != null and controlType != ''">
           and  s.control_type=#{controlType}
        </if>
        order by p.control_level_id
    </select>
    <select id="findJurisdictionData" resultType="java.util.Map">
        SELECT  region_code as "regionCode", region_name as "regionName"
        FROM
            p_code_region
        <where>
            region_code = #{regionCode}   OR parent_code = #{regionCode}
        </where>
    </select>
    <select id="getIndustryCategoryList" resultType="java.util.Map">
        SELECT id,name as label,code as value, layer FROM s_envgas_industry_category
        <where>
            <if test="value != null and value !=''">
                and code like concat(#{value},'%')
            </if>
            <if test="layer != null and layer !=''">
                and layer=#{layer}
            </if>
        </where>
    </select>

</mapper>
