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
fb2239d6
Commit
fb2239d6
authored
Oct 08, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
车辆统计导出bug
parent
56fae1fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
VehicleCountRecordBiz.java
.../com/xxfc/platform/vehicle/biz/VehicleCountRecordBiz.java
+14
-4
No files found.
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleCountRecordBiz.java
View file @
fb2239d6
...
...
@@ -366,20 +366,30 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
ExcelExport
ee1
=
new
ExcelExport
();
ee1
.
addSheetByArray
(
excelParamDto
.
getName
(),
excelParamDto
.
getData
(),
excelParamDto
.
getHeader
());
String
path
=
"/data/temp/"
+
excelParamDto
.
getName
()
+
".xlsx"
;
File
file
=
new
File
(
path
);
if
(!
file
.
exists
())
{
try
{
file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createFailedResult
(
1024
,
"文件写入失败!"
);
}
}
OutputStream
fis
;
try
{
fis
=
new
FileOutputStream
(
path
);
ee1
.
getWorkbook
().
write
(
fis
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createFailedResult
(
10
02
,
"文件不存在
"
);
return
ObjectRestResponse
.
createFailedResult
(
10
24
,
"文件不存在!
"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createFailedResult
(
10
02
,
"文件导出
失败!"
);
return
ObjectRestResponse
.
createFailedResult
(
10
24
,
"文件写入
失败!"
);
}
return
ObjectRestResponse
.
succ
(
path
);
}
public
HttpServletResponse
download
(
String
path
,
HttpServletResponse
response
)
{
public
void
download
(
String
path
,
HttpServletResponse
response
)
{
try
{
// path是指欲下载的文件的路径。
File
file
=
new
File
(
path
);
...
...
@@ -387,6 +397,7 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
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
()];
...
...
@@ -405,7 +416,6 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
return
response
;
}
...
...
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