dangsn
2024-06-14 82ff3244651e8a470237b9667583ad942f3a973e
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
package com.vci.frameworkcore.compatibility.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.vci.corba.common.PLException;
import com.vci.corba.framework.data.FunctionInfo;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.frameworkcore.compatibility.ISmFunctionQueryService;
import com.vci.frameworkcore.enumpck.ResourceControlTypeEnum;
import com.vci.frameworkcore.model.SmFunctionForPlatform1;
import com.vci.frameworkcore.model.SmRoleForPlatform1;
import com.vci.frameworkcore.pagemodel.MenuVO;
import com.vci.frameworkcore.pagemodel.SmFunctionVO;
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.wrapper.VciQueryWrapperForDO;
import com.vci.web.pageModel.UIContentVO;
import com.vci.web.service.UIEngineServiceI;
import com.vci.web.service.WebBoServiceI;
import com.vci.web.util.PlatformClientUtil;
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";
 
 
 
    /**
     * 使用用户查询
     */
    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;
 
    /**
     * 查询所有的功能
     *
     * @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();
        if(resourceControlTypeEnum == null){
            resourceControlTypeEnum = ResourceControlTypeEnum.BS;
        }
        FunctionInfo[] menus = platformClientUtil.getFrameworkService().getModuleListByParentId("modelManagmentNode", true);
        List<MenuVO> functionVOList = new ArrayList<>();
        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.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);
            functionVO.setChildren(findChildFunctionVO(menu.id));
            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());
    }
 
    public List<MenuVO> findChildFunctionVO(String parentOid) throws PLException {
        FunctionInfo[] menus = platformClientUtil.getFrameworkService().getModuleListByParentId(parentOid, true);
        List<MenuVO> functionVOList = new ArrayList<>();
        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));
            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<com.vci.client.bof.ClientBusinessObject> cbos = boService.queryBySql(sql, null);
                if(!CollectionUtils.isEmpty(cbos)){
                    cbos.stream().forEach(cbo->{
                        String roleOid = cbo.getAttributeValue("plroleoid");
                        List<String> functionOids = roleFunctionOidMap.getOrDefault(roleOid,new ArrayList<>());
                        functionOids.add(cbo.getAttributeValue("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() {
 
    }
}