xiejun
2024-09-04 ac3f3629a261770f573f27e5e23f7ec19d096c2a
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
package com.vci.web.service.impl;
 
import com.sun.jnlp.ApiDialog;
import com.vci.client.mw.ClientContextVariable;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.PLException;
import com.vci.corba.framework.data.RoleRightInfo;
import com.vci.corba.omd.btm.BizType;
import com.vci.corba.portal.PortalService;
import com.vci.corba.portal.data.*;
import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI;
import com.vci.pagemodel.OsBtmTypeVO;
import com.vci.pagemodel.PLUILayoutCloneVO;
import com.vci.pagemodel.RoleRightVO;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.pagemodel.SessionInfo;
import com.vci.starter.web.pagemodel.Tree;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.util.VciDateUtil;
import com.vci.starter.web.util.WebThreadLocalUtil;
import com.vci.web.service.OsBtmServiceI;
import com.vci.web.service.UIManagerServiceI;
import com.vci.web.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * UI定义服务界面相关接口
 * @author ludc
 * @date 2024/8/28 17:05
 */
@Service
public class UIManagerServiceImpl implements UIManagerServiceI {
 
    /**
     * 平台的调用工具类
     */
    @Resource
    private PlatformClientUtil platformClientUtil;
    /**
     * 角色
     */
    @Resource
    private SmRoleQueryServiceI smRoleQueryServiceI;
 
    /**
     * 业务类型
     */
    @Resource
    private OsBtmServiceI osBtmServiceI;
 
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    /**
     * 排序比较器
     */
    private Comparator<PLUILayout> pageLayoutComparator = new Comparator<PLUILayout>() {
        @Override
        public int compare(PLUILayout o1, PLUILayout o2) {
            return o1.plCode.compareTo(o2.plCode);
        }
    };
 
    /**
     * 根据业务类型名查询ui上下文数据
     * @param baseQueryObject
     * @return
     * @throws PLException
     */
    @Override
    public DataGrid gridUIContextData(BaseQueryObject baseQueryObject) throws PLException {
        VciBaseUtil.alertNotNull(baseQueryObject,"条件对象");
        int page = baseQueryObject.getPage();
        int limit = baseQueryObject.getLimit();
        Map<String, String> conditionMap = baseQueryObject.getConditionMap();
        String btmName = conditionMap.getOrDefault("btmName","");
        if(Func.isEmpty(conditionMap) || Func.isBlank(btmName)){
            throw new PLException("500",new String[]{"未获取到业务类型名称!"});
        }
        String txtName = conditionMap.getOrDefault("txtName","").trim();
        String txtCode = conditionMap.getOrDefault("txtCode","").trim();
        PortalService.GetPLUILayoutsByRelatedTypeAndQueryInfoResult result = platformClientUtil.getUIService()
                .getPLUILayoutsByRelatedTypeAndQueryInfo(btmName, txtName, txtCode, page, limit);
        DataGrid<PLUILayout> dataGrid = new DataGrid<>();
        int total = (int)result.total;
        dataGrid.setTotal(total);
        dataGrid.setLimit(limit);
        dataGrid.setPage(page);
        PLUILayout[] res = result.returnValue;
        Arrays.sort(res,pageLayoutComparator);
        List<PLUILayout> pluiLayouts = Arrays.asList(res);
        dataGrid.setData(pluiLayouts);
        return dataGrid;
    }
 
    /**
     * ton通过业务类型和名称查询
     * @param btemName
     * @param code
     * @return
     * @throws PLException
     */
    public List<PLUILayout> getUIContextDataByBtName(String btemName,String code) throws PLException {
        List<PLUILayout> pluiLayoutList=new ArrayList<>();
        PLUILayout[]  pluiLayouts=   platformClientUtil.getUIService().getPLUILayoutEntityByTypeAndCode(btemName,code);
        if(pluiLayouts!=null&&pluiLayouts.length>0){
            pluiLayoutList= Stream.of(pluiLayouts).collect(Collectors.toList());
        }
        return pluiLayoutList;
    }
 
