Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YX_IDENT_beijing_auxiliary_YD
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangyusheng
YX_IDENT_beijing_auxiliary_YD
Commits
76c3d4fc
Commit
76c3d4fc
authored
Sep 01, 2021
by
Liuxb@yingxingroup.net
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改xml上传解析的异常处理
parent
38b46dd6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
ReadXmlApi.java
src/main/java/com/yxproject/start/api/ReadXmlApi.java
+11
-8
ImportXmlServiceImpl.java
...om/yxproject/start/service/impl/ImportXmlServiceImpl.java
+6
-1
No files found.
src/main/java/com/yxproject/start/api/ReadXmlApi.java
View file @
76c3d4fc
...
...
@@ -96,33 +96,37 @@ public class ReadXmlApi {
String
str
=
YXStringUtils
.
inputStream2String
(
in
,
"utf-8"
);
in
.
close
();
IDCardFactory
idCardFactory
=
new
IDCardFactory
();
idcardsFactory
(
idCardFactory
.
extractIDCard
(
str
,
date
));
Boolean
aBoolean
=
idcardsFactory
(
idCardFactory
.
extractIDCard
(
str
,
date
));
if
(!
aBoolean
){
errList
.
add
(
"上传文件名:"
+
filename
+
",文件上传失败"
);
continue
;
}
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"上传文件名"
+
filename
);
logger
.
error
(
"UnsupportedEncodingException 上传文件时发现文件编码错误"
,
e
);
yxresp
.
outPutError
(
"UnsupportedEncodingException"
,
"上传文件时发现文件编码错误:"
+
e
.
getMessage
());
//
yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
errList
.
add
(
"上传文件名:"
+
filename
+
",上传文件时发现文件编码错误"
);
continue
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"上传文件名"
+
filename
);
logger
.
error
(
"IOException 上传文件时发生IO错误"
,
e
);
yxresp
.
outPutError
(
"IOException"
,
"上传文件时发生IO错误:"
+
e
.
getMessage
());
//
yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage());
errList
.
add
(
"上传文件名:"
+
filename
+
",上传文件时发生IO错误"
);
continue
;
}
catch
(
DocumentException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"上传文件名"
+
filename
);
logger
.
error
(
"DocumentException 上传文件时发生错误,非法XML文件"
,
e
);
yxresp
.
outPutError
(
"DocumentException"
,
"上传文件时发生IO错误:"
+
e
.
getMessage
());
//
yxresp.outPutError("DocumentException", "上传文件时发生IO错误:" + e.getMessage());
errList
.
add
(
"上传文件名:"
+
filename
+
",上传文件时发生错误,非法XML文件"
);
continue
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"上传文件名"
+
filename
);
logger
.
error
(
"Exception 上传文件时发生错误"
,
e
);
yxresp
.
outPutError
(
"Exception"
,
"上传文件时发生错误,非法XML文件:"
+
filename
);
//
yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
errList
.
add
(
"上传文件名:"
+
filename
+
",上传文件时发生错误"
);
continue
;
}
...
...
@@ -133,7 +137,7 @@ public class ReadXmlApi {
e
.
printStackTrace
();
logger
.
error
(
"上传文件名"
+
filename
);
logger
.
error
(
"FileUploadException 文件上传发生异常"
,
e
);
yxresp
.
outPutError
(
"FileUploadException"
,
"文件上传发生异常:"
+
e
.
getMessage
());
//
yxresp.outPutError("FileUploadException", "文件上传发生异常:" + e.getMessage());
errList
.
add
(
"上传文件名:"
+
filename
+
",上传文件时发生错误"
);
}
if
(
errList
.
size
()
==
0
){
...
...
@@ -148,8 +152,7 @@ public class ReadXmlApi {
}
private
Boolean
idcardsFactory
(
Map
<
String
,
Object
>
map1
)
{
importXmlService
.
importPersonXml
((
List
<
PreproPersonDto
>)
map1
.
get
(
"preproPerson"
),
(
FilesEntity
)
map1
.
get
(
"file"
));
return
true
;
return
importXmlService
.
importPersonXml
((
List
<
PreproPersonDto
>)
map1
.
get
(
"preproPerson"
),
(
FilesEntity
)
map1
.
get
(
"file"
));
}
/**
...
...
src/main/java/com/yxproject/start/service/impl/ImportXmlServiceImpl.java
View file @
76c3d4fc
...
...
@@ -13,6 +13,7 @@ import org.dom4j.Element;
import
org.dom4j.io.OutputFormat
;
import
org.dom4j.io.XMLWriter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.UncategorizedSQLException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -43,7 +44,11 @@ public class ImportXmlServiceImpl implements ImportXmlService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
importPersonXml
(
List
<
PreproPersonDto
>
preproPersonDtos
,
FilesEntity
filesEntity
)
{
long
l
=
filesMapper
.
insertFiles
(
filesEntity
);
try
{
long
l
=
filesMapper
.
insertFiles
(
filesEntity
);
}
catch
(
UncategorizedSQLException
e
){
return
false
;
}
SimpleDateFormat
fo
=
new
SimpleDateFormat
(
"yyyyMMddhhmm"
);
String
uploadDate
=
fo
.
format
(
new
Date
());
for
(
PreproPersonDto
preproPersonDto
:
preproPersonDtos
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment