ludc
2024-08-16 56de7a42d2567ce72885be8ebb1d1250d68ddd1b
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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
package com.vci.frameworkcore.compatibility.impl;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.vci.client.ClientSession;
import com.vci.common.exception.VciException;
import com.vci.common.locale.LocaleDisplay;
import com.vci.corba.common.PLException;
import com.vci.corba.framework.data.FuncOperationInfo;
import com.vci.corba.framework.data.FunctionInfo;
import com.vci.corba.framework.data.OperateInfo;
import com.vci.corba.framework.data.RoleRightInfo;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.frameworkcore.compatibility.ISmFunctionQueryService;
import com.vci.frameworkcore.enumpck.ResourceControlTypeEnum;
import com.vci.model.SmFunctionForPlatform1;
import com.vci.model.SmRoleForPlatform1;
import com.vci.pagemodel.MenuVO;
import com.vci.pagemodel.SmFunctionVO;
import com.vci.omd.utils.ObjectTool;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.*;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.pagemodel.UIContentVO;
import com.vci.web.properties.JsonConfigReader;
import com.vci.web.service.UIEngineServiceI;
import com.vci.web.service.WebBoServiceI;
import com.vci.web.util.Func;
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.RightControlUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 老平台的权限服务
 * @author weidy
 * @date 2020/3/1
 */
@Service
public class SmFunctionQueryServicePlatformImpl implements ISmFunctionQueryService {
 
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    /**
     * 菜单的根节点主键,这个是平台定义的
     */
    private final String ROOT_MENU_ID  = "modelManagmentNode";
 
    /**
     * 管理功能模块菜单根节点
     */
    private final String SYSTEMMANAGMENTNODE = "systemManagmentNode";
 
    /**
     * 操作类型管理菜单根节点
     */
    private final String OPERATENODE = "operateNode";
 
    /**
     * 使用用户查询
     */
    public static final String QUERY_BY_USER = "select r.PLFUNCOID from plroleright r left join pluserrole u on r.PLROLEOID = u.PLROLEUID ";
 
    /**
     * 业务数据服务
     */
    @Autowired
    private WebBoServiceI boService;
 
    /**
     * 加载自身
     */
    @Autowired(required = false)
    @Lazy
    private ISmFunctionQueryService self;
 
    @Autowired
    private  UIEngineServiceI uiEngineServiceI;
 
    @Autowired
    private PlatformClientUtil platformClientUtil;
 
    @Autowired
    RightControlUtil rightControlUtil;
 
    /**
     * 查询所有的功能
     *
     * @return 功能的显示对象
     */
    @Override
    public List<SmFunctionVO> selectAllFunction() {
        VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(null, SmFunctionForPlatform1.class);
        List<SmFunctionForPlatform1> functions = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class);
        return functionForPlatform1ToFunctionDOs(functions);
    }
 
    /**
     * 查询所有的功能映射
     *
     * @return 功能的显示对象
     */
    @Override
    public Map<String, SmFunctionVO> selectAllFunctionMap() {
        return Optional.ofNullable(self.selectAllFunction()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t));
    }
 
    /**
     * 根据用户查询关联的权限
     *
     * @param userOid             用户的主键
     * @param queryMap            查询条件,如果要用用户的属性查询,可以使用pkUser.xxx
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象,未转化为上下级关系
     */
    @Override
    public List<SmFunctionVO> listFunctionByUserOid(String userOid, Map<String, String> queryMap, ResourceControlTypeEnum resourceControlTypeEnum) {
        if(StringUtils.isBlank(userOid)){
            return new ArrayList<>();
        }
        VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,SmFunctionForPlatform1.class);
        queryWrapper.in("ploid",QUERY_BY_USER + " where u.pluseruid = '" + userOid.trim() + "'");
        List<SmFunctionForPlatform1> functions = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class);
        if(CollectionUtils.isEmpty(functions)){
            return new ArrayList<>();
        }
        //TODO 密级的控制
        //超级管理员,一般不让登录,登录后可以看业务的功能,也可以看管理功能
        //三员的,只看管理的
        //普通的只看业务的
 
        if(resourceControlTypeEnum == null){
            resourceControlTypeEnum = ResourceControlTypeEnum.BS;
        }
        String controlType = resourceControlTypeEnum.getValue();
        List<SmFunctionVO> functionVOS = functionForPlatform1ToFunctionDOs(functions);
        return functionVOS.stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList());
    }
 
    /**
     * 原平台功能转换为新平台的功能
     * @param functionForPlatform1List 原平台功能对象列表
     * @return 新平台功能对象
     */
    private List<SmFunctionVO> functionForPlatform1ToFunctionDOs(List<SmFunctionForPlatform1> functionForPlatform1List){
        List<SmFunctionVO> functionVOList = new ArrayList<SmFunctionVO>();
        if(!CollectionUtils.isEmpty(functionForPlatform1List)){
            for(int i = 0 ; i < functionForPlatform1List.size(); i ++ ) {
                functionVOList.add(functionForPlatform1ToFunctionVO(functionForPlatform1List.get(i)));
            }
        }
        return functionVOList;
    }
 
    /**
     * 原平台功能转换为新平台的功能
     *
     * @param functionForPlatform1 原平台功能对象
     * @return 新平台功能对象
     */
    private SmFunctionVO functionForPlatform1ToFunctionVO(SmFunctionForPlatform1 functionForPlatform1){
        SmFunctionVO functionVO = new SmFunctionVO();
        functionVO.setOid(functionForPlatform1.getPloid());
        functionVO.setId(String.valueOf(functionForPlatform1.getPlmoduleno()));
        functionVO.setName(functionForPlatform1.getPlname());
        functionVO.setLogName(functionForPlatform1.getPlaliasname());
        if(StringUtils.isNotBlank(functionForPlatform1.getPlresourceb())){
            functionVO.setResourceControlType(ResourceControlTypeEnum.BS.getValue());
            functionVO.setUrl(functionForPlatform1.getPlresourceb());
        }else if(StringUtils.isNotBlank(functionForPlatform1.getPlresourcedotnet())) {
            functionVO.setResourceControlType(ResourceControlTypeEnum.DOTNET.getValue());
            functionVO.setUrl(functionForPlatform1.getPlresourcedotnet());
        }else if(StringUtils.isNotBlank(functionForPlatform1.getPlresourcemobil())) {
            functionVO.setResourceControlType(ResourceControlTypeEnum.MOBILE.getValue());
            functionVO.setUrl(functionForPlatform1.getPlresourcemobil());
        }else {
            functionVO.setResourceControlType(ResourceControlTypeEnum.CS.getValue());
            functionVO.setUrl(functionForPlatform1.getPlresourcec());
        }
        functionVO.setResourceControlTypeText(ResourceControlTypeEnum.getTextByValue(functionVO.getResourceControlType()));
        functionVO.setDisplayFlag((functionForPlatform1.getPlisvalid() !=null&& 1 == functionForPlatform1.getPlisvalid())? true:false);
        functionVO.setControlRightFlag(true);
        functionVO.setParentFunctionId(functionForPlatform1.getPlparentid());
        functionVO.setOrderNum(functionForPlatform1.getPlmodulesequence());
        if(StringUtils.isNotBlank(functionForPlatform1.getPlimage())) {
            functionVO.setIconCss(functionForPlatform1.getPlimage());
        }
        //以前的老图标没办法转换了,但是支持layui的图标
        if(StringUtils.isNotBlank(functionForPlatform1.getPldesc())){
            //需要在平台中设置菜单的图标路径,在描述字段中添加
            //{iconSrc:xxxx,desc:yyyy}
            try{
                JSONObject jo = JSONObject.parseObject(functionForPlatform1.getPldesc());
                if(jo!=null&&jo.containsKey("iconSrc")){
                    functionVO.setIconCss(jo.getString("iconSrc"));
                }
                if(jo!=null&&jo.containsKey("desc")){
                    functionVO.setDescription(jo.getString("desc"));
                }
            }catch(Exception e){
                functionVO.setDescription(functionForPlatform1.getPldesc());
            }
        }
 
        functionVO.setBtmname("function");
        //老的数据里创建人,最后修改人等都没有
        return functionVO;
    }
 
    /**
     * 获取当前角色的菜单
     *
     * @param treeQueryObject     属性查询对象
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 菜单,包含上下级
     */
    @Override
    public List<MenuVO> treeCurrentUserMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException {
        SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException();
        String parentId;
        boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId());
        if (adminOrDeveloperOrRoot) {
            //系统菜单
            parentId = SYSTEMMANAGMENTNODE;
        } else if (rightControlUtil.isThreeAdminCurUser()) {
            //三员返回管理功能模块相关的菜单
            parentId = SYSTEMMANAGMENTNODE;
        } else {
            //普通用户只返回业务功能模块相关的菜单
            parentId = ROOT_MENU_ID;
        }
        RoleRightInfo[] userRoleRights = rightControlUtil.getRoleRightByUserName(sessionInfo.getUserId());
        Map<String, List<FunctionInfo>> map = rightControlUtil.getAllChildrenFunctionsByUserName(
                parentId, sessionInfo.getUserId(), userRoleRights);
 
        List<MenuVO> functionVOList = new ArrayList<>();
        if(Func.isEmpty(map.get(parentId))) {
            return functionVOList;
        }
        for (FunctionInfo menu : map.get(parentId)) {
            if(!menu.isValid){
                continue;
            }
            MenuVO functionVO = new MenuVO();
            functionVO.setId(menu.id);
            functionVO.setSource(menu.image);
            //if(StringUtils.isBlank(menu.resourceB)){
            //    continue;
            //}
            functionVO.setPath(menu.resourceB);
            functionVO.setParentId(menu.parentId);
            functionVO.setCode(menu.aliasName);
            functionVO.setAlias(menu.aliasName);
            functionVO.setName(menu.name);
            functionVO.getMeta().put("keepAlive",false);
            functionVO.setSort((int) menu.seq);
            try {
                functionVO.setChildren(findChildFunctionVO(menu.id, map));
            } catch (PLException e) {
                e.printStackTrace();
                String errorMsg = "菜单查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
                logger.error(errorMsg);
                throw new VciBaseException(errorMsg);
            }
            if(functionVO.getChildren().size() > 0){
                functionVO.setHasChildren(true);
            }else {
                functionVO.setHasChildren(false);
            }
            functionVOList.add(functionVO);
        }
        //如果是开发或者测试用户,需哟获取系统模块配置菜单
        if(adminOrDeveloperOrRoot){
            //获取首页系统模块配置菜单
            MenuVO menuVO = JsonConfigReader.getMenuVO();
            functionVOList.add(menuVO);
        }
        return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList());
    }
 
    /**
     * 通过模块ID获取子级列表
     * @param parentId
     * @param isAll 是否包括无效的模块,true则包括
     * @return
     * @throws VciBaseException
     */
    @Override
    public List<MenuVO> getSysModelTreeMenuByPID(String parentId,boolean isAll) throws VciBaseException{
        List<MenuVO> menuVOList = new ArrayList<>();
        if(Func.isBlank(parentId)){
            return menuVOList;
        }
        if(parentId.equals("mangeModel") || parentId.equals("businessModel")){
            if(parentId.equalsIgnoreCase("FunctionObject")){
                try {
                    /**判断该模块下子对象是模块还是操作,0表示无子节点,1表示是模块,2表示是操作**/
                    int childType = this.checkChildObject(parentId);
                    if(childType == 2){
                        try{
                            FuncOperationInfo[] infos = platformClientUtil.getFrameworkService().getFuncOperationByModule(parentId, "", false);
                            for(int i = 0;i < infos.length ;i++){
                                FuncOperationInfo info = infos[i];
                                MenuVO menuVO = new MenuVO();
                                menuVO.setId(info.id);
                                menuVO.setCode(info.funcId);
                                menuVO.setId(info.operId);
                                menuVO.setName(info.operName);
                                //menuVO.setOperIndentify(info.operIndentify);
                                menuVO.setAlias(info.operAlias);
                                menuVO.setRemark(info.operDesc);
                                menuVO.setSort((int) info.number);
                                //menuVO.setIsValid(info.isValid);
                                menuVO.setHasChildren(false);
                                menuVOList.add(menuVO);
                            }
                        }catch (PLException e) {
                            e.printStackTrace();
                            throw new VciBaseException(String.valueOf(e.code), e.messages);
                        }
                    }else if(childType == 1){
                        try{
                            FunctionInfo[] funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll);
                            for(int i = 0;i < funcInfos.length; i++){
                                FunctionInfo funcInfo = funcInfos[i];
                                MenuVO menuVO = this.functionInfoToMenuVO(funcInfo);
                                menuVOList.add(menuVO);
                            }
                        }catch (PLException e) {
                            e.printStackTrace();
                            throw new VciBaseException(String.valueOf(e.code),e.messages);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new VciBaseException("模块查询时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e));
                }
            }else{
                try{
                    FunctionInfo[] funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll);
                    for(int i = 0;i < funcInfos.length; i++){
                        FunctionInfo funcInfo = funcInfos[i];
                        MenuVO menuVO = this.functionInfoToMenuVO(funcInfo);
                        menuVO.setModeType("FunctionObject");
                        menuVOList.add(menuVO);
                    }
                }catch (PLException e) {
                    e.printStackTrace();
                    throw new VciBaseException(String.valueOf(e.code),e.messages);
                }
            }
        }else if(parentId.equals("operateType")){
            //加载所有操作
            try{
                OperateInfo[] operateInfos = platformClientUtil.getFrameworkService().getOperateTreeList(parentId);
                for(int i = 0; i < operateInfos.length;i++ ){
                    OperateInfo operateInfo = operateInfos[i];
                    MenuVO menuVO = new MenuVO();
                    menuVO.setId(operateInfo.id);
                    menuVO.setName(operateInfo.name);
                    menuVO.setCode(operateInfo.identify);
                    menuVO.setAlias(operateInfo.alias);
                    menuVO.setCategory(2);
                    menuVO.setRemark(operateInfo.desc);
                    menuVO.getMeta().put("keepAlive",false);
                    menuVO.setSort((int) operateInfo.seq);
                    menuVO.setModeType("operateObject");
                    menuVO.setHasChildren(false);
                    menuVOList.add(menuVO);
                }
            }catch (PLException e) {
                e.printStackTrace();
                throw new VciBaseException(String.valueOf(e.code),new String[]{VciBaseUtil.getExceptionMessage(e)});
            }
        }
        return menuVOList;
    }
 
    /**
     * functionInfo转VO对象
     * @param funcInfo
     * @return
     */
    private MenuVO functionInfoToMenuVO(FunctionInfo funcInfo){
        MenuVO menuVO = new MenuVO();
        menuVO.setId(funcInfo.id);
        menuVO.setSource(funcInfo.image);
        //if(StringUtils.isBlank(menu.resourceB)){
        //    continue;
        //}
        menuVO.setPath(funcInfo.resourceB);
        menuVO.setParentId(funcInfo.parentId);
        menuVO.setCode(funcInfo.aliasName);
        menuVO.setAlias(funcInfo.aliasName);
        menuVO.setName(funcInfo.name);
        menuVO.getMeta().put("keepAlive",false);
        menuVO.setSort((int) funcInfo.seq);
        if(this.checkChildObject(menuVO.getId()) == 0){
            menuVO.setHasChildren(false);
        }else{
            menuVO.setHasChildren(true);
        }
        return menuVO;
    }
 
    /**
     * 通过模块ID检查该模块子级对象是模块还是操作
     * @param moduleId
     * @return 0表示没有模块也没有操作,1表示有模块,2表示有操作
     * @throws VciException
     */
    @Override
    public int checkChildObject(String moduleId) throws VciBaseException {
        long res = 0;
        try{
            res = ClientSession.getFrameworkService().checkChildObject(moduleId);
        }catch (PLException e) {
            e.printStackTrace();
            throw new VciBaseException(String.valueOf(e.code),e.messages);
        }
        return (int)res;
    }
 
    public List<MenuVO> findChildFunctionVO(String parentOid,Map<String, List<FunctionInfo>> map) throws PLException {
        List<FunctionInfo> menus = map.get(parentOid);
        List<MenuVO> functionVOList = new ArrayList<>();
        if(menus == null){
            return functionVOList;
        }
        for (FunctionInfo menu : menus) {
            if(!menu.isValid){
                continue;
            }
            MenuVO functionVO = new MenuVO();
            functionVO.setId(menu.id);
            functionVO.setSource(menu.image);
//            if(StringUtils.isBlank(menu.resourceB) ){
//                continue;
//            }
            functionVO.setPath(menu.resourceB);
            functionVO.setCode(menu.aliasName);
            functionVO.setAlias(menu.aliasName);
            functionVO.setParentId(menu.parentId);
            functionVO.setName(menu.name);
            functionVO.getMeta().put("keepAlive",false);
            functionVO.setSort((int) menu.seq);
            functionVO.setChildren(findChildFunctionVO(menu.id,map));
            if(functionVO.getChildren().size() > 0){
                functionVO.setHasChildren(true);
            }else {
                functionVO.setHasChildren(false);
            }
            functionVOList.add(functionVO);
        }
        return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList());
    }
 
    @Override
    public UIContentVO getUIContentByBtmTypeAndId(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException {
        SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException();
        if(resourceControlTypeEnum == null){
            resourceControlTypeEnum = ResourceControlTypeEnum.BS;
        }
        for (PLUILayout allPLUILayout : platformClientUtil.getUIService().getAllPLUILayouts()) {
            if(treeQueryObject.getConditionMap().getOrDefault("type","").equals(allPLUILayout.plRelatedType)
                    && treeQueryObject.getConditionMap().getOrDefault("context","").equals(allPLUILayout.plCode)){
                return uiEngineServiceI.UIContentDO2VO(allPLUILayout,true);
            }
        }
        return null;
    }
 
    /**
     * 获取所有的功能菜单
     *
     * @param treeQueryObject     树查询对象
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 树节点,出现错误会在异常处理器中统一返回Json
     */
    @Override
    public List<Tree> treeAllMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) {
        List<SmFunctionVO> functionVOList = self.selectAllFunction().stream().filter(s -> s.isDisplayFlag() && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList());
        if(!treeQueryObject.isQueryAllLevel() && StringUtils.isNotBlank(treeQueryObject.getParentOid())){
            functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList());
        }
        return dos2Trees(functionVOList.stream().sorted(Comparator.comparing(s -> s.getOrderNum())).collect(Collectors.toList()),treeQueryObject == null?null:treeQueryObject.getParentOid());
    }
 
    /**
     * 批量将数据对象转换为树节点
     * @param functionVOList 数据对象列表
     * @param rootId 根节点的主键,最顶层使用null或者""
     * @return 树节点列表,不存在数据时返回空列表
     */
    public List<Tree> dos2Trees(List<SmFunctionVO> functionVOList,String rootId){
        if(!CollectionUtils.isEmpty(functionVOList)) {
            List<Tree> rootList = new ArrayList<>();
            List<Tree> childList = new ArrayList<>();
            functionVOList.stream().forEach(s -> {
                Tree tree = DO2Tree(s);
                if (tree.getParentId() == null || tree.getParentId().equals(rootId) || ROOT_MENU_ID.equalsIgnoreCase(tree.getParentId())) {
                    rootList.add(tree);
                } else {
                    childList.add(tree);
                }
            });
            return Tree.getChildList(rootList, childList);
        }else{
            return  new ArrayList<>();
        }
    }
 
    /**
     * 数据对象转换为树节点
     * @param functionVO 数据显示对象
     * @return 树节点对象
     */
    public Tree DO2Tree(SmFunctionVO functionVO){
        Tree tree = new Tree();
        tree.setOid(functionVO.getOid());
        tree.setText(functionVO.getName());
        tree.setIndex(functionVO.getOrderNum() + "");
        tree.setParentId(functionVO.getParentFunctionId());
        tree.setIconCls(functionVO.getIconCss());
        tree.setHref(functionVO.getUrl());
        try {
            tree.setAttributes(WebUtil.objectToMapString(functionVO));
        } catch (Throwable e) {
            logger.error("拷贝信息",e);
        }
        return tree;
    }
 
    /**
     * 通过上级节点获取下级的所有的菜单节点
     *
     * @param treeQueryObject     树查询对象
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 树节点,出现错误会在异常处理器中统一返回Json
     */
    @Override
    public List<Tree> treeFunctionByParent(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) {
         List<SmFunctionVO> functionVOList = self.selectAllFunction().stream().filter(s -> s.isDisplayFlag() && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList());
         if(!treeQueryObject.isQueryAllLevel() && StringUtils.isNotBlank(treeQueryObject.getParentOid())){
             functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList());
         }
         return dos2Trees(functionVOList,treeQueryObject == null?null:treeQueryObject.getParentOid());
    }
 
    /**
     * 通过上级节点获取当前角色有权限的下级的所有的菜单节点
     *
     * @param treeQueryObject     树查询对象
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 树节点,出现错误会在异常处理器中统一返回Json
     */
    @Override
    public List<Tree> treeCurrentFunctionByParent(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) {
        SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfo();
         List<SmFunctionVO> functionVOList =self.selectAllFunction().stream().filter(s -> s.isDisplayFlag()
                 && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType())
                 && !CollectionUtils.isEmpty(sessionInfo.getFunctionOids())
                 && sessionInfo.getFunctionOids().contains(s.getOid())
                 ).collect(Collectors.toList());
         if(!treeQueryObject.isQueryAllLevel() && StringUtils.isNotBlank(treeQueryObject.getParentOid())){
             functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList());
         }
         return dos2Trees(functionVOList,treeQueryObject == null?null:treeQueryObject.getParentOid());
    }
 
    /**
     * 获取系统功能列表
     *
     * @param queryMap   查询条件
     * @param pageHelper 排序和分页对象
     * @return DataGrid 系统功能列表
     */
    @Override
    public DataGrid<SmFunctionVO> dataGrid(Map<String, String> queryMap, PageHelper pageHelper) {
        VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(queryMap,SmFunctionForPlatform1.class,pageHelper);
        List<SmFunctionForPlatform1> functionForPlatform1s = boService.selectByQueryWrapper(queryWrapperForDO, SmFunctionForPlatform1.class);
        List<SmFunctionVO> functionVOS = functionForPlatform1ToFunctionDOs(functionForPlatform1s);
        DataGrid dataGrid = new DataGrid();
        dataGrid.setData(functionVOS);
        if(!CollectionUtils.isEmpty(functionVOS)){
            dataGrid.setTotal(boService.countByQueryWrapper(queryWrapperForDO,SmFunctionForPlatform1.class));
        }
        return dataGrid;
    }
 
    /**
     * 根据角色主键获取关联的权限
     *
     * @param roleOid             角色主键
     * @param queryMap            查询条件,如果需要使用角色的属性来查询可以使用pkUser.xxxx
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象
     */
    @Override
    public List<SmFunctionVO> listFunctionByRoleOid(String roleOid, Map<String, String> queryMap, ResourceControlTypeEnum resourceControlTypeEnum) {
        String controlType = resourceControlTypeEnum == null? ResourceControlTypeEnum.BS.getValue(): resourceControlTypeEnum.getValue();
        return Optional.ofNullable(listFunctionByRoleOid(roleOid,queryMap,false)).orElseGet(()->new ArrayList<>()).stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList());
    }
 
    /**
     * 获取未关联某个角色的权限
     *
     * @param roleOid             角色主键
     * @param queryMap            查询条件,如果需要使用角色的属性来查询可以使用pkUser.xxxx
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象
     */
    @Override
    public List<SmFunctionVO> listFunctionUnInRoleOid(String roleOid, Map<String, String> queryMap, ResourceControlTypeEnum resourceControlTypeEnum) {
        String controlType = resourceControlTypeEnum == null? ResourceControlTypeEnum.BS.getValue(): resourceControlTypeEnum.getValue();
        return Optional.ofNullable(listFunctionByRoleOid(roleOid,queryMap,true)).orElseGet(()->new ArrayList<>()).stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList());
    }
 
    /**
     * 使用角色主键查询权限
     * @param roleOid 用户主键
     * @param queryMap 查询条件
     * @param notIn 是否为不包含
     * @return 角色的显示对象
     */
    private List<SmFunctionVO> listFunctionByRoleOid(String roleOid, Map<String,String> queryMap, boolean notIn){
        if(StringUtils.isBlank(roleOid)){
            return new ArrayList<>();
        }
        if(queryMap == null){
            queryMap = new HashMap<>();
        }
        List<SmFunctionForPlatform1> functions = new ArrayList<>();
        if(roleOid.contains(",")){
            Map<String, String> finalQueryMap = queryMap;
            WebUtil.switchCollectionForOracleIn(WebUtil.str2List(roleOid)).stream().forEach(roleOids->{
                Map<String,String> conditionMap = new HashMap<>();
                finalQueryMap.forEach((key,value)->{
                    conditionMap.put(key,value);
                });
                conditionMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid in (" + WebUtil.toInSql(roleOids.toArray(new String[0])) + ")");
                VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmRoleForPlatform1.class);
                List<SmFunctionForPlatform1> functionForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class);
                if(!CollectionUtils.isEmpty(functionForPlatform1s)){
                    functions.addAll(functionForPlatform1s);
                }
            });
        }else {
            queryMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid ='" + roleOid.trim() + "'");
        }
        VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,SmRoleForPlatform1.class);
        List<SmFunctionForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class);
        if(!CollectionUtils.isEmpty(roleForPlatform1s)){
            functions.addAll(roleForPlatform1s);
        }
        return functionForPlatform1ToFunctionDOs(functions);
    }
 
    /**
     * 获取未关联某个角色的权限
     *
     * @param roleOid             角色主键
     * @param queryMap            查询条件,如果需要使用角色的属性来查询可以使用pkUser.xxxx
     * @param pageHelper          分页和排序对象,老平台不支持使用权限编号来排序
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象
     */
    @Override
    public DataGrid<SmFunctionVO> gridFunctionUninRoleOid(String roleOid, Map<String, String> queryMap, PageHelper pageHelper, ResourceControlTypeEnum resourceControlTypeEnum) {
        return gridFunctionByRoleOid(roleOid,queryMap,pageHelper,resourceControlTypeEnum,true);
    }
 
    /**
     * 批量根据角色的主键来获取权限
     *
     * @param roleOidCollection   角色主键集合
     * @param queryMap            查询条件,如果需要使用角色的属性来查询可以使用pkRole.xxxx
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象,key是角色主键,value是这个角色关联的权限
     */
    @Override
    public Map<String, List<SmFunctionVO>> batchListFunctionByRoleOids(Collection<String> roleOidCollection, Map<String, String> queryMap, ResourceControlTypeEnum resourceControlTypeEnum) {
        if(CollectionUtils.isEmpty(roleOidCollection)){
            return new HashMap<>();
        }
        List<SmFunctionVO> functionVOList = new ArrayList<>();
        Map<String,List<String>>  roleFunctionOidMap = new HashMap<>();
        String roleContoll = resourceControlTypeEnum == null?ResourceControlTypeEnum.BS.getValue():resourceControlTypeEnum.getValue();
        WebUtil.switchCollectionForOracleIn(roleOidCollection).stream().forEach(roleOids->{
            List<SmFunctionVO> functionVOS = Optional.ofNullable(listFunctionByRoleOid(roleOids.stream().collect(Collectors.joining(",")), queryMap, false)).orElseGet(()->new ArrayList<>()).stream().filter(s->roleContoll.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(functionVOS)){
                functionVOList.addAll(functionVOS);
                String sql = "select plfuncoid,plroleoid from plroleright where plroleoid in (" + WebUtil.toInSql(roleOids.toArray(new String[0])) + ")";
                List<BusinessObject> cbos = boService.queryBySql(sql, null);
                if(!CollectionUtils.isEmpty(cbos)){
                    cbos.stream().forEach(cbo->{
                        String roleOid = ObjectTool.getBOAttributeValue(cbo,"plroleoid");
                        List<String> functionOids = roleFunctionOidMap.getOrDefault(roleOid,new ArrayList<>());
                        functionOids.add(ObjectTool.getBOAttributeValue(cbo,"plfuncoid"));
                        roleFunctionOidMap.put(roleOid,functionOids);
                    });
                }
            }
        });
        if(!CollectionUtils.isEmpty(functionVOList)){
            Map<String, SmFunctionVO> functionVOMap = functionVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
            Map<String, List<SmFunctionVO>> roleFunctionVOMap = new HashMap<>();
            roleFunctionOidMap.forEach((roleOid,functionOids)->{
                List<SmFunctionVO> functionVOS = new ArrayList<>();
                functionOids.forEach(functionOid->{
                    if(functionVOMap.containsKey(functionOid)){
                        functionVOS.add(functionVOMap.get(functionOid));
                    }
                });
                roleFunctionVOMap.put(roleOid,functionVOS);
            });
            return roleFunctionVOMap;
        }
        return  new HashMap<>();
    }
 
    /**
     * 使用角色查询权限表
     * @param roleOid 角色的主键
     * @param queryMap 查询条件
     * @param pageHelper 分页对象
     * @param notIn 不包含
     * @return 列表数据
     */
    private DataGrid<SmFunctionVO> gridFunctionByRoleOid(String roleOid,Map<String,String> queryMap,PageHelper pageHelper,ResourceControlTypeEnum resourceControlTypeEnum,boolean notIn){
        if(queryMap == null){
            queryMap = new HashMap<>();
        }
        if(StringUtils.isBlank(roleOid)){
            return new DataGrid<>();
        }
        if(roleOid.contains(",")){
            String[] roleOids = roleOid.trim().split(",");
            if(roleOids.length>1000){
                //这个方法不支持超过1000个的用户查询
                throw new VciBaseException("这个方法不支持超过1000个角色的主键来查询");
            }
            queryMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid in (" + WebUtil.toInSql(roleOid) + ")");
        }else {
            queryMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid ='" + roleOid.trim() + "'");
        }
        if(resourceControlTypeEnum == null){
            resourceControlTypeEnum = ResourceControlTypeEnum.BS;
        }
        switch (resourceControlTypeEnum){
            case BS:
                queryMap.put("plresourceb",QueryOptionConstant.ISNOTNULL);
                break;
            case DOTNET:
                queryMap.put("plresourcedotnet",QueryOptionConstant.ISNOTNULL);
                break;
            case MOBILE:
                queryMap.put("plresourcemobil",QueryOptionConstant.ISNOTNULL);
                break;
            default:
                queryMap.put("plsuffixc",QueryOptionConstant.ISNOTNULL);
        }
        return dataGrid(queryMap,pageHelper);
    }
 
    /**
     * 批量根据角色的主键获取关联的权限
     *
     * @param roleOidCollection   角色的主键集合
     * @param queryMap            查询条件,如果需要使用角色的属性来查询可以使用pkRole.xxxx
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象, 会去除重复的项
     */
    @Override
    public List<SmFunctionVO> listFunctionByRoleOids(Collection<String> roleOidCollection, Map<String, String> queryMap, ResourceControlTypeEnum resourceControlTypeEnum) {
        if(CollectionUtils.isEmpty(roleOidCollection)){
            return new ArrayList<>();
        }
        return listFunctionByRoleOid(roleOidCollection.stream().collect(Collectors.joining(",")),queryMap,false);
    }
 
    /**
     * 批量根据角色的主键获取关联的权限
     *
     * @param roleOidCollection   角色的主键集合
     * @param queryMap            查询条件,如果需要使用角色的属性来查询可以使用pkRole.xxxx
     * @param pageHelper          分页对象
     * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域
     * @return 权限的显示对象, 会去除重复的项
     */
    @Override
    public DataGrid<SmFunctionVO> gridFunctionByRoleOids(Collection<String> roleOidCollection, Map<String, String> queryMap, PageHelper pageHelper, ResourceControlTypeEnum resourceControlTypeEnum) {
        if(CollectionUtils.isEmpty(roleOidCollection)){
            return new DataGrid<>();
        }
        return gridFunctionByRoleOid(roleOidCollection.stream().collect(Collectors.joining(",")), queryMap,pageHelper,resourceControlTypeEnum,false);
    }
 
    /**
     * 清除缓存
     */
    @Override
    public void clearCache() {
 
    }
}