zhaowenxuan
2024-12-02 b98bda282397df60077efbe4c1ad35a44bdfffb9
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<?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.ltkj.system.mapper.SysDeptMapper">
 
    <resultMap type="SysDept" id="SysDeptResult">
        <id property="deptId" column="dept_id"/>
        <result property="parentId" column="parent_id"/>
        <result property="ancestors" column="ancestors"/>
        <result property="deptName" column="dept_name"/>
        <result property="orderNum" column="order_num"/>
        <result property="leader" column="leader"/>
        <result property="phone" column="phone"/>
        <result property="email" column="email"/>
        <result property="status" column="status"/>
        <result property="deleted" column="deleted"/>
        <!--        <result property="parentName" column="parent_name" />-->
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
 
        <result property="departmentEnName" column="department_en_name"/>
        <result property="orgType" column="org_type"/>
        <result property="departmentCode" column="department_code"/>
        <result property="parentOrgId" column="parent_org_id"/>
        <result property="parentOrgName" column="parent_org_name"/>
        <result property="parentOrgCode" column="parent_org_code"/>
        <result property="parentOrgType" column="parent_org_type"/>
        <result property="hospId" column="hosp_id"/>
        <result property="hospCode" column="hosp_code"/>
        <result property="hospName" column="hosp_name"/>
        <result property="contactPerson" column="contact_person"/>
        <result property="contactPhone" column="contact_phone"/>
        <result property="postalCode" column="postal_code"/>
        <result property="officialWeb" column="official_web"/>
        <result property="plaitBed" column="plait_bed"/>
        <result property="openBed" column="open_bed"/>
        <result property="buildDate" column="build_date"/>
        <result property="overDate" column="over_date"/>
        <result property="peofile" column="peofile"/>
        <result property="standardDeptCode" column="standard_dept_code"/>
        <result property="deptTypeCode" column="dept_type_code"/>
        <result property="deptFcusTypeCode" column="dept_fcus_type_code"/>
        <result property="modality" column="modality"/>
    </resultMap>
 
    <sql id="selectDeptVo">
        select d.dept_id,
               d.parent_id,
               d.ancestors,
               d.dept_name,
               d.order_num,
               d.leader,
               d.phone,
               d.email,
               d.status,
               d.deleted,
               d.create_by,
               d.create_time,
               d.department_en_name,
               d.org_type,
               d.department_code,
               d.parent_org_id,
               d.parent_org_name,
               d.parent_org_code,
               d.parent_org_type,
               d.hosp_id,
               d.hosp_code,
               d.hosp_name,
               d.contact_person,
               d.contact_phone,
               d.postal_code,
               d.official_web,
               d.plait_bed,
               d.open_bed,
               d.build_date,
               d.over_date,
               d.peofile,
               d.standard_dept_code,
               d.dept_type_code,
               d.dept_fcus_type_code,
               d.modality
        from sys_dept d
    </sql>
 
    <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where d.deleted = '0'
        <if test="deptId != null and deptId != 0">
            AND dept_id = #{deptId}
        </if>
        <if test="parentId != null and parentId != 0">
            AND parent_id = #{parentId}
        </if>
        <if test="deptName != null and deptName != ''">
            AND dept_name like concat('%', #{deptName}, '%')
        </if>
        <if test="status != null and status != ''">
            AND status = #{status}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.parent_id, d.order_num
    </select>
 
    <select id="selectDeptListByRoleId" resultType="Long">
        select d.dept_id
        from sys_dept d
        left join sys_role_dept rd on d.dept_id = rd.dept_id
        where rd.role_id = #{roleId}
        <if test="deptCheckStrictly">
            and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id =
            rd.dept_id and rd.role_id = #{roleId})
        </if>
        order by d.parent_id, d.order_num
    </select>
 
    <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
        select d.dept_id,
               d.parent_id,
               d.ancestors,
               d.dept_name,
               d.order_num,
               d.leader,
               d.phone,
               d.email,
               d.status,
               (select dept_name from sys_dept where dept_id = d.parent_id) parent_name
        from sys_dept d
        where d.dept_id = #{deptId}
    </select>
 
    <select id="checkDeptExistUser" parameterType="Long" resultType="int">
        select count(1)
        from sys_user
        where dept_id = #{deptId}
          and deleted = '0'
    </select>
 
    <select id="hasChildByDeptId" parameterType="Long" resultType="int">
        select count(1)
        from sys_dept
        where deleted = '0'
          and parent_id = #{deptId} limit 1
    </select>
 
    <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
        select *
        from sys_dept
        where find_in_set(#{deptId}, ancestors)
    </select>
 
    <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
        select count(*)
        from sys_dept
        where status = 0
          and deleted = '0'
          and find_in_set(#{deptId}, ancestors)
    </select>
 
    <select id="checkDeptNameUnique" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where dept_name=#{deptName} and parent_id = #{parentId} and deleted = '0' limit 1
    </select>
 
    <insert id="insertDept" parameterType="SysDept">
        insert into sys_dept(
        <if test="deptId != null and deptId != 0">dept_id,</if>
        <if test="parentId != null and parentId != 0">parent_id,</if>
        <if test="deptName != null and deptName != ''">dept_name,</if>
        <if test="ancestors != null and ancestors != ''">ancestors,</if>
        <if test="orderNum != null">order_num,</if>
        <if test="leader != null and leader != ''">leader,</if>
        <if test="phone != null and phone != ''">phone,</if>
        <if test="email != null and email != ''">email,</if>
        <if test="status != null">status,</if>
 
        <if test="departmentEnName != null">department_en_name,</if>
        <if test="orgType != null">org_type,</if>
        <if test="departmentCode != null">department_code,</if>
        <if test="parentOrgId != null">parent_org_id,</if>
        <if test="parentOrgName != null">parent_org_name,</if>
        <if test="parentOrgCode != null">parent_org_code,</if>
        <if test="parentOrgType != null">parent_org_type,</if>
        <if test="hospId != null">hosp_id,</if>
        <if test="hospCode != null">hosp_code,</if>
        <if test="hospName != null">hosp_name,</if>
        <if test="contactPerson != null">contact_person,</if>
        <if test="contactPhone != null">contact_phone,</if>
        <if test="postalCode != null">postal_code,</if>
        <if test="officialWeb != null">official_web,</if>
        <if test="plaitBed != null">plait_bed,</if>
        <if test="openBed != null">open_bed,</if>
        <if test="buildDate != null">build_date,</if>
        <if test="overDate != null">over_date,</if>
        <if test="peofile != null">peofile,</if>
        <if test="standardDeptCode != null">standard_dept_code,</if>
 
        <if test="deptTypeCode != null">dept_type_code,</if>
        <if test="deptFcusTypeCode != null">dept_fcus_type_code,</if>
 
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="modality != null and modality != ''">modality,</if>
        create_time
        )values(
        <if test="deptId != null and deptId != 0">#{deptId},</if>
        <if test="parentId != null and parentId != 0">#{parentId},</if>
        <if test="deptName != null and deptName != ''">#{deptName},</if>
        <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
        <if test="orderNum != null">#{orderNum},</if>
        <if test="leader != null and leader != ''">#{leader},</if>
        <if test="phone != null and phone != ''">#{phone},</if>
        <if test="email != null and email != ''">#{email},</if>
        <if test="status != null">#{status},</if>
 
        <if test="departmentEnName != null">#{departmentEnName},</if>
        <if test="orgType != null">#{orgType},</if>
        <if test="departmentCode != null">#{departmentCode},</if>
        <if test="parentOrgId != null">#{parentOrgId},</if>
        <if test="parentOrgName != null">#{parentOrgName},</if>
        <if test="parentOrgCode != null">#{parentOrgCode},</if>
        <if test="parentOrgType != null">#{parentOrgType},</if>
        <if test="hospId != null">#{hospId},</if>
        <if test="hospCode != null">#{hospCode},</if>
        <if test="hospName != null">#{hospName},</if>
        <if test="contactPerson != null">#{contactPerson},</if>
        <if test="contactPhone != null">#{contactPhone},</if>
        <if test="postalCode != null">#{postalCode},</if>
        <if test="officialWeb != null">#{officialWeb},</if>
        <if test="plaitBed != null">#{plaitBed},</if>
        <if test="openBed != null">#{openBed},</if>
        <if test="buildDate != null">#{buildDate},</if>
        <if test="overDate != null">#{overDate},</if>
        <if test="peofile != null">#{peofile},</if>
        <if test="standardDeptCode != null">#{standardDeptCode},</if>
        <if test="deptTypeCode != null">#{deptTypeCode},</if>
        <if test="deptFcusTypeCode != null">#{deptFcusTypeCode},</if>
 
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="modality != null and modality != ''">#{modality},</if>
        sysdate()
        )
    </insert>
 
    <update id="updateDept" parameterType="SysDept">
        update sys_dept
        <set>
            <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
            <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
            <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
            <if test="orderNum != null">order_num = #{orderNum},</if>
            <if test="leader != null">leader = #{leader},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="email != null">email = #{email},</if>
            <if test="status != null and status != ''">status = #{status},</if>
 
            <if test="departmentEnName != null">department_en_name = #{departmentEnName},</if>
            <if test="orgType != null">org_type = #{orgType},</if>
            <if test="departmentCode != null">department_code = #{departmentCode},</if>
            <if test="parentOrgId != null">parent_org_id = #{parentOrgId},</if>
            <if test="parentOrgName != null">parent_org_name = #{parentOrgName},</if>
            <if test="parentOrgCode != null">parent_org_code = #{parentOrgCode},</if>
            <if test="parentOrgType != null">parent_org_type = #{parentOrgType},</if>
            <if test="hospId != null">hosp_id = #{hospId},</if>
            <if test="hospCode != null">hosp_code = #{hospCode},</if>
            <if test="hospName != null">hosp_name = #{hospName},</if>
            <if test="contactPerson != null">contact_person = #{contactPerson},</if>
            <if test="contactPhone != null">contact_phone = #{contactPhone},</if>
            <if test="postalCode != null">postal_code = #{postalCode},</if>
            <if test="officialWeb != null">official_web = #{officialWeb},</if>
            <if test="plaitBed != null">plait_bed = #{plaitBed},</if>
            <if test="openBed != null">open_bed = #{openBed},</if>
            <if test="buildDate != null">build_date = #{buildDate},</if>
            <if test="overDate != null">over_date = #{overDate},</if>
            <if test="peofile != null">peofile = #{peofile},</if>
            <if test="standardDeptCode != null">standard_dept_code = #{standardDeptCode},</if>
            <if test="deptTypeCode != null">dept_type_code = #{deptTypeCode},</if>
            <if test="deptFcusTypeCode != null">dept_fcus_type_code = #{deptFcusTypeCode},</if>
 
 
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="modality != null and modality != ''">modality = #{modality},</if>
            update_time = sysdate()
        </set>
        where dept_id = #{deptId}
    </update>
 
    <update id="updateDeptChildren" parameterType="java.util.List">
        update sys_dept set ancestors =
        <foreach collection="depts" item="item" index="index"
                 separator=" " open="case dept_id" close="end">
            when #{item.deptId} then #{item.ancestors}
        </foreach>
        where dept_id in
        <foreach collection="depts" item="item" index="index"
                 separator="," open="(" close=")">
            #{item.deptId}
        </foreach>
    </update>
 
    <update id="updateDeptStatusNormal" parameterType="Long">
        update sys_dept set status = '0' where dept_id in
        <foreach collection="array" item="deptId" open="(" separator="," close=")">
            #{deptId}
        </foreach>
    </update>
 
    <delete id="deleteDeptById" parameterType="Long">
        update sys_dept
        set deleted = '2'
        where dept_id = #{deptId}
    </delete>
 
    <update id="updateDeptStatus" parameterType="SysDept">
        update sys_dept
        set status = #{status}
        where dept_id = #{deptId}
    </update>
 
 
    <select id="getSysDeptYjWjCustomerList1" parameterType="java.util.Map"  statementType="CALLABLE" resultType="java.util.Map">
        {call pro_tjhzlb_list(
 
                #{deptid,mode=IN,jdbcType=VARCHAR},
                #{tjname,mode=IN,jdbcType=VARCHAR},
                #{tjNumber,mode=IN,jdbcType=VARCHAR},
                #{type,mode=IN,jdbcType=INTEGER},
                #{page,mode=IN,jdbcType=INTEGER},
                #{pageSize,mode=IN,jdbcType=INTEGER},
                #{totalRows,mode=OUT,jdbcType=INTEGER}
            )}
    </select>
 
 
 
    <select id="getSysDeptYjWjCustomerList2" parameterType="java.util.Map"  statementType="CALLABLE" resultType="java.util.EventObject">
        {call pro_tjhzlb_list(
 
                #{deptid,mode=IN,jdbcType=VARCHAR},
                #{tjname,mode=IN,jdbcType=VARCHAR},
                #{tjNumber,mode=IN,jdbcType=VARCHAR},
                #{type,mode=IN,jdbcType=INTEGER},
                #{page,mode=IN,jdbcType=INTEGER},
                #{pageSize,mode=IN,jdbcType=INTEGER},
                #{totalRows,mode=OUT,jdbcType=INTEGER}
            )}
    </select>
 
 
    <select id="getSysDeptYjWjCustomerList13" parameterType="java.util.Map"  statementType="CALLABLE" resultType="java.util.Map">
        {call pro_tjhzlb_list(
 
                #{deptid,mode=IN,jdbcType=VARCHAR},
                #{tjname,mode=IN,jdbcType=VARCHAR},
                #{tjNumber,mode=IN,jdbcType=VARCHAR},
                #{type,mode=IN,jdbcType=INTEGER},
                #{page,mode=IN,jdbcType=INTEGER},
                #{pageSize,mode=IN,jdbcType=INTEGER},
                #{totalRows,mode=OUT,jdbcType=INTEGER}
            )}
    </select>
 
 
    <select id="getSysDeptHyAndYxYjWjCustomerList13" parameterType="java.util.Map"  statementType="CALLABLE" resultType="java.util.Map">
        {call check_hyAndYx_list(
                #{deptid,mode=IN,jdbcType=VARCHAR},
                #{tjname,mode=IN,jdbcType=VARCHAR},
                #{tjNumber,mode=IN,jdbcType=VARCHAR},
                #{type,mode=IN,jdbcType=INTEGER},
                #{page,mode=IN,jdbcType=INTEGER},
                #{pageSize,mode=IN,jdbcType=INTEGER},
                #{totalRows,mode=OUT,jdbcType=INTEGER}
            )}
    </select>
 
</mapper>