Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
ab96c218
Commit
ab96c218
authored
Oct 08, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
车辆统计导出bug
parent
fb2239d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
25 deletions
+23
-25
VehicleCountRecordBiz.java
.../com/xxfc/platform/vehicle/biz/VehicleCountRecordBiz.java
+23
-25
No files found.
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleCountRecordBiz.java
View file @
ab96c218
...
@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz;
...
@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.order.contant.enumerate.OrderTypeEnum
;
import
com.xxfc.platform.order.contant.enumerate.OrderTypeEnum
;
import
com.xxfc.platform.order.entity.OrderRentVehicleDetail
;
import
com.xxfc.platform.order.entity.OrderRentVehicleDetail
;
...
@@ -389,32 +390,29 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
...
@@ -389,32 +390,29 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
return
ObjectRestResponse
.
succ
(
path
);
return
ObjectRestResponse
.
succ
(
path
);
}
}
public
void
download
(
String
path
,
HttpServletResponse
response
)
{
public
void
download
(
String
path
,
HttpServletResponse
response
){
// 下载本地文件
String
fileName
=
"export.xlsx"
.
toString
();
// 文件的默认保存名
// 读到流中
InputStream
inStream
=
null
;
// 文件的存放路径
try
{
try
{
// path是指欲下载的文件的路径。
inStream
=
new
FileInputStream
(
path
);
File
file
=
new
File
(
path
);
}
catch
(
FileNotFoundException
e
)
{
// 取得文件名。
e
.
printStackTrace
();
String
filename
=
file
.
getName
();
}
// 取得文件的后缀名。
// 设置输出的格式
String
ext
=
filename
.
substring
(
filename
.
lastIndexOf
(
"."
)
+
1
).
toUpperCase
();
// 以流的形式下载文件。
InputStream
fis
=
new
BufferedInputStream
(
new
FileInputStream
(
path
));
byte
[]
buffer
=
new
byte
[
fis
.
available
()];
fis
.
read
(
buffer
);
fis
.
close
();
// 清空response
response
.
reset
();
response
.
reset
();
// 设置response的Header
response
.
setContentType
(
"bin"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
new
String
(
filename
.
getBytes
()));
response
.
addHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
response
.
addHeader
(
"Content-Length"
,
""
+
file
.
length
());
// 循环取出流中的数据
OutputStream
toClient
=
new
BufferedOutputStream
(
response
.
getOutputStream
());
byte
[]
b
=
new
byte
[
100
];
response
.
setContentType
(
"application/octet-stream"
);
int
len
;
toClient
.
write
(
buffer
);
try
{
toClient
.
flush
();
while
((
len
=
inStream
.
read
(
b
))
>
0
)
toClient
.
close
();
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
catch
(
IOException
ex
)
{
inStream
.
close
();
ex
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
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