Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
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
liqin
chnmuseum-party
Commits
e3853537
Commit
e3853537
authored
May 06, 2021
by
jiawei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增 TBoxOperationController==》》excelPageList 机顶盒分页查询列表导出excel
parent
7cc2a9f3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
1 deletion
+98
-1
TBoxOperation.java
src/main/java/cn/chnmuseum/party/model/TBoxOperation.java
+7
-0
TBoxOperationController.java
...nmuseum/party/web/controller/TBoxOperationController.java
+91
-1
No files found.
src/main/java/cn/chnmuseum/party/model/TBoxOperation.java
View file @
e3853537
...
...
@@ -51,6 +51,13 @@ public class TBoxOperation implements Serializable {
@TableField
(
"status"
)
private
Integer
status
;
/**
* 用于excel导出字段
*/
@ApiModelProperty
(
hidden
=
true
)
@TableField
(
exist
=
false
)
private
String
statusString
;
@ApiModelProperty
(
"区域id"
)
@TableField
(
"area_id"
)
private
String
areaId
;
...
...
src/main/java/cn/chnmuseum/party/web/controller/TBoxOperationController.java
View file @
e3853537
...
...
@@ -13,6 +13,9 @@ import cn.chnmuseum.party.service.TAreaService;
import
cn.chnmuseum.party.service.TBoxOperationService
;
import
cn.chnmuseum.party.service.impl.TUserServiceImpl
;
import
cn.chnmuseum.party.web.controller.base.BaseController
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
cn.hutool.poi.excel.ExcelWriter
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
...
...
@@ -33,8 +36,12 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -290,7 +297,16 @@ public class TBoxOperationController extends BaseController {
List
<
TArea
>
tAreas
=
areaService
.
list
(
wrapper
);
//设置区域名称
records
.
stream
().
forEach
(
r
->
{
Integer
status
=
r
.
getStatus
();
if
(
status
.
equals
(
1
)){
r
.
setStatusString
(
"未激活"
);
}
if
(
status
.
equals
(
2
)){
r
.
setStatusString
(
"已激活"
);
}
if
(
status
.
equals
(
3
)){
r
.
setStatusString
(
"故障"
);
}
tAreas
.
stream
().
forEach
(
a
->
{
if
(
r
.
getAreaId
()
!=
null
&&
r
.
getAreaId
().
equals
(
String
.
valueOf
(
a
.
getId
())))
{
//设置地区全名
...
...
@@ -300,6 +316,80 @@ public class TBoxOperationController extends BaseController {
});
}
//机顶盒导出
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"organId"
,
value
=
"所属单位"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态 1.未激活 2.已激活 3.故障"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"areaId"
,
value
=
"区域"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
@PostMapping
(
"/excel/getPageList"
)
@RequiresAuthentication
//@RequiresPermissions("/boxOperation/getPageList")
@ApiOperation
(
value
=
"获取机顶盒运维信息分页列表Excel导出"
,
notes
=
"获取机顶盒运维信息分页列表Excel导出"
)
@MethodLog
(
operModule
=
OperModule
.
STBOPERATION
,
operType
=
OperType
.
SELECT
)
public
void
excelPageList
(
String
organId
,
Integer
status
,
String
areaId
,
HttpServletResponse
response
)
{
TUser
user
=
getcurUser
();
TBoxOperation
tBoxOperation
=
new
TBoxOperation
();
if
(
StringUtils
.
isNotBlank
(
organId
))
{
tBoxOperation
.
setOrganId
(
organId
);
}
if
(
status
!=
null
)
{
tBoxOperation
.
setStatus
(
status
);
}
if
(
StringUtils
.
isNotBlank
(
areaId
))
{
tBoxOperation
.
setAreaId
(
areaId
);
}
if
(
StringUtils
.
isNotBlank
(
user
.
getAreaId
()))
{
if
(
"4"
.
equals
(
user
.
getType
()))
{
//如果是运维账号设置数据权限
tBoxOperation
.
setAreaName
(
getAreaId
(
user
.
getAreaId
()));
}
}
if
(
user
.
getRoleList
().
size
()
>
0
&&
!
user
.
getRoleList
().
contains
(
"1"
))
{
//设置用户数据权限
tBoxOperation
.
setOrganCode
(
user
.
getOrgCode
());
}
Page
<
TBoxOperation
>
page
=
null
;
try
{
page
=
this
.
tBoxOperationService
.
selectPage
(
getPage
(),
tBoxOperation
);
//
List
<
TBoxOperation
>
records
=
page
.
getRecords
();
fillAreaName
(
records
);
//导出excel
ExcelWriter
writer
=
ExcelUtil
.
getWriter
();
writer
.
addHeaderAlias
(
"mac"
,
"MAC地址"
);
writer
.
addHeaderAlias
(
"organName"
,
"所属单位"
);
writer
.
addHeaderAlias
(
"userName"
,
"单位管理员"
);
writer
.
addHeaderAlias
(
"areaName"
,
"所属区域"
);
writer
.
addHeaderAlias
(
"statusString"
,
"机顶盒状态"
);
//
writer
.
setOnlyAlias
(
true
);
writer
.
write
(
records
,
true
);
response
.
setContentType
(
"application/vnd.ms-excel;charset=utf-8"
);
String
name
=
"机顶盒运维信息"
;
name
=
URLEncoder
.
encode
(
name
,
String
.
valueOf
(
StandardCharsets
.
UTF_8
));
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
name
+
".xls"
);
ServletOutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
writer
.
flush
(
out
,
true
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
// 关闭writer,释放内存
writer
.
close
();
}
//此处记得关闭输出Servlet流
IoUtil
.
close
(
out
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@ApiOperation
(
value
=
"获取机顶盒运维信息详情"
,
notes
=
"获取机顶盒运维信息详情"
)
@GetMapping
(
"/getById"
)
@RequiresAuthentication
//@RequiresPermissions("/boxOperation/getById")
...
...
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