xiejun
2023-09-18 978f74777e10a0531c4413ab36320d2be36f42ea
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
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
package com.vci.rmip.code.client.codeapply.Apply410;
 
import com.vci.base.ui.swing.VCIOptionPane;
import com.vci.base.ui.swing.components.*;
import com.vci.base.ui.tree.VCIBaseTreeNode;
import com.vci.rmip.code.client.codeapply.Apply410.enums.VciFieldTypeEnum;
import com.vci.rmip.code.client.codeapply.Apply410.object.*;
import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeBasicSecVO;
import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeClassifyTemplateAttrVO;
import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeFixedValueVO;
import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeRuleVO;
import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.KeyValue;
import com.vci.rmip.code.client.codeapply.Apply410.swing.IntegerTextField;
import com.vci.rmip.code.client.codeapply.Apply410.swing.RealTextField;
import com.vci.rmip.code.client.codeapply.Apply410.swing.VCIJComboxBox;
import com.vci.rmip.code.client.codeapply.Apply410.utils.BeanUtilForVCI;
import com.vci.rmip.code.client.codeapply.Apply410.utils.ConfigUtils;
import com.vci.rmip.code.client.codeapply.Apply410.utils.HttpUtil;
import com.vci.rmip.code.client.codeapply.Apply410.utils.VciBaseUtil;
 
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
 
import javax.swing.*;
import javax.swing.text.JTextComponent;
import javax.swing.tree.TreeNode;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.regex.Pattern;
 
public class CodeApplyFor410MainPanel  extends VCIJPanel {
 
    private String url=ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController");
    //410新需求
    private final String SPECIAL_RULE_NAME="Special.rule.name";
    private final String SPECIAL_SECTION_NAME = "Special.section.name";
    private final String SPECIAL_CONTROL_SECTION_NAME = "Special.control.other.section.name";
    private final String SPECIAL_SECTION_VALUE = "Special.section.val";
 
    private final String MAX_ATTR_IN_LINE_KEY = "RMData.MaxAttrInLine";
    private final String TEXTAREA_ENABLE_KEY = "RMData.TextArea.Enable";
    private final String MAX_STRING_LENGTH_KEY = "RMData.MaxStringLength";
    private final String TEXTAREA_PRE_SIZE_WIDTH = "RMData.TextArea.PreferredSize.Width";
    private final String TEXTAREA_PRE_SIZE_HEIGHT = "RMData.TextArea.PreferredSize.Height";
    private final String TEXTAREA_MIN_SIZE_WIDTH = "RMData.TextArea.MinimumSize.Width";
    private final String TEXTAREA_MIN_SIZE_HEIGHT = "RMData.TextArea.MinimumSize.Height";
    private final String TEXTAREA_MAX_SIZE_WIDTH = "RMData.TextArea.MaximumSize.Width";
    private final String TEXTAREA_MAX_SIZE_HEIGHT = "RMData.TextArea.MaximumSize.Height";
    // 是否启用属性长度过长时,用TextArea显示,true:启用 false:不启用,默认值true
    private boolean isEnableTextArea = false;
    // 启用了TextArea后,此TextArea的PreferredSize、MinimumSize、MaximumSize的Width、Height
    private int textAreaPreSizeWidth = 100;
    private int textAreaPreSizeHeight = 50;
    private int textAreaMinSizeWidth = 100;
    private int textAreaMinSizeHeight = 30;
    private int textAreaMaxSizeWidth = 100;
    private int textAreaMaxSizeHeight = 80;
    // 同一行内,最多加载的属性个数,一行为一组,即一组内最多加载的属性个数,默认值2
    private int maxAttrInLine = 2;
    // 当String类型的属性值的长度大于此值时,该属性就需要用TextArea显示,并占用整行,默认值100
    private int maxStringLength = 100;
    private int levelPositon = -1;
    private TransmitTreeObject transTreeObject = new TransmitTreeObject();
    private TokenUserObject tokenUserObject;
    private String deptName;
    //存储每个实际 码段列对应的码段对象
    protected Map<Integer,CodeBasicSecVO> columnSecMap = new LinkedHashMap<Integer,CodeBasicSecVO>();
    private LinkedHashMap<Integer, JComponent> compMaps = new LinkedHashMap<Integer, JComponent>();
    private Map<String, JComponent> secAndComMap = new LinkedHashMap<String, JComponent>();
 
    private Map<JComponent, JComponent> comtMap = new LinkedHashMap<JComponent, JComponent>();
    private Map<String, VCIJComboBox> secNameAndComtMap = new LinkedHashMap<String, VCIJComboBox>();
    private Map<Integer,String> secIndexAndNameMap = new LinkedHashMap<Integer, String>();
    private List<JComponent> specSecList = new ArrayList<JComponent>();
    private boolean isSpecialRuleFlag = false;
    private String specialSectioName = "";
    private VCIJPanel rulePal = new VCIJPanel();
    private StringBuffer tempStr= new StringBuffer();//可变码段的值;
    private  String  levelRes="";
    private String[] specialSecVals = new String[0];
    private RMDataTransmitObject transmitForRMData = new RMDataTransmitObject();
    private CodeRuleVO codeRuleVO=null;
    /**
     * 存储属性和值的Map,key,用于默认值的显示
     */
    private Map<String,String> displayValues = new HashMap<>();
    /**
     * 属性ID与属性对应的控件之间的映射MAP
     */
    private LinkedHashMap<String, JComponent> attrIdToCtrlMaps = new LinkedHashMap<String, JComponent>();
    /**
     * 属性的内部名称与属性对应的控件之间的映射MAP
     */
    private LinkedHashMap<String, JComponent> attrInnerNameToCtrlMaps = new LinkedHashMap<String, JComponent>();
 
    /**
     * 引用玛段码值与combox元素位置的映射MAP
     */
    private LinkedHashMap<String, Integer>  refSecValueToCombxindex = new LinkedHashMap<String, Integer>();
    /**
     * 码段id与分类码段码值描述对象对应的控件之间的映射MAP
     */
    private LinkedHashMap<String, JComponent> secIdToClsfIdMap = new LinkedHashMap<String, JComponent>();
 
    private List<VCIJTextField> textCompts = new LinkedList<VCIJTextField>();
    /**
     * 当前选择的分类的模板
     */
    private CodeClassifyTemplateVO currentCodeClassifyTemplateVO;
    // 实际的
    private VCIJDialog realDialogInstance = null;
    public CodeApplyFor410MainPanel(TransmitTreeObject transTreeObject, TokenUserObject tokenUserObject, CodeClassifyTemplateVO currentCodeClassifyTemplateVO) {
        this.transTreeObject = transTreeObject;
        this.tokenUserObject = tokenUserObject;
        this.currentCodeClassifyTemplateVO=currentCodeClassifyTemplateVO;
    }
 
    public CodeApplyFor410MainPanel(TransmitTreeObject transTreeObject,TokenUserObject tokenUserObject,String deptName,CodeClassifyTemplateVO currentCodeClassifyTemplateVO,Map displayValues) {
        this.transTreeObject = transTreeObject;
        this.tokenUserObject = tokenUserObject;
        this.deptName = deptName;
        this.currentCodeClassifyTemplateVO=currentCodeClassifyTemplateVO;
        this.displayValues = displayValues;
    }
 
