linwe
2023-12-23 55d677758efadb6d42e6d4e595cecc2c50c20d5a
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?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="org.springblade.modules.grid.mapper.GridmanMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="gridmanResultMap" type="org.springblade.modules.grid.entity.GridmanEntity">
        <result column="id" property="id"/>
        <result column="grid_id" property="gridId"/>
        <result column="user_id" property="userId"/>
        <result column="gridman_name" property="gridmanName"/>
        <result column="mobile" property="mobile"/>
        <result column="remark" property="remark"/>
        <result column="create_time" property="createTime"/>
        <result column="create_user" property="createUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <!--自定义分页查询-->
    <select id="selectGridmanPage" resultType="org.springblade.modules.grid.vo.GridmanVO">
        select
        jgm.*,jg.community_code communityCode
        from jczz_gridman jgm
        left join jczz_grid jg on jg.id = jgm.grid_id and jg.is_deleted = 0
        where jgm.is_deleted = 0
        <if test="gridman.gridmanName!=null and gridman.gridmanName!=''">
            and jgm.gridman_name like concat('%',#{gridman.gridmanName},'%')
        </if>
        <if test="gridman.mobile!=null and gridman.mobile!=''">
            and jgm.mobile like concat('%',#{gridman.mobile},'%')
        </if>
        <if test="gridman.gridId!=null">
            and jg.id = #{gridman.gridId}
        </if>
        <if test="gridman.communityCode!=null and gridman.communityCode!=''">
            and jg.community_code like concat('%',#{gridman.communityCode},'%')
        </if>
    </select>
 
    <!--自定义分页查询-->
    <select id="getGridmanList" resultType="org.springblade.modules.grid.vo.GridmanVO">
        select
        jgm.*
        from jczz_gridman jgm
        where jgm.is_deleted = 0
        <if test="gridman.gridmanName!=null and gridman.gridmanName!=''">
            and jgm.gridman_name like concat('%',#{gridman.gridmanName},'%')
        </if>
        <if test="gridman.mobile!=null and gridman.mobile!=''">
            and jgm.mobile like concat('%',#{gridman.mobile},'%')
        </if>
    </select>
 
    <select id="getGridStatistics" resultType="java.lang.Integer">
        SELECT count(1) number
        FROM jczz_gridman jgm
        LEFT JOIN jczz_grid jg  ON jg.id = jgm.grid_id
        WHERE jg.community_code = #{code}
        AND jg.is_deleted = 0
        <if test="userId!=null and roleType == '1'">
          and jgm.user_id= #{userId}
        </if>
    </select>
 
    <select id="getCompanyStatistics" resultType="java.lang.Integer">
        SELECT
        count(1)
        FROM
        jczz_property_company_district jpcd
        LEFT JOIN jczz_district jd ON jd.id = jpcd.district_id
        WHERE
        jd.community_code = #{code}
        and jpcd.is_deleted= 0
        <if test="userId!=null and roleType == '1'">
            AND jd.aoi_code in (
            SELECT distinct
            jda.aoi_code
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jgr.house_code
            WHERE
            jgm.user_id = #{userId}
            AND jg.is_deleted = 0
            AND jda.aoi_code IS NOT NULL
            )
        </if>
    </select>
 
    <select id="getOwnersCommitteeStatistics" resultType="java.lang.Integer">
        SELECT
        count(1)
        FROM jczz_owners_committee joc LEFT JOIN
        jczz_district jd ON jd.id = joc.area_id
        WHERE
        jd.community_code = #{code}
        and jpcd.is_deleted= 0
        <if test="userId!=null and roleType == '1'">
            AND jd.aoi_code in (
            SELECT distinct
            jda.aoi_code
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jgr.house_code
            WHERE
            jgm.user_id = #{userId}
            AND jg.is_deleted = 0
            AND jda.aoi_code IS NOT NULL
            )
        </if>
    </select>
 
 
    <!--网格员表 自定义详情-->
    <select id="getDetail" resultType="org.springblade.modules.grid.vo.GridmanVO">
        select
        jgm.*,jg.community_code communityCode
        from jczz_gridman jgm
        left join jczz_grid jg on jg.id = jgm.grid_id and jg.is_deleted = 0
        where jgm.is_deleted = 0
        and jgm.id = #{gridman.id}
    </select>
</mapper>