9281ad1dca34384230e0b6283185b7c73bcb37c6.svn-base
55.7 KB
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
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.reg.service.base;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseC;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseLjz;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBasePerson;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseXm;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZrz;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.reg.dao.base.RegBaseXmDao;
/**
* 项目(小区)信息维护Service
* @author xuyg
* @version 2015-11-11
*/
@Service
@Transactional(readOnly = true)
public class RegBaseXmService extends CrudService<RegBaseXmDao, RegBaseXm> {
@Autowired
private RegBaseZdjbxxService regBaseZdjbxxService;
public RegBaseXm get(String id) {
return super.get(id);
}
public String getXmbmStr(){
return dao.getXmbmStr();
}
public List<RegBaseXm> findList(RegBaseXm regBaseXm) {
return super.findList(regBaseXm);
}
public List<RegBaseXm> findXmmcList(RegBaseXm regBaseXm) {
return dao.findXmmcList(regBaseXm);
}
public Page<RegBaseXm> findPage(Page<RegBaseXm> page, RegBaseXm regBaseXm) {
return super.findPage(page, regBaseXm);
}
public Page<RegBaseXm> findTdPage(Page<RegBaseXm> page, RegBaseXm regBaseXm) {
regBaseXm.setPage(page);
page.setList(dao.findTdPage(regBaseXm));
return page;
}
@Transactional(readOnly = false)
public void save(RegBaseXm regBaseXm) {
super.save(regBaseXm);
}
@Transactional(readOnly = false)
public void save1(RegBaseXm regBaseXm) {
super.save1(regBaseXm);
}
@Transactional(readOnly = false)
public void delete(RegBaseXm regBaseXm) {
super.delete(regBaseXm);
}
@Transactional(readOnly = false)
public void xmdelete(RegBaseXm regBaseXm) {
dao.xmdelete(regBaseXm);
}
/*
* 项目小区导入,获取excel表格对应的信息数据
*/
public List<Object> importRegBaseXm(InputStream in, String name) throws IOException {
List<Object> list = readRegBaseXmXls(in,name);
// for (RegBaseXm regBaseXm : regBaseXms) {
// mapper.updateByConditions(regBaseXm);
// }
return list;
}
private List<Object> readRegBaseXmXls(InputStream is,String name) throws IOException{
// HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
//判断是excel2003还是excel2007
Workbook wb = null;
if(name.endsWith("xlsx")){
wb = new XSSFWorkbook(is);
}else{
wb = new HSSFWorkbook(is);
}
// try{
// wb = new XSSFWorkbook(is);
// }catch(Exception e){
// wb = new HSSFWorkbook(is);
// }
List<Object> list1 = new ArrayList<Object>();//错误信息收集
list1.add("1");
List<Object> list = new ArrayList<Object>();//正确的数据
list.add("2");
// List<RegBaseXm> regBaseXms = new ArrayList<RegBaseXm>();
// List<RegBaseZrz> regBaseZrzs = new ArrayList<RegBaseZrz>();
List<RegBaseC> regBaseCs = new ArrayList<RegBaseC>();
List<RegBaseH> regBaseHs = new ArrayList<RegBaseH>();
RegBasePerson regBasePerson = null;
RegBaseXm regBaseXm = null;
RegBaseZrz regBaseZrz = null;
RegBaseC regBaseC;
RegBaseH regBaseH;
String msg;
SimpleDateFormat s1 = new SimpleDateFormat("yyyy-MM-dd");
String strCell;
Map<String,Double> map = new HashMap<String,Double>();
Double zdmj = 0.0;
// 循环工作表Sheet
//for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
for (int numSheet = 0; numSheet < wb.getNumberOfSheets(); numSheet++) {
Sheet sheet = wb.getSheetAt(numSheet);
// if (hssfSheet == null) {
// continue;
// }
//判断是否是指定的模板
if(numSheet==0){
System.out.println("进入模板判断");
Row row = sheet.getRow(2);
if(row==null){
list1.add("导入的文件不符合模板格式,请导入正规模板数据。");
return list1;
}
Cell cell = row.getCell(1);
System.out.println(cell);
if(cell==null || StringUtils.isBlank(getValue(cell))|| !"不动产登记平台栋信息导入模板".equals(getValue(cell).trim())){
list1.add("导入的文件不符合模板格式,请导入正规模板数据。");
return list1;
}
}
//建设单位(权利人)信息
if(numSheet==1){
// 循环行Row
// for (int rowNum = 2; rowNum <=2; rowNum++) {
int rowNum = 2;
regBasePerson = new RegBasePerson();
Row row = sheet.getRow(rowNum);
if(row==null){
msg = "建设单位信息表没填写内容。";
list1.add(msg);
continue;
}
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++){
Cell cell = row.getCell(cellNum);
// if(hssfCell==null){
// continue;
// }
// String strCell = getValue(hssfCell);
if (cellNum == 0) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
regBasePerson.setRymc(strCell);
} else if (cellNum == 1) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
cellNum++;
list1.add(msg);
continue;
}
strCell = getValue(cell);
String zjzlValue = DictUtils.getDictValue(strCell, "reg_bus_zjlx", "1");
regBasePerson.setZjzl(zjzlValue);
} else if (cellNum == 2) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}else{
String zjzl = regBasePerson.getZjzl();
strCell = getValue(cell);
if(("1".equals(zjzl) || "4".equals(zjzl)) && !isCardNo(strCell)){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入格式错误。";
list1.add(msg);
continue;
}
if("6".equals(zjzl) && !isOrgon(strCell)){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入格式错误。";
list1.add(msg);
continue;
}
if("7".equals(zjzl) && !isIng(strCell)){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入格式错误。";
list1.add(msg);
continue;
}
if("99".equals(zjzl) && !isOther(strCell)){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入格式错误。";
list1.add(msg);
continue;
}
regBasePerson.setZjh(strCell);
}
} else if (cellNum == 3 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
String sshyValue = DictUtils.getDictValue(strCell, "reg_bus_sshy", "0");
regBasePerson.setSshy(sshyValue);
} else if (cellNum == 4 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
String sexValue = DictUtils.getDictValue(strCell, "sex", "3");
regBasePerson.setXb(sexValue);
} else if (cellNum == 5 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBasePerson.setDh(strCell);
} else if (cellNum == 6 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBasePerson.setYb(strCell);
} else if (cellNum == 7) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
regBasePerson.setDz(strCell);
} else if (cellNum == 8 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBasePerson.setGzdw(strCell);
} else if (cellNum == 9) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "建设单位信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String rylxValue = DictUtils.getDictValue(strCell, "reg_bus_qlrlx", "1");
regBasePerson.setRylx(rylxValue);
} else if (cellNum == 10 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBasePerson.setBz(strCell);
}
}
// }
list.add(regBasePerson);
//项目小区
} else if(numSheet==2){
// 循环行Row
// for (int rowNum = 1; rowNum <=hssfSheet.getLastRowNum(); rowNum++) {
int rowNum = 2 ;
regBaseXm = new RegBaseXm();
Row row = sheet.getRow(rowNum);
if(row==null){
msg = "项目信息表没填写内容";
list1.add(msg);
continue;
}
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++){
Cell cell = row.getCell(cellNum);
// if(hssfCell==null){
// continue;
// }
// String strCell = getValue(hssfCell);
if (cellNum == 0) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "项目信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
regBaseXm.setXmmc(StringEscapeUtils.escapeHtml4(strCell));
} else if (cellNum == 1) {
regBaseXm.setJsdwmc(regBasePerson.getRymc());
} else if (cellNum == 2) {
regBaseXm.setZjzl(regBasePerson.getZjzl());
} else if (cellNum == 3) {
regBaseXm.setZjh(regBasePerson.getZjh());
} else if (cellNum == 4) {
regBaseXm.setDwdz(regBasePerson.getDz());
} else if (cellNum == 5) {
//TODO 该cell数据待确定
continue;
} else if (cellNum == 6 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBaseXm.setSm(strCell);
}
}
// regBaseXms.add(regBaseXm);
// }
list.add(regBaseXm);
//楼栋(自然幢)信息
}else if(numSheet==3){
// 循环行Row
// String nextZHSort = "0000";
// String zddm = "";
// for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
int rowNum = 2;
regBaseZrz = new RegBaseZrz();
Row row = sheet.getRow(rowNum);
if(row==null){
msg = "楼栋信息表没填写内容";
list1.add(msg);
continue;
}
Double zdmj1 = null;
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++){
Cell cell = row.getCell(cellNum);
if (cellNum == 0) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell).trim();//.substring(0, 19);
if(!isTbdcdyh(strCell)){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:土地不动产单元号填写错误,请检查。";
list1.add(msg);
continue;
}
// strCell = strCell.substring(0, 19);
String zddm = strCell.substring(0, 19);
RegBaseZdjbxx regBaseZdjbxx = regBaseZdjbxxService.getdy(zddm);
if(regBaseZdjbxx==null){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:没有找到该不动产单元号对应土地信息,请检查输入是否正确。";
list1.add(msg);
continue;
}
zdmj1 = regBaseZdjbxx.getZdmj();
regBaseZrz.setZddm(regBaseZdjbxx.getZddm());
} else if (cellNum == 1) {
regBaseZrz.setXmmc(regBaseXm.getXmmc());
} else if (cellNum == 2) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
regBaseZrz.setGzwmc(strCell);
} else if (cellNum == 3) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
// msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
// list1.add(msg);
continue;
}
// System.out.println(cell);
strCell = getStringValue(cell);
// System.out.println(strCell);
try {
regBaseZrz.setJgrq(s1.parse(strCell));
} catch (ParseException e) {
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:时间格式错误。";
list1.add(msg);
continue;
//e.printStackTrace();
}
} else if (cellNum == 4 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseZrz.setJzwgd(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 5) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
try{
Double zzdmj = Double.valueOf(strCell);
zdmj = zzdmj;
regBaseZrz.setZzdmj(zzdmj);
if(zdmj1!=null && zzdmj>zdmj1){
msg = "幢占地面积大于所在宗地面积,请检查。";
list1.add(msg);
continue;
}
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 6) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);regBaseZrz.setScjzmj(Double.valueOf(strCell));
try{
regBaseZrz.setScjzmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 7) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);//System.out.println(strCell);
try{
regBaseZrz.setZcs(Integer.valueOf(strCell));
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 8) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);//System.out.println(strCell);
try{
regBaseZrz.setDscs(strCell);
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 9 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);//System.out.println(strCell);
try{
regBaseZrz.setDxcs(strCell);
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 10) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String ghytValue = DictUtils.getDictValue(strCell, "reg_bus_fwyt", "10");
regBaseZrz.setGhyt(ghytValue);
} else if (cellNum == 11) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String fwjgValue = DictUtils.getDictValue(strCell, "reg_bus_fwjg", "1");
regBaseZrz.setFwjg(fwjgValue);
} else if (cellNum == 12 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseZrz.setZts(Integer.valueOf(strCell));
}catch(NumberFormatException e){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 13) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "楼栋信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String zdftfsValue = DictUtils.getDictValue(strCell, "reg_bus_zdftfs", "2");
regBaseZrz.setZdftfs(zdftfsValue);
} else if (cellNum == 14 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBaseZrz.setDah(strCell);
//regBaseZrz.setZydmj(Double.valueOf(strCell));
} else if (cellNum == 15 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBaseZrz.setJzwjbyt(strCell);
} else if (cellNum == 16 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
regBaseZrz.setBz(strCell);
} else if (cellNum == 17) {
if(cell==null){
strCell = "";
}
strCell = getValue(cell);
String ztValue = DictUtils.getDictValue(strCell, "reg_bus_bdcdyzt", "1");
regBaseZrz.setZt(ztValue);
break;
}
}
// regBaseZrzs.add(regBaseZrz);
// }
list.add(regBaseZrz);
//层信息
}else if(numSheet==4){
// 循环行Row
CR: for (int rowNum = 2; rowNum <= sheet.getLastRowNum(); rowNum++) {
regBaseC = new RegBaseC();
Row row = sheet.getRow(rowNum);
if(row==null){
continue;
}
for (int cellNum = 2; cellNum < row.getLastCellNum(); cellNum++){
Cell cell = row.getCell(cellNum);
// if(hssfCell==null){
// continue;
// }
// strCell = getValue(hssfCell);
// if (cellNum == 0) {
// regBaseC.setZrzh(strCell);
// } else if (cellNum == 1) {
// regBaseC.setSjc(Integer.valueOf(strCell));
// } else
if (cellNum == 2) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
try{
regBaseC.setSjc(strCell);
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 3 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCjzmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 4 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCtnjzmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 5 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCytmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 6 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCgyjzmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 7 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCftjzmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 8 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setSptymj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 9 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCbqmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 10 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
strCell = getValue(cell);
try{
regBaseC.setCg(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 11) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "层信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String fcValue = DictUtils.getDictValue(strCell, "yes_no", "0");
regBaseC.setIsnegativelayer(fcValue);
regBaseCs.add(regBaseC);
} else if (cellNum == 12 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
if("END".equals(getValue(cell).trim().toUpperCase())){
break CR;
}else{
break;
}
}
}
}
list.add(regBaseCs);
//户信息
}else if(numSheet==5){
// 循环行Row
HR: for (int rowNum = 2; rowNum <= sheet.getLastRowNum(); rowNum++) {
regBaseH = new RegBaseH();
Row row = sheet.getRow(rowNum);
if(row==null){
continue;
}
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++){
Cell cell = row.getCell(cellNum);
if (cellNum == 0) {
regBaseH.setXmmc(regBaseXm.getXmmc());
} else if (cellNum == 1) {
regBaseH.setJgzwmc(regBaseZrz.getGzwmc());
} else if (cellNum == 2) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
cellNum = cellNum+3;
continue;
}
strCell = getValue(cell);
int beginc;
try{
beginc = Integer.valueOf(strCell);
}catch(NumberFormatException e){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
regBaseH.setBeginc(String.valueOf(beginc));
int zbeginc = Math.abs(beginc);
String ch = RegUtils.getZHhStrNum(String.valueOf(zbeginc));
if(beginc<0){
ch = "-"+ch;
}
regBaseH.setCh(Integer.parseInt(ch)+"");
} else if (cellNum == 3) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
cellNum = cellNum+2;
continue;
}
strCell = getValue(cell);
try{
regBaseH.setEndc(Integer.valueOf(strCell).toString());
}catch(NumberFormatException e){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 4) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
cellNum = cellNum+1;
continue;
}
strCell = getValue(cell);
try{
int n = Integer.parseInt(strCell);
if(n>0){
regBaseH.setHh(strCell);
}else{
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:户号输入错误。";
}
}catch(NumberFormatException e){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
// String xyposition = regBaseH.getBeginc() + RegUtils.getNextHSort(strCell);
String xyposition = getCHSort(Integer.valueOf(regBaseH.getBeginc()),0) + getCHSort(Integer.valueOf(regBaseH.getHh()),0);
regBaseH.setXyposition(xyposition);
} else if (cellNum == 5) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
// String shbw = RegUtils.getNextHSort(regBaseH.getBeginc())+RegUtils.getNextHSort(regBaseH.getHh().toString());
String shbw = getCHSort(Integer.valueOf(regBaseH.getBeginc()),1) + getCHSort(Integer.valueOf(regBaseH.getHh()),0)+"室";
regBaseH.setShbw(shbw);
}else{
strCell = getValue(cell);
regBaseH.setShbw(strCell);
}
} else if (cellNum == 6) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String hxValue = DictUtils.getDictValue(strCell, "reg_bus_hx", "1");
regBaseH.setHx(hxValue);
} else if (cellNum == 7) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String hxjgValue = DictUtils.getDictValue(strCell, "reg_bus_hxjg", "1");
regBaseH.setHxjg(hxjgValue);
} else if (cellNum == 8) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String fwyt1Value = DictUtils.getDictValue(strCell, "reg_bus_fwyt", "10");
regBaseH.setFwyt1(fwyt1Value);
} else if (cellNum == 9) {
System.out.println(rowNum+1);
System.out.println(cellNum+1);
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
try{
regBaseH.setScjzmj(Double.valueOf(strCell));
}catch(NumberFormatException e){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 10) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
try{
regBaseH.setSctnjzmj(Double.valueOf(strCell));
if(regBaseH.getScjzmj()<regBaseH.getSctnjzmj()){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:建筑面积小于套内面积,请检查。";
list1.add(msg);
continue;
}
}catch(NumberFormatException e){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:输入的内容("+strCell+")有非法字符存在。";
list1.add(msg);
continue;
}
} else if (cellNum == 11) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String qlxzValue = DictUtils.getDictValue(strCell, "reg_bus_qlxz", "102");
regBaseH.setQlxz(qlxzValue);
} else if (cellNum == 12) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String fwxzValue = DictUtils.getDictValue(strCell, "reg_bus_fwxz", "0");
regBaseH.setFwxz(fwxzValue);
} else if (cellNum == 13) {
if(cell==null || StringUtils.isBlank(getValue(cell))){
msg = "户信息表:第"+(rowNum+1)+"行,第"+(cellNum+1)+"列:必填数据为空。";
list1.add(msg);
continue;
}
strCell = getValue(cell);
String fwlxValue = DictUtils.getDictValue(strCell, "reg_bus_fwlx", "1");
regBaseH.setFwlx(fwlxValue);
}else if (cellNum == 14) {//新增坐落,以模板为准,模板没有则系统保存时自动生成
if(cell==null || StringUtils.isBlank(getValue(cell))){
regBaseH.setZl(null);
}else {
strCell = getValue(cell);
regBaseH.setZl(strCell);
}
regBaseHs.add(regBaseH);
} else if (cellNum == 15 && cell!=null && StringUtils.isNotBlank(getValue(cell))) {
if("END".equals(getValue(cell).trim().toUpperCase())){
break HR;
}else{
break;
}
}
// else if (cellNum == 15) {
// String mjdwValue = DictUtils.getDictValue(strCell, "reg_bus_mjdw", "1");
// regBaseH.setMjdw(mjdwValue);
// } else if (cellNum == 16) {
// regBaseH.setSjcs(Integer.valueOf(strCell));
// } else if (cellNum == 17) {
// String ztValue = DictUtils.getDictValue(strCell, "reg_bus_bdcdyzt", "1");
// regBaseH.setZt(ztValue);
// } else if (cellNum == 18) {
// regBaseH.setYcjzmj(Double.valueOf(strCell));
// } else if (cellNum == 19) {
// regBaseH.setYctnjzmj(Double.valueOf(strCell));
// } else if (cellNum == 20) {
// regBaseH.setYcftjzmj(Double.valueOf(strCell));
// } else if (cellNum == 21) {
// regBaseH.setYcdxbfjzmj(Double.valueOf(strCell));
// } else if (cellNum == 22) {
// regBaseH.setYcqtjzmj(Double.valueOf(strCell));
// } else if (cellNum == 23) {
// regBaseH.setYcftxs(Double.valueOf(strCell));
// } else if (cellNum == 24) {
// regBaseH.setScdxbfjzmj(Double.valueOf(strCell));
// } else if (cellNum == 25) {
// regBaseH.setScqtjzmj(Double.valueOf(strCell));
// } else if (cellNum == 26) {
// regBaseH.setScftxs(Double.valueOf(strCell));
// } else if (cellNum == 27) {
// regBaseH.setGytdmj(Double.valueOf(strCell));
// } else if (cellNum == 28) {
// regBaseH.setFttdmj(Double.valueOf(strCell));
// } else if (cellNum == 29) {
// regBaseH.setDytdmj(Double.valueOf(strCell));
// break;
// }
}
String hbeginc = regBaseH.getBeginc();
Double hscjzmj = regBaseH.getScjzmj();
if(hbeginc != null && hscjzmj != null){
if(map.containsKey(hbeginc)){
map.put(hbeginc,map.get(hbeginc) + hscjzmj );
} else {
map.put(hbeginc, hscjzmj);
}
}
}
list.add(regBaseHs);
break;
}
}
for(String key : map.keySet()){
if(map.get(key)>zdmj){
list.add(key+"层的户总面积("+map.get(key)+")大于楼栋基座面积("+zdmj+"),请确认是否继续导入?");
}
}
//System.out.println(list.size()+"|"+list1.size());
//System.out.println(list1);
if(list1.size()>1){
return list1;
}else{
return list;
}
}
//身份证
private boolean isCardNo(String cardNo){
String regex = "(^\\d{15}$)|(^\\d{17}(\\d|X|x)$)";
return cardNo.matches(regex);
}
//组织机构
private boolean isOrgon(String num){
String regex = "^[a-zA-Z\\d]{8}\\-[a-zA-Z\\d]$";
return num.matches(regex);
}
//营业执照
private boolean isIng(String num){
String regex = "^\\d{15}$|^[0-9a-zA-Z]{18}$";
return num.matches(regex);
}
//其他证件只能以数字开头
private boolean isOther(String num){
String regex = "^[0-9].*$";
return num.matches(regex);
}
//土地不动产单元号验证 例:610702003014GB00007W00000000
private boolean isTbdcdyh(String num){
String regex = "^\\d{12}[A-Z]{2}\\d{5}W00000000";
return num.matches(regex);
}
/**
* 生成xy对应层户str段
* @param n
* @return
*/
private String getCHSort(int n,int m){
// String STR_FORMAT = "000";
// DecimalFormat df = new DecimalFormat(STR_FORMAT);
// String nextZHSort = df.format(n);
String CHSort = "000";
if(StringUtils.isNotBlank(String.valueOf(n))){
int zn = Math.abs(n);
if (zn < 10) {
CHSort = "00" + zn;
}else if (zn < 100) {
CHSort = "0" + zn;
}else{
CHSort = zn +"";
}
}
if(n<0){
if(m==1){
return "负"+CHSort;
}
return "-"+CHSort;
}else{
return CHSort;
}
}
@SuppressWarnings("static-access")
private String getValue(Cell cell){
if(cell.getCellType() == cell.CELL_TYPE_BOOLEAN){
return String.valueOf( cell.getBooleanCellValue());
}else if(cell.getCellType() == cell.CELL_TYPE_NUMERIC){
double doubleVal = cell.getNumericCellValue();
long longVal = Math.round(doubleVal);
if(Double.parseDouble(longVal + ".0") == doubleVal){
return String.valueOf(longVal);
} else {
return String.valueOf(doubleVal);
}
}else if (cell.getCellType() ==cell.CELL_TYPE_STRING){
return String.valueOf(cell.getStringCellValue());
}else{
return String.valueOf( cell.getStringCellValue());
}
}
/**
* 获取单元格数据内容为字符串类型的数据
*
* @param cell Excel单元格
* @return String 单元格数据内容
*/
private static String getStringValue(Cell cell) {
String strCell = "";
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
strCell = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
// 如果是date类型则 ,获取该cell的date值
strCell = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue()));
} else { // 纯数字
strCell = String.valueOf(cell.getNumericCellValue());
}
break;
case Cell.CELL_TYPE_BOOLEAN:
strCell = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_BLANK:
strCell = "";
break;
default:
strCell = "";
break;
}
if (strCell.equals("") || strCell == null) {
return "";
}
return strCell;
}
public List<RegBaseXm> findByXmbh(String xmbh) {
// TODO Auto-generated method stub
return dao.findByXmbh(xmbh);
}
/*
public List<List<?>> importRegBaseXm(InputStream in) throws IOException {
List<List<?>> list = readRegBaseXmXls(in);
// for (RegBaseXm regBaseXm : regBaseXms) {
// mapper.updateByConditions(regBaseXm);
// }
return list;
}
private List<List<?>> readRegBaseXmXls(InputStream is) throws IOException{
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
List<List<?>> list = new ArrayList<List<?>>();
List<RegBaseXm> regBaseXms = new ArrayList<RegBaseXm>();
List<RegBaseZrz> regBaseZrzs = new ArrayList<RegBaseZrz>();
List<RegBaseC> regBaseCs = new ArrayList<RegBaseC>();
List<RegBaseH> regBaseHs = new ArrayList<RegBaseH>();
RegBaseXm regBaseXm;
RegBaseZrz regBaseZrz;
RegBaseC regBaseC;
RegBaseH regBaseH;
// 循环工作表Sheet
//for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
for (int numSheet = 0; numSheet < 4; numSheet++) {
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
// if (hssfSheet == null) {
// continue;
// }
if(numSheet==0){
// 循环行Row
for (int rowNum = 1; rowNum <=hssfSheet.getLastRowNum(); rowNum++) {
regBaseXm = new RegBaseXm();
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
if(hssfRow==null){
continue;
}
for (int cellNum = 0; cellNum < hssfRow.getLastCellNum(); cellNum++){
HSSFCell hssfCell = hssfRow.getCell(cellNum);
if(hssfCell==null){
continue;
}
String strCell = getValue(hssfCell);
if (cellNum == 0) {
regBaseXm.setXmmc(strCell);
} else if (cellNum == 1) {
regBaseXm.setJsdwmc(strCell);
} else if (cellNum == 2) {
String zjzlValue = DictUtils.getDictValue(strCell, "reg_bus_zjlx", "1");
regBaseXm.setZjzl(zjzlValue);
} else if (cellNum == 3) {
regBaseXm.setZjh(strCell);
} else if (cellNum == 4) {
regBaseXm.setDwdz(strCell);
} else if (cellNum == 5) {
regBaseXm.setSm(strCell);
break;
}
}
regBaseXms.add(regBaseXm);
}
list.add(regBaseXms);
}else if(numSheet==1){
// 循环行Row
String nextZHSort = "0000";
String zddm = "";
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
regBaseZrz = new RegBaseZrz();
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
if(hssfRow==null){
continue;
}
for (int cellNum = 0; cellNum < hssfRow.getLastCellNum(); cellNum++){
HSSFCell hssfCell = hssfRow.getCell(cellNum);
if(hssfCell==null){
continue;
}
String strCell = getValue(hssfCell);
if (cellNum == 0) {
regBaseZrz.setXmmc(strCell);
} else if (cellNum == 1) {
zddm = strCell;
regBaseZrz.setZddm(strCell);
nextZHSort = RegUtils.getNextZHSort(nextZHSort);
String bdcdyh = zddm+"F"+ nextZHSort +"0000";
regBaseZrz.setBdcdyh(bdcdyh);
} else if (cellNum == 2) {
regBaseZrz.setGzwmc(strCell);
} else if (cellNum == 3) {
regBaseZrz.setZzdmj(Double.valueOf(strCell));
} else if (cellNum == 4) {
regBaseZrz.setScjzmj(Double.valueOf(strCell));
} else if (cellNum == 5) {
regBaseZrz.setZcs(Integer.valueOf(strCell));
} else if (cellNum == 6) {
regBaseZrz.setDscs(Integer.valueOf(strCell));
} else if (cellNum == 7) {
String ghytValue = DictUtils.getDictValue(strCell, "reg_bus_fwyt", "10");
regBaseZrz.setGhyt(ghytValue);
} else if (cellNum == 8) {
String fwjgValue = DictUtils.getDictValue(strCell, "reg_bus_fwjg", "1");
regBaseZrz.setFwjg(fwjgValue);
} else if (cellNum == 9) {
String zdftfsValue = DictUtils.getDictValue(strCell, "reg_bus_zdftfs", "2");
regBaseZrz.setZdftfs(zdftfsValue);
} else if (cellNum == 10) {
regBaseZrz.setZrzh(strCell);
} else if (cellNum == 11) {
regBaseZrz.setDxcs(Integer.valueOf(strCell));
} else if (cellNum == 12) {
SimpleDateFormat s1 = new SimpleDateFormat("yyyy.MM.dd");
try {
regBaseZrz.setJgrq(s1.parse(strCell));
} catch (ParseException e) {
System.out.println("幢信息表:第"+rowNum+"行,第"+cellNum+"列时间格式错误");
e.printStackTrace();
}
} else if (cellNum == 13) {
regBaseZrz.setJzwgd(Double.valueOf(strCell));
} else if (cellNum == 14) {
regBaseZrz.setZydmj(Double.valueOf(strCell));
} else if (cellNum == 15) {
regBaseZrz.setZts(Integer.valueOf(strCell));
} else if (cellNum == 16) {
regBaseZrz.setJzwjbyt(strCell);
} else if (cellNum == 17) {
regBaseZrz.setDah(strCell);
} else if (cellNum == 18) {
regBaseZrz.setBz(strCell);
} else if (cellNum == 19) {
String ztValue = DictUtils.getDictValue(strCell, "reg_bus_bdcdyzt", "1");
regBaseZrz.setZt(ztValue);
break;
}
}
regBaseZrzs.add(regBaseZrz);
}
list.add(regBaseZrzs);
}else if(numSheet==2){
// 循环行Row
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
regBaseC = new RegBaseC();
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
if(hssfRow==null){
continue;
}
for (int cellNum = 0; cellNum < hssfRow.getLastCellNum(); cellNum++){
HSSFCell hssfCell = hssfRow.getCell(cellNum);
if(hssfCell==null){
continue;
}
String strCell = getValue(hssfCell);
if (cellNum == 0) {
regBaseC.setZrzh(strCell);
} else if (cellNum == 1) {
regBaseC.setSjc(Integer.valueOf(strCell));
} else if (cellNum == 2) {
String fcValue = DictUtils.getDictValue(strCell, "yes_no", "0");
regBaseC.setIsnegativelayer(fcValue);
} else if (cellNum == 3) {
regBaseC.setCg(Double.valueOf(strCell));
} else if (cellNum == 4) {
regBaseC.setCjzmj(Double.valueOf(strCell));
} else if (cellNum == 5) {
regBaseC.setCtnjzmj(Double.valueOf(strCell));
} else if (cellNum == 6) {
regBaseC.setCytmj(Double.valueOf(strCell));
} else if (cellNum == 7) {
regBaseC.setSptymj(Double.valueOf(strCell));
} else if (cellNum == 8) {
regBaseC.setCgyjzmj(Double.valueOf(strCell));
} else if (cellNum == 9) {
regBaseC.setCftjzmj(Double.valueOf(strCell));
} else if (cellNum == 10) {
regBaseC.setCbqmj(Double.valueOf(strCell));
break;
}
}
regBaseCs.add(regBaseC);
}
list.add(regBaseCs);
}else{
// 循环行Row
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
regBaseH = new RegBaseH();
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
if(hssfRow==null){
continue;
}
for (int cellNum = 0; cellNum < hssfRow.getLastCellNum(); cellNum++){
HSSFCell hssfCell = hssfRow.getCell(cellNum);
if(hssfCell==null && cellNum!=13){
continue;
}
String strCell = "";
if(hssfCell!=null){
strCell = getValue(hssfCell);
}
if (cellNum == 0) {
regBaseH.setXmmc(strCell);
} else if (cellNum == 1) {
regBaseH.setJgzwmc(strCell);
} else if (cellNum == 2) {
regBaseH.setZrzh(strCell);
} else if (cellNum == 3) {
regBaseH.setBeginc(strCell);
int beginc = Integer.valueOf(strCell);
int zbeginc = Math.abs(beginc);
String ch = RegUtils.getZHhStrNum(String.valueOf(zbeginc));
if(beginc<0){
ch = "-"+ch;
}
regBaseH.setCh(ch);
} else if (cellNum == 4) {
regBaseH.setEndc(strCell);
} else if (cellNum == 5) {
int hh = Integer.valueOf(strCell);
regBaseH.setHh(hh);
String beginc = regBaseH.getBeginc();
String xyposition = beginc + RegUtils.getNextHSort(strCell);
regBaseH.setXyposition(xyposition);
} else if (cellNum == 6) {
String hxValue = DictUtils.getDictValue(strCell, "reg_bus_hx", "1");
regBaseH.setHx(hxValue);
} else if (cellNum == 7) {
String hxjgValue = DictUtils.getDictValue(strCell, "reg_bus_hxjg", "1");
regBaseH.setHxjg(hxjgValue);
} else if (cellNum == 8) {
String fwyt1Value = DictUtils.getDictValue(strCell, "reg_bus_fwyt", "10");
regBaseH.setFwyt1(fwyt1Value);
} else if (cellNum == 9) {
String qlxzValue = DictUtils.getDictValue(strCell, "reg_bus_qlxz", "102");
regBaseH.setQlxz(qlxzValue);
} else if (cellNum == 10) {
String fwxzValue = DictUtils.getDictValue(strCell, "reg_bus_fwxz", "0");
regBaseH.setFwxz(fwxzValue);
} else if (cellNum == 11) {
regBaseH.setScjzmj(Double.valueOf(strCell));
} else if (cellNum == 12) {
regBaseH.setScjzmj(Double.valueOf(strCell));
} else if (cellNum == 13) {
System.out.println(strCell);
if(!StringUtils.isBlank(strCell)){
regBaseH.setShbw(strCell);
}else{
regBaseH.setShbw("待定001");
}
} else if (cellNum == 14) {
String fwlxValue = DictUtils.getDictValue(strCell, "reg_bus_fwlx", "1");
regBaseH.setFwlx(fwlxValue);
} else if (cellNum == 15) {
String mjdwValue = DictUtils.getDictValue(strCell, "reg_bus_mjdw", "1");
regBaseH.setMjdw(mjdwValue);
} else if (cellNum == 16) {
regBaseH.setSjcs(Integer.valueOf(strCell));
} else if (cellNum == 17) {
String ztValue = DictUtils.getDictValue(strCell, "reg_bus_bdcdyzt", "1");
regBaseH.setZt(ztValue);
} else if (cellNum == 18) {
regBaseH.setYcjzmj(Double.valueOf(strCell));
} else if (cellNum == 19) {
regBaseH.setYctnjzmj(Double.valueOf(strCell));
} else if (cellNum == 20) {
regBaseH.setYcftjzmj(Double.valueOf(strCell));
} else if (cellNum == 21) {
regBaseH.setYcdxbfjzmj(Double.valueOf(strCell));
} else if (cellNum == 22) {
regBaseH.setYcqtjzmj(Double.valueOf(strCell));
} else if (cellNum == 23) {
regBaseH.setYcftxs(Double.valueOf(strCell));
} else if (cellNum == 24) {
regBaseH.setScdxbfjzmj(Double.valueOf(strCell));
} else if (cellNum == 25) {
regBaseH.setScqtjzmj(Double.valueOf(strCell));
} else if (cellNum == 26) {
regBaseH.setScftxs(Double.valueOf(strCell));
} else if (cellNum == 27) {
regBaseH.setGytdmj(Double.valueOf(strCell));
} else if (cellNum == 28) {
regBaseH.setFttdmj(Double.valueOf(strCell));
} else if (cellNum == 29) {
regBaseH.setDytdmj(Double.valueOf(strCell));
break;
}
}
regBaseHs.add(regBaseH);
}
list.add(regBaseHs);
}
}
return list;
}
@SuppressWarnings("static-access")
private String getValue(HSSFCell hssfCell){
if(hssfCell.getCellType() == hssfCell.CELL_TYPE_BOOLEAN){
return String.valueOf( hssfCell.getBooleanCellValue());
}else if(hssfCell.getCellType() == hssfCell.CELL_TYPE_NUMERIC){
return String.valueOf( hssfCell.getNumericCellValue());
}else if (hssfCell.getCellType() ==hssfCell.CELL_TYPE_STRING){
return String.valueOf(hssfCell.getStringCellValue());
}else{
return String.valueOf( hssfCell.getStringCellValue());
}
}
*/
}