    /**
     *
     * @param type, 1代表申请,2设置流水
     */
    public void buildMainPanel(int type) {
        try {
            init(type);
            if (type == 2) {
                return;
            }
            this.initRMTypeTreeMaps();
            this.initContents();
        }catch (Exception e){
            VCIOptionPane.showMessage(this,e.getMessage());
        }
    }
    private void init(int type){
        this.loadTextAreaEnableEnv(); //add by liujw
        //this.loadSpecialRuleConfig();
        CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        //String url= ConfigUtils.getConfigValue("410.PDM.rule.url","http://127.0.0.1:36014/codeApplySwingController/getCodeRuleByClassifyFullInfo");
        /**系统只加载代码项  如果libName不为空,直接获取对应的代码项**/
        Map<String,String> condtionMap=new HashMap<>();
        condtionMap.put("codeClassId", rmType.getOid());
        Map<String,String> headerMap=new HashMap<>();
        headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
        R r= HttpUtil.sendGet(url+"/getCodeRuleByClassifyFullInfo",condtionMap,headerMap);
        codeRuleVO=new CodeRuleVO();
        if(r.isSuccess()){
            Object object= r.getData();
            if(object!=null) {
                ObjectMapper objectMapper = new ObjectMapper();
                try {
                    codeRuleVO = objectMapper.readValue(object.toString(),CodeRuleVO.class);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                
            }
        }else{
        /*    if(!r.getMsg().equals("当前主题库分类,以及它的所有的上级分类都没有设置编码规则")){
                VCIOptionPane.showMessage(this,r.getMsg());
                }*/
            }
        /**加载规则对应的码段信息**/
        if(codeRuleVO!=null){
            List<CodeBasicSecVO> codeBasicSecVOList=codeRuleVO.getSecVOList();
            if(!CollectionUtils.isEmpty(codeBasicSecVOList) ){
                /**初始化码段panel**/
                initSectionPanel(codeBasicSecVOList, codeRuleVO.getOid(), type);//初始化规则码段
            }
        }
        this.setLayout(new BorderLayout());
        this.add(rulePal,BorderLayout.CENTER);
 
    }
    /**
     * 规则码段主界面
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2012-8-7
     * @param objs
     * @param cRuleId
     */
    private void initSectionPanel(List<CodeBasicSecVO> objs, String cRuleId, int type)  {
        //循环获取列名
        int column = 0;
        for(int i = 0; i < objs.size(); i++) {
            if(objs.get(i).getSecType().equals("codeserialsec")){//流水码段不在TABLE里显示
                if (type == 1) {
                    continue;
                } else if (type == 2) {
                    break;
                }
            }
            columnSecMap.put(column++,objs.get(i));
        }
        createSectionPanel(objs, type);
    }
    private void createSectionPanel(List<CodeBasicSecVO> secObjs, int type)  {
        /**每次选择代码项后,自动加载规则码段和模板属性信息,清除原来的码段信息**/
        rulePal.removeAll();
        rulePal.updateUI();
 
        /**根据规则获取码段信息界面**/
        VCIJPanel sectionPal = new VCIJPanel(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        int x = 0;
        int y = 0;
        int maxAttrInLine = 1;
        int column = 2;
 
        List<CodeBasicSecVO> secList = new ArrayList<CodeBasicSecVO>();
        List<VCIJComboxBox> comList = new ArrayList<VCIJComboxBox>();
 
        compMaps.clear();
        secAndComMap.clear();
        secIdToClsfIdMap.clear();
        secNameAndComtMap.clear();
        secIndexAndNameMap.clear();
        // 加载码段列表
        boolean isBreak = false;
        for(int secIndex = 0; secIndex < secObjs.size(); secIndex += maxAttrInLine){//for1
            for(int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++){ //for2
                if(secIndex + columnIndex >= secObjs.size()){
                    break;
                }
                if(secObjs.get(secIndex).getSecType().equals("codeserialsec")){//流水码段不在TABLE里显示
                    if (type == 1) {
                        continue;
                    } else {
                        isBreak = true;
                        break;
                    }
                } /*else if (secObjs[secIndex].getSecType() == SectionConstant.SectionType.SECCHAR){//是分隔符
                    continue;
                }*/
                CodeBasicSecVO secObj = secObjs.get(secIndex+columnIndex);
 
                VCIJLabel lbl = new VCIJLabel(secObj.getName() + ":");
                lbl.setForeground(new Color(129, 0, 0));
                JComponent compt = null;//码段名称
 
                VCIJComboxBox cbx = new VCIJComboxBox();
                compt = cbx;
                secList.add(secObj);
                comList.add(cbx);
                compMaps.put(column, compt);
                secNameAndComtMap.put(secObj.getName(), cbx);
                secIndexAndNameMap.put(column, secObj.getName());
 
                /**层级码段需要特殊处理:如果是层级码段,下拉框不能编辑,显示的值是选中的树节点的分类名称和代号**/
                if(secObj.getSecType().equals ("codelevelsec")) {//层级码段
                    levelPositon = column;
                    compt.setEnabled(false);
                }
//                relationMap.put(secIndex, column);
                secAndComMap.put(secObj.getId(), cbx);
                column++;
 
                c.gridx = x++;
                c.gridy = y;
                c.gridheight = 1;
                c.gridwidth = 1;
                c.weightx = 0d;
                c.weighty = 0d;
//                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.EAST;
                c.insets = new Insets(1, 1, 10, 10);
                c.ipadx = 3;
                c.ipady = 3;
                lbl.setPreferredSize(new Dimension(100,25));
                sectionPal.add(lbl, c);
 
                c.gridx = x++;
                c.weightx = 0d;
                c.fill = GridBagConstraints.CENTER;
                c.anchor = GridBagConstraints.WEST;
                compt.setPreferredSize(new Dimension(200,25));
                sectionPal.add(compt, c);
                //如果当前码段是需要特殊处理的码段,系统进行记录处理
                if(isSpecialRuleFlag && specialSectioName.equals(secObj.getName())) {
                    specSecList.add(lbl);
                    specSecList.add(compt);
                }
                /**分类码段添加描述信息  410新需求:分类码段码值增加'码值描述'字段 BEGIN***/
                if(secObj.getSecType().equals("codeclassifysec")) {
                    VCIJLabel lblDesc = new VCIJLabel("描述:");
                    c.gridx = x++;
                    c.weightx = 0d;
                    c.fill = GridBagConstraints.NONE;
                    c.anchor = GridBagConstraints.WEST;
                    lblDesc.setPreferredSize(new Dimension(40,25));
                    sectionPal.add(lblDesc, c);
                    VCIJTextField txtDesc = new VCIJTextField("");
                    c.gridx = x++;
                    c.weightx = 0d;
                    c.fill = GridBagConstraints.CENTER;
                    c.anchor = GridBagConstraints.WEST;
                    txtDesc.setPreferredSize(new Dimension(200,25));
                    txtDesc.setEditable(false);
                    sectionPal.add(txtDesc, c);
                    secIdToClsfIdMap.put(secObj.getId(), txtDesc);
                    //详细描述信息的查看
                    VCIJLabel clsfDescLbl = new VCIJLabel();
                    clsfDescLbl.setText("<html><u>"+"详细描述"+"</u><html>");
                    clsfDescLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    clsfDescLbl.setForeground(Color.RED);
 
                    comtMap.put(clsfDescLbl,txtDesc);
                    clsfDescLbl.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e){
                            clsfValDescActionListener(e);
                        }
                    });
                    c.gridx = x++;
                    c.weightx = 0d;
                    c.fill = GridBagConstraints.NONE;
                    c.anchor = GridBagConstraints.WEST;
//                    lblDesc.setPreferredSize(new Dimension(100,25));
                    sectionPal.add(clsfDescLbl, c);
 
                    //如果当前码段是需要特殊处理的码段,系统进行记录处理
                    if(isSpecialRuleFlag && specialSectioName.equals(secObj.getName())) {
                        specSecList.add(lblDesc);
                        specSecList.add(txtDesc);
                        specSecList.add(clsfDescLbl);
                    }
 
                }
                /****************************END**********************************/
 
            }// for 2
            if (isBreak) {
                break;
            }
            x = 0;
            y += 1;
        }// for 1
 
