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
7efbdb4f
Commit
7efbdb4f
authored
Mar 12, 2019
by
dahai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 并修改生成xml数据包
parent
3b14f791
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
162 additions
and
36 deletions
+162
-36
ExportExcelApi.java
src/main/java/com/yxproject/start/api/ExportExcelApi.java
+10
-0
ExportXMLApi.java
src/main/java/com/yxproject/start/api/ExportXMLApi.java
+41
-29
DetailReceiptListEntity.java
...a/com/yxproject/start/entity/DetailReceiptListEntity.java
+15
-3
QuerySequenceMapper.java
.../java/com/yxproject/start/mapper/QuerySequenceMapper.java
+2
-2
QuerySequenceSercive.java
.../java/com/yxproject/start/utils/QuerySequenceSercive.java
+10
-2
ZipUtils.java
src/main/java/com/yxproject/start/utils/ZipUtils.java
+84
-0
No files found.
src/main/java/com/yxproject/start/api/ExportExcelApi.java
View file @
7efbdb4f
package
com
.
yxproject
.
start
.
api
;
import
com.yxproject.start.service.DetailReceiptListService
;
import
com.yxproject.start.service.ReceiptService
;
import
com.yxproject.start.utils.ExportExcel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -9,6 +12,13 @@ import java.util.List;
@RestController
@RequestMapping
(
"exportExcel"
)
public
class
ExportExcelApi
{
@Autowired
private
ReceiptService
receiptService
;
@Autowired
private
DetailReceiptListService
detailReceiptListService
;
public
Byte
[]
exportExcel
(){
return
null
;
}
...
...
src/main/java/com/yxproject/start/api/ExportXMLApi.java
View file @
7efbdb4f
...
...
@@ -7,6 +7,7 @@ import com.yxproject.start.service.FilesService;
import
com.yxproject.start.service.NewFilesService
;
import
com.yxproject.start.service.PreproPersonService
;
import
com.yxproject.start.utils.QuerySequenceSercive
;
import
com.yxproject.start.utils.ZipUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentHelper
;
...
...
@@ -22,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.zip.ZipOutputStream
;
/**
* @auther zhangyusheng
...
...
@@ -46,16 +48,9 @@ public class ExportXMLApi {
@RequestMapping
(
"printXmlData"
)
// @RequiresPermissions("userInfo.add")//权限管理;
public
byte
[]
printXmlData
(
@RequestParam
(
"uploadNo"
)
String
uploadNo
,
@RequestParam
(
"IDCard"
)
String
IDCard
,
@RequestParam
(
"oldFile"
)
String
oldFile
,
@RequestParam
(
"newFile"
)
String
newFile
,
@RequestParam
(
"SSXQDM"
)
String
SSXQDM
,
@RequestParam
(
"cardType"
)
String
cardType
,
@RequestParam
(
"state"
)
String
state
,
@RequestParam
(
"uploadDate"
)
String
uploadDate
,
HttpServletResponse
response
)
{
response
.
setContentType
(
"application/x-download"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
String
dateTime
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyyMMddHH"
);
//使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String
fout
=
null
;
List
<
PreproPersonEntity
>
preproPersonEntities
=
preproPersonService
.
selectAllPreproPerson
(
uploadNo
,
IDCard
,
oldFile
,
newFile
,
SSXQDM
,
cardType
,
state
,
replaceDate
(
uploadDate
));
if
(
preproPersonEntities
.
size
()>
0
){
//todo 查询制证数据包信息
//将制证详情详细划分
Map
<
Long
,
Object
>
map
=
new
LinkedHashMap
<>();
for
(
PreproPersonEntity
preproPersonEntity:
preproPersonEntities
){
...
...
@@ -76,9 +71,8 @@ public class ExportXMLApi {
List
<
PreproPersonEntity
>
preproPersonEntityList
=(
List
<
PreproPersonEntity
>)
map
.
get
(
cardTypeId
);
Map
<
Long
,
Object
>
mapFileId
=
new
LinkedHashMap
<>();
for
(
PreproPersonEntity
preproPersonEntity:
preproPersonEntityList
){
if
(
mapFileId
!=
null
&&
mapFileId
.
containsKey
(
preproPersonEntity
.
getFileId
())){
List
<
PreproPersonEntity
>
preproPersonEntityListFileId
=
(
List
<
PreproPersonEntity
>)
map
.
get
(
preproPersonEntity
.
getFileId
());
List
<
PreproPersonEntity
>
preproPersonEntityListFileId
=
(
List
<
PreproPersonEntity
>)
map
FileId
.
get
(
preproPersonEntity
.
getFileId
());
preproPersonEntityListFileId
.
add
(
preproPersonEntity
);
mapFileId
.
put
(
preproPersonEntity
.
getFileId
(),
preproPersonEntityListFileId
);
}
else
{
...
...
@@ -90,16 +84,17 @@ public class ExportXMLApi {
list
.
add
(
mapFileId
);
lists
.
add
(
list
);
}
//TODO
List
<
String
>
documentList
=
new
ArrayList
<>();
//执行生成XML文件方法
for
(
List
<
Map
<
Long
,
Object
>>
mapList
:
lists
){
for
(
Map
<
Long
,
Object
>
objectMap
:
mapList
){
for
(
Long
fileId
:
objectMap
.
keySet
()){
List
<
PreproPersonEntity
>
preproPersonEntityList
=(
List
<
PreproPersonEntity
>)
m
ap
.
get
(
fileId
);
List
<
PreproPersonEntity
>
preproPersonEntityList
=(
List
<
PreproPersonEntity
>)
objectM
ap
.
get
(
fileId
);
int
i
=
0
;
List
<
List
>
listList
=
new
ArrayList
<>();
List
list
=
new
ArrayList
();
for
(
PreproPersonEntity
preproPersonEntity
:
preproPersonEntityList
){
for
(
int
a
=
0
;
a
<
preproPersonEntityList
.
size
();
a
++){
PreproPersonEntity
preproPersonEntity
=
preproPersonEntityList
.
get
(
a
);
list
.
add
(
preproPersonEntity
);
i
++;
if
(
i
<
80
){
...
...
@@ -109,6 +104,9 @@ public class ExportXMLApi {
list
=
new
ArrayList
();
i
=
0
;
}
if
(
list
.
size
()>
0
&&
a
==
preproPersonEntityList
.
size
()-
1
){
listList
.
add
(
list
);
}
}
for
(
List
list1
:
listList
)
{
List
<
PreproPersonEntity
>
preproPersonEntityList1
=
(
List
<
PreproPersonEntity
>)
list1
;
...
...
@@ -116,32 +114,43 @@ public class ExportXMLApi {
FilesEntity
filesEntity
=
filesEntities
.
get
(
0
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddhhmmss"
);
filesEntity
.
setCreateTime
(
simpleDateFormat
.
format
(
new
Date
()));
String
xml
=
null
;
try
{
fout
=
createToMakePackageXML
(
preproPersonEntityList1
,
filesEntity
,
"\\zhang"
);
xml
=
createToMakePackageXML
(
preproPersonEntityList1
,
filesEntity
,
"\\zhang"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
outFile
=
dateTime
+
"制证数据包"
;
documentList
.
add
(
xml
);
}
}
}
}
// -----制证包数据打包下载
String
zipName
=
"myfile.zip"
;
response
.
setContentType
(
"APPLICATION/OCTET-STREAM"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
zipName
);
ZipOutputStream
out
=
null
;
try
{
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
fout
));
byte
[]
b
=
new
byte
[
fis
.
available
()];
fis
.
read
(
b
);
fis
.
close
();
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
outFile
+
".xml"
);
return
b
;
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
out
=
new
ZipOutputStream
(
response
.
getOutputStream
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
for
(
String
document
:
documentList
){
ZipUtils
.
doCompress
(
document
,
out
);
response
.
flushBuffer
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
out
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
@@ -184,7 +193,7 @@ public class ExportXMLApi {
newFilesEntity
.
setVersionCode
(
filesEntity
.
getVersionCode
());
newFilesEntity
.
setRecordNumber
((
long
)
preproPersonEntities
.
size
());
long
l
=
newFilesService
.
saveNewFiles
(
newFilesEntity
);
newFilesEntity
.
setNewFileName
(
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
l
);
newFilesEntity
.
setNewFileName
(
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
newFilesEntity
.
getId
()
);
newFilesService
.
saveNewFiles
(
newFilesEntity
);
int
NO
=
1
;
...
...
@@ -242,7 +251,7 @@ public class ExportXMLApi {
preproPersonEntity
.
setNewFileId
(
newFilesEntity
.
getId
());
}
preproPersonService
.
updatePreproPerson_NewFileName
(
preproPersonEntities
);
String
files_seq
=
querySequenceSercive
.
selectSequenceNextValue
(
"FILES_SEQ"
)
;
String
files_seq
=
newFilesEntity
.
getId
()+
""
;
FileOutputStream
fout
=
null
;
try
{
FileOutputStream
fos
=
new
FileOutputStream
(
"D:\\XML\\"
+
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
files_seq
+
".xml"
);
...
...
@@ -261,7 +270,10 @@ public class ExportXMLApi {
}
System
.
out
.
println
(
"XML文件生成成功..."
+
new
Date
());
return
"D:\\XML\\"
+
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
l
+
".xml"
;
// return document;
return
"D:\\XML\\"
+
simpleDateFormat
.
format
(
new
Date
())+
"-"
+
files_seq
+
".xml"
;
}
/**
...
...
src/main/java/com/yxproject/start/entity/DetailReceiptListEntity.java
View file @
7efbdb4f
...
...
@@ -5,7 +5,7 @@ import java.util.Objects;
/**
* @auther zhangyusheng
* 2019/3/1
0 14:52
* 2019/3/1
2 11:05
*/
@Entity
@Table
(
name
=
"DETAIL_RECEIPT_LIST"
,
schema
=
"YINGXIN"
,
catalog
=
""
)
...
...
@@ -18,6 +18,7 @@ public class DetailReceiptListEntity {
private
String
cardId
;
private
String
note
;
private
String
signGovt
;
private
Long
receiptId
;
@Id
@Column
(
name
=
"ID"
)
...
...
@@ -99,6 +100,16 @@ public class DetailReceiptListEntity {
this
.
signGovt
=
signGovt
;
}
@Basic
@Column
(
name
=
"RECEIPT_ID"
)
public
Long
getReceiptId
()
{
return
receiptId
;
}
public
void
setReceiptId
(
Long
receiptId
)
{
this
.
receiptId
=
receiptId
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
...
...
@@ -111,11 +122,12 @@ public class DetailReceiptListEntity {
Objects
.
equals
(
policeCode
,
that
.
policeCode
)
&&
Objects
.
equals
(
cardId
,
that
.
cardId
)
&&
Objects
.
equals
(
note
,
that
.
note
)
&&
Objects
.
equals
(
signGovt
,
that
.
signGovt
);
Objects
.
equals
(
signGovt
,
that
.
signGovt
)
&&
Objects
.
equals
(
receiptId
,
that
.
receiptId
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
,
uploadNo
,
acceptNo
,
name
,
policeCode
,
cardId
,
note
,
signGovt
);
return
Objects
.
hash
(
id
,
uploadNo
,
acceptNo
,
name
,
policeCode
,
cardId
,
note
,
signGovt
,
receiptId
);
}
}
src/main/java/com/yxproject/start/mapper/QuerySequenceMapper.java
View file @
7efbdb4f
...
...
@@ -13,6 +13,6 @@ import java.util.Map;
*/
@Mapper
public
interface
QuerySequenceMapper
{
@Select
(
"select #{sequenceName}
,#{sequenceName} as num2
from dual"
)
public
List
<
Map
<
String
,
Object
>>
selectSequenceNextValue
(
@Param
(
"sequenceName"
)
String
sequenceName
);
@Select
(
"select #{sequenceName}
from dual"
)
public
int
selectSequenceNextValue
(
@Param
(
"sequenceName"
)
String
sequenceName
);
}
src/main/java/com/yxproject/start/utils/QuerySequenceSercive.java
View file @
7efbdb4f
...
...
@@ -17,8 +17,16 @@ public class QuerySequenceSercive {
private
QuerySequenceMapper
querySequenceMapper
;
public
String
selectSequenceNextValue
(
String
sequenceName
){
List
<
Map
<
String
,
Object
>>
mapList
=
querySequenceMapper
.
selectSequenceNextValue
(
sequenceName
+
".nextval"
);
return
mapList
.
get
(
0
).
get
(
"NUM2"
).
toString
();
// List<Map<String, Object>> mapList = querySequenceMapper.selectSequenceNextValue(sequenceName + ".nextval");
// System.out.println(mapList.get(0)+"--------");
// System.out.println(mapList.get(0).keySet());
// for (String string :mapList.get(0).keySet()){
//
// }
// return mapList.get(0).get("NUM2").toString();
int
i
=
querySequenceMapper
.
selectSequenceNextValue
(
sequenceName
+
".nextval"
);
System
.
out
.
println
(
i
);
return
null
;
}
...
...
src/main/java/com/yxproject/start/utils/ZipUtils.java
0 → 100644
View file @
7efbdb4f
package
com
.
yxproject
.
start
.
utils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
/**
* @auther zhangyusheng
* 2019/3/12 12:27
*/
public
class
ZipUtils
{
private
ZipUtils
(){
}
public
static
void
doCompress
(
String
srcFile
,
String
zipFile
)
throws
IOException
{
doCompress
(
new
File
(
srcFile
),
new
File
(
zipFile
));
}
/**
* 文件压缩
* @param srcFile 目录或者单个文件
* @param zipFile 压缩后的ZIP文件
*/
public
static
void
doCompress
(
File
srcFile
,
File
zipFile
)
throws
IOException
{
ZipOutputStream
out
=
null
;
try
{
out
=
new
ZipOutputStream
(
new
FileOutputStream
(
zipFile
));
doCompress
(
srcFile
,
out
);
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
out
.
close
();
//记得关闭资源
}
}
public
static
void
doCompress
(
String
filelName
,
ZipOutputStream
out
)
throws
IOException
{
doCompress
(
new
File
(
filelName
),
out
);
}
public
static
void
doCompress
(
File
file
,
ZipOutputStream
out
)
throws
IOException
{
doCompress
(
file
,
out
,
""
);
}
public
static
void
doCompress
(
File
inFile
,
ZipOutputStream
out
,
String
dir
)
throws
IOException
{
if
(
inFile
.
isDirectory
()
)
{
File
[]
files
=
inFile
.
listFiles
();
if
(
files
!=
null
&&
files
.
length
>
0
)
{
for
(
File
file
:
files
)
{
String
name
=
inFile
.
getName
();
if
(!
""
.
equals
(
dir
))
{
name
=
dir
+
"/"
+
name
;
}
ZipUtils
.
doCompress
(
file
,
out
,
name
);
}
}
}
else
{
ZipUtils
.
doZip
(
inFile
,
out
,
dir
);
}
}
public
static
void
doZip
(
File
inFile
,
ZipOutputStream
out
,
String
dir
)
throws
IOException
{
String
entryName
=
null
;
if
(!
""
.
equals
(
dir
))
{
entryName
=
dir
+
"/"
+
inFile
.
getName
();
}
else
{
entryName
=
inFile
.
getName
();
}
ZipEntry
entry
=
new
ZipEntry
(
entryName
);
out
.
putNextEntry
(
entry
);
int
len
=
0
;
byte
[]
buffer
=
new
byte
[
1024
];
FileInputStream
fis
=
new
FileInputStream
(
inFile
);
while
((
len
=
fis
.
read
(
buffer
))
>
0
)
{
out
.
write
(
buffer
,
0
,
len
);
out
.
flush
();
}
out
.
closeEntry
();
fis
.
close
();
}
}
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