<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.gridQy" name="小区功能">
    <select id="getGridNewQyByQyID" parameterType="map" resultType="map">
        SELECT
            a.id,
            a.qy_type,
            a.qy_id,
            a.`code`,
            a.state,
            a.old_area_id,
            a.old_street_id,
            a.old_community_id,
            a.old_residential_id,
            a.old_garden_id,
            a.new_area_id,
            a.new_street_id,
            a.new_community_id,
            a.new_residential_id,
            a.new_garden_id,
            a.create_by,
            a.create_time,
            a.update_by,
            a.update_time,
            a.log_num,
            a.refuse_reason
        FROM
            jl_grid_qy_log a
        WHERE
            a.state = '0'
        AND a.qy_id = #{qy_id}
    </select>
    <select id="getResidentialByID" parameterType="String" resultType="map">
        SELECT
            a.id,
            a.qy_type,
            a.qy_id,
            a.`code`,
            a.state,
            a.old_area_id,
            a.old_street_id,
            a.old_community_id,
            a.old_residential_id,
            a.old_garden_id,
            a.new_area_id,
            a.new_street_id,
            a.new_community_id,
            a.new_residential_id,
            a.new_garden_id,
            a.create_by,
            a.create_time,
            a.update_by,
            a.update_time,
            a.log_num,
            a.refuse_reason
        FROM
            jl_grid_qy_log a
        WHERE
            a.state = '0'
        AND ( a.old_residential_id = #{residential_id} OR a.new_residential_id = #{residential_id} )
    </select>

    <select id="getGardenByID" parameterType="String" resultType="map">
    SELECT
        a.id,
        a.qy_type,
        a.qy_id,
        a.`code`,
        a.state,
        a.old_area_id,
        a.old_street_id,
        a.old_community_id,
        a.old_residential_id,
        a.old_garden_id,
        a.new_area_id,
        a.new_street_id,
        a.new_community_id,
        a.new_residential_id,
        a.new_garden_id,
        a.create_by,
        a.create_time,
        a.update_by,
        a.update_time,
        a.log_num,
        a.refuse_reason
    FROM
        jl_grid_qy_log a
    WHERE
        a.state = '0'
    AND ( a.old_garden_id = #{garden_id} OR a.new_garden_id = #{garden_id} )
    </select>
    <select id="getBuildingLogByCommunityID" parameterType="String" resultType="map">
        SELECT
            id,
            building_id,
            examine_code,
            examine_type,
            community_id,
            old_garden_id,
            new_garden_id,
            create_time,
            create_by,
            company_code,
            change_num_json,
            begin_time,
            end_time,
            random,
            update_time
        FROM
            jl_grid_transfer_log_community
        WHERE
            community_id = #{community_id}
        AND examine_type IN ( '0', '1' )
    </select>
    <select id="getGardenLogByCommunityID" parameterType="String" resultType="map">
        SELECT
            id,
            examine_code,
            examine_type,
            community_id,
            garden_id,
            residential_id,
            create_time,
            create_by,
            company_code,
            change_num_json,
            begin_time,
            end_time,
            random,
            update_time
        FROM
            jl_grid_residential_garden
        WHERE
            community_id = #{community_id}
        AND examine_type IN ( '0', '1' )
    </select>
    <select id="getJudgeResidentialForQYID" parameterType="String" resultType="map">
        SELECT
            a.id,
            a.qy_type,
            a.qy_id,
            a.`code`,
            a.state,
            a.old_area_id,
            a.old_street_id,
            a.old_community_id,
            a.old_residential_id,
            a.old_garden_id,
            a.new_area_id,
            a.new_street_id,
            a.new_community_id,
            a.new_residential_id,
            a.new_garden_id,
            a.create_by,
            a.create_time,
            a.update_by,
            a.update_time,
            a.log_num,
            a.refuse_reason
        FROM
            jl_grid_qy_log a
        WHERE
            a.state = '0'
        AND a.qy_id = #{residential_id}
    </select>
    <select id="getJudgeGardenForQYID" parameterType="String" resultType="map">
        SELECT
            a.id,
            a.qy_type,
            a.qy_id,
            a.`code`,
            a.state,
            a.old_area_id,
            a.old_street_id,
            a.old_community_id,
            a.old_residential_id,
            a.old_garden_id,
            a.new_area_id,
            a.new_street_id,
            a.new_community_id,
            a.new_residential_id,
            a.new_garden_id,
            a.create_by,
            a.create_time,
            a.update_by,
            a.update_time,
            a.log_num,
            a.refuse_reason
        FROM
            jl_grid_qy_log a
        WHERE
            a.state = '0'
        AND a.qy_id = #{garden_id}
    </select>
    <select id="getJudgeBuildingForQYID" parameterType="String" resultType="map">
        SELECT
            a.id,
            a.qy_type,
            a.qy_id,
            a.`code`,
            a.state,
            a.old_area_id,
            a.old_street_id,
            a.old_community_id,
            a.old_residential_id,
            a.old_garden_id,
            a.new_area_id,
            a.new_street_id,
            a.new_community_id,
            a.new_residential_id,
            a.new_garden_id,
            a.create_by,
            a.create_time,
            a.update_by,
            a.update_time,
            a.log_num,
            a.refuse_reason
        FROM
            jl_grid_qy_log a
        WHERE
            a.state = '0'
        AND a.qy_id = #{building_id}
    </select>
    <select id="getQYByCode" parameterType="map" resultType="map">
        SELECT
            id,
            qy_type,
            qy_id,
            `code`,
            state,
            old_area_id,
            old_street_id,
            old_community_id,
            old_residential_id,
            old_garden_id,
            new_area_id,
            new_street_id,
            new_community_id,
            new_residential_id,
            new_garden_id,
            create_by,
            create_time,
            update_by,
            update_time,
            log_num,
            refuse_reason
        FROM
            jl_grid_qy_log
        WHERE
            state = '0'
        AND
            code = #{code}
    </select>
    <select id="getResidentialInfo" parameterType="String" resultType="map">
    SELECT
        id,
        `name`,
        address,
        measure,
        grade,
        csc_mapjson,
        area_id,
        street_id,
        community_id,
        create_by,
        create_time,
        update_by,
        update_time,
        map_type,
        manager,
        binding,
        del_flag,
        parent_ids,
        company_code,
        szdwbb,
        szdzbbb,
        type,
        csc_mapjson_ht,
        qh_code
    FROM
        jl_grid_residential
    WHERE
        id = #{residential_id}
    </select>
    <select id="getGardenInfo" parameterType="String" resultType="map">
        SELECT
            id,
            `name`,
            grade,
            csc_mapjson,
            company_code,
            area_id,
            street_id,
            community_id,
            residential_id,
            del_flag,
            create_by,
            create_time,
            update_by,
            update_time,
            map_type,
            manager,
            manager_tel,
            binding,
            parent_ids,
            net_id,
            csc_mapjson_ht,
            count,
            time,
            qh_code
        FROM
            jl_grid_garden
        WHERE
            id = #{garden_id}
    </select>
    <select id="getGardenInfoBYQYID" parameterType="String" resultType="map">
        SELECT
            id,
            `name`,
            grade,
            csc_mapjson,
            company_code,
            area_id,
            street_id,
            community_id,
            residential_id,
            del_flag,
            create_by,
            create_time,
            update_by,
            update_time,
            map_type,
            manager,
            manager_tel,
            binding,
            parent_ids,
            net_id,
            csc_mapjson_ht,
            count,
            time,
            qh_code
        FROM
            jl_grid_garden
        WHERE
            id = #{qy_id}
    </select>
    <select id="getBuildingInfo" parameterType="String" resultType="map">
        SELECT
            id,
            brand,
            `name`,
            grade,
            csc_mapjson,
            company_code,
            area_id,
            street_id,
            community_id,
            residential_id,
            garden_id,
            del_flag,
            create_by,
            create_time,
            update_by,
            update_time,
            map_type,
            manager,
            manager_tel,
            parent_ids,
            build_type,
            csc_mapjson_ht
        FROM
            jl_grid_building
        WHERE
            id = #{building_id}
    </select>
    <select id="getBuildingInfoBYQYID" parameterType="String" resultType="map">
        SELECT
            id,
            brand,
            `name`,
            grade,
            csc_mapjson,
            company_code,
            area_id,
            street_id,
            community_id,
            residential_id,
            garden_id,
            del_flag,
            create_by,
            create_time,
            update_by,
            update_time,
            map_type,
            manager,
            manager_tel,
            parent_ids,
            build_type,
            csc_mapjson_ht
        FROM
            jl_grid_building
        WHERE
            id = #{qy_id}
    </select>

    <update id="updateResidentialForQYResidential" parameterType="map">
        UPDATE jl_grid_residential
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            qh_code = null
        WHERE
            id = #{qy_id}
            AND area_id = #{old_area_id}
            AND street_id = #{old_street_id}
            AND community_id = #{old_community_id}
    </update>
    <update id="updateGardenForQYResidential" parameterType="map">
        UPDATE jl_grid_garden
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            qh_code = null
        WHERE
            residential_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
    </update>
    <update id="updateBuildingForQYResidential" parameterType="map">
        UPDATE jl_grid_building
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id}
        WHERE
            residential_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
    </update>
    <update id="updateUnitForQYResidential" parameterType="map">
        UPDATE jl_grid_unit
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id}
        WHERE
            residential_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
    </update>
    <update id="updateFloorForQYResidential" parameterType="map">
        UPDATE jl_grid_floor
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id}
        WHERE
            residential_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
    </update>
    <update id="updateDoorplateForQYResidential" parameterType="map">
        UPDATE jl_grid_doorplate
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id}
        WHERE
            residential_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
    </update>
    <update id="updatePeopleForQYResidential" parameterType="map">
        UPDATE jl_grid_user
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id}
        WHERE
            residential_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
    </update>


    <update id="updateGardenForQYGarden" parameterType="map">
        UPDATE jl_grid_garden
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id},
            qh_code = null
        WHERE
            id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
    </update>
    <update id="updateBuildingForQYGarden" parameterType="map">
        UPDATE jl_grid_building
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id}
        WHERE
            garden_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
    </update>
    <update id="updateUnitForQYGarden" parameterType="map">
        UPDATE jl_grid_unit
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id}
        WHERE
            garden_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
    </update>
    <update id="updateFloorForQYGarden" parameterType="map">
        UPDATE jl_grid_floor
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id}
        WHERE
            garden_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
    </update>
    <update id="updateDoorplateForQYGarden" parameterType="map">
        UPDATE jl_grid_doorplate
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id}
        WHERE
            garden_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
    </update>
    <update id="updatePeopleForQYGarden" parameterType="map">
        UPDATE jl_grid_user
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id}
        WHERE
            garden_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
    </update>

    <update id="updateBuildingForQYBuilding" parameterType="map">
        UPDATE jl_grid_building
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id},
            garden_id = #{new_garden_id}
        WHERE
            id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
        AND garden_id = #{old_garden_id}
    </update>
    <update id="updateUnitForQYBuilding" parameterType="map">
        UPDATE jl_grid_unit
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id},
            garden_id = #{new_garden_id}
        WHERE
            building_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
        AND garden_id = #{old_garden_id}
    </update>
    <update id="updateFloorForQYBuilding" parameterType="map">
        UPDATE jl_grid_floor
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id},
            garden_id = #{new_garden_id}
        WHERE
            building_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
        AND garden_id = #{old_garden_id}
    </update>
    <update id="updateDoorplateForQYBuilding" parameterType="map">
        UPDATE jl_grid_doorplate
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id},
            garden_id = #{new_garden_id}
        WHERE
            building_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
        AND garden_id = #{old_garden_id}
    </update>
    <update id="updatePeopleForQYBuilding" parameterType="map">
        UPDATE jl_grid_user
        SET area_id = #{new_area_id},
            street_id = #{new_street_id},
            community_id = #{new_community_id},
            residential_id = #{new_residential_id},
            garden_id = #{new_garden_id}
        WHERE
            building_id = #{qy_id}
        AND area_id = #{old_area_id}
        AND street_id = #{old_street_id}
        AND community_id = #{old_community_id}
        AND residential_id = #{old_residential_id}
        AND garden_id = #{old_garden_id}
    </update>


    <update id="updateQyType" parameterType="map">
        UPDATE jl_grid_qy_log
        <set>
            state = #{state},
            update_by = #{_user.company_id},
            update_time = now(),
            <if test="state == '1'.toString()">
                log_num = #{log_num},
            </if>
            <if test="state == '2'.toString() or state == '3'.toString()">
                refuse_reason = #{refuse_reason},
            </if>
        </set>
        WHERE
            code = #{code}
    </update>

    <insert id="createQyApply" parameterType="map">
        INSERT INTO jl_grid_qy_log(
            id,
            qy_type,
            qy_id,
            `code`,
            state,
            old_area_id,
            old_street_id,
            old_community_id,
        <if test="qy_type == 'garden'.toString()">
            old_residential_id,
        </if>
        <if test="qy_type == 'building'.toString()">
            old_residential_id,
            old_garden_id,
        </if>
            new_area_id,
            new_street_id,
            new_community_id,
        <if test="qy_type == 'garden'.toString()">
            new_residential_id,
        </if>
        <if test="qy_type == 'building'.toString()">
            new_residential_id,
            new_garden_id,
        </if>
            create_by,
            create_time,
            create_type
        )VALUES(
            uuid(),
            #{qy_type},
            #{qy_id},
            #{code},
            '0',
            #{old_area_id},
            #{old_street_id},
            #{old_community_id},
        <if test="qy_type == 'garden'.toString()">
            #{old_residential_id},
        </if>
        <if test="qy_type == 'building'.toString()">
            #{old_residential_id},
            #{old_garden_id},
        </if>
            #{new_area_id},
            #{new_street_id},
            #{new_community_id},
        <if test="qy_type == 'garden'.toString()">
            #{new_residential_id},
        </if>
        <if test="qy_type == 'building'.toString()">
            #{new_residential_id},
            #{new_garden_id},
        </if>
            #{_user.company_id},
            now(),
            #{create_type}
        )
    </insert>
    <select id="findQYApplyList" parameterType="page" resultType="map" expose="true">
        SELECT *
        FROM (
        SELECT
        a.id,
        a.qy_type,
        a.qy_id,
        a.code,
        a.state,
        a.old_area_id,
        a.old_street_id,
        a.old_community_id,
        a.old_residential_id,
        a.old_garden_id,
        a.new_area_id,
        a.new_street_id,
        a.new_community_id,
        a.new_residential_id,
        a.new_garden_id,
        a.create_by,
        date_format( a.create_time, '%Y-%m-%d %T' ) AS create_time,
        a.update_by,
        date_format( a.update_time, '%Y-%m-%d %T' ) AS update_time,
        a.log_num,
        a.refuse_reason,
        CASE
        a.state
        WHEN '0' THEN
        '待审批'
        WHEN '1' THEN
        '审批通过'
        WHEN '2' THEN
        '审批驳回'
        WHEN '3' THEN
        '取消申请'
        WHEN '99' THEN
        '系统处理失败'
        END AS 'state_name',
        CASE
        a.qy_type
        WHEN 'residential' THEN
        '小区'
        WHEN 'garden' THEN
        '网格'
        WHEN 'building' THEN
        '楼'
        END AS 'qy_type_name',
        CASE
        a.qy_type
        WHEN 'residential' THEN
        ( SELECT `name` FROM jl_grid_residential WHERE id = a.qy_id )
        WHEN 'garden' THEN
        ( SELECT `name` FROM jl_grid_garden WHERE id = a.qy_id )
        WHEN 'building' THEN
        ( SELECT `name` FROM jl_grid_building WHERE id = a.qy_id )
        END AS 'qy_id_name',
        ( SELECT `name` FROM sys_office WHERE id = a.old_area_id ) AS old_area_name,
        ( SELECT `name` FROM sys_office WHERE id = a.new_area_id ) AS new_area_name,
        ( SELECT `name` FROM sys_office WHERE id = a.old_street_id ) AS old_street_name,
        ( SELECT `name` FROM sys_office WHERE id = a.new_street_id ) AS new_street_name,
        ( SELECT `name` FROM sys_office WHERE id = a.old_community_id ) AS old_community_name,
        ( SELECT `name` FROM sys_office WHERE id = a.new_community_id ) AS new_community_name,
        ( SELECT `name` FROM jl_grid_residential WHERE id = a.old_residential_id ) AS old_residential_name,
        ( SELECT `name` FROM jl_grid_residential WHERE id = a.new_residential_id ) AS new_residential_name,
        ( SELECT `name` FROM jl_grid_garden WHERE id = a.old_garden_id ) AS old_garden_name,
        ( SELECT `name` FROM jl_grid_garden WHERE id = a.new_garden_id ) AS new_garden_name
        FROM
            jl_grid_qy_log a
        WHERE
            1 = 1
        <if test="params._user.company_grade == '2'.toString()">
            AND a.state != '99'
            AND a.create_type != 'community'
        </if>
        <if test="params._user.company_grade == '3'.toString()">
            AND a.create_by = #{params._user.company_id}
            AND a.state != '99'
            AND a.create_type != 'community'
        </if>
        <if test="params._user.company_grade == '5'.toString()">
            AND a.create_by = #{params._user.company_id}
            AND a.create_type = 'community'
        </if>
        <if test="params.state != null and params.state != ''">
            AND  a.state = #{params.state}
        </if>
        <if test="params.qy_type != null and params.qy_type != ''">
            AND  a.qy_type = #{params.qy_type}
        </if>
        <if test="params.old_area_id != null and params.old_area_id != ''">
            AND  a.old_area_id = #{params.old_area_id}
        </if>
        <if test="params.new_area_id != null and params.new_area_id != ''">
            AND  a.new_area_id = #{params.new_area_id}
        </if>
        ORDER BY
        a.create_time DESC
        ) a
    </select>
    <select id="getQYTaskMsg" parameterType="map" resultType="map" expose="true">
        SELECT
            id,
            qy_type,
            qy_id,
            `code`,
            state,
            old_area_id,
            old_street_id,
            old_community_id,
            old_residential_id,
            old_garden_id,
            new_area_id,
            new_street_id,
            new_community_id,
            new_residential_id,
            new_garden_id,
            create_by,
            create_time,
            update_by,
            update_time,
            log_num,
            refuse_reason
        FROM
            jl_grid_qy_log
        WHERE
            state = '0'
        AND
            create_type = 'community'
        ORDER BY
            create_time
        ASC
        LIMIT 1
    </select>
    <update id="updateQyTypeForTask" parameterType="map">
        UPDATE jl_grid_qy_log
        <set>
            state = #{state},
            update_by = 'TASK',
            update_time = now(),
            <if test="state == '1'.toString()">
                log_num = #{log_num},
            </if>
            <if test="state == '99'.toString()">
                refuse_reason = #{refuse_reason},
            </if>
        </set>
        WHERE
            code = #{code}
    </update>

    <select id="getGardenNameCount" parameterType="map" resultType="int">
        SELECT
        COUNT(1)
        FROM
        jl_grid_garden
        WHERE
        name = #{name}
        AND community_id = #{_user.company_id}
    </select>

    <select id="getResidentialNameCount" parameterType="map" resultType="int">
        SELECT
            COUNT(1)
        FROM
            jl_grid_residential
        WHERE
            name = #{name}
        AND garden_id = #{garden_id}
    </select>

    <select id="getBuildingNameCount" parameterType="map" resultType="int">
        SELECT
        COUNT(1)
        FROM
        jl_grid_building
        WHERE
        name = #{name}
        AND garden_id = #{garden_id}
    </select>

    <select id="getUnitNameCount" parameterType="map" resultType="int">
        SELECT
        COUNT(1)
        FROM
        jl_grid_unit
        WHERE
        name = #{name}
        AND building_id = #{building_id}
    </select>

    <select id="getDoorplateNameCount" parameterType="map" resultType="int">
        SELECT
        COUNT(1)
        FROM
        jl_grid_doorplate
        WHERE
        name = #{name}
        AND floor_id = #{floor_id}
    </select>

    <select id="getFloorNameCount" parameterType="map" resultType="int">
        SELECT
            COUNT(1)
        FROM
            jl_grid_floor
        WHERE
            name = #{name}
        AND unit_id = #{unit_id}
    </select>

    <update id="updateFloor" parameterType="map" expose="true" name="修改层信息" desc="修改层信息">
        UPDATE jl_grid_floor
        SET name=#{name},
        sort=#{sort}
        WHERE id=#{id}
    </update>
</mapper>