McConstructionMapper.xml
19.4 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?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="com.chinagas.modules.schsf.mapper.McConstructionMapper">
<resultMap type="com.chinagas.modules.schsf.domain.McConstruction" id="McConstructionResult">
<result property="id" column="id" />
<result property="cmtyId" column="cmty_id" />
<result property="regionName" column="region_name" />
<result property="groupName" column="group_name" />
<result property="companyName" column="company_name" />
<result property="companyCode" column="company_code" />
<result property="province" column="province" />
<result property="city" column="city" />
<result property="district" column="district" />
<result property="street" column="street" />
<result property="vlgOrCmty" column="vlg_or_cmty" />
<result property="urbRurCls" column="urb_rur_cls" />
<result property="projectTypeName" column="project_type_name" />
<result property="projectTypeCode" column="project_type_code" />
<result property="assignmentTime" column="assignment_time" />
<result property="isCompleted" column="is_completed" />
<result property="completionTime" column="completion_time" />
<result property="nonNcmpRsn" column="non_ncmp_rsn" />
<result property="projectPersonId" column="project_person_id" />
<result property="projectPersonName" column="project_person_name" />
<result property="projectPersonAccount" column="project_person_account" />
<result property="gasConnMtrRis" column="gas_conn_mtr_ris" />
<result property="gctMtrrisTime" column="gct_mtrris_time" />
<result property="gctNcmpRsn" column="gct_ncmp_rsn" />
<result property="operatePersonId" column="operate_person_id" />
<result property="operatePersonName" column="operate_person_name" />
<result property="operatePersonAccount" column="operate_person_account" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="defFlag" column="def_flag" />
<result property="statusCode" column="status_code" />
<result property="statusName" column="status_name" />
</resultMap>
<sql id="selectMcConstructionVo">
SELECT DISTINCT t.id,t.cmty_id,t.region_name,t.group_name,t.company_name,t.company_code,t.province,t.city,t.district,t.street,t.vlg_or_cmty,t.urb_rur_cls,t.project_type_name,t.project_type_code,t.assignment_time,t.is_completed,t.completion_time,t.non_ncmp_rsn,t.project_person_id,t.project_person_name,t.project_person_account,t.gas_conn_mtr_ris,t.gct_mtrris_time,t.gct_ncmp_rsn,t.operate_person_id,t.operate_person_name,t.operate_person_account,t.remark,t.create_time,t.create_by,t.update_time,t.update_by,t.def_flag,t.status_code,t.status_name
FROM mc_construction t
left join sys_user u on u.user_id = t.create_by
left join sys_dept d on d.dept_id = t.company_code
</sql>
<select id="selectMcConstructionList" parameterType="com.chinagas.modules.schsf.domain.McConstruction" resultMap="McConstructionResult">
<include refid="selectMcConstructionVo"/>
where 1=1
<if test="cmtyId != null "> and t.cmty_id = #{cmtyId}</if>
<if test="regionName != null and regionName != ''"> and t.region_name like concat('%', #{regionName}, '%')</if>
<if test="groupName != null and groupName != ''"> and t.group_name like concat('%', #{groupName}, '%')</if>
<if test="companyName != null and companyName != ''"> and t.company_name like concat('%', #{companyName}, '%')</if>
<if test="companyCode != null and companyCode != ''"> and t.company_code = #{companyCode}</if>
<if test="province != null and province != ''"> and t.province = #{province}</if>
<if test="city != null and city != ''"> and t.city = #{city}</if>
<if test="district != null and district != ''"> and t.district = #{district}</if>
<if test="street != null and street != ''"> and t.street = #{street}</if>
<if test="vlgOrCmty != null and vlgOrCmty != ''"> and t.vlg_or_cmty = #{vlgOrCmty}</if>
<if test="urbRurCls != null and urbRurCls != ''"> and t.urb_rur_cls = #{urbRurCls}</if>
<if test="projectTypeName != null and projectTypeName != ''"> and t.project_type_name like concat('%', #{projectTypeName}, '%')</if>
<if test="projectTypeCode != null and projectTypeCode != ''"> and t.project_type_code = #{projectTypeCode}</if>
<if test="assignmentTime != null "> and t.assignment_time = #{assignmentTime}</if>
<if test="isCompleted != null and isCompleted != ''"> and t.is_completed = #{isCompleted}</if>
<if test="completionTime != null "> and t.completion_time = #{completionTime}</if>
<if test="nonNcmpRsn != null and nonNcmpRsn != ''"> and t.non_ncmp_rsn = #{nonNcmpRsn}</if>
<if test="projectPersonId != null "> and t.project_person_id = #{projectPersonId}</if>
<if test="projectPersonName != null and projectPersonName != ''"> and t.project_person_name like concat('%', #{projectPersonName}, '%')</if>
<if test="projectPersonAccount != null and projectPersonAccount != ''"> and t.project_person_account = #{projectPersonAccount}</if>
<if test="gasConnMtrRis != null and gasConnMtrRis != ''"> and t.gas_conn_mtr_ris = #{gasConnMtrRis}</if>
<if test="gctMtrrisTime != null "> and t.gct_mtrris_time = #{gctMtrrisTime}</if>
<if test="gctNcmpRsn != null and gctNcmpRsn != ''"> and t.gct_ncmp_rsn = #{gctNcmpRsn}</if>
<if test="operatePersonId != null "> and t.operate_person_id = #{operatePersonId}</if>
<if test="operatePersonName != null and operatePersonName != ''"> and t.operate_person_name like concat('%', #{operatePersonName}, '%')</if>
<if test="operatePersonAccount != null and operatePersonAccount != ''"> and t.operate_person_account = #{operatePersonAccount}</if>
<if test="defFlag != null and defFlag != ''"> and t.def_flag = #{defFlag}</if>
<if test="statusCode != null and statusCode != ''"> and t.status_code = #{statusCode}</if>
<if test="statusName != null and statusName != ''"> and t.status_name = #{statusName}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by update_time desc
</select>
<select id="selectMcConstructionById" parameterType="Long" resultMap="McConstructionResult">
<include refid="selectMcConstructionVo"/>
where id = #{id}
</select>
<insert id="insertMcConstruction" parameterType="com.chinagas.modules.schsf.domain.McConstruction" useGeneratedKeys="true" keyProperty="id">
insert into mc_construction
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="cmtyId != null">cmty_id,</if>
<if test="regionName != null and regionName != ''">region_name,</if>
<if test="groupName != null and groupName != ''">group_name,</if>
<if test="companyName != null and companyName != ''">company_name,</if>
<if test="companyCode != null and companyCode != ''">company_code,</if>
<if test="province != null">province,</if>
<if test="city != null">city,</if>
<if test="district != null">district,</if>
<if test="street != null">street,</if>
<if test="vlgOrCmty != null">vlg_or_cmty,</if>
<if test="urbRurCls != null">urb_rur_cls,</if>
<if test="projectTypeName != null">project_type_name,</if>
<if test="projectTypeCode != null">project_type_code,</if>
<if test="assignmentTime != null">assignment_time,</if>
<if test="isCompleted != null">is_completed,</if>
<if test="completionTime != null">completion_time,</if>
<if test="nonNcmpRsn != null">non_ncmp_rsn,</if>
<if test="projectPersonId != null">project_person_id,</if>
<if test="projectPersonName != null">project_person_name,</if>
<if test="projectPersonAccount != null">project_person_account,</if>
<if test="gasConnMtrRis != null">gas_conn_mtr_ris,</if>
<if test="gctMtrrisTime != null">gct_mtrris_time,</if>
<if test="gctNcmpRsn != null">gct_ncmp_rsn,</if>
<if test="operatePersonId != null">operate_person_id,</if>
<if test="operatePersonName != null">operate_person_name,</if>
<if test="operatePersonAccount != null">operate_person_account,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="defFlag != null and defFlag != ''">def_flag,</if>
<if test="statusCode != null">status_code,</if>
<if test="statusName != null">status_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="cmtyId != null">#{cmtyId},</if>
<if test="regionName != null and regionName != ''">#{regionName},</if>
<if test="groupName != null and groupName != ''">#{groupName},</if>
<if test="companyName != null and companyName != ''">#{companyName},</if>
<if test="companyCode != null and companyCode != ''">#{companyCode},</if>
<if test="province != null">#{province},</if>
<if test="city != null">#{city},</if>
<if test="district != null">#{district},</if>
<if test="street != null">#{street},</if>
<if test="vlgOrCmty != null">#{vlgOrCmty},</if>
<if test="urbRurCls != null">#{urbRurCls},</if>
<if test="projectTypeName != null">#{projectTypeName},</if>
<if test="projectTypeCode != null">#{projectTypeCode},</if>
<if test="assignmentTime != null">#{assignmentTime},</if>
<if test="isCompleted != null">#{isCompleted},</if>
<if test="completionTime != null">#{completionTime},</if>
<if test="nonNcmpRsn != null">#{nonNcmpRsn},</if>
<if test="projectPersonId != null">#{projectPersonId},</if>
<if test="projectPersonName != null">#{projectPersonName},</if>
<if test="projectPersonAccount != null">#{projectPersonAccount},</if>
<if test="gasConnMtrRis != null">#{gasConnMtrRis},</if>
<if test="gctMtrrisTime != null">#{gctMtrrisTime},</if>
<if test="gctNcmpRsn != null">#{gctNcmpRsn},</if>
<if test="operatePersonId != null">#{operatePersonId},</if>
<if test="operatePersonName != null">#{operatePersonName},</if>
<if test="operatePersonAccount != null">#{operatePersonAccount},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="defFlag != null and defFlag != ''">#{defFlag},</if>
<if test="statusCode != null">#{statusCode},</if>
<if test="statusName != null">#{statusName},</if>
</trim>
</insert>
<update id="updateMcConstruction" parameterType="com.chinagas.modules.schsf.domain.McConstruction">
update mc_construction
<trim prefix="SET" suffixOverrides=",">
<if test="cmtyId != null">cmty_id = #{cmtyId},</if>
<if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
<if test="groupName != null and groupName != ''">group_name = #{groupName},</if>
<if test="companyName != null and companyName != ''">company_name = #{companyName},</if>
<if test="companyCode != null and companyCode != ''">company_code = #{companyCode},</if>
<if test="province != null">province = #{province},</if>
<if test="city != null">city = #{city},</if>
<if test="district != null">district = #{district},</if>
<if test="street != null">street = #{street},</if>
<if test="vlgOrCmty != null">vlg_or_cmty = #{vlgOrCmty},</if>
<if test="urbRurCls != null">urb_rur_cls = #{urbRurCls},</if>
<if test="projectTypeName != null">project_type_name = #{projectTypeName},</if>
<if test="projectTypeCode != null">project_type_code = #{projectTypeCode},</if>
<if test="assignmentTime != null">assignment_time = #{assignmentTime},</if>
<if test="isCompleted != null">is_completed = #{isCompleted},</if>
<if test="completionTime != null">completion_time = #{completionTime},</if>
<if test="nonNcmpRsn != null">non_ncmp_rsn = #{nonNcmpRsn},</if>
<if test="projectPersonId != null">project_person_id = #{projectPersonId},</if>
<if test="projectPersonName != null">project_person_name = #{projectPersonName},</if>
<if test="projectPersonAccount != null">project_person_account = #{projectPersonAccount},</if>
<if test="gasConnMtrRis != null">gas_conn_mtr_ris = #{gasConnMtrRis},</if>
<if test="gctMtrrisTime != null">gct_mtrris_time = #{gctMtrrisTime},</if>
<if test="gctNcmpRsn != null">gct_ncmp_rsn = #{gctNcmpRsn},</if>
<if test="operatePersonId != null">operate_person_id = #{operatePersonId},</if>
<if test="operatePersonName != null">operate_person_name = #{operatePersonName},</if>
<if test="operatePersonAccount != null">operate_person_account = #{operatePersonAccount},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="defFlag != null and defFlag != ''">def_flag = #{defFlag},</if>
<if test="statusCode != null">status_code = #{statusCode},</if>
<if test="statusName != null">status_name = #{statusName},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMcConstructionById" parameterType="Long">
delete from mc_construction where id = #{id}
</delete>
<delete id="deleteMcConstructionByIds" parameterType="String">
delete from mc_construction where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectMcConstructionByData" resultMap="McConstructionResult" parameterType="com.chinagas.modules.schsf.domain.McConstruction" >
<include refid="selectMcConstructionVo"/>
where 1 = 1
and t.region_name = #{regionName}
and t.group_name = #{groupName}
and t.company_name = #{companyName}
and t.company_code = #{companyCode}
<if test="province != null">
and t.province = #{province}
</if>
<if test="city != null">
and t.city = #{city}
</if>
<if test="district != null">
and t.district = #{district}
</if>
<if test="street != null">
and t.street = #{street}
</if>
<if test="statusCode != null">
and status_code = #{statusCode}
</if>
and t.vlg_or_cmty = #{vlgOrCmty}
</select>
<select id="selectMcConstructionNodeUserList" resultType="com.chinagas.modules.schsf.domain.dto.NodeUsersDto" parameterType="String">
SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id
INNER JOIN sys_user us on us.user_id = userRole.user_id
LEFT JOIN sys_user_unite un on un.user_id=us.user_id
WHERE menu.perms=#{nodeType,jdbcType=VARCHAR}
and role.data_scope='1'
UNION
SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id
INNER JOIN sys_user us on us.user_id = userRole.user_id
INNER JOIN sys_user_dept userDept on userDept.user_id=us.user_id and userDept.dept_id in ( SELECT construction.company_code FROM mc_construction construction WHERE construction.id=#{id})
LEFT JOIN sys_user_unite un on un.user_id=us.user_id
WHERE menu.perms=#{nodeType,jdbcType=VARCHAR}
and role.data_scope='3'
UNION
SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id
INNER JOIN sys_user us on us.user_id = userRole.user_id
INNER JOIN sys_user_dept userDept on userDept.user_id=us.user_id
INNER JOIN sys_dept dept on dept.dept_id =userDept.dept_id
INNER JOIN sys_dept dept2 on dept2.dept_id in (SELECT a.dept_id FROM sys_dept a WHERE a.dept_id = dept.dept_id or find_in_set( dept.parent_id , ancestors ) )
and dept2.dept_id = (SELECT construction.company_code FROM mc_construction construction WHERE construction.id=#{id} )
LEFT JOIN sys_user_unite un on un.user_id=us.user_id
WHERE menu.perms= #{nodeType,jdbcType=VARCHAR}
and role.data_scope='4'
UNION
SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id and userRole.user_id = (SELECT construction.create_by FROM mc_construction construction WHERE construction.id=#{id} )
INNER JOIN sys_user us on us.user_id = userRole.user_id
LEFT JOIN sys_user_unite un on un.user_id=us.user_id
WHERE menu.perms=#{nodeType,jdbcType=VARCHAR}
and role.data_scope='5'
</select>
</mapper>