Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e36b7baf
authored
Jun 29, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
导出运营报表
1 parent
feb3650d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
4 deletions
src/main/java/cn/com/glsx/admin/modules/controller/AbstractController.java
src/main/java/cn/com/glsx/admin/modules/controller/OpereportController.java
src/main/java/cn/com/glsx/admin/modules/controller/AbstractController.java
View file @
e36b7ba
...
@@ -27,4 +27,11 @@ public class AbstractController {
...
@@ -27,4 +27,11 @@ public class AbstractController {
return
""
;
return
""
;
}
}
public
String
getExportFileUrl
(
String
fileName
,
ByteArrayOutputStream
baos
)
{
//将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
FileUploadServerData
uploadServerData
=
FileUploadUtil
.
uploadToFileSystem
(
fileName
,
baos
.
toByteArray
(),
FileConstants
.
EXCEL_TYPE_XLSX
);
return
uploadServerData
.
getSecureUrl
();
}
}
}
src/main/java/cn/com/glsx/admin/modules/controller/OpereportController.java
View file @
e36b7ba
...
@@ -10,6 +10,7 @@ import cn.com.glsx.admin.modules.service.OpereportService;
...
@@ -10,6 +10,7 @@ import cn.com.glsx.admin.modules.service.OpereportService;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.plat.common.utils.DateUtils
;
import
com.glsx.plat.common.utils.DateUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.office.excel.EasyExcelUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -41,8 +44,20 @@ public class OpereportController extends AbstractController {
...
@@ -41,8 +44,20 @@ public class OpereportController extends AbstractController {
@GetMapping
(
value
=
"/vehicle/export"
)
@GetMapping
(
value
=
"/vehicle/export"
)
public
R
vehicleExport
(
ReportVehicleSearch
search
)
{
public
R
vehicleExport
(
ReportVehicleSearch
search
)
{
List
<
ReportVehicleExport
>
list
=
opereportService
.
vehicleExport
(
search
);
List
<
ReportVehicleExport
>
list
=
opereportService
.
vehicleExport
(
search
);
String
url
=
super
.
uploadExcel
(
list
,
"运营统计报表(车辆维度)_"
+
DateUtils
.
formatSerial
(
new
Date
()),
ReportVehicleExport
.
class
);
//String url = super.uploadExcel(list, "运营统计报表(车辆维度)_" + DateUtils.formatSerial(new Date()), ReportVehicleExport.class);
return
R
.
ok
().
data
(
url
);
String
fileName
=
"运营统计报表(车辆维度)_"
+
DateUtils
.
formatSerial
(
new
Date
());
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
EasyExcelUtils
.
writeExcel
(
baos
,
list
,
fileName
,
ReportVehicleExport
.
class
);
String
url
=
getExportFileUrl
(
fileName
,
baos
);
return
R
.
ok
().
data
(
url
);
}
catch
(
IOException
e
)
{
log
.
error
(
"上传Excel失败:{}"
,
e
.
getMessage
());
}
return
R
.
error
(
"下载失败"
);
}
}
@ApiOperation
(
value
=
"设备列表查询"
)
@ApiOperation
(
value
=
"设备列表查询"
)
...
@@ -56,8 +71,20 @@ public class OpereportController extends AbstractController {
...
@@ -56,8 +71,20 @@ public class OpereportController extends AbstractController {
@GetMapping
(
value
=
"/device/export"
)
@GetMapping
(
value
=
"/device/export"
)
public
R
deviceExport
(
ReportDeviceSearch
search
)
{
public
R
deviceExport
(
ReportDeviceSearch
search
)
{
List
<
ReportDeviceExport
>
list
=
opereportService
.
deviceExport
(
search
);
List
<
ReportDeviceExport
>
list
=
opereportService
.
deviceExport
(
search
);
String
url
=
super
.
uploadExcel
(
list
,
"运营统计报表(设备维度)_"
+
DateUtils
.
formatSerial
(
new
Date
()),
ReportDeviceExport
.
class
);
//String url = super.uploadExcel(list, "运营统计报表(设备维度)_" + DateUtils.formatSerial(new Date()), ReportDeviceExport.class);
return
R
.
ok
().
data
(
url
);
String
fileName
=
"运营统计报表(设备维度)_"
+
DateUtils
.
formatSerial
(
new
Date
());
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
EasyExcelUtils
.
writeExcel
(
baos
,
list
,
fileName
,
ReportDeviceExport
.
class
);
String
url
=
getExportFileUrl
(
fileName
,
baos
);
return
R
.
ok
().
data
(
url
);
}
catch
(
IOException
e
)
{
log
.
error
(
"上传Excel失败:{}"
,
e
.
getMessage
());
}
return
R
.
error
(
"下载失败"
);
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment