liujie
2025-06-09 70d2a5d0f9c6951b2d4cac954041ed73582ff7eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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.panzhihua.service_community.dao.ComActVillageDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComMngVillageDO">
        <id column="village_id" property="villageId" />
        <result column="street_id" property="streetId" />
        <result column="community_id" property="communityId" />
        <result column="alley" property="alley" />
        <result column="house_num" property="houseNum" />
        <result column="group_at" property="groupAt" />
        <result column="type" property="type" />
        <result column="name" property="name" />
        <result column="build_sum" property="buildSum" />
        <result column="build_year" property="buildYear" />
        <result column="build_type" property="buildType" />
        <result column="property" property="property" />
        <result column="developers" property="developers" />
        <result column="user_sum" property="userSum" />
        <result column="village_images" property="villageImages" />
        <result column="address" property="address" />
        <result column="path" property="path" />
        <result column="lng" property="lng" />
        <result column="lat" property="lat" />
        <result column="create_at" property="createAt" />
        <result column="update_at" property="updateAt" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        village_id, street_id, community_id, alley, house_num, group_at, type, name, build_sum, build_year, build_type, property, developers, user_sum, village_images, address, path, lng, lat, create_at, update_at
    </sql>
 
    <select id="getGridVillageListApp" resultType="com.panzhihua.common.model.vos.grid.PageComMngVillageVO">
        SELECT    cmv.village_id,    cmv.`name` AS userName,    IFNULL((select count(id) from com_mng_building where village_id = cmv.village_id),0) as buildSum,    address,
        cmv.create_at as createAt,    cmv.lng,    cmv.lat,
        ( SELECT count( id ) FROM com_mng_population WHERE village_id = cmv.village_id ) AS userSum,
        ( SELECT count( id ) FROM com_mng_population_house WHERE village_id = cmv.village_id ) AS houseNum,
        ( SELECT count( id ) FROM com_mng_population WHERE village_id = cmv.village_id AND out_or_local = 1 ) AS registerNum,
        ( SELECT count( id ) FROM com_mng_population WHERE village_id = cmv.village_id AND is_rent = 2 ) AS rentNum
        FROM    com_mng_village AS cmv
        LEFT JOIN event_grid_data as egd on egd.grid_community_id = cmv.community_id
        where 1=1
        <if test='villageListAppDTO.gridId != null'>
            and egd.id = #{villageListAppDTO.gridId}
        </if>
        <if test='villageListAppDTO.address != null and villageListAppDTO.address != &quot;&quot;'>
            and cmv.address like concat(#{villageListAppDTO.address},'%')
        </if>
        <if test='villageListAppDTO.alley != null and villageListAppDTO.alley != &quot;&quot;'>
            and cmv.alley like concat(#{villageListAppDTO.alley},'%')
        </if>
        <if test='villageListAppDTO.houseNum != null and villageListAppDTO.houseNum != &quot;&quot;'>
            and cmv.house_num like concat(#{villageListAppDTO.houseNum},'%')
        </if>
        <if test='villageListAppDTO.groupAt != null and villageListAppDTO.groupAt != &quot;&quot;'>
            and cmv.group_at like concat(#{villageListAppDTO.groupAt},'%')
        </if>
        <if test='villageListAppDTO.name != null and villageListAppDTO.name != &quot;&quot;'>
            and cmv.name like concat(#{villageListAppDTO.name},'%')
        </if>
        <if test='villageListAppDTO.sortColumns!=null'>
            ORDER BY ${villageListAppDTO.sortColumns} ${villageListAppDTO.sortType}
        </if>
    </select>
 
</mapper>