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
8a6d0627
Commit
8a6d0627
authored
Mar 15, 2019
by
dahai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传生成XML
parent
85a84c47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
9 deletions
+26
-9
ExportXMLApi.java
src/main/java/com/yxproject/start/api/ExportXMLApi.java
+26
-9
No files found.
src/main/java/com/yxproject/start/api/ExportXMLApi.java
View file @
8a6d0627
...
...
@@ -186,10 +186,15 @@ public class ExportXMLApi {
newFilesEntity
.
setVersionCode
(
filesEntity
.
getVersionCode
());
newFilesEntity
.
setRecordNumber
((
long
)
preproPersonEntities
.
size
());
long
l
=
newFilesService
.
saveNewFiles
(
newFilesEntity
);
newFilesEntity
.
setNewFileName
(
"ZAGL_ZZJH_"
+
filesEntity
.
getDwdm
()+
simpleDateFormat
.
format
(
new
Date
())+
""
+
newFilesEntity
.
getId
());
String
files_seq
=
autoGenericCode
(
newFilesEntity
.
getId
()+
""
,
4
)
;
newFilesEntity
.
setNewFileName
(
"ZAGL_ZZJH_"
+
filesEntity
.
getDwdm
()+
simpleDateFormat
.
format
(
new
Date
())+
preproPersonEntities
.
get
(
0
).
getCardTypeId
()+
files_seq
);
newFilesService
.
updateNewFileName
(
newFilesEntity
);
Element
SJBBH
=
PACKAGEHEAD
.
addElement
(
"SJBBH"
);
SJBBH
.
setText
(
filesEntity
.
getDwdm
()+
simpleDateFormat
.
format
(
new
Date
())+
preproPersonEntities
.
get
(
0
).
getCardTypeId
()+
files_seq
);
int
NO
=
1
;
long
cardType
=
0
;
for
(
PreproPersonEntity
preproPersonEntity
:
preproPersonEntities
)
{
Element
RECORD
=
DATA
.
addElement
(
"RECORD"
);
RECORD
.
addAttribute
(
"no"
,
NO
+
""
);
...
...
@@ -242,16 +247,16 @@ public class ExportXMLApi {
SJR_TXDZ
.
setText
(
replaceNullString
(
preproPersonEntity
.
getSjrTxdz
()));
NO
++;
preproPersonEntity
.
setNewFileId
(
newFilesEntity
.
getId
());
cardType
=
preproPersonEntity
.
getCardTypeId
();
}
preproPersonService
.
updatePreproPerson_NewFileName
(
preproPersonEntities
);
String
files_seq
=
newFilesEntity
.
getId
()+
""
;
try
{
FileOutputStream
fos
=
new
FileOutputStream
(
"D:\\XML\\"
+
"ZAGL_ZZJH_"
+
filesEntity
.
getDwdm
()
+
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
files_seq
+
".xml"
);
FileOutputStream
fos
=
new
FileOutputStream
(
"D:\\XML\\"
+
"ZAGL_ZZJH_"
+
filesEntity
.
getDwdm
()
+
simpleDateFormat
.
format
(
new
Date
())+
cardType
+
files_seq
+
".xml"
);
OutputStreamWriter
osw
=
new
OutputStreamWriter
(
fos
,
"UTF-8"
);
OutputFormat
of
=
new
OutputFormat
();
of
.
setEncoding
(
"UTF-8"
);
of
.
setIndent
(
true
);
of
.
setIndent
(
" "
);
of
.
setNewlines
(
true
);
of
.
setNewLineAfterDeclaration
(
false
);
XMLWriter
writer
=
new
XMLWriter
(
osw
,
of
);
...
...
@@ -260,12 +265,8 @@ public class ExportXMLApi {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"XML文件生成成功..."
+
new
Date
());
// return document;
return
"D:\\XML\\"
+
"ZAGL_ZZJH_"
+
filesEntity
.
getDwdm
()+
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
files_seq
+
".xml"
;
return
"D:\\XML\\"
+
"ZAGL_ZZJH_"
+
filesEntity
.
getDwdm
()+
simpleDateFormat
.
format
(
new
Date
())+
cardType
+
files_seq
+
".xml"
;
}
/**
...
...
@@ -288,4 +289,20 @@ public class ExportXMLApi {
return
str
.
replace
(
"-"
,
""
);
}
/**
* 不够位数的在前面补0,保留code的长度位数字
* @param code
* @return
*/
private
String
autoGenericCode
(
String
code
,
int
num
)
{
String
result
=
""
;
// 保留num的位数
// 0 代表前面补充0
// num 代表长度为4
// d 代表参数为正数型
result
=
String
.
format
(
"%0"
+
num
+
"d"
,
Integer
.
parseInt
(
code
)
+
1
);
return
result
;
}
}
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