        rulePal.setLayout(new BorderLayout());
        rulePal.add(sectionPal,BorderLayout.CENTER);
        if (type == 1) {
            rulePal.add(createAttrPal(),BorderLayout.SOUTH);
        }
        initCurrentRow(secList.toArray(new CodeBasicSecVO[0]),comList.toArray(new VCIJComboxBox[0]));
    }
    /**加载模板属性信息面板**/
    private VCIJPanel createAttrPal() {
        VCIJPanel attrPal = new VCIJPanel();
        CodeClassify rmTypeObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        /**选择了代码项**/
        if(rmTypeObj != null) {
            transmitForRMData = loadTemplateAttributes("",rmTypeObj.getId(),"");
            /**代码项下的模板包含属性**/
            if(transmitForRMData.getTempPropObjsList().size() > 0) {
                attrPal = createTemplateAttributePanel(transmitForRMData);
            }
        }
        return attrPal;
    }
    private void loadSpecialRuleConfig() {
        /******added by ligang 是否是特殊规则的判断Begin******/
        /*CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        RuleManagerObject ruleObj = ruleDel.getRuleManagerById(rmType.getRuleOid());
 
        String specialRuleName = ConfigUtils.getConfigValue(SPECIAL_RULE_NAME);
        isSpecialRuleFlag = ruleObj.getPlname().toUpperCase().equals(specialRuleName.toUpperCase()) ? true : false;
        specialControlSecName = ConfigUtils.getConfigValue(SPECIAL_CONTROL_SECTION_NAME);
        specialSectioName = ConfigUtils.getConfigValue(SPECIAL_SECTION_NAME);
        specialSecVals = ConfigUtils.getConfigValue(SPECIAL_SECTION_VALUE).split(",");*/
        /*********************End*************************/
    }
 
    /**
     * 加载是否启用TextArea环境参数
     * <p>
     * Description:
     * </p>
     * @author liujw
     * @throws
     * @time 2013-4-16
     */
    private void loadTextAreaEnableEnv()  {
        String textAreaEnable = ConfigUtils.getConfigValue(TEXTAREA_ENABLE_KEY);
        String strAttrInLine = ConfigUtils.getConfigValue(MAX_ATTR_IN_LINE_KEY);
        if (isNumber(strAttrInLine)) {
            Integer iLength = Integer.valueOf(strAttrInLine);
            if (iLength > 0) {
                this.maxAttrInLine = iLength;
            }
        }
        if (textAreaEnable.toLowerCase().equals("true")) {
            this.isEnableTextArea = true;
        }
        if(this.isEnableTextArea){
            String cfgValue = "";
 
            cfgValue = ConfigUtils.getConfigValue(MAX_STRING_LENGTH_KEY);
            if (isNumber(cfgValue)) {
                Integer iLength = Integer.valueOf(cfgValue);
                if (iLength > 0) {
                    this.maxStringLength = iLength;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_PRE_SIZE_WIDTH);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaPreSizeWidth = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_PRE_SIZE_HEIGHT);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaPreSizeHeight = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MIN_SIZE_WIDTH);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaMinSizeWidth = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MIN_SIZE_HEIGHT);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaMinSizeHeight = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MAX_SIZE_WIDTH);
            if (isNumber(cfgValue)) {
                Integer iLength = Integer.valueOf(cfgValue);
                if (iLength > 0) {
                    this.textAreaMaxSizeWidth = iLength;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MAX_SIZE_HEIGHT);
            if (isNumber(cfgValue)) {
                Integer iLength = Integer.valueOf(cfgValue);
                if (iLength > 0) {
                    this.textAreaMaxSizeHeight = iLength;
                }
            }
        }
    }
    /**
     * 分类层级注入功能的完善
     * <p>Description: </p>
     *
     * @author ligang
     * @time 2013-5-7
     */
    private void initContents() {
        Iterator<String> keys = transmitForRMData.getTempPropObjsMap().keySet().iterator();
        while(keys.hasNext()){
            String key = keys.next();
            CodeClassifyTemplateAttrVO tempPropObj = transmitForRMData.getTempPropObjsMap().get(key);
            String referConfig=tempPropObj.getReferConfig();//参照配置
            String componentRule=tempPropObj.getComponentRule();//组合规则
            String innerName = tempPropObj.getId();
            if (attrInnerNameToCtrlMaps.containsKey(innerName)) {
                String classifyLevel = tempPropObj.getClassifyInvokeLevel();
                String classifyInvokeAttr= tempPropObj.getClassifyInvokeAttr();
                JComponent compt = attrInnerNameToCtrlMaps.get(innerName);
                if(StringUtils.isNotBlank(classifyLevel)&&!classifyLevel.equals("none")) {
                    compt.setEnabled(false);
                    //ClassifyLevel classifyLevelObj=new ClassifyLevel();
                    //ObjectMapper objectMapper = new ObjectMapper();
                    String value = "";
                    /*classifyLevelObj = objectMapper.readValue(classifyLevel.toString(), ClassifyLevel.class);
                    String set=classifyLevelObj.getSet();
                    String type=classifyLevelObj.getType();*/
                    if (classifyLevel.equals("min")) {
                        CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
                        if ("name".equals(classifyInvokeAttr)) {
                            value = rmType.getName();
                        } else if ("id".equals(classifyInvokeAttr)) {
                            value = rmType.getId();
                        }
 
                    } else {
                        int intLevel = Integer.parseInt(classifyLevel);
                        if (rmTypeTreeMaps.containsKey(intLevel)) {
                            CodeClassify rmType = rmTypeTreeMaps.get(intLevel);
                            if ("name".equals(classifyInvokeAttr)) {
                                value = rmType.getName();
                            } else if ("id".equals(classifyInvokeAttr)) {
                                value = rmType.getId();
                            }
                        }
                    }
                    if (compt instanceof JTextComponent) {
                        ((JTextComponent) compt).setText(value);
                    }
                }
                //参照配置的设置成只读模式
                if(StringUtils.isNotBlank(referConfig)||StringUtils.isNotBlank(componentRule)){
                    compt.setEnabled(false);
                }
            }
        }
    }
    /**
     * 分类树中的分类对象map
     */
    private LinkedHashMap<Integer, CodeClassify> rmTypeTreeMaps = new LinkedHashMap();
 
    private void initRMTypeTreeMaps(){
        if(transTreeObject != null){
            TreeNode[] nodes = transTreeObject.getTreeModel().getPathToRoot(transTreeObject.getCurrentTreeNode());
            int level = 1;
            int start = 1;
            for(int i = start; i < nodes.length; i++){
                TreeNode node = nodes[i];
                if(node instanceof VCIBaseTreeNode){
                    VCIBaseTreeNode treeNode = (VCIBaseTreeNode) node;
                    Object obj = treeNode.getObj();
                    if((treeNode.isRoot() || (obj instanceof String))){
                        //
                    }else if(obj instanceof CodeClassify){
                        CodeClassify rmType = (CodeClassify)obj;
                        rmTypeTreeMaps.put(level++, rmType);
                    }
                }
            }
        }
    }
 
 
    /**
     * 初始化个码段码值,如果是分类码只加载父分类的分类码值,子分类不加载
     * @param secObjs
     */
    public void initCurrentRow(CodeBasicSecVO[] secObjs,VCIJComboxBox[] secCombos) {
        SectionObject lastSecObj = null;
        VCIJComboxBox hisCombo = null;
        try {
            final Map<String, String> secValMap = getSpecialValMap(specialSecVals);
            Map<String,List<String>> secIdTOListValueOidMap=new HashMap<>();
            for(int k = 0;k < secObjs.length; k++) {
                final CodeBasicSecVO secObj = secObjs[k];
                final VCIJComboxBox secCombo = secCombos[k];
                if(null == secObj) {
                    return;
                }
                if (secObj.getSecType().equals("codeclassifysec")) {// 是分类码
                    String  secOid=secObj.getOid();
                    String parentClassifySecOid= secObj.getParentClassifySecOid();
                    String parentClassifyValueOid="";
                    if(secIdTOListValueOidMap.containsKey(parentClassifySecOid)){
                        List<String> parentClassifyValueList= secIdTOListValueOidMap.get(parentClassifySecOid);
                        parentClassifyValueOid= VciBaseUtil.array2String(parentClassifyValueList.toArray(new String[]{}));
                    }
                    Map<String,String> condtionMap=new HashMap<>();
                    condtionMap.put("secOid", secOid);
                    condtionMap.put("parentClassifyValueOid", parentClassifyValueOid);
                    Map<String,String> headerMap=new HashMap<>();
                    headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
                    R r=HttpUtil.sendGet(url+"/listCodeClassifyValueBySecOid",condtionMap,headerMap);
                    List<CodeClassifyValue> codeClassifyValueList=new ArrayList<>();
                    if(r.isSuccess()){
                        Object object= r.getData();
                        if(object!=null) {
                            ObjectMapper objectMapper = new ObjectMapper();
                            try {
                                codeClassifyValueList = objectMapper.readValue(object.toString(), new TypeReference<List<CodeClassifyValue>>() {});
                            } catch (JsonProcessingException e) {
                                e.printStackTrace();
                            }
                        }
                    }else{
                        VCIOptionPane.showMessage(this,r.getMsg());
                    }
                    List<String>valueOidList=new ArrayList<>();
                    if(!CollectionUtils.isEmpty(codeClassifyValueList)) {
                        if(codeClassifyValueList.size()>1) {
                            secCombo.addItem(new CodeClassifyValue());
                        }
                        for (CodeClassifyValue codeClassifyValue : codeClassifyValueList) {
                            secCombo.addItem(codeClassifyValue);
                            valueOidList.add(codeClassifyValue.getOid());
                        }
                    }
                    secIdTOListValueOidMap.put(secObj.getOid(),valueOidList);
                    /**代码项下拉事件**/
                    secCombo.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            if(secCombo.getSelectedIndex() == -1) {
                                return;
                            }
                            if(secIdToClsfIdMap.containsKey(secObj.getId())){
                                VCIJTextField secDescVcijTextField=(VCIJTextField)secIdToClsfIdMap.get(secObj.getId());
                                CodeClassifyValue codeClassifyValue= (CodeClassifyValue) secCombo.getSelectedItem();
                                secDescVcijTextField.setText(codeClassifyValue.getName());
                            }
                        }
                    });
                    /*if (secCombo.getItemCount() > 10){
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo);
                                }
                            });
                        }
                    }else {
                        secCombo.setFlag(false);
                        secCombo.getSearchBtn().setVisible(false);
                    }*/
                } else
                    // 是固定码
                    if (secObj.getSecType() .equals("codefixedsec")) {
                        List<CodeFixedValueVO> fixedValueVOList=secObj.getFixedValueVOList();
                    //如果只有一个值,则系统默认选择,不加空值
                    if(fixedValueVOList.size() >1) {
                        secCombo.addItem(new CodeFixedValue());
                    }
                    for (CodeFixedValueVO codeFixedValueVO : fixedValueVOList) {
                        CodeFixedValue codeFixedValue=new CodeFixedValue();
                        
                        BeanUtilForVCI.copyPropertiesIgnoreCase(codeFixedValueVO,codeFixedValue);
                        secCombo.addItem(codeFixedValue);
                    }
                    /**当系统选择的是指定码段值时,组别代号的码段系统不显示 Begin**/
                    /*FixCodeValObject selObj = (FixCodeValObject) secCombo.getSelectedItem();
                    if(isSpecialRuleFlag && (secObj.getName().equals(specialControlSecName) && secValMap.containsKey(selObj.getValue())) || secValMap.containsKey(getControlSecSelectValue())) {
                        setComponentStatus(false);
                    }else {
                        setComponentStatus(true);
                    }*/
                    /*if (secCombo.getItemCount() > 10){
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo);
                                }
                            });
                        }
                    }else {
                        secCombo.setFlag(false);
                        secCombo.getSearchBtn().setVisible(false);
                    }*/
                }  else
                        // 是日期码段
                    if (secObj.getSecType().equals("codedatesec")) {
                        String df =secObj.getCodeDateFormatStr();
                        SimpleDateFormat dateFormate = new SimpleDateFormat(df);
                        String curDate = dateFormate.format(Calendar.getInstance().getTime());
                        secCombo.addItem(curDate);
                        /*if(dateObj.getIsModify().equals("Y")){//可以修改
                            secCombo.setEditable(true);
                        }*/
                } else
                        //是引用码段
                    if (secObj.getSecType().equals("coderefersec")) {
 
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo,secObj);
                                }
                            });
                        }
                    /*RefSecObject refObj = getRefSecObj(secObj.getId());
                    DefaultComboBoxModel aModel = getRefSecComboBox(refObj);
                    secCombo.setModel(aModel);
                    if(deptName != null && !("".equals(deptName))){
                        Integer index = refSecValueToCombxindex.get(deptName);
                        if(index !=null){
                            secCombo.setSelectedIndex(index);
                        }
                    }
 
                    if (secCombo.getItemCount() > 10){
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo);
                                }
                            });
                        }
                    }else {
                        secCombo.setFlag(false);
                        secCombo.getSearchBtn().setVisible(false);
                    }
 
                */} else
                    //层级码段码值显示的是选择的代码项的名称
                    if(secObj.getSecType().equals("codelevelsec")) {
                        CodeClassify rmObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
                        secCombo.addItem(rmObj);
                    } else {
                        secCombo.setEditable(true);
                    }
            }
        }catch (Exception e) {
            e.printStackTrace();
            VCIOptionPane.showError(this, "初始化码段码值出现错误!");
        }
    }
    /**
     * 加载模板的定义的属性、属性数据
     * <p>Description: </p>
     *
     * @author xchao
     * @time 2012-6-7
     * @param libId
     * @param classifyId
     * @param templateId
     * @return
     */
    public RMDataTransmitObject loadTemplateAttributes(String libId, String classifyId, String templateId) {
        RMDataTransmitObject transmit=new RMDataTransmitObject();
        transmit.setLibId(libId);
        transmit.setClassifyId(classifyId);
        CodeClassify codeClassify = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        transmit.setRmTypeObject(codeClassify);
        if(currentCodeClassifyTemplateVO!=null) {
            transmit.setTemplateId(templateId);
            Map<String, CodeClassifyTemplateAttrVO> tempPropObjMapsByInnerName = new HashMap<>();
            for (CodeClassifyTemplateAttrVO attribute : currentCodeClassifyTemplateVO.getAttributes()) {
                tempPropObjMapsByInnerName.put(attribute.getId().toLowerCase(Locale.ROOT),attribute);
            }
            transmit.setClassifyCode(codeClassify.getId());
            transmit.setTempPropObjMapsByInnerName(tempPropObjMapsByInnerName);
            Map<String, CodeClassifyTemplateAttrVO> tempPropObjsMap = new HashMap<>();
            for (CodeClassifyTemplateAttrVO attribute : currentCodeClassifyTemplateVO.getAttributes()) {
                tempPropObjsMap.put(attribute.getOid().toLowerCase(Locale.ROOT),attribute);
            }
            transmit.setTempPropObjsMap(tempPropObjsMap);
            transmit.setTemplateObject(currentCodeClassifyTemplateVO);
            transmit.setTempPropObjsList(this.currentCodeClassifyTemplateVO.getAttributes());
        }
        return transmit;
    }
 
    /****
     * 加载代码项对应的模板属性信息列表
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2013-3-23
     * @param transmitForRMData :模板属性,分类等信息
     * @return
     */
    private VCIJPanel createTemplateAttributePanel(final RMDataTransmitObject transmitForRMData)  {
        //int maxAttrInLine = 2;
        VCIJPanel pal = new VCIJPanel();
        pal.setLayout(new GridBagLayout());
        int gridx = -1;
        int gridy = -1;
        int gridwidth = 1;
        double weighty = 0.0;
        CodeClassifyTemplateAttrVO[] realAttrs = getRealAttributeObjects(transmitForRMData);
        Map<String, String> attrMaps = getTempPropMap(transmitForRMData);
 
        attrIdToCtrlMaps.clear();
        attrInnerNameToCtrlMaps.clear();
 
        for (int attrIndex = 0; attrIndex < realAttrs.length; attrIndex += maxAttrInLine) {// for1
            gridx = 0;
            gridy += 1;
            boolean leastNewLine = checkLeastNewLine(attrIndex, maxAttrInLine,attrMaps,realAttrs);
            for (int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++) { // for2
                int index = columnIndex + attrIndex;
                if (index >= realAttrs.length) {
                    break;
                }
                final CodeClassifyTemplateAttrVO attrObj = realAttrs[index];
 
                /***如果模板配置了引用模板,属性名称列表添加链接进行处理 BEGIN**/
                //ADD BY liujw
                VCIJLabel lbl = null;
                if(StringUtils.isNotBlank(attrObj.getReferConfig())) {//引用模板属性值
                    lbl = new VCIJLabel("<html><u>"+(attrObj.getName() + ":")+"</u><html>");
                    lbl.setForeground(Color.MAGENTA);
                    lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    lbl.setToolTipText("点击此处加载引用模板属性数据");
                    lbl.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e){
                            getReferTempRMData(attrObj,attrIdToCtrlMaps,transmitForRMData.getTempPropObjsList());
                        }
                    });
                } else if(!"".equals(attrObj.getComponentRule())) {//模板规则的组合
                    String lblName = "☆"+attrObj.getName() + "☆:";
                    lbl = new VCIJLabel("<html><u>"+lblName+"<u></html>");
                    lbl.setForeground(Color.BLUE);
                    lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    lbl.setToolTipText("点击此处获取模板对应规则的值");
                    lbl.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e){
                        getComptAttrValue(attrObj,attrIdToCtrlMaps);
 
                        }
                    });
                } else if(attrObj.getKeyAttrFlag().equals("true")) {//关键属性
                    lbl = new VCIJLabel(attrObj.getName() + ":");
                    lbl.setForeground(new Color(255, 0, 0));
                }
                else {
                    lbl = new VCIJLabel(attrObj.getName() + ":");
                    lbl.setForeground(attrObj.getRequireFlag().equals("true") ? new Color(0, 120, 0) : new Color(129, 0, 0));
                }
                JComponent compt = createComponent(attrObj);
                JComponent comptAddToPanel = compt;
 
                //by liujw
                boolean isMultiLineFlag = attrObj.getTextAreaFlag().equals("true") ? true : false;
                if (this.isEnableTextArea && isMultiLineFlag // 启用TextArea显示处理,且属性长度超过一定范围
                    && attrObj.getAttributeDataType().toUpperCase().equals("VTstring".toUpperCase()) // String类型
                ) {
                    VCIJTextArea textArea = new VCIJTextArea("", attrObj.getRequireFlag().equals("true"));
                    VCIJScrollPane textAreaScroll = createTextAreaScrollPane(textArea);
                    textArea.setEnabled(compt.isEnabled());
                    comptAddToPanel = textAreaScroll;
                    if(compt instanceof JTextComponent){
                        textArea.setText(((JTextComponent)compt).getText());
                    }
                    compt = textArea;
                }
                /**
                 * 方案:V1 属性组件加载、显示策略 1、每行(一组)最多显示maxAttrInLine个属性
                 * 2、如果isEnableTextArea为true,则是启用TextArea
                 * 3、启用TextArea后,如果一组内的属性,只要任意一个属性定义的属性长度大于或等于maxStringLength
                 * ,则该组内的每个属性都将独占一整行
                 * 此方案存在的问题:因为除TextArea之外的属性也将占整行显示,如果一组内的属性个数较多
                 * (大于2)时,界面显示层面不太,友好,尤其是连续出现多个TextArea时此现象更加明显
                 * 因此建议配置:启用TextArea时,RMData.MaxAttrInLine=2,即一组内最多加载两个属性。
                 */
                // 一组至少存在着一个TextArea时,该组内其它属性也将占整个宽度(独占一行),
                if (leastNewLine) {
                    gridwidth = maxAttrInLine * 2;
                    gridx = 0;
                    gridy += 1;
//                        weighty = 1.0;
                    weighty = 0.0;
                } else {
                    gridwidth = 1;
                    weighty = 0.0;
                }
                pal.add(lbl,createGridBagConstraints(gridx, gridy, 1, 1, 0.0, 0.0,GridBagConstraints.NORTHEAST,GridBagConstraints.NONE));
                pal.add(comptAddToPanel,createGridBagConstraints(gridx + 1, gridy, gridwidth,1, 1.0, weighty, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH));
                // 如果这一组内不存在着需要占整行显示的,则计算横坐标
                //gridx += 2;
                if (!leastNewLine) {
                    gridx += 2;
                }
                /*********************** 方案:V1 End ***********************/
 
                // 缓存各属性对应的控&组件
                String key = attrObj.getId();
                if (!attrIdToCtrlMaps.containsKey(key)) {
                    attrIdToCtrlMaps.put(key, compt);
                }
                // 存储属性内部名称与控件的关系
                key = attrObj.getId();
                if (!attrInnerNameToCtrlMaps.containsKey(key)) {
                    attrInnerNameToCtrlMaps.put(key, compt);
                }
            }// for 2
        }// for 1
        // 在底部添加一行,占据全部的空余区域,其它控件自动从对齐到顶部
        pal.add(new VCIJLabel(""),createGridBagConstraints(0, gridy + 1, maxAttrInLine * 2, 1,1.0, 10.0, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH));
        this.setTextComptList(textCompts);
        return pal;
    }
    /**
     * 获取真实的、实际的需要加载到UI的属性列表
     * <p>
     * Description:
     * </p>
     *
     * @author xchao
     * @time 2012-11-6
     * @param transmitForRMData
     *            当前上下数据传递对象
     * @return
     */
    private CodeClassifyTemplateAttrVO[] getRealAttributeObjects(RMDataTransmitObject transmitForRMData) {
        // 取模板的属性
        CodeClassifyTemplateAttrVO[] tempAttrs = transmitForRMData.getTempPropObjsList().toArray(new CodeClassifyTemplateAttrVO[0]);
        LinkedList<CodeClassifyTemplateAttrVO> attrsList = new LinkedList<CodeClassifyTemplateAttrVO>();
        // 进行过滤,隐藏的不显示,企业代码不显示,其它的允许录入
        for (CodeClassifyTemplateAttrVO attrObj : tempAttrs) {
            String attrId = attrObj.getOid();
            // 判断属性是否隐藏,隐藏的不需要提供录入项
            if (attrObj.getFormDisplayFlag().equals("false")) {
                continue;
            }
            // 如果是代码列,则也隐藏,通过代码申请框架录入
            else if (attrObj.getId().toUpperCase().equals("id".toUpperCase())) {
                continue;
            }
            attrsList.add(attrObj);
        }
        // 有效的、需要显示录入框的属性列表
        CodeClassifyTemplateAttrVO[] attrs = attrsList.toArray(new CodeClassifyTemplateAttrVO[] {});
        return attrs;
    }
    /**
     * 创建属性在UI中呈现的组件
     * <p>
     * Description:
     * </p>
     *
     * @author xchao
     * @time 2012-11-6
     * @param attrObj
     *            属性在模板中对应的属性对象
     * @return
     */
    private JComponent createComponent(CodeClassifyTemplateAttrVO attrObj)  {
        JComponent compt = null;
        String attrId = attrObj.getId();
        // 查出属性的取值范围
        if(StringUtils.isNotBlank(attrObj.getEnumString())||StringUtils.isNotBlank(attrObj.getEnumId())){
            KeyValue[] keyValues = getAttrRangeObjects(attrObj.getOid());
            // 如果存在取值范围,只能从取值范围里选择
            if (keyValues.length != 0) {
                AttrRangObjectWarper[] objs = new AttrRangObjectWarper[keyValues.length];
                VCIJComboBox cbx = new VCIJComboBox();
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                //存在取值范围,如果可以为空,则添加一个空值
                int comboBoxIndex = 1;
                KeyValue keyValue = new KeyValue();
                keyValue.setValue("");
                keyValue.setKey("");
                AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
                model.addElement(wrapper);
                /*** 如果模板属性不是必填项,加入空值后修改时功能的完善 **/
                LinkedHashMap<String, Integer> specMap = new LinkedHashMap<String, Integer>();
                for (int i = 0; i < objs.length; i++) {
                    objs[i] = new AttrRangObjectWarper(keyValues[i]);
                    model.addElement(objs[i]);
                    specMap.put(objs[i].toString(), comboBoxIndex++);
                }
                cbx.setModel(model);
                if(displayValues.containsKey(attrObj.getId())){
//                    cbx.setSelectedItem(displayValues.get(attrObj.getId()));
//                    cbx.setSelectedIndex(3);
                    for (int i = 0; i < objs.length; i++) {
                        if(objs[i].getKeyValue().getKey().equals(displayValues.get(attrObj.getId()))){
                            cbx.setSelectedIndex(i);
                        }
                    }
                    cbx.setEnabled(false);
                }
                compt = cbx;
            }
        } else if(StringUtils.isNotBlank(attrObj.getReferConfig())){//参照的需要设置成下拉框,并且只读
            VCIJComboBox cbx = new VCIJComboBox();
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            KeyValue keyValue = new KeyValue();
            keyValue.setValue("");
            keyValue.setKey("");
            AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
            model.addElement(wrapper);
            cbx.setModel(model);
            compt = cbx;
        } else { // 不存在取值范围则按类型生成不同的控件
             if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTBoolean.toString())) { // Boolean类型
                VCIJComboBox cbx = new VCIJComboBox();
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                model.addElement("0");
                model.addElement("1");
                cbx.setModel(model);
                if(displayValues.containsKey(attrObj.getId())){
                    cbx.setSelectedIndex(Integer.parseInt(displayValues.get(attrObj.getId())));
                    cbx.setEnabled(false);
                    return cbx;
                }
                compt = cbx;
            } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDate.toString())) { // 日期类型
                 VCIJCalendarPanel aTrue = new VCIJCalendarPanel("yyyy-MM-dd",
                     attrObj.getRequireFlag().equals("true"), true, false);
                 if(displayValues.containsKey(attrObj.getId())){
                     aTrue.setDateString(displayValues.get(attrObj.getId()));
                     aTrue.setEnabled(false);
                     return aTrue;
                 }
                 compt = aTrue;
            } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDateTime.toString())) { // 日期类型
                 VCIJCalendarPanel aTrue = new VCIJCalendarPanel("yyyy-MM-dd HH:mm:ss",
                     attrObj.getRequireFlag().equals("true"), true, false);
                 if(displayValues.containsKey(attrObj.getId())){
                     aTrue.setDateString(displayValues.get(attrObj.getId()));
                     aTrue.setEnabled(false);
                     return aTrue;
                 }
                 compt = aTrue;
             }else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTTime.toString())) { // 日期类型
                 VCIJCalendarPanel aTrue = new VCIJCalendarPanel("HH:mm:ss",
                     attrObj.getRequireFlag().equals("true"), true, false);
                 if(displayValues.containsKey(attrObj.getId())){
                     aTrue.setDateString(displayValues.get(attrObj.getId()));
                     aTrue.setEnabled(false);
                     return aTrue;
                 }
                 compt = aTrue;
             }
             else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDouble.toString())||attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTLong.toString())) { // Real类型
                RealTextField txt = new RealTextField("");
                txt.setRequired(attrObj.getRequireFlag().equals("true"));
                if(displayValues.containsKey(attrObj.getId())){
                    txt.setText(displayValues.get(attrObj.getId()));
                    txt.setEditable(false);
                }
                compt = txt;
            } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTInteger.toString())) { // Integer类型
                IntegerTextField txt = new IntegerTextField("");
                txt.setRequired(attrObj.getRequireFlag().equals("true"));
                if(displayValues.containsKey(attrObj.getId())){
                     txt.setText(displayValues.get(attrObj.getId()));
                     txt.setEditable(false);
                }
                compt = txt;
            }
             else{
                 VCIJTextField txt = new VCIJTextField(this,attrObj.getRequireFlag().equals("true"));
                 if(displayValues.containsKey(attrObj.getId())){
                     txt.setText(displayValues.get(attrObj.getId()));
                     txt.setEditable(false);
                 }
                 compt = txt;
                 textCompts.add(txt);
             }
            boolean enabled = true;
 
            // 集团代码、集团附加码不可以手工录入数据
            if (attrObj.getId().toLowerCase().equals("groupcode")) {
                enabled = false;
            }
 
            compt.setEnabled(enabled);
        }
 
        return compt;
    }
    /****
     * 根据属性id获取属性取值范围的值
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2013-3-23
     * @param attrId
     * @return
     */
    private KeyValue[] getAttrRangeObjects(String attrId){
        KeyValue[] res = new KeyValue[0];
        //String url= ConfigUtils.getConfigValue("410.PDM.attrKeyValue.url","http://127.0.0.1:36014/codeApplySwingController/listComboboxItems");
        /**系统只加载代码项  如果libName不为空,直接获取对应的代码项**/
        Map<String,String> condtionMap=new HashMap<>();
        condtionMap.put("oid", attrId);
        Map<String,String> headerMap=new HashMap<>();
        headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
 
        R r=HttpUtil.sendGet(url+"/listComboboxItems",condtionMap,headerMap);
        List<KeyValue> keyValueList=new ArrayList<>();
        if(r.isSuccess()){
            Object object= r.getData();
            if(object!=null) {
                ObjectMapper objectMapper = new ObjectMapper();
                try {
                    keyValueList = objectMapper.readValue(object.toString(), new TypeReference<List<KeyValue>>() {
                    });
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }else{
            VCIOptionPane.showMessage(this,r.getMsg());
        }
        return keyValueList.toArray(new KeyValue[]{});
    }
    /**
     * 检查需要在一行中显示的那些组件(控件)中,是否至少存在着一个需要换行(占整行)显示的组件
     * <p>
     * Description:
     * </p>
     *
     * @author liujw
     * @time 2013-4-16
     * @param attrIndex
     *            循环属性的索引
     * @param maxAttrInLine
     *            需要换行显示的判断条件,属性的长度
     * @param realAttrs
     *            真实的需要加载的属性列表
     * @return
     */
    private boolean checkLeastNewLine(int attrIndex, int maxAttrInLine,Map<String, String> attrMaps, CodeClassifyTemplateAttrVO[] realAttrs){
        boolean res = false;
        int attrsLength = realAttrs.length;
        for(int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++){
            int index = attrIndex + columnIndex;
            if(index < attrsLength){
                CodeClassifyTemplateAttrVO attrObj = realAttrs[index];
                boolean isStringType = attrObj.getAttributeDataType().toUpperCase().equals("VTstring".toUpperCase());
                // 启用TextArea时才进行判断
                if(this.isEnableTextArea && isStringType && attrMaps.size() > 0 && attrMaps.containsKey(attrObj.getId())){
                    res = true;
                    break;
                }
            }
        }
        return res;
    }
 
    /***获取属性模板对象  @author liujw**/
    private Map<String, String> getTempPropMap(RMDataTransmitObject transmitForRMData) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        List<CodeClassifyTemplateAttrVO> propObjs = transmitForRMData.getTempPropObjsList();
        for(CodeClassifyTemplateAttrVO obj : propObjs) {
            if(obj.getTextAreaFlag().equals("true")) {
                map.put(obj.getOid(), "Y");
            }
        }
        return map;
    }
    /**码段码值描述信息的详细说明**/
    private void clsfValDescActionListener(MouseEvent e) {
        VCIJTextField txt = (VCIJTextField) comtMap.get(e.getComponent());
        DescViewDialog dialog = new DescViewDialog(this, txt.getText());
        dialog.bulidDialog();
        dialog.setVisible(true);
 
    }
    /**
     * 创建与TextArea相关联的ScrollPane对象
     * <p>
     * Description:
     * </p>
     *
     * @author liujw
     * @time 2013-4-16
     * @param txtArea
     *            VCIJTextArea
     * @return
     */
    private VCIJScrollPane createTextAreaScrollPane(VCIJTextArea txtArea) {
        txtArea.setWrapStyleWord(true);
        txtArea.setLineWrap(true);
        VCIJScrollPane txtScroll = new VCIJScrollPane();
        txtScroll.getViewport().add(txtArea);
        txtScroll.setPreferredSize(new Dimension(textAreaPreSizeWidth, textAreaPreSizeHeight));
        txtScroll.setMinimumSize(new Dimension(textAreaMinSizeWidth, textAreaMinSizeHeight));
        txtScroll.setMaximumSize(new Dimension(textAreaMaxSizeWidth, textAreaMaxSizeHeight));
        txtScroll.setBorder(null);
        return txtScroll;
    }
 
    /**
     * 返回GridBagLayout布局管理的Constraints对象
     * <p>
     * Description:
     * </p>
     *
     * @author xchao
     * @time 2012-11-6
     * @param gridx
     * @param gridy
     * @param gridwidth
     * @param gridheight
     * @param weightx
     * @param weighty
     * @param anchor
     * @param fill
     * @return
     */
 
    private GridBagConstraints createGridBagConstraints(int gridx, int gridy,
                                                        int gridwidth, int gridheight, double weightx, double weighty,int anchor, int fill) {
        int padxy = 5;
        return new GridBagConstraints(gridx, gridy, gridwidth, gridheight,weightx, weighty, anchor, fill, new Insets(padxy, padxy, padxy,padxy), padxy, padxy);
    }
 
    /**根据属性组合规则获取属性的值 **/
    private void getComptAttrValue( CodeClassifyTemplateAttrVO  tempPropObj, LinkedHashMap<String, JComponent> attrIdToCtrlMaps) {
        Map<String,String> dataMap=new HashMap<>();
        Map<String,String> condtionMap=new HashMap<>();
        for(String key: attrIdToCtrlMaps.keySet()){
            JComponent compt = attrIdToCtrlMaps.get(key);
            String value = "";
            if (compt instanceof JTextComponent) {
                value = ((JTextComponent) compt).getText();
            } else if (compt instanceof VCIJCalendarPanel) {
                value = ((VCIJCalendarPanel) compt).getDateString();
                value = value == null ? "" : value;
            } else if (compt instanceof VCIJComboBox) {
                Object objItem = ((VCIJComboBox) compt).getSelectedItem();
                if (objItem instanceof AttrRangObjectWarper) { // 属性取值范围
                    value = ((AttrRangObjectWarper) objItem).getKeyValue().getValue();
                } else if (objItem instanceof String) { // Boolean类型的会提供0\1选择
                    value = (String) objItem;
                }
            }
            dataMap.put(key,value);
            condtionMap.put("dataMap["+key+"]",value);
        }
        condtionMap.put("componentRuleValue",tempPropObj.getComponentRule());
        Map<String,String> headerMap=new HashMap<>();
        headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
 
        R r= HttpUtil.sendGet(url+"/getValueByFormula",condtionMap,headerMap);
        String value="";
        if(r.isSuccess()){
            value= r.getData().toString();
            if(attrIdToCtrlMaps.containsKey(tempPropObj.getId())){
                JComponent comp = attrInnerNameToCtrlMaps.get(tempPropObj.getId());
                if(comp instanceof JTextComponent) {
                    ((JTextComponent) comp).setText(value);
                }
            }
            Object object= r.getData();
            if(object!=null) {
                value= object.toString();
 
            }
        }else{
            VCIOptionPane.showMessage(this,r.getMsg());
        }
    }
        /**
         * 根据引用模板的id获取引用模板对象包含的数据
         * <p>Description: </p>
         *
         * @author liujw
         * @time 2012-11-29
         * @param //referTempId 引用模板id
         */
    private void getReferTempRMData(final CodeClassifyTemplateAttrVO tempPropObj,final LinkedHashMap<String, JComponent> attrIdToCtrlMaps,
                                    final List<CodeClassifyTemplateAttrVO>  tempPropList) {
        // 本空窗口调用 有可能来自两处
        // 流程任务引用
        // 一般的数据录入、修改
        // 不同的来源,需要维护好Owner父
        /*VCIJDialog ownerDialog = realDialogInstance;
        if(ownerDialog == null){
            ownerDialog = new VCIJDialog();
            ownerDialog.setSize(880, 500);
        }*/
        //final String referTempId = tempPropObj.getReferBtmId();
        if(StringUtils.isBlank(tempPropObj.getReferConfig())){
            VCIOptionPane.showMessage(this,"参照配置信息不正确,请核对!");
            return;
        }
        final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,tempPropObj.getReferConfig());
        dialog.setDialogCallback(new Runnable() {
            @Override
            public void run() {
                KeyValue keyValue=new KeyValue();
                /*if(dialog.isFromTableDoubleClick()){
                    int index = dialog.getRMDataMainPanel().getTablePanel().getTable().getSelectedRow();
                    list.clear();
                    list.add(dialog.getRMDataMainPanel().getTablePanel().getTableModel().getList().get(index).getObject());
                }*/
                keyValue= dialog.getKeyValue();
                //for(CodeClassifyTemplateAttrVO obj : tempPropList) {
                    if(attrIdToCtrlMaps.containsKey(tempPropObj.getId())) {
                        JComponent comp = attrIdToCtrlMaps.get(tempPropObj.getId());
                        /*if(comp instanceof VCIJTextField) {
                            int index = innnerNamesMaps.get(tempPropObj.getInternalname());
                            ((VCIJTextField) comp).setText(datas[index]);
                        }else if (comp instanceof VCIJCalendarPanel) {
                            int index = innnerNamesMaps.get(tempPropObj.getInternalname());
                            ((VCIJCalendarPanel) comp).setDateString(datas[index]);
                        } else */
                        if (comp instanceof VCIJComboBox) {
                            //DefaultComboBoxModel model = new DefaultComboBoxModel();
                            if(keyValue!=null) {
                                AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
                                ((VCIJComboBox) comp).getModel().setSelectedItem(wrapper);
                            }
                            //model.addElement(wrapper);
                             //((VCIJComboBox) comp).setModel(model);
                        }
                    }
                //}
 
            }
        });
        //dialog.initDialogSize(ownerDialog.getWidth(), ownerDialog.getHeight());
        Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
        int x = dime.width/2 - 400;
        int y = dime.height/2 -300;
        dialog.setLocation(x, y);
        dialog.setSize(new Dimension(900, 600));
        dialog.setModal(true);
        dialog.setVisible(true);
    }
 
    private void doSearch(final VCIJComboxBox comboxBox, CodeBasicSecVO secObj){
        if(StringUtils.isBlank(secObj.getReferConfig())){
            VCIOptionPane.showMessage(this,"参照配置信息不正确,请核对!");
            return;
        }
        final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,secObj.getReferConfig());
        dialog.setDialogCallback(new Runnable() {
            @Override
            public void run() {
                KeyValue keyValue=new KeyValue();
                keyValue= dialog.getKeyValue();
                //for(CodeClassifyTemplateAttrVO obj : tempPropList) {
                if (keyValue != null) {
                    AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
                    comboxBox.getModel().setSelectedItem(wrapper);
                }
            }
        });
        //dialog.initDialogSize(ownerDialog.getWidth(), ownerDialog.getHeight());
        Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
        int x = dime.width/2 - 400;
        int y = dime.height/2 -300;
        dialog.setLocation(x, y);
        dialog.setSize(new Dimension(900, 600));
        dialog.setModal(true);
        dialog.setVisible(true);
 
    }
 
    /**
     * 检查申请码值的数据填写是否完整
     * 1.检查各个码段的值是否已经填写
     * 2.如果有日期码段,并且日期码段的值为可修改,需校验修改后的日期的格式是否符合
     * @return
     */
    public boolean checkIsAllowed(){
        Iterator<Integer> ite = compMaps.keySet().iterator();
        JComponent compt = null;
        /**校验1:检查各个码段的值是否已经填写完成**/
        while(ite.hasNext()) {
            int k = ite.next();
            //如果是层级码,跳出不进行判断
            if(k == levelPositon) {
                continue;
            }
            compt = compMaps.get(k);
            if(compt instanceof VCIJComboBox) {
                Object obj = ((VCIJComboBox) compt).getSelectedItem();
                if(obj == null || "".equals(obj)) {
                    VCIOptionPane.showMessageDialog(this, "请将信息填写完整!");
                    return false;
                }
            }
        }
 
        int len = columnSecMap.size();
        for (int i = 0; i < len; i++) {
            CodeBasicSecVO secObj = columnSecMap.get(i);
            String cType = secObj.getSecType();
            /**校验2:如果有日期码段,并且日期码段的值为可修改,需校验修改后的日期的格式是否符合**/
            if (cType.equals("codedatesec")) {
                String df =secObj.getCodeDateFormatStr();
                SimpleDateFormat dateFormate = new SimpleDateFormat(df);
                //String curDate = dateFormate.format(Calendar.getInstance().getTime());
                dateFormate.setLenient(false);//设置严格校验
                String dateStr = (String) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem();
                try {
                    dateFormate.parse(dateStr);
                } catch (ParseException e) {
                    VCIOptionPane.showMessageDialog(this, "修改后的日期格式跟日期码段设置的格式不匹配,请修改!");
                    return false;
                }
                /**校验三:可变码段的校验**/
            } else if (cType .equals( "codevariablesec")) {
                 tempStr = new StringBuffer();
                String codeSecLength =secObj.getCodeSecLength();
                int secLen= Integer.parseInt(codeSecLength);
                //取出用户输入的值
                String varStr = (String) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem();
                if(varStr.length() >secLen){
                    VCIOptionPane.showMessageDialog(this, "输入的可变码值超出了该码段的定义长度"+codeSecLength+"请修改");
                    return false;
                }
                //如果是固定长度,则需要考虑填充和补位
//                if(varObj.getLenType() == SectionConstant.SectionLengthType.VARLEN) {
                if(varStr.length() < secLen) {//没有达到最大长度
                    if(secObj.getCodeFillType().equals("L")) {//如果需要左填充
                        tempStr = new StringBuffer();
                        for(int j=0;j<secLen - varStr.length();j++) {
                            tempStr.append(secObj.getCodeFillSeparator());
                        }
                        tempStr.append(varStr);
                    } else if(secObj.getCodeFillType().equals("R")) {//如果需要右填充
                        tempStr = new StringBuffer();
                        tempStr.append(varStr);
                        for(int j=0;j<secLen- varStr.length();j++) {
                            tempStr.append(secObj.getCodeFillSeparator());
                        }
                    } else {
                        tempStr = new StringBuffer();
                        tempStr.append(varStr);
                    }
                } else {
                    tempStr = new StringBuffer();
                    tempStr.append(varStr);
                }
//                }
                /**层级码段的校验**/
            } else if (cType.equals("codelevelsec")) {
                Integer levelVal= secObj.getCodeLevelValue();
                levelRes = getRuleLevelCodeFromTree(secObj.getCodeLevelValue());
                if("".equals(levelRes)) {
//                    setBuildingHasError(true);
                    if(secObj.getCodeLevelType().equals("min")) {
                        VCIOptionPane.showError(this, "当前编码项规则中包含层级码段,并且层级设置为最小层,选择的当前节点包含子节点,不允许在当前分类下进行码值申请!");
                    }else {
                        VCIOptionPane.showError(this, "请至少在第 " + levelVal + "层(分类)添加数据!(编码项节点不算)" +
                            "\n(注意:如果算上编码项节点,则至少应该在第 " + (levelVal + 1) + " 层(分类)添加数据!)");
                    }
 
                    return false;
                }
            } else if(cType  .equals("codeclassifysec")) {//分类码段码值添加了空值,需要特殊判断一下
                // update by xchao 2013.07.09
//                ClsfCodeValObject obj = (ClsfCodeValObject) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem();
                // 分类码码值为空时,也可以申请编码
//                if("".equals(obj.getValue())) {
//                    VCIOptionPane.showMessageDialog(this, "请选择码段:"+secObj.getName()+" 对应的码值");
//                    return false;
//                }
            } else if(cType .equals( "codefixedsec")) {//固定码段码值添加了空值,需要特殊判断一下
                CodeFixedValueVO obj = (CodeFixedValueVO) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem();
                if("".equals(obj.getId())) {
                    VCIOptionPane.showMessageDialog(this, "请选择码段:"+secObj.getName()+" 对应的码值");
                    return false;
                }
            } else if(cType.equals("coderefersec")) {//引用码段码值添加了空值,需要特殊判断一下
                KeyValue keyValue = ((AttrRangObjectWarper)((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem()).getKeyValue();
                if(keyValue!=null&&("".equals(keyValue.getKey()))) {
                    VCIOptionPane.showMessageDialog(this, "请选择码段:"+secObj.getName()+" 对应的码值");
                    return false;
                }
            }
        }
 
        return true;
    }
    private LinkedList<VCIBaseTreeNode> parentTreeNodeListDesc = new LinkedList<VCIBaseTreeNode>();
    private LinkedList<VCIBaseTreeNode> parentTreeNodeListAsc = new LinkedList<VCIBaseTreeNode>();
    private String getRuleLevelCodeFromTree(int level){
        String res = null;
        TransmitTreeObject CodeClassifyTreeObj = this.transTreeObject;
        if(CodeClassifyTreeObj != null){
            VCIBaseTreeNode node = CodeClassifyTreeObj.getCurrentTreeNode();
            parentTreeNodeListDesc.clear();
            //每次进行申请时都重新初始化存储树结构的对象
            parentTreeNodeListAsc.clear();
            calcParentTreeNode(node);
            for(int i = parentTreeNodeListDesc.size() - 1; i >=0; i--){
                parentTreeNodeListAsc.add(parentTreeNodeListDesc.get(i));
            }
            /***校验:申请码值时,层级的处理 level = 0 标示任意层,level = 99 标示最小层  ,其它指指定层BEGIN**/
            if(level == 0) {
                res = ((CodeClassify)node.getObj()).getId();
                /***level == 99 并且是叶子节点时,才允许进行编码申请**/
            } else if(level == 99) {
                if(checkIsHasSonCodeClassify(node)) {
                    res = ((CodeClassify)node.getObj()).getId();
                }else {
                    res = "";
                }
            } else if(level == 99 && !checkIsHasSonCodeClassify(node)){
                res = "";
            } else if(parentTreeNodeListAsc.size() > level + 1) {
                VCIBaseTreeNode levelNode = parentTreeNodeListAsc.get(level + 1);
                CodeClassify codeClassify = (CodeClassify) levelNode.getObj();
                res = codeClassify.getId();
            } else {
                res = "";
            }
            /**************************************END**********************************/
        }
        return res;
    }
    /**
     * 检查选择的当前分类是否有子分类
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2013-4-10
     * @return
     */
    public boolean checkIsHasSonCodeClassify(VCIBaseTreeNode node) {
        int count = 0;
        if(node.isExpand()) {
            count = node.getChildCount();
        } else {
            //则需要去查询下面的是否存在
            CodeClassify codeClassify = (CodeClassify) node.getObj();
            codeClassify.getOid();
            Map<String,String> condtionMap=new HashMap<>();
            condtionMap.put("codeClassId", codeClassify.getOid());
            Map<String,String> headerMap=new HashMap<>();
            headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
            R r= HttpUtil.sendGet(url+"/countChildrenByClassifyOid",condtionMap,headerMap);
            if(r.isSuccess()){
                Object object= r.getData();
                count=(int)object;
            }
        }
        if(count <= 0) {
            return true;
        }
        return false;
    }
 
    /**
     * 提供调用者获取各个码段的拼接值
     * <p>Description: </p>
     *
     * @author xf
     * @time 2012-5-28
     * @return
     */
    public List<KeyValue> getSectionValues(){
        List<KeyValue> keyValueList=new ArrayList<>();
        if(getCodeRuleVO()!=null) {
            List<CodeBasicSecVO> codeBasicSecVOList = this.getCodeRuleVO().getSecVOList();
            if (!CollectionUtils.isEmpty(codeBasicSecVOList)) {
                for (int i = 0; i < codeBasicSecVOList.size(); i++) {
                    CodeBasicSecVO secObj=codeBasicSecVOList.get(i);
                    KeyValue keyValue = new KeyValue();
                    String cVal = "";
                    String secObjOid = secObj.getOid();
                    String secType = secObj.getSecType();
                    /***如果系统选择的是特殊规则,即工装图样代码规则,组别代号码段自动设置为空**Begin***/
                    if (isSpecialRuleFlag && secObj.getName().equals(specialSectioName)) {
                        cVal = "";
                        /**********************************End************************/
                    } else if (secType.equals("codedatesec")) {//日期码段的值
                        cVal = (String) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem();
                    } else if (secType.equals("codevariablesec")) {//可变码段的值
//                        cVal = (String) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem();
                        cVal = tempStr.toString();
                    } else if (secType.equals("codeclassifysec")) {//分类码段码值
                        cVal = ((CodeClassifyValue) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem()).getOid();
                    } else if (secType.equals( "codefixedsec")) {//固定码段码值
                        cVal = ((CodeFixedValueVO) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem()).getId();
                    } else if (secType.equals("coderefersec")) {//引用码段码值
//                    cVal = ((CodeValueObject)((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem()).getPlcodeval();
                        KeyValue newKeyValue = ((AttrRangObjectWarper) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem()).getKeyValue();
                        cVal=newKeyValue.getKey();
                    /*} else if (secType == SectionConstant.SectionType.SECCHAR) {//分隔符
                        cVal = secObj.getName();*/
                    } else if (secType.equals("codelevelsec")) {//层级码段
                        cVal = levelRes;
                    } else if (secType.equals("codeserialsec")) {
                            continue;
                    } else {
                        cVal = (String) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem();
                    }
                    keyValue.setKey(secObjOid);
                    keyValue.setValue(cVal);
                    keyValueList.add(keyValue);
                }
            }
        }
        return keyValueList;
    }
    /**
     * 校验模板属性信息是否正确
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2013-3-23
     * @return
     */
    public String[][] checkInputValues() {
        Map<String, String> attrNameMap = new LinkedHashMap<String, String>();
        Map<String, String> tempProMap = new LinkedHashMap<String, String>();
 
        // 各属性的内部名称
        LinkedList<String> listInnerNames = new LinkedList<String>();
        // 存储属性的外部名称
        LinkedList<String> listOutNames = new LinkedList<String>();
        // 各属性对应的数据值
        LinkedList<String> listValues = new LinkedList<String>();
        // 各属性的类型
        LinkedList<String> listDataTypes = new LinkedList<String>();
        Map<String,CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOMap = new HashMap<>();
        for (CodeClassifyTemplateAttrVO codeClassifyTemplateAttrVO : transmitForRMData.getTempPropObjsList()) {
            codeClassifyTemplateAttrVOMap.put(codeClassifyTemplateAttrVO.getId(),codeClassifyTemplateAttrVO);
        }
        Iterator<String> keys = attrIdToCtrlMaps.keySet().iterator();
        JComponent compt = null;
        JComponent firstCompt = null;
        while (keys.hasNext()) {
            String attrOid = keys.next();
            compt = attrIdToCtrlMaps.get(attrOid);
            String value = "";
            CodeClassifyTemplateAttrVO propObj = codeClassifyTemplateAttrVOMap.get(attrOid);
 
            boolean isExistError = false;
            String message = "";
 
            if (compt instanceof JTextComponent) {
                value = ((JTextComponent) compt).getText();
            } else if (compt instanceof VCIJCalendarPanel) {
                value = ((VCIJCalendarPanel) compt).getDateString();
                value = value == null ? "" : value;
            } else if (compt instanceof VCIJComboBox) {
                Object objItem = ((VCIJComboBox) compt).getSelectedItem();
                if (objItem instanceof AttrRangObjectWarper) { // 属性取值范围
                    value = ((AttrRangObjectWarper) objItem).getKeyValue().getKey();
                } else if (objItem instanceof String) { // Boolean类型的会提供0\1选择
                    value = (String) objItem;
                }
            }
 
            boolean checkNullInput = true;
            if (checkNullInput) {
                // 检查属性是否可以为空 isNull=0 表示不能为空,isNull=1表示可以为空
                if ("true".equals(propObj.getRequireFlag())) {// 不能为空时需要判断输入的值是否为空
                    if ((value == null) || (value != null && value.trim().length() == 0)) {
                        isExistError = true;
                        compt.requestFocus();
                        message = propObj.getName() + " 不能为空,请重新输入!";
                    }
                }
                // 校验长度
                else if ((value != null && !value.equals(""))
                    && value.length() > Integer.valueOf(propObj.getControlLength())
                    && !(propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDate)||
                    propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDateTime))
                ) {
                    isExistError = true;
                    compt.requestFocus();
                    message = propObj.getName() + " 的属性值  " + value
                        + " 的长度不能超过" + propObj.getControlLength();
                }
 
                // 检查输入的值是否满足属性校验规则(如果存在)
                if (!isExistError && !propObj.getComponentRule().equals("")) { // 存在着属性校验规则
                    // 日期类型的不检查属性校验规则
//                    if (propObj.getAttributeDataType().toUpperCase().equals(Constants.DATA_TYPE_DATE)|| (compt instanceof VCIJComboBox)) {
//                        // 不做检查
//                    } else {
//                        initAllAttrRuleMaps();
//                        // 做检查
//                        if (!value.equals("") && allAttrRulesMap.containsKey(propObj.getAttrRuleId())) {
//                            // TODO 调用属性校验规则的接口,校验当前输入的值是否满足规则条件
//                            AttrRuleObject attrRuleObj = allAttrRulesMap.get(attrObj.getAttrRuleId());
//                            String regex = attrRuleObj.getRule();
//                            Pattern p = Pattern.compile(regex);
//                            if (!p.matcher(value).matches()) {
//                                // 不匹配
//
//                                isExistError = true;
//                                compt.requestFocus();
//                                message = attrObj.getName() + "的输入值 " + value
//                                    + " 不满足该属性定义的校验规则  \n\n" + ""
//                                    + attrRuleObj.getRuleName() + ":\t"
//                                    + attrRuleObj.getRule() + "\n\n"
//                                    + "请重新输入!";
//                            }
//                        }
//                    }
                }
            }
 
            // 是否存在错误
            if (isExistError) {
                //setErrorMessageFlag(true);
                listInnerNames.clear();
                listOutNames.clear();
                listValues.clear();
                listDataTypes.clear();
                VCIOptionPane.showMessage(this, message);
                break;
            } else {
                //setErrorMessageFlag(false);
                // 如果是日期类型,且属性可空,又没有选择日期值,则给个默认值
                if (value == null && propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDate)) {
                    SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    value = sdfDateAndTime.format(new Date());
                }else if(value == null&&propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDateTime)){
                    SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("HH:mm:ss");
                    value = sdfDateAndTime.format(new Date());
                }
                // 全部验证通过
                value = value.trim();
                listInnerNames.add(propObj.getId());
                listOutNames.add(propObj.getName());
                listValues.add(value);
                if(propObj.getAttributeDataType().equals(VciFieldTypeEnum.VTFilePath)){
                    listDataTypes.add("String");
                }else{
                    listDataTypes.add(propObj.getAttributeDataType());
                }
 
                attrNameMap.put(propObj.getName(), value);
                tempProMap.put(propObj.getId(), propObj.getId());
 
            }
            // update by xchao 2012.07.11
            if (firstCompt == null) {
                firstCompt = compt;
            }
        }// end while(keys.hadNext())
 
 
        LinkedList<String[]> res = new LinkedList<String[]>();
 
        res.add(listInnerNames.toArray(new String[] {}));
        res.add(listValues.toArray(new String[] {}));
        res.add(listDataTypes.toArray(new String[] {}));
        res.add(listOutNames.toArray(new String[]{}));
        return res.toArray(new String[][] {});
    }
 
    private void calcParentTreeNode(VCIBaseTreeNode node){
        parentTreeNodeListDesc.add(node);
        if(node.getParent() != null){
            calcParentTreeNode((VCIBaseTreeNode)node.getParent());
        } else{
            // 根节点
            // 来自专用库(带分类显示的)
            // 由于专用库(带分类显示的)将库节点向上提升了一级,库节点就是根节点
            // 因此为保持统计,方便根据层级取分类码(代号),在此将原因的根添加到集合
            if(node.getObj() instanceof CodeClassify){
                parentTreeNodeListDesc.add(new VCIBaseTreeNode("所有资源数据", "root"));
            }
        }
    }
 
    //获取系统配置的码段码值
    private Map<String, String> getSpecialValMap(String[] vals) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        for (String val : vals) {
            map.put(val, "Y");
        }
        return map;
    }
    private boolean isNumber(String value) {
        return Pattern.matches("[0-9]+", value);
    }
 
    public LinkedHashMap<String, JComponent> getAttrIdToCtrlMaps() {
        return attrIdToCtrlMaps;
    }
 
    public void setAttrIdToCtrlMaps(LinkedHashMap<String, JComponent> attrIdToCtrlMaps) {
        this.attrIdToCtrlMaps = attrIdToCtrlMaps;
    }
 
    public LinkedHashMap<String, JComponent> getAttrInnerNameToCtrlMaps() {
        return attrInnerNameToCtrlMaps;
    }
 
    public void setAttrInnerNameToCtrlMaps(LinkedHashMap<String, JComponent> attrInnerNameToCtrlMaps) {
        this.attrInnerNameToCtrlMaps = attrInnerNameToCtrlMaps;
    }
 
    public TransmitTreeObject getTransTreeObject() {
        return transTreeObject;
    }
 
    public void setTransTreeObject(TransmitTreeObject transTreeObject) {
        this.transTreeObject = transTreeObject;
    }
 
    public CodeRuleVO getCodeRuleVO() {
        return codeRuleVO;
    }
 
    public void setCodeRuleVO(CodeRuleVO codeRuleVO) {
        this.codeRuleVO = codeRuleVO;
    }
 
    public TokenUserObject getTokenUserObject() {
        return tokenUserObject;
    }
 
    public void setTokenUserObject(TokenUserObject tokenUserObject) {
        this.tokenUserObject = tokenUserObject;
    }
}