lin
2024-05-10 fe59ae00aef5cdbc39c6d1b29c84af25071a32ff
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
<?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.backblast.mapper.BackblastWarnHanRecMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="backblastWarnHanRecResultMap" type="org.springblade.modules.backblast.vo.BackblastWarnHanRecVO">
    </resultMap>
 
    <!--自定义分页列表查询-->
    <select id="selectBackblastWarnHanRecPage" resultMap="backblastWarnHanRecResultMap">
        select
        jbwhr.*,
        br.town_name as townName,
        br.name as communityName,
        jpag.pcs_name pcsName,
        bd.dept_name
        from jczz_backblast_warn_han_rec jbwhr
        LEFT JOIN jczz_grid jg on jg.grid_code = jbwhr.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jbwhr.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_user bu ON bu.id = jbwhr.create_user
        LEFT JOIN blade_dept bd on bd.id = bu.dept_id
        where jbwhr.is_deleted = 0
        <if test="backblastWarnHanRec.townName != null and backblastWarnHanRec.townName != ''">
            and br.town_name like concat('%',#{backblastWarnHanRec.townName},'%')
        </if>
        <if test="backblastWarnHanRec.communityName != null and backblastWarnHanRec.communityName != ''">
            and jbr.name like concat('%',#{backblastWarnHanRec.communityName},'%')
        </if>
        <if test="backblastWarnHanRec.pcsName != null and backblastWarnHanRec.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastWarnHanRec.pcsName},'%')
        </if>
        <if test="backblastWarnHanRec.houseCode != null and backblastWarnHanRec.houseCode != ''">
            and jbwhr.house_code = #{backblastWarnHanRec.houseCode}
        </if>
        <if test="backblastWarnHanRec.address != null and backblastWarnHanRec.address != ''">
            and jbwhr.address like concat('%',#{backblastWarnHanRec.address},'%')
        </if>
        <if test="backblastWarnHanRec.recContent != null and backblastWarnHanRec.recContent != ''">
            and jbwhr.rec_content like concat('%',#{backblastWarnHanRec.recContent},'%')
        </if>
        <if test="backblastWarnHanRec.policeman != null and backblastWarnHanRec.policeman != ''">
            and jbwhr.policeman like concat('%',#{backblastWarnHanRec.policeman},'%')
        </if>
        <if test="backblastWarnHanRec.policemanPhone != null and backblastWarnHanRec.policemanPhone != ''">
            and jbwhr.policeman_phone like concat('%',#{backblastWarnHanRec.policemanPhone},'%')
        </if>
        <if test="backblastWarnHanRec.startTime != null and backblastWarnHanRec.startTime != ''">
            and date_format(jbwhr.create_time,'%Y-%m-%d') &gt;= #{backblastWarnHanRec.startTime}
        </if>
        <if test="backblastWarnHanRec.endTime != null and backblastWarnHanRec.endTime != ''">
            and date_format(jbwhr.create_time,'%Y-%m-%d') &lt;= #{backblastWarnHanRec.endTime}
        </if>
        <if test="backblastWarnHanRec.createUser != null">
            and jbwhr.create_user = #{backblastWarnHanRec.createUser}
        </if>
        <if test="backblastWarnHanRec.deptName != null and backblastWarnHanRec.deptName != ''">
            and  bd.dept_name like concat('%',#{backblastWarnHanRec.deptName},'%')
        </if>
        <if test="backblastWarnHanRec.searchKey!=null and backblastWarnHanRec.searchKey!=''">
            and CONCAT(
            ifnull(jbwhr.policeman_phone,''),
            ifnull(jbwhr.address,''),
            ifnull(jbwhr.rec_content,''),
            ifnull(jbwhr.policeman,'')
            ) like CONCAT ('%', #{backblastWarnHanRec.searchKey},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="backblastWarnHanRec.roleName != null and backblastWarnHanRec.roleName != ''">
                    <if test="backblastWarnHanRec.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="backblastWarnHanRec.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 ('')
                            )
                        </otherwise>
                    </choose>
                </otherwise>
            </choose>
        </if>
        order by jbwhr.id desc,jbwhr.create_time desc
    </select>
 
    <!--自定义分页列表查询-->
    <select id="getDetail" resultType="org.springblade.modules.backblast.vo.BackblastWarnHanRecVO">
        select
        jbwhr.*,
        br.town_name as townName,
        br.name as communityName,
        jpag.pcs_name pcsName
        from jczz_backblast_warn_han_rec jbwhr
        LEFT JOIN jczz_grid jg on jg.grid_code = jbwhr.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jbwhr.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jpag.community_code
        where jbwhr.is_deleted = 0
        <if test="backblastWarnHanRec.townName != null and backblastWarnHanRec.townName != ''">
            and br.town_name like concat('%',#{backblastWarnHanRec.townName},'%')
        </if>
        <if test="backblastWarnHanRec.communityName != null and backblastWarnHanRec.communityName != ''">
            and jbr.name like concat('%',#{backblastWarnHanRec.communityName},'%')
        </if>
        <if test="backblastWarnHanRec.pcsName != null and backblastWarnHanRec.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastWarnHanRec.pcsName},'%')
        </if>
        <if test="backblastWarnHanRec.houseCode != null and backblastWarnHanRec.houseCode != ''">
            and jbwhr.house_code = #{backblastWarnHanRec.houseCode}
        </if>
        <if test="backblastWarnHanRec.id != null">
            and jbwhr.id = #{backblastWarnHanRec.id}
        </if>
        <if test="backblastWarnHanRec.address != null and backblastWarnHanRec.address != ''">
            and jbwhr.address like concat('%',#{backblastWarnHanRec.address},'%')
        </if>
        <if test="backblastWarnHanRec.recContent != null and backblastWarnHanRec.recContent != ''">
            and jbwhr.rec_content like concat('%',#{backblastWarnHanRec.recContent},'%')
        </if>
        <if test="backblastWarnHanRec.policeman != null and backblastWarnHanRec.policeman != ''">
            and jbwhr.policeman like concat('%',#{backblastWarnHanRec.policeman},'%')
        </if>
        <if test="backblastWarnHanRec.policemanPhone != null and backblastWarnHanRec.policemanPhone != ''">
            and jbwhr.policeman_phone like concat('%',#{backblastWarnHanRec.policemanPhone},'%')
        </if>
    </select>
 
 
</mapper>