Person.java
9.8 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
package com.sunyo.office.model;
import com.tianbo.util.Date.DateUtil;
import com.tianbo.util.XML.XMLXPath;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.springframework.stereotype.Component;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
@Slf4j
@Component
public class Person {
private String XingMing;
private String XingBie;
private String ChuShengNianYue;
private String MinZu;
private String JiGuan;
private String ChuShengDi;
private String RuDangShiJian;
private String CanJiaGongZuoShiJian;
private String JianKangZhuangKuang;
private String ZhuanYeJiShuZhiWu;
private String ShuXiZhuanYeYouHeZhuanChang;
private String QuanRiZhiJiaoYu_XueLi;
private String QuanRiZhiJiaoYu_XueWei;
private String QuanRiZhiJiaoYu_XueLi_BiYeYuanXiaoXi;
private String QuanRiZhiJiaoYu_XueWei_BiYeYuanXiaoXi;
private String ZaiZhiJiaoYu_XueLi;
private String ZaiZhiJiaoYu_XueWei;
private String ZaiZhiJiaoYu_XueLi_BiYeYuanXiaoXi;
private String ZaiZhiJiaoYu_XueWei_BiYeYuanXiaoXi;
private String XianRenZhiWu;
private String NiRenZhiWu;
private String NiMianZhiWu;
private String JianLi;
private String JiangChengQingKuang;
private String NianDuKaoHeJieGuo;
private String RenMianLiYou;
private List<Family> JiaTingChengYuan;
private String ChengBaoDanWei;
private String JiSuanNianLingShiJian;
private String TianBiaoShiJian;
private String TianBiaoRen;
private String ShenFenZheng;
private String ZhaoPian;
private String Version;
private String Age;
private File XmlFile;
public final static String XingMing_Node = "//Person/XingMing";
public final static String XingBie_Node = "//Person/XingBie";
public final static String ChuShengNianYue_Node = "//Person/ChuShengNianYue";
public final static String MinZu_Node = "//Person/MinZu";
public final static String JiGuan_Node = "//Person/JiGuan";
public final static String ChuShengDi_Node = "//Person/ChuShengDi";
public final static String RuDangShiJian_Node = "//Person/RuDangShiJian";
public final static String CanJiaGongZuoShiJian_Node = "//Person/CanJiaGongZuoShiJian";
public final static String JianKangZhuangKuang_Node = "//Person/JianKangZhuangKuang";
public final static String ZhuanYeJiShuZhiWu_Node = "//Person/ZhuanYeJiShuZhiWu";
public final static String ShuXiZhuanYeYouHeZhuanChang_Node = "//Person/ShuXiZhuanYeYouHeZhuanChang";
public final static String QuanRiZhiJiaoYu_XueLi_Node = "//Person/QuanRiZhiJiaoYu_XueLi";
public final static String QuanRiZhiJiaoYu_XueWei_Node = "//Person/QuanRiZhiJiaoYu_XueWei";
public final static String QuanRiZhiJiaoYu_XueLi_BiYeYuanXiaoXi_Node = "//Person/QuanRiZhiJiaoYu_XueLi_BiYeYuanXiaoXi";
public final static String QuanRiZhiJiaoYu_XueWei_BiYeYuanXiaoXi_Node = "//Person/QuanRiZhiJiaoYu_XueWei_BiYeYuanXiaoXi";
public final static String ZaiZhiJiaoYu_XueLi_Node = "//Person/ZaiZhiJiaoYu_XueLi";
public final static String ZaiZhiJiaoYu_XueWei_Node = "//Person/ZaiZhiJiaoYu_XueWei";
public final static String ZaiZhiJiaoYu_XueLi_BiYeYuanXiaoXi_Node = "//Person/ZaiZhiJiaoYu_XueLi_BiYeYuanXiaoXi";
public final static String ZaiZhiJiaoYu_XueWei_BiYeYuanXiaoXi_Node = "//Person/ZaiZhiJiaoYu_XueWei_BiYeYuanXiaoXi";
public final static String XianRenZhiWu_Node = "//Person/XianRenZhiWu";
public final static String NiRenZhiWu_Node = "//Person/NiRenZhiWu";
public final static String NiMianZhiWu_Node = "//Person/NiMianZhiWu";
public final static String JianLi_Node = "//Person/JianLi";
public final static String JiangChengQingKuang_Node = "//Person/JiangChengQingKuang";
public final static String NianDuKaoHeJieGuo_Node = "//Person/NianDuKaoHeJieGuo";
public final static String RenMianLiYou_Node = "//Person/RenMianLiYou";
public final static String ChengBaoDanWei_Node = "//Person/ChengBaoDanWei";
public final static String JiSuanNianLingShiJian_Node = "//Person/JiSuanNianLingShiJian";
public final static String TianBiaoShiJian_Node = "//Person/TianBiaoShiJian";
public final static String TianBiaoRen_Node = "//Person/TianBiaoRen";
public final static String ShenFenZheng_Node = "//Person/ShenFenZheng";
public final static String ZhaoPian_Node = "//Person/ZhaoPian";
public final static String Version_Node = "//Person/Version";
public final static String JiaTingChengYuan_ChengWei_Node = "//Person/JiaTingChengYuan/Item";
public Person(File xmlFile) {
this.XmlFile = xmlFile;
try{
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(XmlFile);
Element contentRoot = document.getRootElement();
this.XingMing = XMLXPath.getSingleValueByPath(document,XingMing_Node);
this.XingBie = XMLXPath.getSingleValueByPath(document,XingBie_Node);
this.ChuShengNianYue = XMLXPath.getSingleValueByPath(document,ChuShengNianYue_Node);
this.MinZu = XMLXPath.getSingleValueByPath(document,MinZu_Node);
this.JiGuan = XMLXPath.getSingleValueByPath(document,JiGuan_Node);
this.ChuShengDi = XMLXPath.getSingleValueByPath(document,ChuShengDi_Node);
this.RuDangShiJian = XMLXPath.getSingleValueByPath(document,RuDangShiJian_Node);
this.CanJiaGongZuoShiJian = XMLXPath.getSingleValueByPath(document,CanJiaGongZuoShiJian_Node);
this.JianKangZhuangKuang = XMLXPath.getSingleValueByPath(document,JianKangZhuangKuang_Node);
this.ZhuanYeJiShuZhiWu = XMLXPath.getSingleValueByPath(document,ZhuanYeJiShuZhiWu_Node);
this.ShuXiZhuanYeYouHeZhuanChang = XMLXPath.getSingleValueByPath(document,ShuXiZhuanYeYouHeZhuanChang_Node);
this.QuanRiZhiJiaoYu_XueLi = XMLXPath.getSingleValueByPath(document,QuanRiZhiJiaoYu_XueLi_Node);
this.QuanRiZhiJiaoYu_XueWei = XMLXPath.getSingleValueByPath(document,QuanRiZhiJiaoYu_XueWei_Node);
this.QuanRiZhiJiaoYu_XueLi_BiYeYuanXiaoXi = XMLXPath.getSingleValueByPath(document,QuanRiZhiJiaoYu_XueLi_BiYeYuanXiaoXi_Node);
this.QuanRiZhiJiaoYu_XueWei_BiYeYuanXiaoXi = XMLXPath.getSingleValueByPath(document,QuanRiZhiJiaoYu_XueWei_BiYeYuanXiaoXi_Node);
this.ZaiZhiJiaoYu_XueLi = XMLXPath.getSingleValueByPath(document,ZaiZhiJiaoYu_XueLi_Node);
this.ZaiZhiJiaoYu_XueWei = XMLXPath.getSingleValueByPath(document,ZaiZhiJiaoYu_XueWei_Node);
this.ZaiZhiJiaoYu_XueLi_BiYeYuanXiaoXi = XMLXPath.getSingleValueByPath(document,ZaiZhiJiaoYu_XueLi_BiYeYuanXiaoXi_Node);
this.ZaiZhiJiaoYu_XueWei_BiYeYuanXiaoXi = XMLXPath.getSingleValueByPath(document,ZaiZhiJiaoYu_XueWei_BiYeYuanXiaoXi_Node);
this.XianRenZhiWu = XMLXPath.getSingleValueByPath(document,XianRenZhiWu_Node);
this.NiRenZhiWu = XMLXPath.getSingleValueByPath(document,NiRenZhiWu_Node);
this.NiMianZhiWu = XMLXPath.getSingleValueByPath(document,NiMianZhiWu_Node);
this.JianLi = XMLXPath.getSingleValueByPath(document,JianLi_Node);
this.JiangChengQingKuang = XMLXPath.getSingleValueByPath(document,JiangChengQingKuang_Node);
this.NianDuKaoHeJieGuo = XMLXPath.getSingleValueByPath(document,NianDuKaoHeJieGuo_Node);
this.RenMianLiYou = XMLXPath.getSingleValueByPath(document,RenMianLiYou_Node);
this.ChengBaoDanWei = XMLXPath.getSingleValueByPath(document,ChengBaoDanWei_Node);
this.JiSuanNianLingShiJian = XMLXPath.getSingleValueByPath(document,JiSuanNianLingShiJian_Node);
this.TianBiaoShiJian = XMLXPath.getSingleValueByPath(document,TianBiaoShiJian_Node);
this.TianBiaoRen = XMLXPath.getSingleValueByPath(document,TianBiaoRen_Node);
this.ShenFenZheng = XMLXPath.getSingleValueByPath(document,ShenFenZheng_Node);
this.ZhaoPian = XMLXPath.getSingleValueByPath(document,ZhaoPian_Node);
this.Version = XMLXPath.getSingleValueByPath(document,Version_Node);
Date chushengDate = DateUtil.parseDate(this.ChuShengNianYue,"yyyyMM");
int age = DateUtil.getAgeByBirth(chushengDate);
this.Age = String.valueOf(age);
List<Node> JiaTingChengYuan_Node = XMLXPath.getPathValues(document,JiaTingChengYuan_ChengWei_Node);
List<Family> familyList = new ArrayList<>();
if (!JiaTingChengYuan_Node.isEmpty()){
for (Node node:JiaTingChengYuan_Node
) {
Family family = new Family();
family.setChengWei(node.selectSingleNode("ChengWei").getText());
family.setXingMing(node.selectSingleNode("XingMing").getText());
family.setZhengZhiMianMao(node.selectSingleNode("ZhengZhiMianMao").getText());
family.setGongZuoDanWeiJiZhiWu(node.selectSingleNode("GongZuoDanWeiJiZhiWu").getText());
family.setChuShengRiQi(node.selectSingleNode("ChuShengRiQi").getText());
family.setAge();
familyList.add(family);
}
log.info("家庭部分解析完成");
this.JiaTingChengYuan = familyList;
}
log.info("XML解析完成");
}catch (DocumentException e){
e.printStackTrace();
}catch (ParseException e){
this.Age = "0";
}
}
public Person() {
}
}