heheng
9 天以前 bd605ac1e79b73db3b501f323d6f4a10c0f27dd5
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
package com.gkhy.exam.system.service.impl;
 
 
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gkhy.exam.common.constant.UserConstant;
import com.gkhy.exam.common.domain.TreeSelect;
import com.gkhy.exam.common.domain.entity.SysDept;
import com.gkhy.exam.common.domain.entity.SysRole;
import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.common.utils.SpringUtils;
import com.gkhy.exam.system.domain.SysDeptResponsibility;
import com.gkhy.exam.system.domain.SysFunctionalDistribution;
import com.gkhy.exam.system.domain.vo.*;
import com.gkhy.exam.system.mapper.SysDeptMapper;
import com.gkhy.exam.system.mapper.SysDeptResponsibilityMapper;
import com.gkhy.exam.system.mapper.SysFunctionalDistributionMapper;
import com.gkhy.exam.system.mapper.SysRoleMapper;
import com.gkhy.exam.system.service.ISysDeptService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 部门管理 服务实现
 * 
 * @author expert
 */
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
    @Autowired
    private SysDeptMapper deptMapper;
 
    @Autowired
    private SysRoleMapper roleMapper;
 
    @Autowired
    private SysDeptResponsibilityMapper deptResponsibilityMapper;
 
    @Autowired
    private SysFunctionalDistributionMapper sysFunctionalDistributionMapper;
    public static final String[] DEPT_ROOT = {"4.1",  "4.2", "4.3", "4.4", "5.1", "5.2", "5.3","6.1", "6.2", "6.3",
            "7.1.1",  "7.1.2", "7.1.3", "7.1.4", "7.1.5", "7.1.6"};
    /**
     * 查询部门管理数据
     * 
     * @param dept 部门信息
     * @return 部门信息集合
     */
    @Override
 
    public List<DeptVo> selectDeptList(SysDept dept)
    {
        if (dept.getCompanyId() == null){
            dept.setCompanyId(SecurityUtils.getCompanyId());
        }
        return deptMapper.selectDeptList(dept);
    }
 
    @Override
    public List<SysDept> getOutDeptList(SysDept dept) {
        return deptMapper.getOutDeptList(dept);
    }
 
    /**
     * 查询部门树结构信息
     * 
     * @param dept 部门信息
     * @return 部门树信息集合
     */
    @Override
    public List<TreeSelect> selectDeptTreeList(SysDept dept)
    {
        List<SysDept> depts = SpringUtils.getAopProxy(this).getOutDeptList(dept);
        return buildDeptTreeSelect(depts);
    }
 
    /**
     * 构建前端所需要树结构
     * 
     * @param depts 部门列表
     * @return 树结构列表
     */
    @Override
    public List<SysDept> buildDeptTree(List<SysDept> depts)
    {
        List<SysDept> returnList = new ArrayList<SysDept>();
        List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
        for (SysDept dept : depts)
        {
            // 如果是顶级节点, 遍历该父节点的所有子节点
            if (!tempList.contains(dept.getParentId()))
            {
                recursionFn(depts, dept);
                returnList.add(dept);
            }
        }
        if (returnList.isEmpty())
        {
            returnList = depts;
        }
        return returnList;
    }
 
    /**
     * 构建前端所需要下拉树结构
     * 
     * @param depts 部门列表
     * @return 下拉树结构列表
     */
    @Override
    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
    {
        List<SysDept> deptTrees = buildDeptTree(depts);
        return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
    }
 
    /**
     * 根据角色ID查询部门树信息
     * 
     * @param roleId 角色ID
     * @return 选中部门列表
     */
    @Override
    public List<Long> selectDeptListByRoleId(Long roleId)
    {
        SysRole role = roleMapper.selectRoleById(roleId);
        return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
    }
 
    /**
     * 根据部门ID查询信息
     * 
     * @param deptId 部门ID
     * @return 部门信息
     */
    @Override
    public DeptDetialVo selectDeptById(Long deptId)
    {
        SysDept sysDept = deptMapper.selectDeptById(deptId);
        DeptDetialVo deptDetialVo = new DeptDetialVo();
        BeanUtils.copyProperties(sysDept, deptDetialVo);
        LambdaQueryWrapper<SysDeptResponsibility> lambdaQueryWrapper = Wrappers.<SysDeptResponsibility>lambdaQuery()
                .eq(SysDeptResponsibility::getDeptId, deptId)
                .eq(SysDeptResponsibility::getDelFlag, UserConstant.ENABLE)
                .orderByAsc(SysDeptResponsibility::getClauseNum);
        List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(lambdaQueryWrapper);
        deptDetialVo.setSysDeptResponsibilitys(sysDeptResponsibilities);
 
        return deptDetialVo ;
    }
 
    /**
     * 根据ID查询所有子部门(正常状态)
     * 
     * @param deptId 部门ID
     * @return 子部门数
     */
    @Override
    public int selectNormalChildrenDeptById(Long deptId)
    {
        return deptMapper.selectNormalChildrenDeptById(deptId);
    }
 
    /**
     * 是否存在子节点
     * 
     * @param deptId 部门ID
     * @return 结果
     */
    @Override
    public boolean hasChildByDeptId(Long deptId)
    {
        int result = deptMapper.hasChildByDeptId(deptId);
        return result > 0;
    }
 
    /**
     * 查询部门是否存在用户
     * 
     * @param deptId 部门ID
     * @return 结果 true 存在 false 不存在
     */
    @Override
    public boolean checkDeptExistUser(Long deptId)
    {
        int result = deptMapper.checkDeptExistUser(deptId);
        return result > 0;
    }
 
    /**
     * 校验部门名称是否唯一
     * 
     * @param dept 部门信息
     * @return 结果
     */
    @Override
    public boolean checkDeptNameUnique(SysDept dept)
    {
        Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
        Long companyId = SecurityUtils.getCompanyId();
 
        SysDept info = deptMapper.checkDeptNameUnique(companyId,dept.getDeptName(), dept.getParentId());
        if (ObjectUtil.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
        {
            return UserConstant.NOT_UNIQUE;
        }
        return UserConstant.UNIQUE;
    }
 
    /**
     * 校验部门是否有数据权限
     * 
     * @param deptId 部门id
     */
    @Override
    public void checkDeptDataScope(Long deptId)
    {
        if (!SecurityUtils.adminUser() && ObjectUtil.isNotNull(deptId))
        {
            SysDept dept = new SysDept();
            dept.setDeptId(deptId);
            List<SysDept> depts = SpringUtils.getAopProxy(this).getOutDeptList(dept);
            if (ObjectUtil.isEmpty(depts))
            {
                throw new ApiException("没有权限访问部门数据!");
            }
        }
    }
 
    /**
     * 新增保存部门信息
     * 
     * @param dept 部门信息
     * @return 结果
     */
    @Override
    public int insertDept(SysDept dept)
    {
        SysDept info = deptMapper.selectDeptById(dept.getParentId());
        // 如果父节点不为正常状态,则不允许新增子节点
        if (!UserConstant.DEPT_NORMAL.equals(info.getStatus()))
        {
            throw new ApiException("部门停用,不允许新增");
        }
        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
        return deptMapper.insertDept(dept);
    }
 
    @Override
    @Transactional
    public int saveDept(SysDeptSaveDTOReq dept) {
//        Long companyId = SecurityUtils.getCompanyId();
//        if (!companyId.equals(dept.getCompanyId())){
//            throw new ApiException("无权操作!");
//        }
        SysDept sysDept = new SysDept();
        BeanUtils.copyProperties(dept, sysDept);
        boolean b = checkDeptNameUnique(sysDept);
        if (!b){
            throw new ApiException("部门名称已存在!");
        }
        int i = 0;
        if (sysDept.getDeptId() == null){
            sysDept.setCreateBy(SecurityUtils.getUsername());
             i = deptMapper.insertDept(sysDept);
        }else {
            sysDept.setUpdateBy(SecurityUtils.getUsername());
            sysDept.setUpdateTime(LocalDateTime.now());
            i = deptMapper.updateDept(sysDept);
        }
        if (i > 0){
            List<Long> delCaluseIds = dept.getDelCaluseIds();
            if (delCaluseIds != null && !delCaluseIds.isEmpty())
            {
                delCaluse(sysDept.getDeptId(), delCaluseIds);
            }
            //处理条款
            batchSaveCaluse(sysDept.getDeptId(), dept.getCompanyId(), dept.getCaluseVO1List());
 
        }
 
        return sysDept.getDeptId().byteValue();
    }
 
    @Override
    @Transactional
    public int saveDeptResponsibility(SysDeptResponsibilityReqVo reqVo) {
//        Long companyId = SecurityUtils.getCompanyId();
//        if (!companyId.equals(reqVo.getCompanyId())){
//            throw new ApiException("无权操作!");
//        }
        SysDept sysDept = deptMapper.selectDeptById(reqVo.getDeptId());
        if (null == sysDept){
            throw new ApiException("部门不存在!");
        }
        if (!reqVo.getCompanyId().equals(sysDept.getCompanyId())){
            throw new ApiException("无权操作!");
        }
        SysDept dept = new SysDept();
        dept.setDeptId(reqVo.getDeptId());
        dept.setPersonNum(reqVo.getPersonNum());
        dept.setInternalAuditors(reqVo.getInternalAuditors());
        dept.setResponsibilities(reqVo.getResponsibilities());
        dept.setUpdateBy(SecurityUtils.getUsername());
        dept.setUpdateTime(LocalDateTime.now());
        int i = deptMapper.updateDept(dept);
        if (i < 1){
            throw new ApiException("编辑失败!");
        }
 
        batchSaveRespon(reqVo);
        return 1;
    }
 
    @Override
    public List<SysFunctionalDistribution> getFunctionalDistributionList(Long companyId) {
        if (companyId != null){
            companyId = SecurityUtils.getCompanyId();
        }
       return sysFunctionalDistributionMapper.selectListVo(companyId);
    }
 
    @Override
    @Transactional
    public int initFunctionalDistribution(Long companyId) {
 
//        if (!companyId.equals(SecurityUtils.getCompanyId())){
//            throw new ApiException("无权操作!");
//        }
 
        sysFunctionalDistributionMapper.delByCompanyId(companyId);
        SysDept sysDept = new SysDept();
        sysDept.setCompanyId(companyId);
        List<DeptVo> deptVos = deptMapper.selectDeptList(sysDept);
        if (deptVos != null && !deptVos.isEmpty()){
            List<SysFunctionalDistribution> sysFunctionalDistributions = new ArrayList<>();
            for (DeptVo deptVo : deptVos) {
                for (String s : DEPT_ROOT) {
                    SysFunctionalDistribution sysFunctionalDistribution = new SysFunctionalDistribution();
                    sysFunctionalDistribution.setDeptId(deptVo.getDeptId());
                    sysFunctionalDistribution.setCompanyId(companyId);
                    sysFunctionalDistribution.setCreateBy(SecurityUtils.getUsername());
                    sysFunctionalDistribution.setCreateTime(LocalDateTime.now());
                    sysFunctionalDistribution.setClauseNum(s);
                    sysFunctionalDistribution.setChooseLab(0);
                    sysFunctionalDistributions.add(sysFunctionalDistribution);
                }
 
            }
            int i = sysFunctionalDistributionMapper.batchInsert(sysFunctionalDistributions);
            if (i < 1){
                throw new ApiException("初始化失败!");
            }
        }
 
        return 1;
    }
 
    @Override
    public int saveFunctionalDistribution(FunctionalDistributionVo reqVo) {
//        Long companyId = SecurityUtils.getCompanyId();
//        if (!companyId.equals(reqVo.getCompanyId())){
//            throw new ApiException("无权操作!");
//        }
        List<SysFunctionalDistribution> list = reqVo.getList();
        if (list != null && !list.isEmpty())
        {
            for (SysFunctionalDistribution sysFunctionalDistribution : list) {
                sysFunctionalDistribution.setCompanyId(reqVo.getCompanyId());
                sysFunctionalDistribution.setUpdateBy(SecurityUtils.getUsername());
                sysFunctionalDistribution.setUpdateTime(LocalDateTime.now());
            }
        }
        int i = sysFunctionalDistributionMapper.batchUpdate(list);
        if (i < 1){
            throw new ApiException("保存失败!");
        }
        return 1;
    }
 
 
    private void batchSaveRespon(SysDeptResponsibilityReqVo reqVo) {
        List<Long> delData = reqVo.getDelData();
        if (delData != null && !delData.isEmpty())
        {
            deptResponsibilityMapper
                    .update(new SysDeptResponsibility(),
                            new LambdaUpdateWrapper<SysDeptResponsibility>().set(SysDeptResponsibility::getDelFlag, UserConstant.DEPT_DISABLE)
                                    .set(SysDeptResponsibility::getUpdateTime, LocalDateTime.now()).set(SysDeptResponsibility::getUpdateBy, SecurityUtils.getUsername())
                                    .in(SysDeptResponsibility::getId, delData)
                    );
        }
        List<SysDeptResponsibility> sysDeptResponsibilityList = reqVo.getSysDeptResponsibilityList();
        List<String> emptyIdClauseNums = sysDeptResponsibilityList.stream()
                .map(SysDeptResponsibility::getClauseNum)
                .collect(Collectors.toList());
        Set<String> emptyIdClauseNumSet = new HashSet<>(emptyIdClauseNums);
        if (emptyIdClauseNumSet.size() !=  emptyIdClauseNums.size()){
            throw new ApiException("部门条款编码重复!");
        }
        List<Long> emptyIdClauseIds = sysDeptResponsibilityList.stream()
                .filter(item -> item.getId() != null)
                .map(SysDeptResponsibility::getId)
                .collect(Collectors.toList());
 
        if (!emptyIdClauseNums.isEmpty()){
            List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>()
                    .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId())
                    .in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)
                    .notIn(SysDeptResponsibility::getId, emptyIdClauseIds).eq(SysDeptResponsibility::getDelFlag, "0"));
            if (!sysDeptResponsibilities.isEmpty()){
                throw new ApiException("部门条款编码重复!");
            }
        }
        for (SysDeptResponsibility sysDeptResponsibility : sysDeptResponsibilityList) {
            if (sysDeptResponsibility.getId() == null){
                sysDeptResponsibility.setCreateBy(SecurityUtils.getUsername());
                sysDeptResponsibility.setCreateTime(LocalDateTime.now());
                sysDeptResponsibility.setDeptId(reqVo.getDeptId());
                sysDeptResponsibility.setCompanyId(reqVo.getCompanyId());
                deptResponsibilityMapper.insert(sysDeptResponsibility);
            }else {
                sysDeptResponsibility.setUpdateBy(SecurityUtils.getUsername());
                sysDeptResponsibility.setUpdateTime(LocalDateTime.now());
                deptResponsibilityMapper.updateById(sysDeptResponsibility);
            }
 
        }
    }
 
 
    private void delCaluse(Long deptId,  List<Long> delCaluseIds)
    {
        deptResponsibilityMapper
                .update(new SysDeptResponsibility(),
                        new LambdaUpdateWrapper<SysDeptResponsibility>().set(SysDeptResponsibility::getDelFlag, UserConstant.DEPT_DISABLE)
                                .set(SysDeptResponsibility::getUpdateTime, LocalDateTime.now()).set(SysDeptResponsibility::getUpdateBy, SecurityUtils.getUsername())
                                .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getId, delCaluseIds));
    }
 
    private void batchSaveCaluse(Long deptId,Long companyId, List<CaluseVO1> caluseVO1List) {
 
        List<String> emptyIdClauseNums = caluseVO1List.stream()
                .filter(item -> item.getId() == null)
                .map(CaluseVO1::getClauseNum)
                .collect(Collectors.toList());
        if (!emptyIdClauseNums.isEmpty()){
            List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>()
                    .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)
                    .eq(SysDeptResponsibility::getCompanyId, companyId).eq(SysDeptResponsibility::getDelFlag, "0"));
            if (!sysDeptResponsibilities.isEmpty()){
                throw new ApiException("部门条款编码重复!");
            }
        }
 
        for (CaluseVO1 caluseVO1 : caluseVO1List) {
            SysDeptResponsibility sysDeptResponsibility = new SysDeptResponsibility();
            BeanUtils.copyProperties(caluseVO1, sysDeptResponsibility);
            sysDeptResponsibility.setCompanyId(companyId);
            sysDeptResponsibility.setDeptId(deptId);
 
 
            if (sysDeptResponsibility.getId() == null){
                sysDeptResponsibility.setCreateBy(SecurityUtils.getUsername());
                sysDeptResponsibility.setCreateTime(LocalDateTime.now());
                sysDeptResponsibility.setDataType("2");
                deptResponsibilityMapper.insert(sysDeptResponsibility);
            }else {
                sysDeptResponsibility.setUpdateBy(SecurityUtils.getUsername());
                sysDeptResponsibility.setUpdateTime(LocalDateTime.now());
                deptResponsibilityMapper.updateById(sysDeptResponsibility);
            }
 
        }
 
    }
 
    /**
     * 修改保存部门信息
     * 
     * @param dept 部门信息
     * @return 结果
     */
    @Override
    public int updateDept(SysDept dept)
    {
        SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
        SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
        if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept))
        {
            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
            String oldAncestors = oldDept.getAncestors();
            dept.setAncestors(newAncestors);
            updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
        }
        int result = deptMapper.updateDept(dept);
        if (UserConstant.DEPT_NORMAL.equals(dept.getStatus()) && ObjectUtil.isNotEmpty(dept.getAncestors())
                && !ObjectUtil.equals("0", dept.getAncestors()))
        {
            // 如果该部门是启用状态,则启用该部门的所有上级部门
            updateParentDeptStatusNormal(dept);
        }
        return result;
    }
 
    /**
     * 修改该部门的父级部门状态
     * 
     * @param dept 当前部门
     */
    private void updateParentDeptStatusNormal(SysDept dept)
    {
        String ancestors = dept.getAncestors();
        Long[] deptIds = Convert.toLongArray(ancestors);
        deptMapper.updateDeptStatusNormal(deptIds);
    }
 
    /**
     * 修改子元素关系
     * 
     * @param deptId 被修改的部门ID
     * @param newAncestors 新的父ID集合
     * @param oldAncestors 旧的父ID集合
     */
    public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
    {
        List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
        for (SysDept child : children)
        {
            child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
        }
        if (children.size() > 0)
        {
            deptMapper.updateDeptChildren(children);
        }
    }
 
    /**
     * 删除部门管理信息
     * 
     * @param deptId 部门ID
     * @return 结果
     */
    @Override
    public int deleteDeptById(Long deptId)
    {
        return deptMapper.deleteDeptById(deptId);
    }
 
    /**
     * 递归列表
     */
    private void recursionFn(List<SysDept> list, SysDept t)
    {
        // 得到子节点列表
        List<SysDept> childList = getChildList(list, t);
        t.setChildren(childList);
        for (SysDept tChild : childList)
        {
            if (hasChild(list, tChild))
            {
                recursionFn(list, tChild);
            }
        }
    }
 
    /**
     * 得到子节点列表
     */
    private List<SysDept> getChildList(List<SysDept> list, SysDept t)
    {
        List<SysDept> tlist = new ArrayList<SysDept>();
        Iterator<SysDept> it = list.iterator();
        while (it.hasNext())
        {
            SysDept n = (SysDept) it.next();
            if (ObjectUtil.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
            {
                tlist.add(n);
            }
        }
        return tlist;
    }
 
    /**
     * 判断是否有子节点
     */
    private boolean hasChild(List<SysDept> list, SysDept t)
    {
        return getChildList(list, t).size() > 0;
    }
}