<?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.com.countrygarden.bi.main.dao.manager.map.ManagerMapCacheMapper">
    <!--<cache eviction="LRU"-->
           <!--type="org.apache.ibatis.cache.impl.PerpetualCache"-->
           <!--flushInterval="120000"-->
           <!--size="1024"-->
           <!--readOnly="true"/>-->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.manager.map.ManagerMapCache">
                                    <id column="id" property="id" />
                                                <result column="organ_name" property="organName" />
                                                <result column="organ_code" property="organCode" />
                                                <result column="comm_count" property="commCount" />
                                                <result column="area_count" property="areaCount" />
                                                <result column="manager_num_count" property="managerNumCount" />
                                                <result column="manager_num_avg" property="managerNumAvg" />
                                                <result column="houserkeeper_organization" property="housekeeperOrganization" />
                                                <result column="houserkeeper_count" property="housekeeperCount" />
                                                <result column="area_avg" property="areaAvg" />
                                                <result column="created_date" property="createdDate" />
                                                <result column="created_by" property="createdBy" />
                                                <result column="updated_date" property="updatedDate" />
                                                <result column="updated_by" property="updatedBy" />
                                                <result column="flag" property="flag" />
                        </resultMap>
    <select id="selectOneByOrganName"
            resultType="cn.com.countrygarden.bi.main.model.manager.map.ManagerMapCache">
        SELECT id,organ_code organCode,organ_name organName,comm_count commCount,area_count areaCount
          ,manager_num_count managerNumCount,manager_num_avg managerNumAvg,houserkeeper_organization houserkeeperOrganization
          ,houserkeeper_count houserkeeperCount,area_avg areaAvg,flag
        FROM manager_map_cache
        WHERE organ_name = #{organName}
        ORDER BY houserkeeper_count DESC
        LIMIT 1
    </select>
    <update id="updateHousekeeperCountByOrganName">
        UPDATE manager_map_cache
        SET houserkeeper_count = #{housekeeperCount}
        WHERE organ_name = #{organName}
    </update>

</mapper>