yuxc
2024-06-24 841588bc33c7ab2f547b046ada0d91bc4be67ade
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
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
package com.vci.web.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
import com.thoughtworks.xstream.io.xml.XppDriver;
import com.vci.corba.common.PLException;
import com.vci.corba.framework.data.RoleRightInfo;
import com.vci.corba.portal.data.*;
import com.vci.starter.web.annotation.log.VciUnLog;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.SessionInfo;
import com.vci.starter.web.util.*;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.enumpck.UIComponentDisplayTypeEnum;
import com.vci.web.enumpck.UIComponentTypeEnum;
import com.vci.web.enumpck.UIFieldTypeEnum;
import com.vci.web.enumpck.UILayoutAreaTypeEnum;
import com.vci.web.pageModel.*;
import com.vci.web.service.OsAttributeServiceI;
import com.vci.web.service.OsBtmServiceI;
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 com.vci.web.xmlmodel.UIComponentDefineXO;
import com.vci.web.xmlmodel.UIComponentDetailXO;
import com.vci.web.xmlmodel.UIComponentItemXO;
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;
 
import static com.vci.web.constant.EnumIdConstant.LC_STATUS_SUBFIX;
 
/**
 * UI引擎服务,以前平台封装到action里的,
 * @author weidy
 *
 */
@Service
public class UIEngineServiceImpl implements UIEngineServiceI {
 
    /**
     * 是否从缓存中查询
     */
    public static boolean QUERY_BY_CACHE = true;
 
    /**
     * 平台调用工具类
     */
    @Autowired
    private PlatformClientUtil platformClientUtil;
 
    /**
     * 日志对象
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    /**
     * 加载自身
     */
    @Lazy
    @Autowired(required = false)
    private UIEngineServiceI self;
 
    /**
     * 属性的服务
     */
    @Autowired
    private OsAttributeServiceI attributeService;
 
    /**
     * 业务类型的服务
     */
    @Autowired
    private OsBtmServiceI btmService;
 
    /**
     * 业务类型的服务
     */
    @Autowired
    private WebBoServiceI boService;
 
    /**
     * 表单的字段类型映射
     */
    private static Map<String,String> formFieldTypeMap = new HashMap(){
        {
            put("text","text");
            put("textarea","textarea");
            put("number","text");
            put("password","password");
            put("radio","radio");
            put("checkbox","checkbox");
            put("select","combox");
            put("webeditor","webeditor");
            put("date","date");
            put("time","time");
            put("datetime","datetime");
            put("hidden","hidden");
            put("file","file");
            put("multiFile","multiFile");
            put("custom","custom");
        }
    };
 
    /**
     * 默认的时间格式
     */
    private static Map<String,String> dateDefaultFormatMap = new HashMap(){
        {
            put("date",VciDateUtil.DateFormat);
            put("time",VciDateUtil.TimeFormat);
            put("datetime",VciDateUtil.DateTimeFormat);
        }
    };
 
    /**
     * 检查无效的xml
     */
    @Override
    public void checkInvalidXmlVI() {
        PortalVI[] portalVIS = null;
        try {
            portalVIS = platformClientUtil.getUIService().getAllPortalVI();
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        for(int i = 0 ; i < portalVIS.length ; i++){
            PortalVI portalVI = portalVIS[i];
            try {
                UIComponentDetailXO detailXO = readInfoFromXML(portalVI.prm, UIComponentDetailXO.class);
            }catch (Throwable e){
                logger.error(portalVI.typeName + " ----" + portalVI.viName);
            }
        }
    }
 
    /**
     * 查询所有的表单定义
     *
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public List<UIFormDefineVO> selectAllForm() {
        PortalVI[] portalVIS = null;
        try {
            portalVIS = platformClientUtil.getUIService().getAllPortalVI();
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        List<PortalVI> portalVIList = Arrays.stream(portalVIS).filter(portal -> 1 == portal.viType).collect(Collectors.toList());
        return formDO2VOs(portalVIList);
    }
 
    /**
     * 查询所有的表单定义的映射
     *
     * @return key是表单英文名称
     */
    @Override
    public Map<String, UIFormDefineVO> selectAllFormMap() {
        return Optional.ofNullable(self.selectAllForm()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getBtmType().toLowerCase() + SEP + s.getId().toLowerCase(),t->t,(o1,o2)->o1));
    }
 
    /**
     * 表单数据对象转换为显示对象
     *
     * @param portalVIS 数据对象
     * @return 显示对象
     */
    @Override
    public List<UIFormDefineVO> formDO2VOs(Collection<PortalVI> portalVIS) {
        List<UIFormDefineVO> formDefineVOList = new ArrayList<>();
        Optional.ofNullable(portalVIS).orElseGet(()->new ArrayList<PortalVI>()).stream().forEach(portal->{
            try {
                UIFormDefineVO defineVO = formDO2VO(portal);
                formDefineVOList.add(defineVO);
            }catch (Throwable e){
                if(logger.isErrorEnabled()){
                    logger.error("表单的内容有错误,这个表单没有成功被查询");
                }
            }
        });
        return formDefineVOList;
    }
 