    /**
     * 给业务类型下添加ui上下文
     * @param pluiLayout
     * @return
     * @throws PLException
     */
    @Override
    public boolean saveUIContextData(PLUILayout pluiLayout) throws VciBaseException {
        try {
            //ui上下文对象校验
            canContinue(pluiLayout);
 
            String code = pluiLayout.plCode;
            String name = pluiLayout.plName;
            boolean isExist = nameOrCodeIsExist(pluiLayout, false);
            //是否存在校验
            if (isExist){
                throw new VciBaseException("上下文编码或名称已经存在,请检查!");
            }
 
            PLUILayout pld = new PLUILayout();
            pld.plOId = ObjectUtility.getNewObjectID36();
            pld.plCode = code;
            pld.plName = name;
            pld.plRelatedType = pluiLayout.plRelatedType;
            pld.plDesc = pluiLayout.plDesc;
            SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
            pld.plCreateUser = sessionInfo.getUserId();
            pld.plModifyUser = sessionInfo.getUserId();
            //导航区
            pld.plIsShowForm = pluiLayout.plIsShowForm;
            //控制区
            pld.plIsShowNavigator = pluiLayout.plIsShowNavigator;
            //操作区
            pld.plIsShowTab = pluiLayout.plIsShowTab;
            //执行保存
            return platformClientUtil.getUIService().savePLUILayout(pld);
        } catch (PLException e) {
            e.printStackTrace();
            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            throw new VciBaseException(exceptionMessage);
        }
    }
 
    /**
     * 修改ui上下文
     * @param pluiLayout
     * @return
     * @throws PLException
     */
    @Override
    public boolean updateUIContextData(PLUILayout pluiLayout) throws VciBaseException {
        this.canContinue(pluiLayout);
        try {
            String code = pluiLayout.plCode;
            String name = pluiLayout.plName;
            boolean isExist = nameOrCodeIsExist(pluiLayout, true);
            if (isExist){
                throw new VciBaseException("上下文编码或名称已经存在,请检查!");
            }
 
            PLUILayout pld = new PLUILayout();
            pld.plOId = pluiLayout.plOId;
            pld.plCode = code;
            pld.plName = name;
            pld.plRelatedType = pluiLayout.plRelatedType;
            pld.plDesc = pluiLayout.plDesc;
            pld.plCreateUser = pluiLayout.plCreateUser;
            pld.plModifyUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
 
            //导航区
            pld.plIsShowForm = pluiLayout.plIsShowForm;
            //控制区
            pld.plIsShowNavigator = pluiLayout.plIsShowNavigator;
            //操作区
            pld.plIsShowTab = pluiLayout.plIsShowTab;
            //执行修改
            return platformClientUtil.getUIService().updatePLUILayout(pld);
        } catch (PLException e) {
            e.printStackTrace();
            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            throw new VciBaseException(exceptionMessage);
        }
    }
 
