Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
2c0ae092
提交
2c0ae092
authored
6月 08, 2021
作者:
133
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[添加用户导出接口] 代码提交
上级
680aafb9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
105 行增加
和
2 行删除
+105
-2
GenerateTestPaperController.java
.../device/train/controller/GenerateTestPaperController.java
+72
-2
UserExcel.java
...n/java/com/tykj/dev/device/train/entity/vo/UserExcel.java
+33
-0
没有找到文件。
dev-train/src/main/java/com/tykj/dev/device/train/controller/GenerateTestPaperController.java
浏览文件 @
2c0ae092
package
com
.
tykj
.
dev
.
device
.
train
.
controller
;
package
com
.
tykj
.
dev
.
device
.
train
.
controller
;
import
cn.afterturn.easypoi.excel.ExcelExportUtil
;
import
cn.afterturn.easypoi.excel.entity.ExportParams
;
import
cn.afterturn.easypoi.excel.entity.enmus.ExcelType
;
import
com.tykj.dev.config.swagger.AutoDocument
;
import
com.tykj.dev.config.swagger.AutoDocument
;
import
com.tykj.dev.device.excel.utils.ExcelStyleUtil
;
import
com.tykj.dev.device.excel.utils.ExcelUtil
;
import
com.tykj.dev.device.train.entity.vo.UserExcel
;
import
com.tykj.dev.device.user.base.ret.LeftNavigation
;
import
com.tykj.dev.device.user.subject.entity.SecurityUser
;
import
com.tykj.dev.device.user.subject.service.UnitsService
;
import
com.tykj.dev.device.user.subject.service.UserService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
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
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* @author zjm
* @author zjm
...
@@ -13,9 +35,57 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,9 +35,57 @@ import org.springframework.web.bind.annotation.RestController;
* @createTime 2021年06月02日 18:34:00
* @createTime 2021年06月02日 18:34:00
*/
*/
@RestController
@RestController
@RequestMapping
(
value
=
"/
generateTestPaper
"
)
@RequestMapping
(
value
=
"/
test
"
)
@AutoDocument
@AutoDocument
@Api
(
tags
=
"
培训试卷模版"
,
description
=
"培训试卷模版
"
)
@Api
(
tags
=
"
测试接口"
,
description
=
"测试接口
"
)
public
class
GenerateTestPaperController
{
public
class
GenerateTestPaperController
{
@Autowired
UnitsService
unitsService
;
@Autowired
UserService
userService
;
@GetMapping
(
value
=
"/excel/user"
)
@ApiOperation
(
value
=
"导出用户列表"
,
notes
=
"导出用户列表"
)
public
ResponseEntity
excelUser
(
@ApiIgnore
@AuthenticationPrincipal
SecurityUser
securityUser
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
LeftNavigation
leftNavigation
=
unitsService
.
findLeftNavigation
(
securityUser
);
List
<
UserExcel
>
list
=
new
ArrayList
<>();
for
(
LeftNavigation
leftNavigation1:
leftNavigation
.
getLeftNavigations
()){
if
(
leftNavigation1
.
getType
()==
2
){
userService
.
findAllByUnite
(
leftNavigation1
.
getId
()).
forEach
(
user
->
{
UserExcel
userExcel
=
new
UserExcel
();
userExcel
.
setUnit
(
leftNavigation1
.
getName
());
userExcel
.
setArea
(
leftNavigation
.
getName
());
userExcel
.
setName
(
user
.
getName
());
userExcel
.
setDes
(
user
.
getUsername
());
list
.
add
(
userExcel
);
}
);
}
else
{
for
(
LeftNavigation
leftNavigation2:
leftNavigation1
.
getLeftNavigations
()){
userService
.
findAllByUnite
(
leftNavigation2
.
getId
()).
forEach
(
user
->
{
UserExcel
userExcel
=
new
UserExcel
();
userExcel
.
setUnit
(
leftNavigation2
.
getName
());
userExcel
.
setArea
(
leftNavigation1
.
getName
());
userExcel
.
setName
(
user
.
getName
());
userExcel
.
setDes
(
user
.
getUsername
());
list
.
add
(
userExcel
);
}
);
}
}
}
ExportParams
exportParams
=
new
ExportParams
(
"xxx"
,
"xxx"
,
ExcelType
.
XSSF
);
exportParams
.
setStyle
(
ExcelStyleUtil
.
class
);
Workbook
workbook
=
ExcelExportUtil
.
exportExcel
(
exportParams
,
UserExcel
.
class
,
list
);
ExcelUtil
.
downloadExcel
(
request
,
response
,
workbook
,
"xxx"
);
return
ResponseEntity
.
ok
(
"ok"
);
}
}
}
dev-train/src/main/java/com/tykj/dev/device/train/entity/vo/UserExcel.java
0 → 100644
浏览文件 @
2c0ae092
package
com
.
tykj
.
dev
.
device
.
train
.
entity
.
vo
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author zjm
* @version 1.0.0
* @ClassName TrainExcel.java
* @Description excel导出实体类
* @createTime 2021年04月29日 15:22:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
UserExcel
{
@Excel
(
name
=
"区域名称"
,
orderNum
=
"1"
,
width
=
30
,
needMerge
=
true
)
private
String
area
;
@Excel
(
name
=
"单位名称"
,
orderNum
=
"2"
,
width
=
30
,
needMerge
=
true
)
private
String
unit
;
@Excel
(
name
=
"姓名"
,
orderNum
=
"3"
,
width
=
30
,
needMerge
=
true
)
private
String
name
;
@Excel
(
name
=
"账号"
,
orderNum
=
"4"
,
width
=
30
,
needMerge
=
true
)
private
String
des
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论