<?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.jly.mapper.ConfigureGriddingMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jly.entity.ConfigureGridding">
        <id column="id" property="id"/>
        <result column="epc" property="epc"/>
        <result column="gridding_image_url" property="griddingImageUrl"/>
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
    </resultMap>

    <!--    <select id="getpageGridding" resultType="java.util.HashMap">-->
    <!--        SELECT i.cmp_name AS cmpName,o.epc,o.gridding_image_url AS griddingImageUrl ,d.collection_point_network AS img FROM configure_gridding o LEFT JOIN enterprise_info i ON o.epc = i.enterprise_code and o.del_flag = "1"-->
    <!--        LEFT JOIN dict_region r ON r.id = i.region_code LEFT JOIN dict_region dr ON dr.id = r.pid LEFT JOIN dict_region dir ON dir.id = dr.pid LEFT JOIN inspection_data d ON o.epc = d.enterprise_code-->
    <!--        <where>-->
    <!--            <if test="flag == 3">-->
    <!--                AND i.region_code = #{code}-->
    <!--            </if>-->
    <!--            <if test="flag == 2">-->
    <!--                AND dr.id = #{code}-->
    <!--            </if>-->
    <!--            <if test="flag == 1">-->
    <!--                AND dir.id = #{code}-->
    <!--            </if>-->
    <!--            <if test="industryCode != null and industryCode != ''">-->
    <!--                AND i.industry_code = #{industryCode}-->
    <!--            </if>-->
    <!--            <if test="cmpName != null and cmpName != ''">-->
    <!--                AND i.cmp_name LIKE CONCAT('%',#{cmpName},'%')-->
    <!--            </if>-->
    <!--        </where>-->
    <!--    </select>-->
    <select id="getpageGridding" resultType="java.util.HashMap">
        SELECT i.cmp_name AS
        cmpName,i.address,i.region_code,i.corporation_name,o.enterprise_code,o.collection_point_network AS img, i.region_code dept_id FROM
        inspection_data o LEFT JOIN enterprise_info i ON o.enterprise_code = i.enterprise_code and o.del_flag = "1"
        LEFT JOIN dict_region r ON r.id = i.region_code LEFT JOIN dict_region dr ON dr.id = r.pid LEFT JOIN dict_region
        dir ON dir.id = dr.pid
        where o.collection_point_network != "D"
        <if test="flag == 3">
            AND i.region_code = #{code}
        </if>
        <if test="flag == 2">
            AND dr.id = #{code}
        </if>
        <if test="flag == 1">
            AND dir.id = #{code}
        </if>
        <if test="industryCode != null and industryCode != ''">
            AND i.industry_code = #{industryCode}
        </if>
        <if test="cmpName != null and cmpName != ''">
            AND i.cmp_name LIKE CONCAT('%',#{cmpName},'%')
        </if>
        <if test="epc != null and epc != ''">
            AND i.enterprise_code = #{epc}
        </if>
    </select>

</mapper>
