linwe
2024-09-03 764d883b5ea3bdc06abbec548b6df0511e567978
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?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.PoliceAlarmRecordsMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="policeAlarmRecordsResultMap" type="org.springblade.modules.police.vo.PoliceAlarmRecordsVO">
    </resultMap>
 
 
    <select id="selectPoliceAlarmRecordsPage" resultMap="policeAlarmRecordsResultMap">
        select
        jpar.*,
        bdb.dict_value as alarmTypeName,
        jpag.pcs_name
        from jczz_police_alarm_records jpar
        LEFT JOIN jczz_grid jg on jg.grid_code = jpar.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jpar.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jpag.community_code
        LEFT JOIN blade_dict_biz bdb ON bdb.dict_key = jpar.alarm_type and bdb.is_deleted = 0 and bdb.code = 'applyAlarmType'
        <where>
            <if test="vo.status != null">
                and jpar.status = #{vo.status}
            </if>
            <if test="vo.alarmDescribe != null and vo.alarmDescribe != ''">
                and jpar.alarm_describe like concat('%',#{vo.alarmDescribe},'%')
            </if>
            <if test="vo.policeName != null and vo.policeName != ''">
                and jpar.police_name like concat('%',#{vo.policeName},'%')
            </if>
 
            <if test="vo.pcsName != null and vo.pcsName != ''">
                and jpag.pcs_name like concat('%',#{vo.pcsName},'%')
            </if>
            <if test="vo.startTime != null and vo.startTime != ''">
                and date_format(jpar.create_time,'%Y-%m-%d') &gt;= #{vo.startTime}
            </if>
            <if test="vo.endTime != null and vo.endTime != ''">
                and date_format(jpar.create_time,'%Y-%m-%d') &lt;= #{vo.endTime}
            </if>
            <if test="vo.searchKey!=null and vo.searchKey!=''">
                and CONCAT(
                ifnull(jpar.name,''),
                ifnull(jpar.phone,''),
                ifnull(jpar.address,''),
                ifnull(jpar.alarm_describe,''),
                ifnull(jpar.police_name,'')
                ) like CONCAT ('%', #{vo.searchKey},'%')
            </if>
            <if test="isAdministrator==2">
                <choose>
                    <when test="vo.roleName != null and vo.roleName != ''">
                        <if test="vo.roleName=='wgy'">
                            <choose>
                                <when test="gridCodeList !=null and gridCodeList.size()>0">
                                    and jg.grid_code in
                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jg.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="vo.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>
                                    <if test="vo.policeId != null">
                                        or jpar.police_id = #{vo.policeId}
                                    </if>
                                </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 ('')
                                )
                            </otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
           and jpar.is_deleted = 0
        </where>
        order by jpar.id desc,jpar.create_time desc
    </select>
 
    <resultMap type="org.springblade.modules.police.dto.PoliceAlarmRecordsDTO" id="PoliceAlarmRecordsDTOResult">
        <result property="id"    column="id"    />
        <result property="houseCode"    column="house_code"    />
        <result property="address"    column="address"    />
        <result property="name"    column="name"    />
        <result property="phone"    column="phone"    />
        <result property="alarmType"    column="alarm_type"    />
        <result property="injuryFlag"    column="injury_flag"    />
        <result property="gridCode"    column="grid_code"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="policeId"    column="police_id"    />
        <result property="policeName"    column="police_name"    />
        <result property="policePhone"    column="police_phone"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="gender"    column="gender"    />
        <result property="jwGridCode"    column="jw_grid_code"    />
        <result property="alarmResponseTime"    column="alarm_response_time"    />
        <result property="alarmDescribe"    column="alarm_describe"    />
        <result property="publicIncidents"    column="public_incidents"    />
        <result property="status"    column="status"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
    </resultMap>
 
    <sql id="selectPoliceAlarmRecords">
        select
            id,
            house_code,
            address,
            name,
            phone,
            alarm_type,
            injury_flag,
            grid_code,
            create_time,
            update_time,
            police_id,
            police_name,
            police_phone,
            is_deleted,
            gender,
            jw_grid_code,
            alarm_response_time,
            alarm_describe,
            public_incidents,
            status,
            longitude,
            latitude
        from
            jczz_police_alarm_records
    </sql>
 
<!--    <select id="selectPoliceAlarmRecordsById" parameterType="long" resultMap="PoliceAlarmRecordsDTOResult">-->
<!--        <include refid="selectPoliceAlarmRecords"/>-->
<!--        where-->
<!--        id = #{id}-->
<!--    </select>-->
 
<!--    <select id="selectPoliceAlarmRecordsList" parameterType="rg.springblade.modules.dto.PoliceAlarmRecordsDTO" resultMap="PoliceAlarmRecordsDTOResult">-->
<!--        <include refid="selectPoliceAlarmRecords"/>-->
<!--        <where>-->
<!--            <if test="id != null "> and id = #{id}</if>
        <if test="houseCode != null  and houseCode != ''"> and house_code = #{houseCode}</if>
        <if test="address != null  and address != ''"> and address = #{address}</if>
        <if test="name != null  and name != ''"> and name = #{name}</if>
        <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
        <if test="alarmType != null  and alarmType != ''"> and alarm_type = #{alarmType}</if>
        <if test="injuryFlag != null "> and injury_flag = #{injuryFlag}</if>
        <if test="gridCode != null  and gridCode != ''"> and grid_code = #{gridCode}</if>
        <if test="createTime != null "> and create_time = #{createTime}</if>
        <if test="updateTime != null "> and update_time = #{updateTime}</if>
        <if test="policeId != null "> and police_id = #{policeId}</if>
        <if test="policeName != null  and policeName != ''"> and police_name = #{policeName}</if>
        <if test="policePhone != null  and policePhone != ''"> and police_phone = #{policePhone}</if>
        <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
        <if test="gender != null "> and gender = #{gender}</if>
        <if test="jwGridCode != null  and jwGridCode != ''"> and jw_grid_code = #{jwGridCode}</if>
        <if test="alarmResponseTime != null "> and alarm_response_time = #{alarmResponseTime}</if>
        <if test="alarmDescribe != null  and alarmDescribe != ''"> and alarm_describe = #{alarmDescribe}</if>
        <if test="publicIncidents != null "> and public_incidents = #{publicIncidents}</if>
        <if test="status != null "> and status = #{status}</if>-->
<!--        </where>-->
<!--    </select>-->
 
</mapper>