zhongrj
2024-05-17 cd92c8e582d55bdb683be4003a37caa2c6c3ed6c
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
<?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.police.mapper.PoliceAffairsGridMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="policeAffairsGridResultMap" type="org.springblade.modules.police.vo.PoliceAffairsGridVO">
        <result column="id" property="id"/>
        <result column="object_id" property="objectId"/>
        <result column="jws_code" property="jwsCode"/>
        <result column="user_id" property="userId"/>
        <result column="policeman" property="policeman"/>
        <result column="policeman_phone" property="policemanPhone"/>
        <result column="community_code" property="communityCode"/>
        <result column="community_name" property="communityName"/>
        <result column="police_station_code" property="policeStationCode"/>
        <result column="police_station_name" property="policeStationName"/>
        <result column="geom" property="geom"/>
        <result column="sort" property="sort"/>
        <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="remark" property="remark"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <!--自定义分页查询-->
    <select id="selectPoliceAffairsGridPage" resultMap="policeAffairsGridResultMap">
        select * from jczz_police_affairs_grid where is_deleted = 0
        <if test="policeAffairsGrid.communityName!=null and policeAffairsGrid.communityName!=''">
            and community_name like concat('%',#{policeAffairsGrid.communityName},'%')
        </if>
        <if test="policeAffairsGrid.jwGridCode!=null and policeAffairsGrid.jwGridCode!=''">
            and jw_grid_code like concat('%',#{policeAffairsGrid.jwGridCode},'%')
        </if>
        <if test="policeAffairsGrid.pcsCode!=null and policeAffairsGrid.pcsCode!=''">
            and pcs_code like concat('%',#{policeAffairsGrid.pcsCode},'%')
        </if>
        <if test="policeAffairsGrid.pcsName!=null and policeAffairsGrid.pcsName!=''">
            and pcs_name like concat('%',#{policeAffairsGrid.pcsName},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="policeAffairsGrid.roleName != null and policeAffairsGrid.roleName != ''">
                    <if test="policeAffairsGrid.roleName=='mj'">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and community_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </when>
                <otherwise>
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and community_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                        </when>
                        <otherwise>
                            and community_code in ('')
                        </otherwise>
                    </choose>
                </otherwise>
            </choose>
        </if>
        order by id desc,pcs_code desc
    </select>
 
    <!--判断该点在哪个警务网格-->
    <select id="spatialAnalysis" resultType="org.springblade.modules.police.entity.PoliceAffairsGridEntity">
        SELECT * FROM jczz_police_affairs_grid
        WHERE is_deleted = 0
        and ST_Intersects(geom, ST_GeomFromText(${point},0))
    </select>
 
    <!--查询对应的社区编号-->
    <select id="getCommunityCodeListByUserId" resultType="java.lang.String">
        SELECT community_code FROM jczz_police_affairs_grid
        WHERE is_deleted = 0
        and police_user_id like concat('%',#{userId},'%')
    </select>
 
</mapper>