    /**
     * 根据主键和业务类型oid删除ui上下文数据
     * @return
     */
    @Override
    public boolean delUIContextData(String[] oids) throws PLException {
        VciBaseUtil.alertNotNull(oids,"待删除的对象列表");
        //删除方法中有关联数据删除的操作逻辑
        return platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids);
    }
 
    /**
     * 克隆ui上下文(具备关联数据的克隆)
     * @param pluiLayoutCloneVO
     * @return
     */
    @Override
    public boolean cloneUiContextData(PLUILayoutCloneVO pluiLayoutCloneVO) throws PLException {
        VciBaseUtil.alertNotNull(
            pluiLayoutCloneVO,"克隆参数对象",
            pluiLayoutCloneVO.getSourcePLUILayout(),"克隆的源对象信息",
            pluiLayoutCloneVO.getCloneName(),"克隆的对象名称",
            pluiLayoutCloneVO.getCloneContextCode(),"克隆的对象上下文编码"
        );
        PLUILayout pluiLayout = new PLUILayout();
        PLUILayout sourcePLUILayout = pluiLayoutCloneVO.getSourcePLUILayout();
        //如果选择克隆目标,则克隆到选择的类型下,如果没有选择克隆目标,则克隆到当前类型下
        if(Func.isBlank(pluiLayoutCloneVO.getCloneTargetOid())){
            pluiLayout.plRelatedType = sourcePLUILayout.plRelatedType;
        }
        //克隆的名称和ui上下文编号查重
        String cloneName = pluiLayoutCloneVO.getCloneName();
        String cloneContextCode = pluiLayoutCloneVO.getCloneContextCode();
        pluiLayout.plOId = ObjectUtility.getNewObjectID36();
        pluiLayout.plName = cloneName;
        pluiLayout.plCode = cloneContextCode;
        pluiLayout.plIsShowTab = sourcePLUILayout.plIsShowTab;
        pluiLayout.plIsShowNavigator = sourcePLUILayout.plIsShowNavigator;
        pluiLayout.plIsShowForm = sourcePLUILayout.plIsShowForm;
        pluiLayout.plDesc = sourcePLUILayout.plDesc;
        SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
        pluiLayout.plCreateUser = sessionInfo.getUserId();
        pluiLayout.plModifyUser = sessionInfo.getUserId();
        //克隆目标下ui名称和编号查重
        this.checkCodeName(pluiLayout);
        //1、先保存ui上下文
        boolean res = platformClientUtil.getUIService().savePLUILayout(pluiLayout);
        //2、再考虑子节点的克隆
        PLTabPage[] pages = platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(sourcePLUILayout.plOId); //控制区节点及其子节点的克隆
        if(pages == null){
            return true;
        }
        try {
            for (PLTabPage page : pages) {
                savePlpageLayoutDefinationRelation(page,pluiLayout.plOId);
            }
            return true;
        }catch (Exception e){
            e.printStackTrace();
            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            throw new VciBaseException(exceptionMessage);
        }
    }
 
    @Override
    public void expUiContextData(String[] oids, HttpServletResponse response) throws PLException, IOException {
 
    }
 
    /**
     * 获取UI授权树
     * @param treeQueryObject
     * @return
     * @throws Exception
     */
    @Override
    public List<Tree> getUIAuthor(BaseQueryObject treeQueryObject) throws Exception {
 
        Map<String, String> conditionMap = treeQueryObject.getConditionMap();
        if (conditionMap == null) {
            conditionMap = new HashMap<>();
        }
        String roleId = StringUtils.isBlank(conditionMap.get("roleId")) ? "" : conditionMap.get("roleId");
        String type = StringUtils.isBlank(conditionMap.get("type")) ? "" : conditionMap.get("type");
        String context = StringUtils.isBlank(conditionMap.get("context")) ? "" : conditionMap.get("context");
        boolean showCheckBox = Boolean.parseBoolean(conditionMap.get("showCheckBox"));
       Map<String,RoleRightVO> roleRightVOMap=new HashMap<>();
        if(StringUtils.isNotBlank(roleId)){
          String userName= WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
            RoleRightInfo[] rightInfos= platformClientUtil.getFrameworkService().getRoleRightList(roleId,userName);
            List<RoleRightVO>  roleRightVOList=roleRightDOO2VOS(Arrays.asList(rightInfos));
            roleRightVOMap=roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO));
        }
        BizType[] bizTypes=osBtmServiceI.getBizTypes(type);
        List<Tree> treeList=new ArrayList<>();
        Tree   rootNode =new Tree("root","功能模块","root");
        rootNode.setLevel(0);
        rootNode.setShowCheckbox(true);
        rootNode.setExpanded(true);
        List<Tree> childList=new ArrayList<>();
        for (int i = 0; i < bizTypes.length; i++) {
            Tree bizTypeTree = new Tree(bizTypes[i].oid,bizTypes[i].name,bizTypes[i]);//(btmItems[i].label+" ["+ btmItems[i].name+"]", btmItems[i]);
            bizTypeTree.setLevel(1);
            bizTypeTree.setShowCheckbox(true);
            bizTypeTree.setParentId(rootNode.getOid());
            bizTypeTree.setParentName(rootNode.getText());
            bizTypeTree.setShowCheckbox(true);
            childList.add(bizTypeTree);
            List<PLUILayout>contextList=getUIContextDataByBtName(bizTypes[i].name,context);
            List<Tree> btmChildList=new ArrayList<>();
            btmChildList.add(bizTypeTree);
            setChildNode(btmChildList,contextList,roleRightVOMap,showCheckBox);
        }
        rootNode.setChildren(childList);
        treeList.add(rootNode);
        return treeList;
    }
 
    private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList,Map<String,RoleRightVO> roleRightVOMap,boolean isShowCheckBox){
        Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<Tree>()).stream().forEach(pTree -> {
            Object funcObj=  pTree.getData();
            List<Tree> chiledTreeList=new ArrayList<>();
            if (funcObj instanceof BizType) {//业务类型
                BizType bizType = (BizType) funcObj;
                if(!CollectionUtil.isEmpty(contextList)) {
                    contextList.stream().forEach(context->{
                        Tree childTree=new Tree(context.plOId,context.plName+"("+context.plCode+")",context);
                        childTree.setParentName(pTree.getText());
                        childTree.setParentId(pTree.getOid());
                        childTree.setLevel(pTree.getLevel()+1);
                        childTree.setShowCheckbox(isShowCheckBox);
                        chiledTreeList.add(childTree);
                    });
                    pTree.setChildren(chiledTreeList);
                }
                if(!CollectionUtil.isEmpty(chiledTreeList)) {
                    setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
                }
            }else  if (funcObj instanceof PLUILayout){//UI
                PLUILayout context = (PLUILayout) funcObj;
                PLTabPage[] pages = new PLTabPage[0];
                try {
                    pages = platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(context.plOId);
                } catch (PLException e) {
                    e.printStackTrace();
                }
                if(pages!=null&&pages.length>0){
                    List<PLTabPage> plTabPageList= Arrays.stream(pages).collect(Collectors.toList());
                    plTabPageList.stream().forEach(plTabPage -> {
                        Tree childTree=new Tree(plTabPage.plOId,plTabPage.plName,plTabPage);
                        childTree.setParentName(pTree.getText());
                        childTree.setParentId(pTree.getOid());
                        childTree.setLevel(pTree.getLevel()+1);
                        childTree.setShowCheckbox(isShowCheckBox);
                        chiledTreeList.add(childTree);
                    });
                    pTree.setChildren(chiledTreeList);
                }
                if(!CollectionUtil.isEmpty(chiledTreeList)) {
                    setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
                }
 
            }else if (funcObj instanceof PLTabPage) {//上下文
                PLTabPage plTabPage = (PLTabPage) funcObj;
                List<PLPageDefination>plPageDefinationList=new ArrayList<>();
                try {
                    PLPageDefination[] pLPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(plTabPage.plOId);
                    if(pLPageDefinations!=null&&pLPageDefinations.length>0){
                        plPageDefinationList= Arrays.stream(pLPageDefinations).collect(Collectors.toList());
                        plPageDefinationList.stream().forEach(plPageDefination -> {
                            Tree childTree=new Tree(plPageDefination.plOId,plPageDefination.name,plPageDefination);
                            childTree.setParentName(pTree.getText());
                            childTree.setParentId(pTree.getOid());
                            childTree.setLevel(pTree.getLevel()+1);
                            childTree.setShowCheckbox(isShowCheckBox);
                            chiledTreeList.add(childTree);
                        });
                        pTree.setChildren(chiledTreeList);
                    }
                    if(!CollectionUtil.isEmpty(chiledTreeList)) {
                        setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
                    }
                } catch (PLException e) {
                    e.printStackTrace();
                }
 
            }else if (funcObj instanceof PLPageDefination) {//
                PLPageDefination plPageDefination = (PLPageDefination) funcObj;
                try {
                    List<PLTabButton>plTabButtonList=new ArrayList<>();
                    PLTabButton[] pLTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(plPageDefination.plOId);
                    if(pLTabButtons!=null&&pLTabButtons.length>0){
                        plTabButtonList= Arrays.stream(pLTabButtons).collect(Collectors.toList());
                        plTabButtonList.stream().forEach(plTabButton -> {
                            Tree childTree=new Tree(plTabButton.plOId,plTabButton.plLabel,plTabButton);
                            childTree.setParentName(pTree.getText());
                            childTree.setParentId(pTree.getOid());
                            childTree.setLevel(pTree.getLevel()+1);
                            childTree.setShowCheckbox(isShowCheckBox);
                            childTree.setLeaf(true);
                            chiledTreeList.add(childTree);
                        });
                        pTree.setChildren(chiledTreeList);
                    }
                    if(!CollectionUtil.isEmpty(chiledTreeList)) {
                        setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
                    }
                } catch (PLException e) {
                    e.printStackTrace();
                }
 
            }else if (funcObj instanceof PLTabButton) {//按钮
                String id = ((PLTabButton) funcObj).plTableOId;
                if(roleRightVOMap.containsKey(id)){
                    pTree.setChecked(true);
                }else{
                    pTree.setChecked(false);
                }
            }
        });
    }
    /**
     * UI角色对象转换
     * @param infos
     * @return
     */
    private List<RoleRightVO> roleRightDOO2VOS(List<RoleRightInfo> infos){
        List<RoleRightVO> roleRightVOS=new ArrayList<>();
        Optional.ofNullable(infos).orElseGet(()->new ArrayList<>()).stream().forEach(info -> {
            RoleRightVO vo=roleRightDOO2VO(info);
            roleRightVOS.add(vo);
        });
 
        return roleRightVOS;
    }
 
    /**
     * UI角色对象转换
     * @param info
     * @return
     */
    private RoleRightVO roleRightDOO2VO(RoleRightInfo info){
        RoleRightVO vo=new RoleRightVO();
        vo.setId(info.id);
        vo.setCreateTime(VciDateUtil.date2Str(VciDateUtil.long2Date(info.createTime),""));
        vo.setCreateUser(info.createUser);
        vo.setRoleId(info.roleId);
        vo.setRightType(info.rightType);
        vo.setLicensor(info.licensor);
        vo.setRightValue(info.rightValue);
        vo.setFuncId(info.funcId);
        vo.setModifyTime(VciDateUtil.date2Str(VciDateUtil.long2Date(info.modifyTime),""));
        vo.setModifyUser(info.modifyUser);
        return vo;
    }
 
    /**
     * 控制区节点及其子节点的克隆
     * @param obj
     */
    private void savePlpageLayoutDefinationRelation(Object obj,String plUILayoutId) {
        PLTabPage tabPage = (PLTabPage)obj;
        try {
 
            PLPageDefination[] pLPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(tabPage.plOId);
 
            tabPage.plOId = ObjectUtility.getNewObjectID36();
            tabPage.plContextOId = plUILayoutId;
            //add by caill start 2016.8.15 导航区、控制区、操作区在没有子节点的情况下的克隆
            if(pLPageDefinations.length==0){
                platformClientUtil.getUIService().savePLTabPage(tabPage);
            }
            //add by caill end
            for(int j=0;j<pLPageDefinations.length;j++){
                PLPageDefination plPageDef = pLPageDefinations[j];
 
                platformClientUtil.getUIService().savePLTabPage(tabPage);
                PLTabButton[] pLTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(plPageDef.plOId);
 
                plPageDef.plOId = ObjectUtility.getNewObjectID36();
                plPageDef.plTabPageOId = tabPage.plOId;
                platformClientUtil.getUIService().savePLPageDefination(plPageDef);
 
                for(int b=0;b<pLTabButtons.length;b++){
                    PLTabButton plTabButton = pLTabButtons[b];
                    PLCommandParameter[] pLCommandParameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(plTabButton.plOId);
 
                    plTabButton.plOId = ObjectUtility.getNewObjectID36();
                    plTabButton.plTableOId = plPageDef.plOId;
                    platformClientUtil.getUIService().savePLTabButton(plTabButton);
 
                    for(int c=0;c<pLCommandParameters.length;c++){
                        final PLCommandParameter plCommandParameter = pLCommandParameters[c];
                        plCommandParameter.plOId = ObjectUtility.getNewObjectID36();
                        plCommandParameter.plCommandOId = plTabButton.plOId;
                        platformClientUtil.getUIService().savePLCommandParameter(plCommandParameter);
                    }
                }
            }
        } catch (PLException e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 未做判空处理,调用前请保证obj不为空
     * @param obj
     * @throws PLException
     */
    public void checkCodeName(PLUILayout obj) throws PLException {
        PLUILayout[] plUILayouts = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(obj.plRelatedType);
        int length = plUILayouts.length;
        String code = obj.plCode;
        String name = obj.plName;
 
        if (Func.isNotBlank(name) || Func.isNotBlank(code)){
            for (int i =0;i<length;i++){//循环节点的UI上文和名称
                if (plUILayouts[i].plCode.equalsIgnoreCase(code) || plUILayouts[i].plName.equals(name)){
                    throw new VciBaseException("业务类型下UI名称或UI上下文编码已存在!");
                }
            }
        }
    }
 
    /**
     * ui上下文新增修改前检查
     * @param pluiLayout
     */
    private void canContinue(PLUILayout pluiLayout){
        String code = pluiLayout.plCode;
        String name = pluiLayout.plName;
        if(Func.isBlank(code)){
            throw new VciBaseException("上下文编码不能为空!");
        }
        if(Func.isBlank(name)){
            throw new VciBaseException("名称不能为空!");
        }
        if((pluiLayout.plIsShowNavigator == 0) && (pluiLayout.plIsShowForm == 0) && (pluiLayout.plIsShowTab == 0)){
            throw new VciBaseException("上下文至少要包含一个区域!");
        }
    }
 
    /**
     * 检查名称或者编码是否已存在
     * @param pluiLayout
     * @param isEdit
     * @return
     * @throws VciBaseException
     */
    private boolean nameOrCodeIsExist(PLUILayout pluiLayout, boolean isEdit) throws PLException {
        boolean res = false;
        //查询同一业务类型下的ui上下文,然后查重
        PLUILayout[] plpagelayoutdefinations = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(pluiLayout.plRelatedType);
        int length = plpagelayoutdefinations.length;
        for (int i =0;i<length;i++){
            String code = plpagelayoutdefinations[i].plCode;
            String name = plpagelayoutdefinations[i].plName;
            String ids = plpagelayoutdefinations[i].plOId;
            if(isEdit){
                if(!ids.equals(pluiLayout.plOId)){
                    if (pluiLayout.plCode.equalsIgnoreCase(code) || pluiLayout.plName.equals(name)){
                        res = true;
                        break;
                    }
                }
            }
            else {
                if (code.equalsIgnoreCase(code) || name.equals(name)){
                    res = true;
                    break;
                }
            }
        }
        return res;
    }
 
}