linwe
2024-07-08 7a1e4d9fe3fe2172d5c4fba524f17ffd73ffbb3e
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?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.task.mapper.TaskSchoolEvenMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="taskSchoolEvenResultMap" type="org.springblade.modules.task.vo.TaskSchoolEvenVO">
    </resultMap>
 
 
    <select id="selectTaskSchoolEvenPage" resultMap="taskSchoolEvenResultMap">
        select
        jtse.*,
        br.town_name streetName,
        jg.grid_name,
        jda.aoi_name,
        br.village_name communityName,
        bu.name,
        bu.phone,
        jp.location,
        jp.place_name,
        jda.address_name as addressName
        from jczz_task_school_even jtse
        left join jczz_doorplate_address jda on jda.address_code = jtse.house_code
        LEFT JOIN blade_user bu ON bu.id = jtse.create_user
        LEFT JOIN jczz_place jp on jp.house_code= jtse.house_code
        left join jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
        left join blade_region br on br.code = jg.community_code
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        <where>
            <if test="taskSchoolEven.id != null "> and jtse.id = #{taskSchoolEven.id}</if>
            <if test="taskSchoolEven.createUser != null "> and jtse.create_user = #{taskSchoolEven.createUser}</if>
            <if test="taskSchoolEven.images != null  and taskSchoolEven.images != ''"> and jtse.images = #{taskSchoolEven.images}</if>
            <if test="taskSchoolEven.placeName != null  and taskSchoolEven.placeName != ''"> and jp.place_name like concat('%',#{taskSchoolEven.placeName},'%')</if>
            <if test="taskSchoolEven.name != null  and taskSchoolEven.name != ''"> and bu.name like concat('%',#{taskSchoolEven.name},'%')</if>
            <if test="taskSchoolEven.phone != null  and taskSchoolEven.phone != ''"> and bu.phone like concat('%',#{taskSchoolEven.phone},'%')</if>
            <if test="taskSchoolEven.remark != null  and taskSchoolEven.remark != ''"> and jtse.remark like concat('%',#{taskSchoolEven.remark},'%')</if>
            <if test="taskSchoolEven.hiddenDangerType != null  and taskSchoolEven.hiddenDangerType != ''"> and jtse.hidden_danger_type = #{taskSchoolEven.hiddenDangerType}</if>
            <if test="taskSchoolEven.type != null  and taskSchoolEven.type != ''"> and jtse.type = #{taskSchoolEven.type}</if>
            <if test="taskSchoolEven.isProblem != null  and taskSchoolEven.isProblem != ''"> and jtse.is_problem = #{taskSchoolEven.isProblem}</if>
            <if test="taskSchoolEven.isHandle != null  and taskSchoolEven.isHandle != ''"> and jtse.is_handle = #{taskSchoolEven.isHandle}</if>
            <if test="taskSchoolEven.isReporting != null  and taskSchoolEven.isReporting != ''"> and jtse.is_reporting = #{taskSchoolEven.isReporting}</if>
            <if test="taskSchoolEven.workImage != null  and taskSchoolEven.workImage != ''"> and jtse.work_image = #{taskSchoolEven.workImage}</if>
            <if test="taskSchoolEven.confirmFlag != null  and taskSchoolEven.confirmFlag != ''"> and jtse.confirm_flag = #{taskSchoolEven.confirmFlag}</if>
            <if test="taskSchoolEven.confirmTime != null "> and jtse.confirm_time = #{taskSchoolEven.confirmTime}</if>
            <if test="taskSchoolEven.confirmUserId != null "> and jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}</if>
            <if test="taskSchoolEven.confirmUserName != null  and taskSchoolEven.confirmUserName != ''"> and jtse.confirm_user_name = #{taskSchoolEven.confirmUserName}</if>
            <if test="taskSchoolEven.confirmNotion != null  and taskSchoolEven.confirmNotion != ''"> and jtse.confirm_notion = #{taskSchoolEven.confirmNotion}</if>
            <if test="taskSchoolEven.houseCode != null  and taskSchoolEven.houseCode != ''"> and jtse.house_code = #{taskSchoolEven.houseCode}</if>
            <if test="taskSchoolEven.createTime != null "> and jtse.create_time = #{taskSchoolEven.createTime}</if>
            <if test="taskSchoolEven.updateTime != null "> and jtse.update_time = #{taskSchoolEven.updateTime}</if>
            <if test="taskSchoolEven.startTime != null and taskSchoolEven.startTime != ''">
                and date_format(jtse.create_time,'%Y-%m-%d') &gt;= #{taskSchoolEven.startTime}
            </if>
            <if test="taskSchoolEven.endTime != null and taskSchoolEven.endTime != ''">
                and date_format(jtse.create_time,'%Y-%m-%d') &lt;= #{taskSchoolEven.endTime}
            </if>
 
 
            <if test="isAdministrator==2">
                <if test="taskSchoolEven.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>
            </if>
        </where>
        order by jtse.create_time desc
    </select>
 
    <resultMap type="org.springblade.modules.task.dto.TaskSchoolEvenDTO" id="TaskSchoolEvenDTOResult">
        <result property="id"    column="id"    />
        <result property="createUser"    column="create_user"    />
        <result property="images"    column="images"    />
        <result property="remark"    column="remark"    />
        <result property="hiddenDangerType"    column="hidden_danger_type"    />
        <result property="type"    column="type"    />
        <result property="isProblem"    column="is_problem"    />
        <result property="isHandle"    column="is_handle"    />
        <result property="isReporting"    column="is_reporting"    />
        <result property="workImage"    column="work_image"    />
        <result property="confirmFlag"    column="confirm_flag"    />
        <result property="confirmTime"    column="confirm_time"    />
        <result property="confirmUserId"    column="confirm_user_id"    />
        <result property="confirmUserName"    column="confirm_user_name"    />
        <result property="confirmNotion"    column="confirm_notion"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>
 
    <sql id="selectTaskSchoolEven">
        select
            id,
            create_user,
            images,
            remark,
            hidden_danger_type,
            type,
            is_problem,
            is_handle,
            is_reporting,
            work_image,
            confirm_flag,
            confirm_time,
            confirm_user_id,
            confirm_user_name,
            confirm_notion,
            create_time,
            update_time
        from
            jczz_task_school_even
    </sql>
 
    <select id="schoolEvenCount" resultType="java.lang.Integer">
        select
        count(1)
        from jczz_task_school_even jtse
        left join jczz_doorplate_address jda on jda.address_code = jtse.house_code
        LEFT JOIN blade_user bu ON bu.id = jtse.create_user
        LEFT JOIN jczz_place jp on jp.house_code= jtse.house_code
        left join jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
        left join blade_region br on br.code = jg.community_code
        <where>
            <if test="taskSchoolEven.id != null "> and jtse.id = #{taskSchoolEven.id}</if>
            <if test="taskSchoolEven.createUser != null "> and jtse.create_user = #{taskSchoolEven.createUser}</if>
            <if test="taskSchoolEven.images != null  and taskSchoolEven.images != ''"> and jtse.images = #{taskSchoolEven.images}</if>
            <if test="taskSchoolEven.name != null  and taskSchoolEven.name != ''"> and bu.name like concat('%',#{taskSchoolEven.name},'%')</if>
            <if test="taskSchoolEven.phone != null  and taskSchoolEven.phone != ''"> and bu.phone like concat('%',#{taskSchoolEven.phone},'%')</if>
            <if test="taskSchoolEven.remark != null  and taskSchoolEven.remark != ''"> and jtse.remark like concat('%',#{taskSchoolEven.remark},'%')</if>
            <if test="taskSchoolEven.hiddenDangerType != null  and taskSchoolEven.hiddenDangerType != ''"> and jtse.hidden_danger_type = #{taskSchoolEven.hiddenDangerType}</if>
            <if test="taskSchoolEven.type != null  and taskSchoolEven.type != ''"> and jtse.type = #{taskSchoolEven.type}</if>
            <if test="taskSchoolEven.isProblem != null  and taskSchoolEven.isProblem != ''"> and jtse.is_problem = #{taskSchoolEven.isProblem}</if>
            <if test="taskSchoolEven.isHandle != null  and taskSchoolEven.isHandle != ''"> and jtse.is_handle = #{taskSchoolEven.isHandle}</if>
            <if test="taskSchoolEven.isReporting != null  and taskSchoolEven.isReporting != ''"> and jtse.is_reporting = #{taskSchoolEven.isReporting}</if>
            <if test="taskSchoolEven.workImage != null  and taskSchoolEven.workImage != ''"> and jtse.work_image = #{taskSchoolEven.workImage}</if>
            <if test="taskSchoolEven.confirmFlag != null  and taskSchoolEven.confirmFlag != ''"> and jtse.confirm_flag = #{taskSchoolEven.confirmFlag}</if>
            <if test="taskSchoolEven.confirmTime != null "> and jtse.confirm_time = #{taskSchoolEven.confirmTime}</if>
            <if test="taskSchoolEven.confirmUserId != null "> and jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}</if>
            <if test="taskSchoolEven.confirmUserName != null  and taskSchoolEven.confirmUserName != ''"> and jtse.confirm_user_name = #{taskSchoolEven.confirmUserName}</if>
            <if test="taskSchoolEven.confirmNotion != null  and taskSchoolEven.confirmNotion != ''"> and jtse.confirm_notion = #{taskSchoolEven.confirmNotion}</if>
            <if test="taskSchoolEven.houseCode != null  and taskSchoolEven.houseCode != ''"> and jtse.house_code = #{taskSchoolEven.houseCode}</if>
            <if test="taskSchoolEven.createTime != null "> and jtse.create_time = #{taskSchoolEven.createTime}</if>
            <if test="taskSchoolEven.updateTime != null "> and jtse.update_time = #{taskSchoolEven.updateTime}</if>
 
            <if test="isAdministrator==2">
                <!-- 网格员及其他 -->
                <if test="taskSchoolEven.roleType ==null and taskSchoolEven.roleName !='inhabitant' and taskSchoolEven.houseCode == null ">
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and (
                            jg.community_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            )
                        </when>
                    </choose>
 
                    <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>
                    </choose>
 
                    <if test="taskSchoolEven.confirmUserId != null ">
                        or jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}
                    </if>
 
                </if>
            </if>
        </where>
        order by jtse.create_time desc
    </select>
 
    <select id="selectTaskSchoolEvenDetail" resultMap="taskSchoolEvenResultMap">
        select
        jtse.*,
        br.town_name streetName,
        jg.grid_name,
        jda.aoi_name,
        br.village_name communityName,
        bu.name,
        bu.phone,
        jp.location,
        jp.place_name,
        jda.address_name as addressName
        from jczz_task_school_even jtse
        left join jczz_doorplate_address jda on jda.address_code = jtse.house_code
        LEFT JOIN blade_user bu ON bu.id = jtse.create_user
        LEFT JOIN jczz_place jp on jp.house_code= jtse.house_code
        left join jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
        left join blade_region br on br.code = jg.community_code
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        <where>
            <if test="taskSchoolEven.id != null "> and jtse.id = #{taskSchoolEven.id}</if>
            <if test="taskSchoolEven.createUser != null "> and jtse.create_user = #{taskSchoolEven.createUser}</if>
            <if test="taskSchoolEven.images != null  and taskSchoolEven.images != ''"> and jtse.images = #{taskSchoolEven.images}</if>
            <if test="taskSchoolEven.name != null  and taskSchoolEven.name != ''"> and bu.name like concat('%',#{taskSchoolEven.name},'%')</if>
            <if test="taskSchoolEven.phone != null  and taskSchoolEven.phone != ''"> and bu.phone like concat('%',#{taskSchoolEven.phone},'%')</if>
            <if test="taskSchoolEven.remark != null  and taskSchoolEven.remark != ''"> and jtse.remark like concat('%',#{taskSchoolEven.remark},'%')</if>
            <if test="taskSchoolEven.hiddenDangerType != null  and taskSchoolEven.hiddenDangerType != ''"> and jtse.hidden_danger_type = #{taskSchoolEven.hiddenDangerType}</if>
            <if test="taskSchoolEven.type != null  and taskSchoolEven.type != ''"> and jtse.type = #{taskSchoolEven.type}</if>
            <if test="taskSchoolEven.isProblem != null  and taskSchoolEven.isProblem != ''"> and jtse.is_problem = #{taskSchoolEven.isProblem}</if>
            <if test="taskSchoolEven.isHandle != null  and taskSchoolEven.isHandle != ''"> and jtse.is_handle = #{taskSchoolEven.isHandle}</if>
            <if test="taskSchoolEven.isReporting != null  and taskSchoolEven.isReporting != ''"> and jtse.is_reporting = #{taskSchoolEven.isReporting}</if>
            <if test="taskSchoolEven.workImage != null  and taskSchoolEven.workImage != ''"> and jtse.work_image = #{taskSchoolEven.workImage}</if>
            <if test="taskSchoolEven.confirmFlag != null  and taskSchoolEven.confirmFlag != ''"> and jtse.confirm_flag = #{taskSchoolEven.confirmFlag}</if>
            <if test="taskSchoolEven.confirmTime != null "> and jtse.confirm_time = #{taskSchoolEven.confirmTime}</if>
            <if test="taskSchoolEven.confirmUserId != null "> and jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}</if>
            <if test="taskSchoolEven.confirmUserName != null  and taskSchoolEven.confirmUserName != ''"> and jtse.confirm_user_name = #{taskSchoolEven.confirmUserName}</if>
            <if test="taskSchoolEven.confirmNotion != null  and taskSchoolEven.confirmNotion != ''"> and jtse.confirm_notion = #{taskSchoolEven.confirmNotion}</if>
            <if test="taskSchoolEven.houseCode != null  and taskSchoolEven.houseCode != ''"> and jtse.house_code = #{taskSchoolEven.houseCode}</if>
            <if test="taskSchoolEven.createTime != null "> and jtse.create_time = #{taskSchoolEven.createTime}</if>
            <if test="taskSchoolEven.updateTime != null "> and jtse.update_time = #{taskSchoolEven.updateTime}</if>
        </where>
        order by jtse.create_time desc
    </select>
 
</mapper>