zhongrj
2024-02-22 858ddcd71b737c1e2d9f9c1fb9d009209cb97b4e
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?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.place.mapper.PlaceExtMapper">
 
    <resultMap id="detailMap" type="org.springblade.modules.place.vo.PlaceExtVO" autoMapping="true">
        <id property="id" column="id"/>
        <collection property="placePractitioner" javaType="java.util.List"
                    ofType="org.springblade.modules.place.vo.PlacePractitionerVO" autoMapping="true">
            <id property="id" column="cid"/>
        </collection>
    </resultMap>
 
    <!--自定义分页查询-->
    <select id="selectPlaceExtPage" resultType="org.springblade.modules.place.vo.PlaceExtVO">
        SELECT
        jpe.*,
        jp.place_name AS placeName
        FROM
        jczz_place_ext jpe
        LEFT JOIN jczz_place jp ON jpe.place_id = jp.id AND jp.is_deleted = 0
        LEFT JOIN jczz_grid jg ON jp.grid_code = jg.grid_code AND jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag ON jp.jw_grid_code = jpag.jw_grid_code AND jpag.is_deleted = 0
        WHERE jpe.is_deleted = 0
        and jp.place_name != ''
        <if test="isAdministrator==2">
            <choose>
                <when test="placeExt.roleName != null and placeExt.roleName != ''">
                    <if test="placeExt.roleName=='wgy'">
                        <choose>
                            <when test="gridCodeList !=null and gridCodeList.size()>0">
                                and jp.grid_code in
                                <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jp.grid_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                    <if test="placeExt.roleName=='mj'">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and jpag.community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jpag.community_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </when>
                <otherwise>
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and
                            (
                            jg.grid_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            or
                            jpag.community_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            )
                        </when>
                        <otherwise>
                            and
                            (
                            jg.grid_code in ('') or jpag.community_code in in ('')
                            )
                        </otherwise>
                    </choose>
                </otherwise>
            </choose>
        </if>
        <if test="placeExt.placeName != null and placeExt.placeName != ''">
            and jp.place_name like concat('%',#{placeExt.placeName},'%')
        </if>
        <if test="placeExt.communityCode != null and placeExt.communityCode != ''">
            and jpag.community_code like concat('%',#{placeExt.communityCode},'%')
        </if>
        <if test="placeExt.placeId != null">
            and jp.id = #{placeExt.placeId}
        </if>
        <if test="placeExt.isApp != null">
            and jpe.confirm_flag != 4
        </if>
        <if test="placeExt.houseCode != null and placeExt.houseCode != ''">
            and jp.house_code like concat('%',#{placeExt.houseCode},'%')
        </if>
        <if test="placeExt.confirmFlag != null">
            and jpe.confirm_flag = #{placeExt.confirmFlag}
        </if>
        <if test="placeExt.startTime != null and placeExt.startTime != '' and placeExt.endTime != null and placeExt.endTime != '' ">
            AND jpe.create_time BETWEEN #{placeExt.startTime} and #{placeExt.endTime}
        </if>
        <if test="houseCodeList != null and houseCodeList.size()>0">
            and jp.house_code in
            <foreach collection="houseCodeList" item="houseCode" separator="," open="(" close=")">
                #{houseCode}
            </foreach>
        </if>
        order by jpe.create_time desc,jpe.id desc
    </select>
 
    <!--场所审核统计-->
    <select id="selectCount" resultType="java.lang.Integer">
        SELECT
        count( 1 )
        FROM
        jczz_place_ext jpe
        LEFT JOIN jczz_place jp ON jp.id = jpe.place_id and jp.is_deleted = 0
        LEFT JOIN jczz_doorplate_address jda ON locate(jda.address_code,jp.house_code)>0
        <where>
            <if test="confirmFlag != null">
                and jpe.confirm_flag = #{confirmFlag}
            </if>
            <if test="userId != null">
                AND jp.house_code IN (
                SELECT
                jgr.house_code
                FROM
                jczz_grid_range jgr
                LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id
                LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
                WHERE
                jg.is_deleted = 0
                <if test="neiCode != null and neiCode != ''">
                    and jg.community_code = #{neiCode}
                </if>
                AND jgm.user_id = #{userId} )
            </if>
            and jpe.is_deleted = 0
        </where>
 
 
    </select>
 
    <select id="getDetail" resultType="org.springblade.modules.place.vo.PlaceExtVO">
        select jpe.*,
        jp.place_name as placeName,
        jp.lng,
        jp.lat,
        jp.location
        from jczz_place_ext jpe
        left join jczz_place jp on jpe.place_id = jp.id and jp.is_deleted = 0
        where jpe.is_deleted = 0 and jpe.place_id = #{placeExt.placeId}
    </select>
 
 
</mapper>