    /**
     * 表单数据对象转换为显示对象
     *
     * @param portal 数据对象
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public UIFormDefineVO formDO2VO(PortalVI portal) {
        if(portal == null ||StringUtils.isBlank(portal.prm)){
            throw new VciBaseException("表单可能不存在,因为未能获取到它的信息");
        }
        UIFormDefineVO formDefineVO = new UIFormDefineVO();
        formDefineVO.setOid(portal.id);
        formDefineVO.setId(portal.viName);
        formDefineVO.setBtmType(portal.typeName);
        formDefineVO.setLinkTypeFlag(1 == portal.typeFlag);
        UIComponentDetailXO detailXO = readInfoFromXML(portal.prm,UIComponentDetailXO.class);
        if(detailXO == null){
            throw new VciBaseException("读取{0}里{1}表单的信息错误,内容不是完整的xml格式",new String[]{formDefineVO.getBtmType(),formDefineVO.getOid()});
        }
        formDefineVO.setQueryTemplateName(detailXO.getFormQueryTemplateName());
        formDefineVO.setColumnOneRow(WebUtil.getInt(detailXO.getShowColsCount()));
        List<UIFormItemVO> items = new ArrayList<>();
        Optional.ofNullable(detailXO.getItems()).orElseGet(()->new ArrayList<>()).stream().forEach(itemXO->{
            UIFormItemVO itemVO = new UIFormItemVO();
            itemVO.setField(itemXO.getField());
            itemVO.setText(itemXO.getName());
            itemVO.setReadOnly("1".equalsIgnoreCase(itemXO.getEditable()));
            itemVO.setRequired("1".equalsIgnoreCase(itemXO.getRequired()));
            itemVO.setDefaultValue(itemXO.getDefaultValue());
            itemVO.setType(formFieldTypeMap.getOrDefault(itemXO.getDisplayType(),"text"));
            itemVO.setHidden(!"1".equalsIgnoreCase(itemXO.getHidden()));
            itemVO.setVerify(itemXO.getScriptValid());
            if("number".equalsIgnoreCase(itemXO.getDisplayType())){
                List<String> verifys = VciBaseUtil.str2List(itemVO.getVerify());
                if(verifys == null){
                    verifys = new ArrayList<>();
                }
                verifys.add("number");
                itemVO.setVerify(verifys.stream().collect(Collectors.joining(",")));
            }
            if("hidden".equalsIgnoreCase(itemXO.getDisplayType())){
                itemVO.setType(UIFieldTypeEnum.TEXT.getValue());
                itemVO.setHidden(true);
            }
            if (VciQueryWrapperForDO.LIFECYCLE_MANAGE_FIELD_MAP.containsKey(itemVO.getField().toLowerCase())) {
                //生命周期的加下拉菜单的key
                itemVO.setComboxKey(formDefineVO.getBtmType() + LC_STATUS_SUBFIX);
            }
 
            itemVO.setDisplayExtension(itemXO.getDisplayExpression());
            itemVO.setDateFormate(itemXO.getDateFormat());
            if(StringUtils.isBlank(itemVO.getDateFormate())){
                itemVO.setDateFormate(dateDefaultFormatMap.get(itemXO.getDisplayType().toLowerCase()));
                if("createtime".equalsIgnoreCase(itemVO.getField()) || "lastmodifytime".equalsIgnoreCase(itemVO.getField()) ){
                    itemVO.setDateFormate(VciDateUtil.DateTimeFormat);
                }
            }
            itemVO.setTooltips(itemVO.getTooltips());
            if("custom".equalsIgnoreCase(itemXO.getDisplayType())){
                itemVO.setType(UIFieldTypeEnum.TEXT.getValue());
                itemVO.setCustomClass(itemVO.getCustomClass());
            }
 
            if(StringUtils.isNotBlank(itemXO.getRefer())){
                itemVO.setType("refer");
                UIFormReferVO referVO = new UIFormReferVO();
                if(StringUtils.isNotBlank(itemXO.getReferFieldName())){
                    referVO.setTextField(itemXO.getReferFieldName());
                }
                if("layuirefer".equalsIgnoreCase(itemXO.getRefer())){
                    //说明是新的参照的方式
                    referVO.setType(itemXO.getSecondRefer());
                    if(StringUtils.isNotBlank(itemXO.getExtendAttr())) {
                        if(itemXO.getExtendAttr().startsWith("{") && itemXO.getExtendAttr().endsWith("}")) {
                            //要json的形式
                            JSONObject jsonObject = null;
                            try {
                                jsonObject = JSONObject.parseObject(itemXO.getExtendAttr());
                            } catch (Throwable e) {
                                if (logger.isErrorEnabled()) {
                                    logger.error("转换Json的格式出错", e);
                                }
                            }
                            if (jsonObject != null) {
                                referVO.setType(jsonObject.containsKey("type")?jsonObject.getString("type"):"");
                                referVO.setMuti(jsonObject.containsKey("muti")?VciBaseUtil.getBoolean(jsonObject.getString("muti")):false);
                                referVO.setUrl(jsonObject.containsKey("url")?jsonObject.getString("url"):"");
                                referVO.setBackPath(jsonObject.containsKey("backPath")?jsonObject.getString("backPath"):"");
                                referVO.setMethod(jsonObject.containsKey("method")?jsonObject.getString("method"):"");
                                referVO.setHeight(jsonObject.containsKey("height") ? WebUtil.getInt(jsonObject.getString("height")) : null);
                                referVO.setReferType(jsonObject.containsKey("referType")?jsonObject.getString("referType"):null);
                                referVO.setReferContent(jsonObject.containsKey("referContent")?jsonObject.getString("referContent"):null);
                                referVO.setParentFieldName(jsonObject.containsKey("parentFieldName")?jsonObject.getString("parentFieldName"):null);
                                referVO.setParentValue(jsonObject.containsKey("parentValue")?jsonObject.getString("parentValue"):null);
                                referVO.setLoadType(jsonObject.containsKey("loadType")?jsonObject.getString("loadType"):null);
                                referVO.setOnlyLeaf(jsonObject.containsKey("onlyLeaf")?Boolean.valueOf(jsonObject.getString("onlyLeaf")):true);
                                referVO.setDisplayTable(jsonObject.containsKey("displayTable")?jsonObject.getString("displayTable"):null);
                                referVO.setTextField(jsonObject.containsKey("textField")?jsonObject.getString("textField"):null);
                                referVO.setValueField(jsonObject.containsKey("valueField")?jsonObject.getString("valueField"):null);
                                if (jsonObject.containsKey("tableConfig")) {
                                    referVO.setTableConfig(JSONObject.parseObject(jsonObject.getString("tableConfig"), UITableCustomDefineVO.class));
                                }
                            }
                        }else{
                            referVO.setType(itemXO.getExtendAttr());
                        }
                    }
                }else{
                    referVO.setType("stand");
                    referVO.setReferType(itemXO.getRefer());
                    referVO.setReferContent(itemXO.getExtendAttr());
                }
                itemVO.setReferConfig(referVO);
                itemVO.setShowField(itemVO.getField() +"." + referVO.getTextField());
            }else{
                String field = itemVO.getField();
                if(itemVO.getField().toLowerCase().startsWith("t_oid.")
                        ||itemVO.getField().toLowerCase().startsWith("f_oid.")){
                    //说明是链接类型
                    field = field.substring("t_oid.".length());
                }
                OsAttributeVO attributeVO = attributeService.getAttr(field);
                UIFormReferVO referVO = new UIFormReferVO();
                if(attributeVO !=null && StringUtils.isNotBlank(attributeVO.getBtmTypeId())
                        && StringUtils.isBlank(itemXO.getRefer())
                        &&"combox".equalsIgnoreCase(itemVO.getType())){
                    //走默认的参照
                    itemVO.setType("refer");
                    referVO.setType("default");
                    referVO.setTextField("name");
                    referVO.setReferContent(itemXO.getExtendAttr());
                    referVO.setReferType(attributeVO.getBtmTypeId());
                    itemVO.setReferConfig(referVO);
                    itemVO.setShowField(itemVO.getField() +"." + referVO.getTextField());
                }
                if(StringUtils.isNotBlank(itemXO.getExtendAttr())){
                    if(itemXO.getExtendAttr().startsWith("{") && itemXO.getExtendAttr().endsWith("}")){
                        //是json
                        Map<String,String> attrMap = new HashMap<>();
                        Map<String, Object> innerMap = JSONObject.parseObject(itemXO.getExtendAttr()).getInnerMap();
                        innerMap.forEach((key,value)->{
                            attrMap.put(key,WebUtil.getStringValueFromObject(value));
                        });
                        itemVO.setExtendAttrMap(attrMap);
                    }else{
                        Map<String,String> extendAttrMap = new HashMap<>();
                        Arrays.stream(itemXO.getExtendAttr().split("&")).forEach(attr->{
                            if(StringUtils.isNotBlank(attr) && attr.contains("=")) {
                                extendAttrMap.put(attr.split("=")[0], attr.split("=")[1]);
                            }else{
                                itemVO.setExtendAttrString(attr);
                            }
                        });
                        itemVO.setExtendAttrMap(extendAttrMap);
                    }
                }
            }
            if("radio".equalsIgnoreCase(itemVO.getType()) || "checkbox".equalsIgnoreCase(itemVO.getType())
                    || "combox".equalsIgnoreCase(itemVO.getType())){
                //看看有没有单独设置
//                if(StringUtils.isNotBlank(itemXO.getComboxKey())){
//                    itemVO.setComboxKey(itemXO.getComboxKey());
                if(StringUtils.isNotBlank(itemXO.getComboxItems())){
                    List<KeyValue> keyValues = new ArrayList<>();
                    for (String keyValue : itemXO.getComboxItems().split(";")) {
                        KeyValue kv = new KeyValue();
                        String[] split = keyValue.split("\\{");
                        kv.setKey(split[0]);
                        kv.setValue(split[1].substring(0,split[1].length()-1));
                        keyValues.add(kv);
                    }
                    itemVO.setData(keyValues);
                }else{
                    String attr = itemVO.getField();
                    if(itemVO.getField().toLowerCase().startsWith("t_oid.")
                            ||itemVO.getField().toLowerCase().startsWith("f_oid.")){
                        //说明是链接类型
                        attr = attr.substring("t_oid.".length());
                    }
                    OsAttributeVO attributeVO = attributeService.getAttr(attr);
                    if (attributeVO != null) {
                        itemVO.setComboxKey(attributeVO.getEnumId());
                    }
                }
            }
 
            items.add(itemVO);
        });
        formDefineVO.setItems(items);
        return formDefineVO;
    }
 
    /**
     * 使用表单的英文名称获取表单
     *
     * @param btmId 业务类型
     * @param id    表单的英文名称
     * @return 表单的定义
     */
    @Override
    public UIFormDefineVO getFormById(String btmId, String id) {
        if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){
            return null;
        }
        if(!QUERY_BY_CACHE){
            PortalVI portalVI = null;
            try {
                portalVI = platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmId, id);
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
            return formDO2VO(portalVI);
        }
        return self.selectAllFormMap().getOrDefault(btmId.toLowerCase()+SEP+id.toLowerCase(),null);
    }
 
    /**
     * 使用表单的英文名称获取表单
     *
     * @param btmId 业务类型编号
     * @param ids   表单的英文名称
     * @return 表单的定义
     */
    @Override
    public List<UIFormDefineVO> listFormByIds(String btmId, Collection<String> ids) {
        if(StringUtils.isBlank(btmId) || CollectionUtils.isEmpty(ids)){
            return null;
        }
        Map<String, UIFormDefineVO> formDefineVOMap = self.selectAllFormMap();
        List<UIFormDefineVO> defineVOS = new ArrayList<>();
        ids.stream().forEach(id->{
            String key = btmId.toLowerCase()+SEP + id.toLowerCase();
            if(formDefineVOMap.containsKey(key)){
                defineVOS.add(formDefineVOMap.get(key));
            }
        });
        return defineVOS;
    }
 
    /**
     * 查询所有的表格
     *
     * @return 表格的定义
     */
    @Override
    @VciUnLog
    public List<UITableDefineVO> selectAllTable() {
        PortalVI[] portalVIS = null;
        try {
            portalVIS = platformClientUtil.getUIService().getAllPortalVI();
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        List<PortalVI> portalVIList = Arrays.stream(portalVIS).filter(portal -> 0 == portal.viType).collect(Collectors.toList());
        return tableDO2VOs(portalVIList,false);
    }
 
    /**
     * 查询所有的表格
     *
     * @return 表格的定义,key是表格的英文名称
     */
    @Override
    public Map<String,UITableDefineVO> selectAllTableMap() {
        return Optional.ofNullable(self.selectAllTable()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getBtmType().toLowerCase() + SEP + s.getId().toLowerCase(),t->t,(o1,o2)->o1));
    }
 
    /**
     * 表格数据对象转换为显示对象
     *
     * @param prms 数据对象
     * @param queryDetail 查询明细
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public List<UITableDefineVO> tableDO2VOs(Collection<PortalVI> prms, boolean queryDetail) {
        List<UITableDefineVO> tableDefineVOList = new ArrayList<>();
        Optional.ofNullable(prms).orElseGet(()->new ArrayList<PortalVI>()).stream().forEach(portal->{
            UITableDefineVO defineVO = tableDO2VO(portal,queryDetail);
            tableDefineVOList.add(defineVO);
        });
        return tableDefineVOList;
    }
 
    /**
     * 表格的数据对象转换为显示对象
     *
     * @param portal 数据对象
     * @param queryDetail 查询明细
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public UITableDefineVO tableDO2VO(PortalVI portal, boolean queryDetail) {
        UITableDefineVO tableDefineVO = new UITableDefineVO();
        tableDefineVO.setOid(portal.id);
        tableDefineVO.setId(portal.viName);
        tableDefineVO.setBtmType(portal.typeName);
        tableDefineVO.setLinkTypeFlag(1 == portal.typeFlag);
        UIComponentDetailXO detailXO = null;
        try {
            detailXO = readInfoFromXML(portal.prm, UIComponentDetailXO.class);
        }catch (Throwable e){
            logger.error("{}里的表格{}读取xml失败",new String[]{tableDefineVO.getBtmType(),tableDefineVO.getId()});
            throw e;
        }
        if(detailXO == null){
            throw new VciBaseException("读取{0}里{1}表格的信息错误,内容不是完整的xml格式",new String[]{tableDefineVO.getBtmType(),tableDefineVO.getOid()});
        }
        tableDefineVO.setQueryTemplateName(detailXO.getFormQueryTemplateName());
 
        //表格的这个item只有一个
        UIComponentItemXO itemXO = detailXO.getItems().get(0);
        if(StringUtils.isNotBlank(itemXO.getQueryTemplateName())){
            //这个是表格的查询模板,外面还有一个UI的查询模板
            tableDefineVO.setQueryTemplateName(itemXO.getQueryTemplateName());
        }
        String formOid = itemXO.getBindFormOid();
        //获取表单的信息,用来获取字段的信息
        UIFormDefineVO formDefineVO = null;
        if(!queryDetail){
            self.selectAllForm().stream().filter(s -> formOid.equalsIgnoreCase(s.getOid())).findAny().orElseGet(() -> null);
        }else{
            try {
                formDefineVO = formDO2VO(platformClientUtil.getUIService().getPortalVIById(formOid));
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
        }
        if(formDefineVO == null){
            logger.error("{}里的表格{}所需的表单{}不存在",new String[]{tableDefineVO.getBtmType(),tableDefineVO.getId(),formOid});
            //throw new VciBaseException("{0}里的表格{1}所需的表单{2}不存在",new String[]{tableDefineVO.getBtmType(),tableDefineVO.getId(),formOid});
        }else {
            if (StringUtils.isNotBlank(itemXO.getPageSize())) {
                //xxx,yy,zz#aa的格式
                List<String> limitList = null;
                int pageSize = 0;
                if (!itemXO.getPageSize().contains("#")) {
                    pageSize = WebUtil.getInt(itemXO.getPageSize());
                    limitList = new ArrayList<>();
                    limitList.add("15");
                    limitList.add("50");
                    limitList.add("100");
                    limitList.add("500");
                    limitList.add("1000");
                }else{
                    pageSize = WebUtil.getInt(itemXO.getPageSize().split("#")[1]);
                    limitList = WebUtil.str2List(itemXO.getPageSize().split("#")[0]);
                }
                List<Integer> limitIntList = new ArrayList<>();
                limitList.stream().forEach(limit -> {
                    int limitInt = WebUtil.getInt(limit);
                    if(limitInt<=1000) {
                        limitIntList.add(limitInt);
                    }
                });
                if (pageSize > 0) {
                    UITablePageVO pageVO = new UITablePageVO();
                    pageVO.setLimit(pageSize);
                    pageVO.setPage(1);
                    tableDefineVO.setPageVO(pageVO);
                }
                tableDefineVO.setLimits(limitIntList.stream().sorted().collect(Collectors.toList()).toArray(new Integer[0]));
            }
            tableDefineVO.setWhereSql(itemXO.getWhereSql());
            tableDefineVO.setDisplayQueryArea(Boolean.valueOf(itemXO.getDisplayQueryArea()));
            tableDefineVO.setDisplayFolder(Boolean.valueOf(itemXO.getDisplayFolder()));
            tableDefineVO.setFolderParentField(itemXO.getParentFolderName());
 
            //处理列。平台不支持多行的情况
            List<UITableFieldVO> tableFieldVOList = new ArrayList<>();
            if (StringUtils.isBlank(itemXO.getDisplayFields())) {
                logger.error("{},{}列表没有显示的列.或者没有设置宽度",new String[]{tableDefineVO.getBtmType(),tableDefineVO.getId()});
            }else {
                //严格按照数组的顺序,因为宽度是按照这个来的
                String[] fields = itemXO.getDisplayFields().split(",");
                String[] fieldWidths = StringUtils.isBlank(itemXO.getFieldWidths()) ? new String[0] : itemXO.getFieldWidths().split(",");
                Map<String, UIFormItemVO> formFieldMap = formDefineVO.getItems().stream().collect(Collectors.toMap(s -> s.getField().toLowerCase(), t -> t, (o1, o2) -> o1));
                for (int i = 0; i < fields.length; i++) {
                    String fieldName = fields[i];
                    if (formFieldMap.containsKey(fieldName.toLowerCase())) {
                        //throw new VciBaseException("{0}里{1}表格的字段{2}在对应的表单中没有找到",new String[]{tableDefineVO.getBtmType(),tableDefineVO.getId(),fieldName});
                        UIFormItemVO itemVO = formFieldMap.get(fieldName.toLowerCase());
                        UITableFieldVO fieldVO = new UITableFieldVO();
                        if ("combox".equalsIgnoreCase(itemVO.getType())) {
                            fieldVO.setField(fieldName + "text");
                            fieldVO.setComboxKey(itemVO.getComboxKey());
                            fieldVO.setSortField(fieldName);
                            fieldVO.setEdit("combox");
                        } else if ("refer".equalsIgnoreCase(itemVO.getType())) {
                            fieldVO.setField(fieldName + "." + itemVO.getShowField());
                            fieldVO.setSortField(fieldName);
                            fieldVO.setEdit("refer");
                        } else if (VciQueryWrapperForDO.LIFECYCLE_MANAGE_FIELD_MAP.containsKey(fieldName.toLowerCase())) {
                            fieldVO.setField(VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase());
                            fieldVO.setSortField(fieldName);
                            fieldVO.setEdit("combox");
                            //肯定是业务类型,因为链接类型没有这个字段
                            OsBtmTypeVO btmTypeVO = btmService.getBtmById(tableDefineVO.getBtmType());
                            if(btmTypeVO!=null && StringUtils.isNotBlank(btmTypeVO.getLifeCycleId())){
                                fieldVO.setComboxKey(btmTypeVO.getLifeCycleId() + LC_STATUS_SUBFIX);
                            }
 
                        }else if("creator".equalsIgnoreCase(fieldName)){
                            fieldVO.setField("creator_name,(,creator,)");
                            fieldVO.setSortField(fieldName);
                        } else if("lastmodifier".equalsIgnoreCase(fieldName)){
                            fieldVO.setField("lastmodifier_name,(,lastmodifier,)");
                            fieldVO.setSortField(fieldName);
                        } else  {
                            fieldVO.setField(fieldName);
                        }
                        if("text".equalsIgnoreCase(itemVO.getType())){
                            fieldVO.setDateFormate(itemVO.getDateFormate());
                        }
                        if("number".equalsIgnoreCase(itemVO.getType())){
                            fieldVO.setEdit("number");
                        }
                        fieldVO.setTitle(itemVO.getText());
                        if (fieldWidths.length > i) {
                            fieldVO.setWidth(WebUtil.getInt(fieldWidths[i]));
                        }
                        if ("date".equalsIgnoreCase(itemVO.getType()) || "time".equalsIgnoreCase(itemVO.getType()) || "datetime".equalsIgnoreCase(itemVO.getType())) {
                            fieldVO.setDateFormate(itemVO.getDateFormate());
                            fieldVO.setEdit("date");
                            if(StringUtils.isBlank(itemVO.getDateFormate())){
                                fieldVO.setDateFormate(dateDefaultFormatMap.get(itemVO.getType().toLowerCase()));
                            }
                        }
                        if(StringUtils.countMatches(fieldVO.getField(),".")>1 ){
                            fieldVO.setShowField(StringUtils.isBlank(fieldVO.getShowField())?fieldVO.getField().replace(".","--"):fieldVO.getShowField().replace(".","--"));
                        }
                        fieldVO.setFieldType(itemVO.getType());
                        tableFieldVOList.add(fieldVO);
                    } else {
                        logger.error("{}里{}表格的字段{}在对应的表单中没有找到", new String[]{tableDefineVO.getBtmType(), tableDefineVO.getId(), fieldName});
                    }
                }
                List<List<UITableFieldVO>> cols = new ArrayList<>();
                cols.add(tableFieldVOList);
                tableDefineVO.setCols(cols);
                List<UITableFieldVO> canQueryFields = new ArrayList<>();
                tableFieldVOList.stream().filter(s -> !UIFieldTypeEnum.FILE.getValue().equalsIgnoreCase(s.getFieldType())
                        && !UIFieldTypeEnum.MULTI_FILE.getValue().equalsIgnoreCase(s.getFieldType())
                        && !UIFieldTypeEnum.CUSTOM.getValue().equalsIgnoreCase(s.getFieldType())).forEach(fieldVO->{
                    //列表里面不放edit,而查询里面需要放edit
                    UITableFieldVO queryFieldVO = new UITableFieldVO();
                    BeanUtil.convert(fieldVO,queryFieldVO);
                    canQueryFields.add(queryFieldVO);
                });
                tableDefineVO.setSeniorQueryColumns(canQueryFields);
                //要把列上的edit去掉,因为暂时不支持列表直接编辑
                tableFieldVOList.stream().forEach(fieldVO->{
                    fieldVO.setEdit("");
                });
                //查询的列
                if (StringUtils.isNotBlank(itemXO.getQueryFields())) {
                    String[] queryFields = itemXO.getQueryFields().split(",");
                    List<UITableFieldVO> queryFieldVOs = new ArrayList<>();
                    for (int i = 0; i < queryFields.length; i++) {
                        String fieldName = fields[i];
                        if (!formFieldMap.containsKey(fieldName.toLowerCase())) {
                            logger.error("{}里{}表格的字段{}在对应的表单中没有找到", new String[]{tableDefineVO.getBtmType(), tableDefineVO.getOid(), fieldName});
                        } else {
                            UIFormItemVO itemVO = formFieldMap.get(fieldName.toLowerCase());
                            UITableFieldVO fieldVO = new UITableFieldVO();
                            if ("combox".equalsIgnoreCase(itemVO.getType())) {
                                fieldVO.setField(fieldName + "text");
                                fieldVO.setSortField(fieldName);
                                fieldVO.setComboxKey(itemVO.getComboxKey());
                                fieldVO.setData(itemVO.getData());
                                fieldVO.setEdit("combox");
                            } else if ("refer".equalsIgnoreCase(itemVO.getType())) {
                                fieldVO.setField(fieldName + "." + itemVO.getShowField());
                                fieldVO.setSortField(fieldName);
                                fieldVO.setShowField(itemVO.getShowField());
                                fieldVO.setReferConfig(itemVO.getReferConfig());
                                fieldVO.setEdit("refer");
                            } else if (VciQueryWrapperForDO.LIFECYCLE_MANAGE_FIELD_MAP.containsKey(fieldName.toLowerCase())) {
                                fieldVO.setField(VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase());
                                fieldVO.setSortField(fieldName);
                                //肯定是业务类型,因为链接类型没有这个字段
                                OsBtmTypeVO btmTypeVO = btmService.getBtmById(tableDefineVO.getBtmType());
                                if(btmTypeVO!=null && StringUtils.isNotBlank(btmTypeVO.getLifeCycleId())){
                                    fieldVO.setComboxKey(btmTypeVO.getLifeCycleId() + LC_STATUS_SUBFIX);
                                }
                                fieldVO.setEdit("combox");
                            } else {
                                fieldVO.setField(fieldName);
                            }
                            if("number".equalsIgnoreCase(itemVO.getType())){
                                fieldVO.setEdit("number");
                            }
                            fieldVO.setQueryField(fieldName);
                            fieldVO.setTitle(itemVO.getText());
                            if ("date".equalsIgnoreCase(itemVO.getType()) || "time".equalsIgnoreCase(itemVO.getType()) || "datetime".equalsIgnoreCase(itemVO.getType())) {
                                fieldVO.setDateFormate(itemVO.getDateFormate());
                                fieldVO.setEdit("date");
                            }
                            queryFieldVOs.add(fieldVO);
                        }
                    }
                    tableDefineVO.setQueryColumns(queryFieldVOs);
                }
            }
        }
        return tableDefineVO;
    }
 
    /**
     * 使用表格的英文名称获取表单
     *
     * @param btmId 业务类型
     * @param id    表格的英文名称
     * @return 表单的定义
     */
    @Override
    public UITableDefineVO getTableById(String btmId, String id) {
        if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){
            return null;
        }
        if(!QUERY_BY_CACHE){
            PortalVI portalVI = null;
            try {
                portalVI = platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmId, id);
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
            return tableDO2VO(portalVI,true);
        }
        return self.selectAllTableMap().getOrDefault(btmId.toLowerCase()+SEP+id.toLowerCase(),null);
    }
 
    /**
     * 使用表格的英文名称获取表单
     *
     * @param btmId 业务类型编号
     * @param ids   表格的英文名称
     * @return 表单的定义
     */
    @Override
    public List<UITableDefineVO> listTableByIds(String btmId, Collection<String> ids) {
        if(StringUtils.isBlank(btmId) || CollectionUtils.isEmpty(ids)){
            return null;
        }
        Map<String, UITableDefineVO> tableDefineVOMap = self.selectAllTableMap();
        List<UITableDefineVO> defineVOS = new ArrayList<>();
        ids.stream().forEach(id->{
            String key = btmId.toLowerCase()+SEP + id.toLowerCase();
            if(tableDefineVOMap.containsKey(key)){
                defineVOS.add(tableDefineVOMap.get(key));
            }
        });
        return defineVOS;
    }
 
    /**
     * 查询所有的action
     *
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public List<UIActionVO> selectAllAction() {
        try {
            return actionDO2VOs(Arrays.stream(platformClientUtil.getUIService().getAllPLAction()).collect(Collectors.toList()));
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
    }
 
    /**
     * 查询所有的action
     *
     * @return 显示对象,key是action的主键
     */
    @Override
    public Map<String, UIActionVO> selectAllActionMap() {
        return Optional.ofNullable(self.selectAllAction()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t));
    }
 
    /**
     * action数据对象转换为显示对象
     *
     * @param actions 数据对象
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public List<UIActionVO> actionDO2VOs(Collection<PLAction> actions) {
        List<UIActionVO> actionVOS = new ArrayList<>();
        Optional.ofNullable(actions).orElseGet(()->new ArrayList<>()).stream().forEach(action->{
            UIActionVO actionVO = actionDO2VO(action);
            actionVOS.add(actionVO);
        });
        return actionVOS;
    }
 
    /**
     * action数据对象转换为显示对象
     *
     * @param action 数据对象
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public UIActionVO actionDO2VO(PLAction action) {
        UIActionVO actionVO = new UIActionVO();
        if(action!=null){
            actionVO.setOid(action.plOId);
            actionVO.setId(action.plCode);
            actionVO.setName(action.plName);
            actionVO.setBsUrl(StringUtils.isBlank(action.plBSUrl)?"":action.plBSUrl);
            actionVO.setCsClass(StringUtils.isBlank(action.plCSClass)?"":action.plCSClass);
            actionVO.setDescription(action.plDesc);
            actionVO.setActionUsedType(action.plTypeType);
            actionVO.setCreator(action.plCreateUser);
            actionVO.setLastModifier(action.plModifyUser);
            try {
                actionVO.setCreateTime(new Date(action.plCreateTime));
                actionVO.setLastModifyTime(new Date(action.plCreateTime));
            }catch (Throwable e){
                logger.error("转换时间",e);
            }
            actionVO.setActionCls(action.plActionCls);
        }
        return actionVO;
    }
 
    /**
     * 清除缓存
     */
    @Override
    public void clearCache()  {
 
    }
 
    /**
     * 查询所有的UI上下文
     *
     * @return 显示对象
     */
    @Override
    @VciUnLog
    public List<UIContentVO> selectAllUIContent() {
        try {
            return UIContentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLUILayouts()).collect(Collectors.toList()));
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
    }
 
    /**
     * ui上下文 数据对象转换为显示对象
     * @param pageLayoutDefinations 上下文UI对象
     * @return 显示对象
     */
    private List<UIContentVO> UIContentDO2VOs(Collection<PLUILayout> pageLayoutDefinations){
        List<UIContentVO> contentVOS = new ArrayList<>();
        Optional.ofNullable(pageLayoutDefinations).orElseGet(()->new ArrayList<PLUILayout>()).stream().forEach(pageLayout->{
            contentVOS.add(UIContentDO2VO(pageLayout,false));
        });
        if(!CollectionUtils.isEmpty(contentVOS)) {
            Map<String, List<UILayoutVO>> layoutMap = batchListLayoutByContent(contentVOS.stream().map(UIContentVO::getOid).collect(Collectors.toSet()));
            contentVOS.stream().forEach(contentVO-> {
                List<UILayoutVO> layoutVOS = layoutMap.getOrDefault(contentVO.getOid(), new ArrayList<>());
                if(!CollectionUtils.isEmpty(layoutVOS)){
                    Map<String,List<UILayoutVO>> layoutAreaMap = layoutVOS.stream().collect(Collectors.groupingBy(UILayoutVO::getLayoutAreaType));
                    contentVO.setWestAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.WEST.getValue(),new ArrayList<>()));
                    contentVO.setNorthAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.NORTH.getValue(),new ArrayList<>()));
                    contentVO.setCenterAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.CENTER.getValue(),new ArrayList<>()));
                    contentVO.setSouthAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.SOUTH.getValue(),new ArrayList<>()));
                }
            });
        }
        return contentVOS;
    }
 
    /**
     * ui上下文 数据对象转换为显示对象
     * @param pageLayoutDefination  上下文UI对象
     * @param queryDetail 是否查询区域
     * @return 显示对象
     */
    @VciUnLog
    @Override
    public UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail){
        UIContentVO contentVO = new UIContentVO();
        if(pageLayoutDefination !=null){
            contentVO.setOid(pageLayoutDefination.plOId);
            contentVO.setId(pageLayoutDefination.plCode);
            contentVO.setName(pageLayoutDefination.plName);
            contentVO.setBtmTypeId(pageLayoutDefination.plRelatedType);
            contentVO.setDescription(pageLayoutDefination.plDesc);
            contentVO.setCreator(pageLayoutDefination.plCreateUser);
            try {
                contentVO.setCreateTime(new Date(pageLayoutDefination.plCreateTime));
                contentVO.setLastModifyTime(new Date(pageLayoutDefination.plModifyTime));
            } catch (Exception e) {
                e.printStackTrace();
            }
            contentVO.setLastModifier(pageLayoutDefination.plModifyUser);
            if(queryDetail){
                //查询包含的内容
                List<UILayoutVO> layoutVOS = listLayoutByContent(contentVO.getOid());
                if(!CollectionUtils.isEmpty(layoutVOS)){
                    if(layoutVOS.size() == 1){
                        //只有一个区域
                        UILayoutVO layoutVO = layoutVOS.get(0);
                        List<UIComponentVO> componentVOs = layoutVO.getComponentVOs();
                        //第一个作为center
                        UIComponentVO firstCompVO = componentVOs.stream().min((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum())).get();
                        List<UIComponentVO> southCompVO = componentVOs.stream().filter(s->!s.getOid().equals(firstCompVO.getOid())).collect(Collectors.toList());
 
                        UILayoutVO centerVO = new UILayoutVO();
                        BeanUtil.convert(layoutVO,centerVO);
                        centerVO.setOid(centerVO.getOid() + "_center");
                        centerVO.setLayoutAreaType(UILayoutAreaTypeEnum.CENTER.getValue());
                        centerVO.setOrderNum(0);
                        List<UIComponentVO> centerCompVOS = new ArrayList<>();
                        centerCompVOS.add(firstCompVO);
                        centerVO.setComponentVOs(centerCompVOS);
                        centerVO.setTitle(firstCompVO.getName());
                        List<UILayoutVO> centerLayoutVOs = new ArrayList<>();
                        centerLayoutVOs.add(centerVO);
                        contentVO.setCenterAreas(centerLayoutVOs);
 
                        contentVO.setWestAreas(null);
                        contentVO.setNorthAreas(null);
                        contentVO.setSouthAreas(null);
                        //其余的作为south
                        if(!CollectionUtils.isEmpty(southCompVO)) {
                            UILayoutVO southVO = new UILayoutVO();
                            BeanUtil.convert(layoutVO, southVO);
                            southVO.setOid(centerVO.getOid() + "_south");
                            southVO.setLayoutAreaType(UILayoutAreaTypeEnum.SOUTH.getValue());
                            southVO.setOrderNum(0);
                            southVO.setComponentVOs(southCompVO);
 
                            List<UILayoutVO> southLayoutVOs = new ArrayList<>();
                            southLayoutVOs.add(southVO);
                            contentVO.setSouthAreas(southLayoutVOs);
                        }
                    }else {
                        //我们需要过滤一遍是否每个区域都包含
                        Map<String, List<UILayoutVO>> layoutAreaMap = layoutVOS.stream().collect(Collectors.groupingBy(UILayoutVO::getLayoutAreaType));
                        if(pageLayoutDefination.plIsShowNavigator ==1) {
                            contentVO.setWestAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.WEST.getValue(), new ArrayList<>()));
                        }
                        contentVO.setNorthAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.NORTH.getValue(), new ArrayList<>()));
                        if(pageLayoutDefination.plIsShowForm == 1) {
                            contentVO.setCenterAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.CENTER.getValue(), new ArrayList<>()));
                        }
                        if(pageLayoutDefination.plIsShowTab == 1) {
                            contentVO.setSouthAreas(layoutAreaMap.getOrDefault(UILayoutAreaTypeEnum.SOUTH.getValue(), new ArrayList<>()));
                        }
                        if(CollectionUtils.isEmpty(contentVO.getCenterAreas()) && !CollectionUtils.isEmpty(contentVO.getSouthAreas())){
                            //有操作区但是没有控制器的情况
                            contentVO.getSouthAreas().stream().forEach(layoutVO->{
                                layoutVO.setLayoutAreaType(UILayoutAreaTypeEnum.CENTER.getValue());
                            });
                            contentVO.setCenterAreas(contentVO.getSouthAreas());
                            contentVO.setSouthAreas(null);
                        }
                        if(CollectionUtils.isEmpty(contentVO.getCenterAreas()) && !CollectionUtils.isEmpty(contentVO.getWestAreas())){
                            //只有导航区
                            contentVO.getWestAreas().stream().forEach(layoutVO->{
                                layoutVO.setLayoutAreaType(UILayoutAreaTypeEnum.CENTER.getValue());
                            });
                            contentVO.setCenterAreas(contentVO.getWestAreas());
                            contentVO.setWestAreas(null);
                        }
                    }
                }
                //contentVO.setLayouts(listLayoutByContent(contentVO.getOid()));
            }
        }
        return contentVO;
    }
 
    //    private List<UILayoutVO> swapLayArea(List<UILayoutVO> layoutVOS){
    //        List<UILayoutVO> layoutVOList = new ArrayList<>();
    //        //1 导航区
    //        //2 主内容区
    //        //3 页签区
    //        if(!CollectionUtils.isEmpty(layoutVOS)){
    //            //只有一个区域的时候,都放在center里,哪怕本身是导航区
    //            if(layoutVOS.size() == 1){
    //                layoutVOS.get(0).setLayoutAreaType(UILayoutAreaTypeEnum.CENTER.getValue());
    //                layoutVOList.add(layoutVOS.get(0));
    //            }else{
    //                Map<String,List<UILayoutVO>> layoutAreaMap = layoutVOS.stream().collect(Collectors.groupingBy(UILayoutVO::getLayoutAreaType));
    //                if(layoutAreaMap.containsKey("1")){
    //                    //
    //                }
    //            }
    //        }
    //    }
 
    /**
     * 获取某个UI上下文的区域
     * @param pkContent UI上下文的主键
     * @return 上下文
     */
    private List<UILayoutVO> listLayoutByContent(String pkContent){
        try {
            return UILayoutDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(pkContent)).collect(Collectors.toList()),true);
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
    }
 
    /**
     * 批量获取UI上下文的区域
     * @param pkContents ui上下文主键
     * @return key是ui上下文的主键
     */
    private Map<String,List<UILayoutVO>> batchListLayoutByContent(Collection<String> pkContents){
        Map<String, List<UILayoutVO>> layoutMap = self.selectAllUILayoutMap();
        List<UILayoutVO> layoutVOS = new ArrayList<>();
        pkContents.stream().forEach(pkContent->{
            if(layoutMap.containsKey(pkContent)){
                layoutVOS.addAll(layoutMap.get(pkContent));
            }
        });
        return layoutVOS.stream().collect(Collectors.groupingBy(UILayoutVO::getPkContent));
    }
 
    /**
     * 分隔符
     */
    public static final String SEP = "${uiContent}";
 
    /**
     * 查询所有的UI上下文的映射
     *
     * @return 显示对象,key业务类型+${uiContent}+上下文的Id
     */
    @Override
    public Map<String, UIContentVO> selectAllUIContentMap() {
        return Optional.ofNullable(self.selectAllUIContent()).orElseGet(()->new ArrayList<UIContentVO>()).stream().collect(Collectors.toMap(s->s.getBtmTypeId() + SEP + s.getId(),t->t));
    }
 
    /**
     * 查询所有的上下文的区域
     *
     * @return 区域的显示对象
     */
    @Override
    public List<UILayoutVO> selectAllUILayout() {
//        try {
//            return UILayoutDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLTabPages()).collect(Collectors.toList()),true);
//        } catch (PLException vciError) {
//            throw WebUtil.getVciBaseException(vciError);
//        }
        return null;
    }
 
    /**
     * UI区域数据对象转换为显示对象
     * @param pages 区域的数据对象
     * @return 显示对象
     */
    private List<UILayoutVO> UILayoutDO2VOs(Collection<PLTabPage> pages, boolean queryDetail){
        List<UILayoutVO> contentVOS = new ArrayList<>();
        Optional.ofNullable(pages).orElseGet(()->new ArrayList<PLTabPage>()).stream().forEach(page->{
            UILayoutVO layoutVO = UILayoutDO2VO(page, queryDetail);
            if(layoutVO.isEnableStatus()) {
                contentVOS.add(layoutVO);
            }
        });
        if(!queryDetail) {
            Map<String, List<UIComponentVO>> uiComponentMap = self.selectAllUIComponentMap();
            contentVOS.stream().forEach(layout -> {
                if (uiComponentMap.containsKey(layout.getOid())) {
                    layout.setComponentVOs(uiComponentMap.get(layout.getOid()));
                }
            });
        }
        return contentVOS;
    }
 
    /**
     * UI上下文的区域
     * @param page 布局区域
     * @param queryDetail 是否查询组件的信息
     * @return 区域的显示对象
     */
    @VciUnLog
    private UILayoutVO UILayoutDO2VO(PLTabPage page, boolean queryDetail){
        UILayoutVO layoutVO = new UILayoutVO();
        if(page !=null ){
            layoutVO.setOid(page.plOId);
            layoutVO.setId(page.plCode);
            layoutVO.setName(page.plName);
            layoutVO.setEnableStatus(1 == page.plIsOpen?true:false);
            if(!layoutVO.isEnableStatus()){
                //没有启动直接返回了,别查下面了
                return layoutVO;
            }
            layoutVO.setTitle(page.plLabel);
            if(StringUtils.isBlank(layoutVO.getTitle())){
                layoutVO.setTitle(layoutVO.getName());
            }
            layoutVO.setDescription(page.plDesc);
            layoutVO.setOrderNum(page.plSeq);
            layoutVO.setPkContent(page.plOId);
            layoutVO.setLayoutAreaType(page.plAreaType+"");
            if(1 == page.plAreaType) {
                layoutVO.setLayoutAreaType(UILayoutAreaTypeEnum.WEST.getValue());
            }else if(2 == page.plAreaType){
                layoutVO.setLayoutAreaType(UILayoutAreaTypeEnum.CENTER.getValue());
            }else{
                layoutVO.setLayoutAreaType(UILayoutAreaTypeEnum.SOUTH.getValue());
            }
            layoutVO.setCreator(page.plCreateUser);
            try {
                layoutVO.setCreateTime(new Date(page.plCreateTime));
                layoutVO.setLastModifyTime(new Date(page.plModifyTime));
            } catch (Exception e) {
                e.printStackTrace();
            }
            layoutVO.setLastModifier(page.plModifyUser);
            layoutVO.setDisplayExpression(page.plOpenExpression);
            layoutVO.setUiParseClass(page.plUIParser);
            layoutVO.setExtendAttr(page.plExtAttr);
            if(queryDetail){
                //单个的,直接获取
                try {
                    layoutVO.setComponentVOs(uiComponentDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(layoutVO.getOid())).collect(Collectors.toList()),true));
                } catch (PLException vciError) {
                    throw WebUtil.getVciBaseException(vciError);
                }
            }
        }
        return layoutVO;
    }
    /**
     * 查询所有的上下文的区域的映射
     *
     * @return 区域的显示对象 ,key是所属UI上下文的主键
     */
    @Override
    public Map<String, List<UILayoutVO>> selectAllUILayoutMap() {
        return Optional.ofNullable(self.selectAllUILayout()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.groupingBy(s->s.getPkContent()));
    }
 
    /**
     * 查询所有的组件
     *
     * @return UI组件
     */
    @Override
    public List<UIComponentVO> selectAllUIComponent() {
//        try {
//            return uiComponentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLPageDefinations()).collect(Collectors.toList()),false);
//        } catch (PLException vciError) {
//            throw WebUtil.getVciBaseException(vciError);
//        }
        return null;
    }
 
    /**
     * 使用主键获取
     *
     * @param componentOid 组件的主键
     * @return 主键的显示对象
     */
    @Override
    public UIComponentVO getComponentByOid(String componentOid) {
        if(StringUtils.isBlank(componentOid)){
            return null;
        }
        if(!QUERY_BY_CACHE){
            try {
                return uiComponentDO2VO(platformClientUtil.getUIService().getPLPageDefinationById(componentOid),true);
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
        }else{
            List<UIComponentVO> componentVOS = self.selectAllUIComponent();
            List<UIComponentVO> componentVOList = Optional.ofNullable(componentVOS).orElseGet(() -> new ArrayList<>()).stream().filter(s -> s.getOid().equalsIgnoreCase(componentOid)).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(componentVOList)){
                return componentVOList.get(0);
            }
        }
        return null;
    }
 
    /**
     * 组件的数据对象转换为显示对象
     * @param pages 数据对象
     * @return 显示对象
     */
    private List<UIComponentVO> uiComponentDO2VOs(Collection<com.vci.corba.portal.data.PLPageDefination> pages, boolean queryDetail){
        List<UIComponentVO> componentVOS = new ArrayList<>();
        pages.stream().forEach(page->{
            componentVOS.add(uiComponentDO2VO(page,queryDetail));
        });
        return componentVOS;
    }
 
    /**
     * 组件的数据对象转换为显示对象
     * @param page 数据对象
     * @return 显示对象
     */
    @VciUnLog
    private UIComponentVO uiComponentDO2VO(PLPageDefination page, boolean queryDetail){
        UIComponentVO componentVO = new UIComponentVO();
        if(page !=null){
            componentVO.setOid(page.plOId);
            componentVO.setPkLayout(page.plTabPageOId);
            componentVO.setName(page.name);
            componentVO.setDescription(page.desc);
            componentVO.setOrderNum((int) page.seq);
            UIComponentDefineXO componentDefineXO = null;
            try {
                componentDefineXO = readInfoFromXML(page.plDefination, UIComponentDefineXO.class);
            }catch (Throwable e){
                logger.error("读取xml出错",e);
                return  null;
            }
            //之前的类型的值是1,2,3等看着不直观
            UIComponentTypeEnum componentTypeEnum = null;
            if("1".equals(componentDefineXO.getTemplateType())){
                //说明这个表格的类型
                componentTypeEnum = UIComponentTypeEnum.TABLE;
                //查询表格相关的配置
                String btmType ;
                if("1".equals(componentDefineXO.getSearchTarger())){
                    //本对象,就是业务类型
                    btmType = componentDefineXO.getShowType();
                }else{
                    //链接类型
                    btmType = componentDefineXO.getLinkType();
                }
                if(!queryDetail) {
                    //从缓存里获取
                    Map<String, UITableDefineVO> tableDefineVOMap = self.selectAllTableMap();
                    String key = btmType.toLowerCase() + SEP + componentDefineXO.getTemplateId().toLowerCase();
                    if (!tableDefineVOMap.containsKey(key)) {
                        throw new VciBaseException("{0}里的表格{1}不存在", new String[]{btmType, componentDefineXO.getTemplateId()});
                    }
                    componentVO.setTableDefineVO(tableDefineVOMap.get(key));
                }else{
                    try {
                        componentVO.setTableDefineVO(tableDO2VO(platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true));
                    } catch (PLException vciError) {
                        throw WebUtil.getVciBaseException(vciError);
                    }
                }
                if(StringUtils.isNotBlank(componentDefineXO.getQueryTemplateName())){
                    componentVO.getTableDefineVO().setQueryTemplateName(componentDefineXO.getQueryTemplateName());
                }
            }else if("2".equals(componentDefineXO.getTemplateType())){
                //自定义
                componentTypeEnum = UIComponentTypeEnum.CUSTOMER;
                componentVO.setCustomClass(componentDefineXO.getControlPath());
            }else if("3".equals(componentDefineXO.getTemplateType())){
                //树表
                componentTypeEnum = UIComponentTypeEnum.TREE_GRID;
                //查询表格相关的配置
                String btmType ;
                boolean isLink = false;
                if("1".equals(componentDefineXO.getSearchTarger())){
                    //本对象,就是业务类型
                    btmType = componentDefineXO.getShowType();
                }else{
                    //链接类型
                    btmType = componentDefineXO.getLinkType();
                    isLink = true;
                }
                UITableDefineVO tableDefineVO = null;
                if(!queryDetail) {
                    Map<String, UITableDefineVO> tableDefineVOMap = self.selectAllTableMap();
                    String key = btmType.toLowerCase() + SEP + componentDefineXO.getTemplateId().toLowerCase();
                    if (!tableDefineVOMap.containsKey(key)) {
                        throw new VciBaseException("{0}里的表格{1}不存在", new String[]{btmType, componentDefineXO.getTemplateId()});
                    }
                    tableDefineVO= tableDefineVOMap.get(key);
                }else{
                    try {
                        tableDefineVO = tableDO2VO(platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true);
                    } catch (PLException vciError) {
                        throw WebUtil.getVciBaseException(vciError);
                    }
                }
                if(tableDefineVO != null) {
 
                    UITreeTableDefineVO treeTableDefineVO = new UITreeTableDefineVO();
                    BeanUtil.convert(tableDefineVO, treeTableDefineVO);
                    if(isLink){
                        treeTableDefineVO.setTreeCurrentField("t_oid");
                        treeTableDefineVO.setTreeParentField("f_oid");
                        treeTableDefineVO.setTreeFieldName(componentDefineXO.getExpandCols());
                    }else{
                        if(componentDefineXO.getExpandCols().contains(",")){
                            treeTableDefineVO.setTreeParentField(componentDefineXO.getExpandCols().split(",")[0]);
                            treeTableDefineVO.setTreeFieldName(componentDefineXO.getExpandCols().split(",")[1]);
                        }else{
                            treeTableDefineVO.setTreeParentField("parentOid");
                            treeTableDefineVO.setTreeFieldName(componentDefineXO.getExpandCols());
                        }
                    }
                    //现在树表只支持全部展开
                    componentVO.setTreeTableDefineVO(treeTableDefineVO);
                }else{
                    logger.error("{},{}里的信息不正确",new String[]{btmType,});
                }
                if(StringUtils.isNotBlank(componentDefineXO.getQueryTemplateName())){
                    componentVO.getTreeTableDefineVO().setQueryTemplateName(componentDefineXO.getQueryTemplateName());
                }
            }else if ("4".equals(componentDefineXO.getTemplateType())){
                //表单
                componentTypeEnum = UIComponentTypeEnum.FORM;
                //查询表单相关的配置
                String btmType ;
                if("1".equals(componentDefineXO.getSearchTarger())){
                    //本对象,就是业务类型
                    btmType = componentDefineXO.getShowType();
                }else{
                    //链接类型
                    btmType = componentDefineXO.getLinkType();
                }
                if(!queryDetail) {
                    Map<String, UIFormDefineVO> formDefineVOMap = self.selectAllFormMap();
                    String key = btmType.toLowerCase() + SEP + componentDefineXO.getTemplateId().toLowerCase();
                    if (!formDefineVOMap.containsKey(key)) {
                        throw new VciBaseException("{0}里的表格{1}不存在", new String[]{btmType, componentDefineXO.getTemplateId()});
                    }
                    componentVO.setFormDefineVO(formDefineVOMap.get(key));
                }else{
                    try {
                        componentVO.setFormDefineVO(formDO2VO(platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId())));
                    } catch (PLException vciError) {
                        throw WebUtil.getVciBaseException(vciError);
                    }
                }
            }else if("5".equals(componentDefineXO.getTemplateType())){
                //树
                componentTypeEnum = UIComponentTypeEnum.TREE;
                UITreeDefineVO treeDefineVO = new UITreeDefineVO();
                treeDefineVO.setBtmType(componentDefineXO.getShowType());
                treeDefineVO.setLinkType(componentDefineXO.getLinkType());
                treeDefineVO.setLoadType("1".equalsIgnoreCase(componentDefineXO.getExpandMode())?"node":"all");
                treeDefineVO.setOrientation("positive".equalsIgnoreCase(componentDefineXO.getOrientation())?false:true);
                treeDefineVO.setShowImage("1".equalsIgnoreCase(componentDefineXO.getIsShowImage())?true:false);
                treeDefineVO.setRootContent(componentDefineXO.getRootContent());
                treeDefineVO.setFieldSep(StringUtils.isBlank(componentDefineXO.getSeparator())?",":componentDefineXO.getSeparator());
                treeDefineVO.setQueryTemplateName(componentDefineXO.getTemplateId());
                treeDefineVO.setTreeNodeExpression(componentDefineXO.getShowAbs());
                treeDefineVO.setShowLinkAbs(componentDefineXO.getShowLinkAbs());
                componentVO.setTreeDefineVO(treeDefineVO);
            }else{
                throw new VciBaseException("UI组件的类型不支持,{0}",new String[]{componentDefineXO.getTemplateType()});
            }
            componentVO.setUiComponentType(componentTypeEnum.getValue());
            componentVO.setUiComponentTypeText(componentTypeEnum.getText());
 
            //显示类型现在用来做啥的呢
            UIComponentDisplayTypeEnum displayTypeEnum = null;
            if("1".equals(componentDefineXO.getNavigatorType())){
                displayTypeEnum = UIComponentDisplayTypeEnum.NONE;
            }else if("2".equals(componentDefineXO.getNavigatorType())){
                displayTypeEnum = UIComponentDisplayTypeEnum.ROLE;
            }else if("3".equals(componentDefineXO.getNavigatorType())){
                displayTypeEnum = UIComponentDisplayTypeEnum.FOLDER;
            }
            componentVO.setUiParseClass(componentDefineXO.getUIParser());
            componentVO.setExtendAttr(componentDefineXO.getExtAttr());
            componentVO.setButtons(listButtonByComponent(componentVO.getOid()));
        }
        return componentVO;
    }
 
    /**
     * 获取某个组件的按钮
     * @param pkComponent 组件的主键
     * @return 按钮的信息
     */
    @Override
    public List<UIButtonDefineVO> listButtonByComponent(String pkComponent){
        try {
            List<UIButtonDefineVO> buttonDefineVOS = buttonDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLTabButtonsByTableOId(pkComponent)).collect(Collectors.toSet())).stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList());
 
            Map<String,RoleRightInfo> allRightRoleMap = new HashMap<>();
            RoleRightInfo[] bts = platformClientUtil.getFrameworkService().getRoleRightByUserName("bt");
            Map<String,Long> rightMap = new HashMap<String,Long>();
            for(RoleRightInfo obj:bts){
                allRightRoleMap.put(obj.funcId, obj);
                rightMap.put(obj.funcId,obj.rightValue);
            }
            //循环对按钮权限进行判断,没有权限的将移除buttonDefineVOS对象
            Iterator<UIButtonDefineVO> buttonDefineVO = buttonDefineVOS.iterator();
            while (buttonDefineVO.hasNext()){
                UIButtonDefineVO buttonDefine = buttonDefineVO.next();
                if(rightMap.containsKey(buttonDefine.getPkComponent())) {
                    Long rightValue = rightMap.get(buttonDefine.getPkComponent());
                    int nodeValue = buttonDefine.getOrderNum();
                    if (nodeValue >= 0 && nodeValue <= 63) {
                        //进行位与操作,如果相等则表示具有当前操作的权限
                        long preValue = (rightValue >> nodeValue) & 1;
                        if (preValue != 1) {
                            buttonDefineVO.remove();
                        }
                    }
                }
            }
 
            if(CollectionUtils.isEmpty(buttonDefineVOS)){
                return buttonDefineVOS;
            }
            List<UIButtonDefineVO> childrens = buttonDefineVOS.stream().filter(s -> StringUtils.isNotBlank(s.getPkParentOid())).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(childrens)){
                buttonDefineVOS = buttonDefineVOS.stream().filter( s->StringUtils.isBlank(s.getPkParentOid())).collect(Collectors.toList());
                //只支持一级.多了也不好看
                buttonDefineVOS.stream().forEach(buttonVO->{
                    buttonVO.setChildren(childrens.stream().filter(s->buttonVO.getOid().equals(s.getPkParentOid())).collect(Collectors.toList()));
                });
                return buttonDefineVOS;
            }else{
                return buttonDefineVOS;
            }
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
    }
 
    /**
     * 按钮的数据对象转换为显示对象
     * @param buttons 按钮的数据对象
     * @return 显示对象
     */
    @Override
    public List<UIButtonDefineVO> buttonDO2VOs(Collection<com.vci.corba.portal.data.PLTabButton> buttons){
        List<UIButtonDefineVO> buttonDefineVOS = new ArrayList<>();
        Optional.ofNullable(buttons).orElseGet(()->new ArrayList<>()).stream().forEach(button->{
            buttonDefineVOS.add(buttonDO2VO(button));
        });
        return buttonDefineVOS;
    }
 
    /**
     * 按钮的数据对象转换为显示对象
     * @param button 按钮的数据对象
     * @return 显示对象
     */
    @Override
    public UIButtonDefineVO buttonDO2VO(com.vci.corba.portal.data.PLTabButton button)  {
        UIButtonDefineVO buttonVO = new UIButtonDefineVO();
        Map<String, UIActionVO> actionVOMap = self.selectAllActionMap();
//        Map<String, UIActionVO> actionVOMap = ServiceProvider.getUIService().getAllPLAction();
        if(button !=null){
            buttonVO.setOid(button.plOId);
            buttonVO.setPkComponent(button.plTableOId);
            buttonVO.setName(button.plLabel);
            buttonVO.setDescription(button.plDesc);
            buttonVO.setOrderNum((int) button.plSeq);
            buttonVO.setCreator(button.plCreateUser);
            buttonVO.setLastModifier(button.plModifyUser);
            try{
                buttonVO.setCreateTime(VciDateUtil.str2Date(String.valueOf(button.plCreateTime),VciDateUtil.DateTimeFormat));
                buttonVO.setLastModifyTime(VciDateUtil.str2Date(String.valueOf(button.plModifyTime),VciDateUtil.DateTimeFormat));
            }catch (Throwable e){
 
            }
            buttonVO.setPkParentOid(button.plParentOid);
            buttonVO.setDisplayMode(button.displayMode);
            buttonVO.setIconPath(button.iconPath);
            buttonVO.setAuthorization("0".equalsIgnoreCase(button.authorization));
            buttonVO.setHidden(!"0".equalsIgnoreCase(button.show));
            //查询action
            buttonVO.setAreaType(button.plAreaType);
            if(StringUtils.isNotBlank(button.plActionOId) && actionVOMap.containsKey(button.plActionOId)){
                UIActionVO actionVO = actionVOMap.get(button.plActionOId);
                buttonVO.setActionVO(actionVO);
                buttonVO.setId(actionVO.getId());
                buttonVO.setUrl(actionVO.getBsUrl());
                buttonVO.setCsUrl(actionVO.getCsClass());
                //查找参数
                Map<String,String> params = new HashMap<>();
                try {
                    PLCommandParameter[] parameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(buttonVO.getOid());
                    if(parameters!=null && parameters.length > 0){
                        for(PLCommandParameter parameter: parameters){
                            params.put(parameter.plKey,parameter.plValue);
                        }
                    }
                } catch (PLException vciError) {
                    throw WebUtil.getVciBaseException(vciError);
                }
                buttonVO.setParamVOS(params);
                if(StringUtils.isBlank(buttonVO.getIconPath()) && (params.containsKey("icon") || params.containsKey("iconPath") || params.containsKey("iconCls"))){
                    buttonVO.setIconPath(params.getOrDefault("icon",params.getOrDefault("iconPath",params.getOrDefault("iconCls",""))));
                }
            }
        }
        return buttonVO;
    }
 
    /**
     * 从xml的信息中读取对象
     * @param xmlInfo xml的信息
     * @param xoClass 对象的class
     * @param <T> 对象的
     * @return 对象
     * @throws VciBaseException 转换出错会抛出异常
     */
    private <T> T readInfoFromXML(String xmlInfo,Class<T> xoClass) throws VciBaseException{
        XStream xStream = new XStream(new XppDriver(new XmlFriendlyNameCoder("_-","_")));
        xStream.setClassLoader(getClass().getClassLoader());
        xStream.processAnnotations(xoClass);
        xStream.ignoreUnknownElements();
        try{
            return (T)xStream.fromXML(xmlInfo);
        }catch (Throwable e){
            String error = LangBaseUtil.getErrorMsg(e);
            if(logger.isErrorEnabled()){
                logger.error(error,e);
                logger.error(xmlInfo);
            }
            throw new VciBaseException(error,new String[0],e);
        }
    }
 
    /**
     * 查询所有的组件
     *
     * @return key是所属的区域,
     */
    @Override
    public Map<String, List<UIComponentVO>> selectAllUIComponentMap() {
        return Optional.ofNullable(self.selectAllUIComponent()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.groupingBy(UIComponentVO::getPkLayout));
    }
 
    /**
     * 使用业务类型或者链接类型,以及UI上下文的编号,获取相应的信息
     *
     * @param btmType 业务类型
     * @param id      主键
     * @return UI上下文的信息
     */
    @Override
    public UIContentVO getUIContentByBtmTypeAndId(String btmType, String id) {
        WebUtil.alertNotNull(btmType,"业务类型或者链接类型",id,"UI上下文的编号");
        PLUILayout[] obj = null;
        try {
            obj = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(btmType);
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        PLUILayout context = null;
        for (int i = 0; i < obj.length; i++) {
            if (obj[i].plCode.equals(id)) {
                context = obj[i];
                break;
            }
        }
        return UIContentDO2VO(context,true);
    }
}